akhauriyash/Code-Regression huggingface dataset:
import sys
n=int(input())
l=[i for i in range(1,n+1)]
a=tuple(map(int,sys.stdin.readline().strip().split()))
b=tuple(map(int,sys.stdin.readline().strip().split()))
import itertools
List=[]
for i in itertools.permutations(l):
  List+=[i]
print(abs(List.index(a)-List.index(b)))

Measured memory_bytes: 7924
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=51 ;
int main()
{
   fast ;
   ll n ;
   cin>>n ;
   cout<<(n+1)/2 ;

}




Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <iostream>
using namespace std;
const int Max_n = 1e5 + 5;
char s[100];
int main()
{
	cin>>s+1;
	if(s[1] == 'Y' && s[2] == 'A' && s[3] == 'K' && s[4] == 'I') 
		cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(void){
	string S, T, R, P;
	cin >> S >> T;
	map<char, char> s_mp;
	map<char, char> t_mp;
	for(int index = 0; index < S.size(); index++){
		s_mp[S[index]] = T[index];
		t_mp[T[index]] = S[index];
	}

	for(int index = 0; index < S.size(); index++){
		R += s_mp[S[index]];
		P += t_mp[T[index]];
	}
	if(T == R && S == P) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 1204
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int fac(int num) {
  if(num==1) return 1;
  else return num*fac(num-1);
}




int main() {
  ll N,M; cin >> N >> M;
  if(N == 2) N = 0;
  else if(N > 2) N-=2;
  
  if(M == 2) M = 0;
  else if(M > 2) M-=2;
  
  cout << N*M << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  set<int> st;
  for(int i=0;i<n;i++){
    cin>>a[i];
    st.insert(a[i]);
  }
  cout<<st.size()<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  double T, X;
  std::cin >> T >> X;
  std::cout << std::fixed << std::setprecision(10) << (T / X) << std::endl;
  return 0;
}

Measured memory_bytes: 256
/**
  * Created by ??\??? on 2016/12/7.
  */
object Main{
    def main(args: Array[String]): Unit = {
        val T = Console.readLine();
        val lines = T.split(" ")
        val a = lines(0).toInt
        val b = lines(1).toInt
        val c = a*b
        val d = (a+b)*2
        println(c+" "+d)
    }
}

Measured memory_bytes: 43508
N, M = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
total = sum(A)
for i in range(len(A)):
    if A[i] >= (total * (1/(4*M))):
        cnt += 1
if cnt >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define N 100055
#define ll long long
ll v[N],w[N],dp[N];
int main() {
    int n,W;
    scanf("%d%d",&n,&W);
    for(int i=1; i<=n; ++i)
        scanf("%lld %lld",&w[i],&v[i]);
    ll ans = 0;
    for(int i=1; i<=n; ++i) {
        for(int j = W - w[i] ; j>=0;--j){
            dp[j+w[i]] = max( dp[j+w[i]] , dp[j] + v[i] );
            ans = max(ans , dp[j+w[i]]);
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int a, b;
    cin >> a >> b;

    int ans = 6 - a - b;

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC099_B();
        }

        static void ABC099_B()
        {
            var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var sum = 0;
            for (var i = 1; i <= ab[1] - ab[0]; i++) sum += i;
            Console.WriteLine(sum - ab[1]);
        }
    }
}

Measured memory_bytes: 13396
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N = ri()
A = ri()
print(N ** 2 - A)

Measured memory_bytes: 63084
import sys
input=sys.stdin.readline

def main():
    n, k = map(int,input().split())
    H = [0] + list(map(int,input().split()))
    
    dp = [float('inf')]*(n+1)
    dp[1] = 0
    
    for i in range(2,n+1):
        for j in range(1,k+1):
            if i-j <= 0:
                continue
            dp[i] = min(dp[i], abs(H[i]-H[i-j])+dp[i-j])
    
    #print(dp)        
    print(dp[n])
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 86364
#include <bits/stdc++.h>
using namespace std;
#define int double
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
vector<vector<vector<int>>> dp (320, vector<vector<int>>(320, vector<int>(320)));
int n;
vector<vector<vector<bool>>> flag (320, vector<vector<bool>>(320, vector<bool>(320)));
double solve(int c1,int c2,int c3){
    if(c1<0 || c2 <0 || c3<0) return 0;
    if(!c1&&!c2&&!c3) return 0;
	if(flag[c1][c2][c3])return dp[c1][c2][c3];
	flag[c1][c2][c3]=1;
    int i = c1, j = c2, k = c3;
    dp[i][j][k] = (solve(i-1,j,k) * i + solve(i+1,j-1,k)*j + solve(i,j+1,k-1)*k + n)
    / (i+j+k);
    return dp[i][j][k];
}
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    vector <int> a(n);
    vector <int> cnt(3);
    rep(i,n) {
        cin>>a[i];
        cnt[a[i]-1]++;
    }
    

    printf("%.10f\n", solve(cnt[0], cnt[1], cnt[2]));
}


Measured memory_bytes: 271232
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define    endl        '\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x)     for(auto& a : x)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound

/*    For Debugging    */
#define DEBUG         cerr<<"/n>>>I'm Here<<</n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005

void solve()
{
    string s;
    cin>>s;
    ll n=s.length();
    ll ans=0;
    rep(i,0,n/2)
    {
        if(s[i]!=s[n-1-i])
            ans++;
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    FAST
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    TIME
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int A, B; cin >> A >> B;
    if (B == 1) {
        cout << 0 << endl;
        return 0;
    }
    int count = 1;
    int xx = B - A;
    while (xx > 0) {
        ++count;
        xx -= A-1;
    }
    cout << count << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=1e6+5;
struct Trie{
    int next[26];
    int type;
}T[maxn];
int dp[maxn][26],val[maxn];
int le;
void Insert(string s){
    int p=0,len=s.size();
    for (int i=len-1;i>=0;i--){
        int r=s[i]-'a';
        if(T[p].next[r]<=0){
            T[p].next[r]=++le;
			T[le].type=r;
        }
        p=T[p].next[r]; 
    }
	val[p]++;
}
void dfs(int x){
	for(int i=0,v;i<26;i++){
		v=T[x].next[i];
		if(v<=0) continue;
		dfs(v);
		val[x]+=val[v];
		for(int j=0;j<26;j++){
			dp[x][j]+=dp[v][j];
		}
	}
	dp[x][T[x].type]=val[x];
}
long long ans,xx;
void query(string s){
    int p=0,len=s.size();
    xx=0;
    for (int i=len-1;i>=1;i--) {
        int r=s[i]-'a';
        if(T[p].next[r]<=0) {
            return;
        }
        p=T[p].next[r];
    }
   	for(int i=0,v;i<26;i++){
   		v=T[p].next[i];
   		if(v<=0) continue;
   		xx+=dp[v][s[0]-'a'];
	}
	ans+=xx;
}
string s[1000005];
int n;
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    le=1;
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>s[i];
    	Insert(s[i]);
	}
	dfs(0);
    for(int i=1;i<=n;i++){
    	query(s[i]);
	}
	cout<<ans-n;
	return 0;
}


Measured memory_bytes: 297196
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

int main() {
    double n, m, d;
    cin >> n >> m >> d;
    if (d == 0){
        cout << setprecision(10) << (m - 1.0) / n << endl;
    }else{
        cout << setprecision(10) << ((m - 1.0) * (n - d) * 2.0) / n / n  << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr ll MOD = (ll)1e9 + 7;
constexpr ll MOD2 = 998244353;
constexpr ll HIGHINF = (ll)1e18;
constexpr ll LOWINF = (ll)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    V<int> p(N);
    REP(i,N) cin >> p[i];
    int ans = 0;
    for(int i = 1; i + 1 < N; ++i){
        if(p[i-1]<p[i]&&p[i]<p[i+1]) ans++;
        if(p[i-1]>p[i]&&p[i]>p[i+1]) ans++;
    }
    cout << ans << endl;
 

    return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int t[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)t[i]=-1;
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);
		p--;q--;
		t[q]=max(t[q],p);
	}
	int ret=0;
	int las=0;
	for(int i=0;i<a;i++){
		if(t[i]>=las){
			las=i;
			ret++;
		}
	}

	printf("%d\n",ret);
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, x;
    cin >> a >> b >> x;
    if(a > 0) cout << b/x - (a - 1)/x << endl;
    else cout << b/x - a/x + 1 << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
double a[1010],n,tot=1,cnt;
double s;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	    tot*=a[i];
	}
	for(int i=1;i<=n;i++){
	    cnt+=tot/a[i];
	}
	s=tot/cnt;
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 101, inf = 1000111222;

void check(vector<int> ans, vector<int> v) {
    vector<int> a;
    for (int i = 0; i < v.size(); ++i) {
        if (ans[i] > a.size()) {
            cout << -1;
            exit(0);
        }
        a.insert(a.begin() + ans[i], ans[i]);
    }
    if (a != v) {
        cout << -1;
        exit(0);
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    vector<int> v, v1;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        --a;
        v.PB(a);
    }
    v1 = v;
    vector<int> ans;
    for (int i = 0; i < n; ++i) {
        int lst = -1;
        for (int j = 0; j < v.size(); ++j) {
            if (v[j] == j) {
                lst = j;
            }
        }
        if (lst == -1) {
            cout << -1;
            return 0;
        }
        int j = lst;
        ans.PB(lst);
        v.erase(v.begin() + j, v.begin() + j + 1);
    }
    reverse(ans.begin(), ans.end());
    check(ans, v1);
    for (int a : ans) {
        cout << a + 1 << "\n";
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u32 n, x, t;
  cin >> n >> x >> t;

  cout << ((n + x - 1) / x) * t;

  return 0;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S = sc.next();
      int T = 0;
      for(int i=0;i<S.length();i++){
        if((S.substring(i,i+1)).contains("+")){
          T = T + 1;
        }else{
          T = T - 1;
        }
      }
      System.out.println(T);
    }
}

Measured memory_bytes: 35552
#include <bits/stdc++.h>

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n, X);
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  int ans = abs(x[0] - X);
  rep(i, n - 1) ans = gcd(ans, abs(x[i + 1] - X));
  out(ans);
}


Measured memory_bytes: 3664
#include <iostream>
int main(){
    std::string S, T;
    std::cin >> S >> T;
    int cnt = 0;
    for(int i = 0; i<S.length(); i++){
        if(S[i] == T[i])cnt++;
    }
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = 998244353;
const LL N = 2e5+1;

int main() {
	fastio();

	LL n;
	cin >> n;
	

	vector<LL> a(n), b(n);

	for (LL i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	LL ans = 0;
	if (n % 2 == 0) {
		LL val = b[n/2] + b[n/2-1] - a[n/2] - a[n/2-1] + 1;
		if (val > 0) {
			ans = val;
		}
	}
	else {
		LL val = b[n/2] - a[n/2] + 1;
		if (val > 0) {
			ans = val;
		}
	}
	cout << ans << "\n";

}

Measured memory_bytes: 6336
#include <stdio.h>
#define MAX 100000
int partition(int *a,int p,int r){
  int x;
  int i,j;
  int tmp;
  x=a[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(a[j]<=x){
      i++;
      tmp=a[j];
      a[j]=a[i];
      a[i]=tmp;
    }
  }
    tmp=a[i+1];
    a[i+1]=a[r];
    a[r]=tmp;
  
  return i+1;
}
int main(){
  int i,j;
  int n;
  int a[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  j=partition(a,0,n-1);
  for(i=0;i<j;i++)printf("%d ",a[i]);
  printf("[%d] ",a[j]);
  for(i=j+1;i<n-1;i++)printf("%d ",a[i]);
  printf("%d",a[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
  int k;
  cin >> k;
  string s = "ACL";
  string ans;
  for (int i = 0; i < k; i++)
  {
    ans += s;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 998244353;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    rep(i, n - k) {
        if (a[i] < a[i + k]) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4028
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

// s[0] := top,   s[1] := front 
// s[2] := right, s[3] := left
// s[4] := back,  s[5] := bottom
enum{TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM};

string list[24] = {
	"012345","024135","031425","043215","103254","120534",
	"135024","152304","201453","215043","240513","254103",
	"304152","310542","345012","351402","402351","425031",
	"430521","453201","513240","521430","534120","542310"
};

// cube[0..7] := サイコロの状態 string が返ってくる.(入力)
string cube[8];
// used[i] := cube[i] を使ったかどうか
bool used[8];
// s[k][pos] := 位置 pos のダイスの k 番目の文字が返ってくる.
char s[6][8];
// 解
bool ans;

// c1, c2 が同じアルファベットで片方が小文字, もう片方が大文字なら true を返す.
bool check(char c1, char c2){
	return (abs(c1-c2) == 32);
}

// s := いままでの使ったサイコロの状態, pos := 位置(0..7)
void dfs(int pos){
	if( ans ) return;
	if( pos == 8 ){
		ans = true;
		return;
	}
	
	for(int i=0 ; i < 8 ; i++ ){
		if( !used[i] ){
			for(int j=0 ; j < 24 ; j++ ){
				
				for(int k = 0 ; k < 6 ; k++ ){
					s[k][pos] = cube[i][list[j][k]-'0'];
				}
				
				used[i] = true;
				if( pos == 0 ){
					dfs(pos+1);
				}else if( pos == 1 ){
					if( check(s[RIGHT][0],s[LEFT][1]) ){
						dfs(pos+1);
					}
				}else if( pos == 2 ){
					if( check(s[FRONT][0],s[BACK][2]) ){
						dfs(pos+1);
					}
				}else if( pos == 3 ){
					if( check(s[RIGHT][2],s[LEFT][3]) && check(s[FRONT][1],s[BACK][3]) ){
						dfs(pos+1);
					}
				}else if( pos == 4 ){
					if( check(s[BOTTOM][0],s[TOP][4]) ){
						dfs(pos+1);
					}
				}else if( pos == 5 ){
					if( check(s[BOTTOM][1],s[TOP][5]) && check(s[RIGHT][4],s[LEFT][5]) ){
						dfs(pos+1);
					}
				}else if( pos == 6 ){
					if( check(s[BOTTOM][2],s[TOP][6]) && check(s[FRONT][4],s[BACK][6]) ){
						dfs(pos+1);
					}
				}else if( pos == 7 ){
					if( check(s[BOTTOM][3],s[TOP][7]) && check(s[FRONT][5],s[BACK][7]) && check(s[RIGHT][6],s[LEFT][7]) ){
						dfs(pos+1);
						return;
					}
				}
				used[i] = false;
			}
		}
	}
}

int main(){
	string s_;
	while( cin >> s_ , s_ != "0" ){
		// 初期化
		ans = false;
		cube[0] = s_;
		for(int i=0 ; i < 8 ; i++ ) used[i] = false;
		
		for(int i=1 ; i < 8 ; i++ ){
			cin >> cube[i];
		}
		dfs(0);
		cout << (ans? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 1188
n,h = map(int,input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
ab = sorted(ab, key=lambda x: -x[0])
x,y = ab.pop(0)
ab.append([x,y])
ab = sorted(ab, key=lambda x: -x[1])
count = 0
for i ,j in ab:
    if x <= j:
        h -= j
        count += 1
        if h <= 0:
            print(count)
            exit()
    else:
        break

if h%x==0:
    print(count+h//x)
else:
    print(count+1+h//x)

Measured memory_bytes: 74328
n, m = map(int, input().split())
ans = [False for _ in range(n)]
f = [0 for _ in range(n)]
t = 0
fsum = 0
for i in range(m):
    a, b = input().split()
    if not ans[int(a) - 1]:
        if b == 'AC':
            t += 1
            ans[int(a) - 1] = True
            fsum += f[int(a) - 1]
        else:
            f[int(a) - 1] += 1
print(t, fsum)

Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
int Nint;
string N;
vector<string> ans;
string s753 = "753";
int len;


bool ok(string s){
    int n = s.size();
    map<char, int> map;
    rep(i,n){
        map[s[i]]++;
    }
    return map.size() >= 3 && Nint >= stoi(s);
}

void dfs(string s){
    if((int)s.size() > len)return;
    if(ok(s))ans.push_back(s);
    rep(i,3){
        string nxt = s;
        nxt.push_back(s753[i]);
        dfs(nxt);
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    cin >> N;
    Nint = stoi(N);
    len = N.size();
    dfs("");
    cout << ans.size() << endl;
}

Measured memory_bytes: 2044
#include <stdio.h>


int main(void){
    int k[32];
    k[0] = 1;
    k[1] = 1;
    k[2] = 1;
    k[3] = 2;
    k[4] = 1;
    k[5] = 2;
    k[6] = 1;
    k[7] = 5;
    k[8] = 2;
    k[9] = 2;
    k[10] = 1;
    k[11] = 5;
    k[12] = 1;
    k[13] = 2;
    k[14] = 1;
    k[15] = 14;
    k[16] = 1;
    k[17] = 5;
    k[18] = 1;
    k[19] = 5;
    k[20] = 2;
    k[21] = 2;
    k[22] = 1;
    k[23] = 15;
    k[24] = 2;
    k[25] = 2;
    k[26] = 5;
    k[27] = 4;
    k[28] = 1;
    k[29] = 4;
    k[30] = 1;
    k[31] = 51;
    int i;
    scanf("%d", &i);
    printf("%d\n", k[i - 1]);

    return 0;
}

Measured memory_bytes: 128
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto tmp = readln.split.to!(int[]);
    auto A = tmp[0], B = tmp[1];

    enum W = 100, H = 100;

    char[][] cell = new char[][](W, H);

    foreach (y; 0..H) {
        foreach (x; 0..W/2) {
            cell[x][y] = '.';
        }
        foreach (x; W/2..W) {
            cell[x][y] = '#';
        }
    }

    {
        int x = W/2+1, y = 0;
        while (A > 1) {
            cell[x][y] = '.';
            A--;
            if (x+2 >= W) {
                x = W/2+1;
                y += 2;
            } else {
                x += 2;
            }
        }

        x = 0;
        y = 0;
        while (B > 1) {
            cell[x][y] = '#';
            B--;
            if (x+2 >= W/2-1) {
                x = 0;
                y += 2;
            } else {
                x += 2;
            }
        }
    }

    writefln("%d %d", W, H);
    foreach (y; 0..H) {
        foreach (x; 0..W) {
            write(cell[x][y]);
        }
        writeln;
    }
}



Measured memory_bytes: 256
N= int(input())

p=list(map(int,input().split()))
q=sorted(p)

count=0
for i in range(len(p)):
  if p[i]!=q[i]:
    count += 1
#print(N,p,q,count, sep="\n")

#zipを使う
count=0
for a,b in zip(p,q):
  if a!=b:
    count += 1
#print(N,p,q,count, sep="\n")

print('YES' if count<=2 else 'NO')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String tap = reader.nextLine();
		boolean ban = true;
		char paso;
		for(int i=1;i<=tap.length();i++) {
			paso = tap.charAt(i-1);
			if((i & 1)==1) {
				if(paso != 'R' && paso != 'U' && paso != 'D') {
					ban = false;
					break;
				}
			}else {
				if(paso != 'L' && paso != 'U' && paso != 'D') {
					ban = false;
					break;
				}
			}
		}
		if(ban)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


Measured memory_bytes: 22996
#include<stdio.h>
#include<math.h>

double func(int n, int* x, int* y, int t, double sum, int px, int py){
    if(t == 0){
        return sum;
    }
    double a = 0;
    int k = t;
    for(int i=0; i<n; i++){
        if(k%2 == 1){
            a += func(n, x, y, t-pow(2, i), sum + sqrt(pow(px-*(x+i),2)+pow(py-*(y+i), 2)), *(x+i), *(y+i));
        }
        k = k/2;
    }
    return a;
}

int f(int n){
    int a = 1;
    for(int i=2; i<=n;i++){
        a *= i;
    }
    return a;
}

int main(){
    int n;
    scanf("%d", &n);
    int x[n], y[n];
    for(int i=0; i<n; i++){
        scanf("%d%d", &x[i], &y[i]);
    }
    double ans = 0;
    int t = pow(2, n)-1;
    for(int i=0; i<n; i++){
        ans += func(n, x, y, t - pow(2,i), 0, x[i], y[i]);
    }
    ans = ans/f(n);
    printf("%lf", ans);

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

using Weight = int;

struct Edge {
	size_t from;
	size_t to;
	Weight cost;
	Edge(size_t t, Weight c) : to(t), cost(c) {}
	Edge(size_t f, size_t t, Weight c) : from(f), to(t), cost(c) {}
	bool operator<(const Edge& rhs) const { return this->cost > rhs.cost; }
};

struct Graph {
	size_t node;
	std::vector<std::vector<Edge>> edges;

	Graph(size_t n) : node(n), edges(n) {}
};

std::vector<Weight> dijkstra(const Graph& graph, const size_t s) {
	size_t n = graph.node;
	std::vector<bool> used(n, false);
	std::vector<Weight> distances(n, INF);

	distances[s] = 0;
	std::priority_queue<Edge> pq;
	pq.push(Edge(s, 0));
	while(!pq.empty()) {
		Edge edge = pq.top();
		pq.pop();
		if(used[edge.to]) {
			continue;
		}
		used[edge.to] = true;
		for(auto&& e : graph.edges[edge.to]) {
			Weight alt = edge.cost + e.cost;
			if(alt < distances[e.to]) {
				distances[e.to] = alt;
				pq.push(Edge(e.to, alt));
			}
		}
	}

	return distances;
}

int main() {
	int v, e, r;
	scanf("%d %d %d", &v, &e, &r);
	Graph graph(v);
	REP(i, e) {
		int s, t, d;
		scanf("%d %d %d", &s, &t, &d);
		graph.edges[s].push_back(Edge(t, d));
	}
	VI dists = dijkstra(graph, r);

	EACH(e, dists) {
		if(e == INF) {
			puts("INF");
		} else {
			printf("%d\n", e);
		}
	}

	return 0;
}


Measured memory_bytes: 25028
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+9;
int n;
int a[maxn],m1=-1,m2=-1;
int main(){
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        if(a[i]>=m1){
            m2=m1;
            m1=a[i];
        }else if(a[i]>=m2){
            m2=a[i];
        }
    }
    for(int i=1;i<=n;++i){
        printf("%d\n",a[i]==m1?m2:m1);
    }
    return 0;
}

Measured memory_bytes: 2432
N, K = map(int, input().split())
x_coordinate = list(map(int, input().split()))
zero_pos = 0
distance = []

while True:
  try:
    if x_coordinate[zero_pos] >= 0:
      break
    else:
      zero_pos += 1
  except:
    zero_pos = N - 1
    break

for i in range(zero_pos - K, zero_pos + 1):
  if (i >= 0) and (i + K - 1 < N):
    start_pos = x_coordinate[i]
    end_pos = x_coordinate[i + K - 1]
    if start_pos*end_pos >= 0:
      if abs(start_pos) > abs(end_pos):
        distance.append(abs(start_pos))
      else:
        distance.append(abs(end_pos))
    else:
      if abs(start_pos) >= abs(end_pos):
        total = abs(start_pos) + 2*abs(end_pos)
        distance.append(total)
      else:
        total = 2*abs(start_pos) + abs(end_pos)
        distance.append(total)
      
print(min(distance))

Measured memory_bytes: 14780
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#define ll __int64
#define mmax 1010
using namespace std;
int main()
{
    for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
            printf("%dx%d=%d\n",i,j,i*j);
        return 0;
}

Measured memory_bytes: 1096
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var W = vals[0];
        var H = vals[1];
        var x = vals[2];
        var y = vals[3];

        var area = W * (double)H / 2.0;
        var isCenter = x * 2 == W && y * 2 == H;
        Console.WriteLine($"{area} {(isCenter ? 1 : 0)}");
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<pair<int,int>> WE(N);
    if('W' == S[0]){
        WE[0] = {1,0};
    }else{
        WE[0] = {0,1};
    }
    for(int i=1; i<N; i++){
        if('W' == S[i]){
            WE[i] = {WE[i-1].first+1,WE[i-1].second};
        }else{
            WE[i] = {WE[i-1].first,WE[i-1].second+1};
        }
    }
    int ans = N;
    REP(i,N){
        int cnt = 0;
        if(i == 0){
            cnt += WE[N-1].second;
            if(S[i] == 'E')cnt--;
        }else if(i == N-1){
            cnt += WE[N-2].first;
        }else{
            cnt += WE[i-1].first;
            cnt += WE[N-1].second - WE[i-1].second;
            if(S[i] == 'E')cnt--;
        }
        chmin(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6168
n = int(input())
s = input()
ecounter = [0 for _ in range(n)]
wcounter = [0 for _ in range(n)]
ecounter[0] = int(s[0]=='E')
wcounter[n-1] = int(s[n-1]=='W')
ans = n
for i in range(n-1):
    ecounter[i+1] = ecounter[i] + (s[i+1]=='E')
    wcounter[n-2-i] = wcounter[n-1-i] + (s[n-2-i]=='W')
for j in range(n):
    cnt = n - (ecounter[j]+wcounter[j])
    ans = min(cnt,ans)
print(ans)

Measured memory_bytes: 118036
#include <bits/stdc++.h>
using namespace std;

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int64_t N, sum = 0;
    cin >> N;
    vector<int64_t> list(N);

    for (int i = 0; i < N; i++)
    {
        cin >> list[i];
        sum = (sum + list[i]) % MOD;
    }
    int ans = (sum * sum) % MOD;
    for (int i = 0; i < N; i++)
    {
        int64_t tmp = list[i] * list[i] % MOD;
        ans = (ans - tmp + MOD) % MOD;
    }
    if (ans % 2 == 0)
        cout << ans / 2;
    else
        cout << (ans + MOD) / 2;
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll r,g,b,n;cin>>r>>g>>b>>n;
  ll ans = 0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      ll num = n-i*r-j*g;
      if(num >= 0 && num%b == 0){
	ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
YY = int(s[0] + s[1])
MM = int(s[2] + s[3])
if 0 < YY < 13 and 0 < MM < 13:
    print("AMBIGUOUS")
elif YY >= 0 and 0 < MM < 13:
    print("YYMM")
elif 0 < YY < 13 and MM >= 0:
    print("MMYY")
elif YY <= 0 or 13 <= YY or MM <= 0 or 13 <= MM:
    print("NA")

Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int main()
{
	int x=read(),y=read(),ans=0;
	if(x<=3)ans+=(4-x)*100000;
	if(y<=3)ans+=(4-y)*100000;
	if(x==1&&y==1)ans+=400000;
	writeln(ans);
	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
def resolve():
    H,W,M = map(int,input().split())
    xc = defaultdict(int)
    yc = defaultdict(int)
    pos = set()

    for i in range(M):
        h,w = map(int,input().split())
        xc[w]+=1
        yc[h]+=1
        pos.add((h,w))
    xmax = max(xc.values())
    ymax = max(yc.values())
    xk = [k for k,v in xc.items() if v == xmax]
    yk = [k for k,v in yc.items() if v == ymax]
    for i in yk:
        for j in xk:
            if not (i,j) in pos:
                print(xmax+ymax)
                return
    print(xmax+ymax-1)
resolve()

Measured memory_bytes: 186704
li = [int(input()) for i in range(5)]
li_amari = []
time = 0
for i in li:
    if (i % 10 == 0):
        li_amari.append(0)
    else:
        li_amari.append(10 - (int(i % 10)))

a = li_amari.index(max(li_amari))

max_li = li[a]

del li[a]
del li_amari[a]

for j in range(4):
    time += (li[j]+li_amari[j])

print(time + max_li)


Measured memory_bytes: 3064
#include<stdio.h>
int i,j,a,b,c[200],d[200],e[200],f[200],g[200],h[1000][1000],m=0,k,kf=0,fkk=0,im=-1;
int main(void)
{
	scanf("%d %d",&a,&b);
	for(i=0;i<a;i++){
		scanf("%d",&c[i]);
	}
	for(i=0;i<a;i++){
		for(j=0;j<b;j++){
			h[i][j]=-1;
		}
	}
	for(i=0;i<b;i++){
		scanf("%d %d %d",&d[i],&e[i],&f[i]);
	}
	for(i=0;i<b;i++){
		if(c[0]>=d[i] && c[0]<=e[i]){
			h[0][i]=0;
		}
	}
	for(i=0;i<a-1;i++){
		for(j=0;j<b;j++){
			if(h[i][j]!=-1){
				for(k=0;k<b;k++){
					if(c[i+1]>=d[k] && c[i+1]<=e[k]){
						kf=f[j]-f[k];
						if(kf<0){
							kf*=-1;
						}
						if(kf+h[i][j]>h[i+1][k]){
							h[i+1][k]=h[i][j]+kf;
						}
					}
				}
			}
		}
	}
	for(i=0;i<a;i++){
		if(m<h[a-1][i]){
			m=h[a-1][i];
		}
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 1812
#include <iostream>
#include <set>
using namespace std;

const int MAX = 100010;

int parent[MAX], tree_rank[MAX];

void init(int n) {
  // n:要素数
  for (int i = 0; i < n; i++) {
    parent[i] = i;
    tree_rank[i] = 0;
  }
}

int find(int x) {
  // xの根を求める
  if (parent[x] == x) {
    return x;
  } else {
    return parent[x] = find(parent[x]);
    // 繋ぎ変え
  }
}

void unite(int x, int y) {
  // xが入っている集合とyが入っている集合をくっつける
  int rx = find(x);
  int ry = find(y);
  if (rx == ry) {
    // もし同じ集合なら
    return;
  }
  if (tree_rank[rx] < tree_rank[ry]) {
    parent[rx] = ry;
  } else {
    parent[ry] = rx;
    if (tree_rank[rx] == tree_rank[ry]) {
      tree_rank[rx]++;
    }
  }
}

bool issame(int x, int y) { return find(x) == find(y); }

int main() {
  int n, m;
  cin >> n >> m;
  init(n);
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    unite(x, y);
  }
  set<int> roots;
  for (int i = 0; i < n; i++) {
    roots.insert(find(i));
  }
  cout << roots.size() << endl;
}


Measured memory_bytes: 5760
N = int(input())
A = list(map(int, input().split()))


from collections import Counter
def Main(N, A):
    A.sort()
    amax = A[-1]+1
    d = {}
    for i in range(1, amax):
        d[i] = 0
    for a in A:
        i = 1
        while a*i < amax:
            d[a*i] += 1
            i += 1
    ans = 0
    for a in A:
        if d[a] == 1:
            ans += 1
    return ans

print(Main(N, A))

Measured memory_bytes: 103336
N = int(input())
rest = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    rest.append([i+1, s, p])
rest.sort(key=lambda x:x[2],reverse=True)
rest.sort(key=lambda x:x[1])
for i, s, p in rest:
    print(i)


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s == "SAT"){
        cout << "1" << endl;
    }
    if(s == "SUN"){
        cout << "7" << endl;
    }
    if(s == "MON"){
        cout << "6" << endl;
    }
    if(s == "TUE"){
        cout << "5" << endl;
    }
    if(s == "WED"){
        cout << "4" << endl;
    }
    if(s == "THU"){
        cout << "3" << endl;
    }
    if(s == "FRI"){
        cout << "2" << endl;
    }

}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
                divisors.append([n//i,i])

    # divisors.sort()
    
    return divisors

def resolve():

    a = int(input())
    divisors = make_divisors(a)
    anss= [] 
    for i in range(len(divisors)):
        anss.append(sum(divisors[i]))
    print(min(anss) - 2)

    
resolve()

Measured memory_bytes: 3688
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        long k=Long.parseLong(str[1]);
        int next[]=new int[n+1];
        int cnttillthere[]=new int[n+1];
        int cntr=0;
        str=br.readLine().split(" ");
        for(int i=0;i<n;i++)
        next[i+1]=Integer.parseInt(str[i]);
        int nxt=1;
        Arrays.fill(cnttillthere,-1);
        cnttillthere[1]=0;
        while(true)
        {
            if(cnttillthere[next[nxt]]>=0||k==0)
            break;
            cntr++;
            cnttillthere[next[nxt]]=cntr;
            nxt=next[nxt];
            k--;
        }
        if(k==0)
        pw.println(nxt);
        else
        {
            int noe=cntr+1-cnttillthere[next[nxt]];
            k--;
            int rem=(int)(k%noe);
            nxt=next[nxt];
            for(int i=0;i<rem;i++)
            nxt=next[nxt];
            pw.println(nxt);
        }
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 61784
#include <cstdio>
#include <iostream>

using namespace std;

const int N = 1e5 + 5;

#define ll long long

ll n , s;

ll x[N] , p[N];

ll solve(ll l , ll r , ll w){
	if(s < x[l])
		return x[r] - s;
	if(s > x[r])
		return s - x[l];
	if(p[l] >= p[r]){
		p[l] += p[r];
		return solve(l , r - 1 , l) + ((w == r) ? (x[r] - x[l]) : 0);	
	}
	else{
		p[r] += p[l];
		return solve(l + 1 , r , r) + ((w == l) ? (x[r] - x[l]) : 0);
	}
}

int main(){
	cin >> n >> s;
	for(int i = 1; i <= n; i++)
		cin >> x[i] >> p[i];
	cout << solve(1 , n , p[1] < p[n] ? 1 : n) << endl;
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {

     string s;
     int a;
     cin >> a;
     cin >> s;
     int count = 0;
     for(int i = 0;i < a;i++){
      if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
        count++;
      }
     }
     cout << count << endl;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[10];
int main()
{
    ll n,t,x,y=0,i,j,c=0;
    cin>>n;
    for(i= 0 ; i<n ; i++)
    {
        cin>>x;
        if(x>=3200)
            c++;
        else if(x>=2800)
            a[0]++;
        else if(x>=2400)
            a[1]++;
        else if(x>=2000)
            a[2]++;
        else if(x>=1600)
            a[3]++;
        else if(x>=1200)
            a[4]++;
        else if(x>= 800)
            a[5]++;
        else if(x>= 400)
            a[6]++;
        else if(x>=1)
            a[7]++;
    }
    for(i = 0 ; i<9 ; i++)
    {
        if(a[i]>0)
            y++;
    }
    if(y>0)
        cout<<y<<" ";
    else{
        cout<<1<<" ";
        //return 0;
    }
    if(c==0)
        cout<<y<<endl;
    else
    {
        y+=c;
            cout<<y<<endl;
    }
    return 0;
}


Measured memory_bytes: 256