akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class DBrickBreak {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    vector<int> a(N);
	    REP(i,0,N) in >> a[i];
	    int answer = 0;
	    int num = 1;
	    REP(i,0,N) {
	        if (num == a[i]) {
	            num++;
	        } else {
	            answer++;
	        }
	    }
	    if (answer == N) {
	        out << -1 << "\n";
	    } else {
            out << answer << "\n";
	    }
	}
};


signed main() {
	DBrickBreak solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a[]=new int[3];
		a[0]=scan.nextInt();
		a[1]=scan.nextInt();
		a[2]=scan.nextInt();
	Arrays.sort(a);
		System.out.println(a[2]-a[1]+(a[1]-a[0]));
		}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a,b,ab,x,y,pr=0;
    scanf("%lld %lld %lld %lld %lld",&a,&b,&ab,&x,&y);
    ll ans=((a*x)+(b*y));
    if(x>y)
    {
        pr=((2*y*ab)+(x-y)*a);
        ll aa=(2*x*ab);
        //cout<<aa<<endl;
        pr=min(pr,aa);
    }
    else
    {
        pr=((2*x*ab)+(y-x)*b);
        ll aa=(2*y*ab);
        //cout<<aa<<endl;
        pr=min(pr,aa);
    }
    cout<<min(pr,ans)<<endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int64_t> lucas(n + 1);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for(int i = 2; i <= n; i++) {
    lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
  }
  cout << lucas.at(n) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  string S;
  cin>>S;
  
  bool CAN=false;
  for(int i=0; i<S.size()-1; ++i){
    for(int j=i+1; j<S.size(); ++j){
      if(S.at(i)=='C' && S.at(j)=='F') CAN=true;
    }
  }
  
  if(CAN) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    while(N != 0){
        vector<int> A(N);
        for(int i=0; i<N; i++){
            cin >> A[i];
        }
        int mx = inf;
        sort(A.begin(),A.end());
        for(int i=0; i<N-1; i++){
            chmin(mx,A[i+1]-A[i]);
        }
        cout << mx << endl;
        cin >> N;
    }
    return 0;
}


Measured memory_bytes: 3160
#define rep(i, n) for(ll i = 0; i < n; i++)
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	public void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[] X = new long[N];
		long[] Y = new long[N];
		long[] Z = new long[N];
		for (int i = 0; i < N; ++i) {
			X[i] = sc.nextLong();
			Y[i] = sc.nextLong();
			Z[i] = sc.nextLong();
		}
		long ans = 0;
		for (int i = -1; i <= 1; i += 2) {
			for (int j = -1; j <= 1; j += 2) {
				for (int k = -1; k <= 1; k += 2) {

					long[][] a = new long[N][];
					for (int t = 0; t < N; ++t) {
						a[t] = new long[] { X[t] * i, Y[t] * j, Z[t] * k };
					}
					Arrays.sort(a, new Comparator<long[]>() {
						@Override
						public int compare(long[] o1, long[] o2) {
							return Long.compare(o1[0] + o1[1] + o1[2], o2[0] + o2[1] + o2[2]);
						}
					});
					long x = 0, y = 0, z = 0;
					for (int t = 0; t < M; ++t) {
						x += a[t][0];
						y += a[t][1];
						z += a[t][2];
					}
					ans = Math.max(ans, Math.abs(x) + Math.abs(y) + Math.abs(z));
				}
			}
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

}


Measured memory_bytes: 22956
#include<bits/stdc++.h>
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
    for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
    return x*f;
}
const int N=1e4+28,M=1e7+28,inf=0x3f3f3f3f;
int st,ed,ans;
int head[N],cnt=1,dis[N],pre[N],lst[N];
struct Line{int to,nxt,val;}l[2*N];
void Ins(int x,int y,int z){
    l[++cnt].to=y;
    l[cnt].nxt=head[x];
    l[cnt].val=z;
    head[x]=cnt;
}
queue<int>q;
bool Bfs(){
    memset(dis,0,sizeof(dis));
    while(q.size())q.pop();
    dis[st]=1,q.push(st);
    while(q.size()){
	int x=q.front();q.pop();
	for(int i=head[x];i;i=l[i].nxt){
	    if(l[i].val&&!dis[l[i].to]){
		dis[l[i].to]=dis[x]+1;
		if(l[i].to==ed)return true;
		q.push(l[i].to);
	    }
	}
    }
    return false;
}
int Dinic(int x,int limit){
    if(x==ed)return limit;
    int re=0;
    for(int i=head[x],k;i;i=l[i].nxt){
	if(dis[l[i].to]==dis[x]+1&&(k=Dinic(l[i].to,min(limit,l[i].val)))){
	    l[i^1].val+=k,l[i].val-=k;
	    re+=k,limit-=k;
	    if(!limit)break;
	}
    }
    return re;
}
int pr[M],apr[M],tot;
void Pre(int n=1e7+20){
    apr[0]=apr[1]=1;
    for(int i=2;i<=n;i++){
	if(!apr[i])pr[++tot]=i;
	for(int j=1;j<=tot&&pr[j]*i<=n;j++){
	    apr[pr[j]*i]=1;
	    if(i%pr[j]==0)break;
	}
    }
}
int k,a[M],L[N],R[N],sum,mx,n,c1,c2;
signed main(){
    //freopen("oatmeal.in","r",stdin);
    //freopen("oatmeal.out","w",stdout);
    Pre();
    k=read();
    for(int i=1;i<=k;i++){
	int x=read();
	a[x]=1;
	mx=max(x,mx);
    }
    for(int i=1;i<=mx+1;i++){
	if(a[i]!=a[i-1]){
	    if(i&1)L[++c1]=i;
	    else R[++c2]=i;
	}
    }
    st=c1+c2+1,ed=c1+c2+2;
    for(int i=1;i<=c1;i++)
	Ins(st,i,1),Ins(i,st,0);
    for(int i=1;i<=c2;i++)
	Ins(i+c1,ed,1),Ins(ed,i+c1,0);
    for(int i=1;i<=c1;i++){
	for(int j=1;j<=c2;j++){
	    if(apr[abs(L[i]-R[j])])continue;
	    Ins(i,j+c1,1);
	    Ins(j+c1,i,0);
	}
    }
    while(Bfs())ans+=Dinic(st,inf);
    int tmp=ans;
    c1-=tmp,c2-=tmp;
    ans+=2*(c1/2)+2*(c2/2);
    if(c1&1)ans+=3;
    printf("%lld",ans);
    return 0;
}
/*
9
1 2 3 4 5 6 7 8 9
*/


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

struct edge{
  ll to,a,b;
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m,s,t;
  cin>>n>>m>>s>>t;
  vector<vector<edge>> g(n+1);
  rep(i,m){
    int u,v,x,y;
    cin>>u>>v>>x>>y;
    g[u].push_back({v,x,y});
    g[v].push_back({u,x,y});
  }
  vector<ll> d1(n+1,inf),d2(n+1,inf);
  d1[s]=0,d2[t]=0;
  priority_queue<P,vector<P>,greater<P>> que1,que2;
  que1.push(P(0,s)),que2.push(P(0,t));
  while(!que1.empty()){
    P now=que1.top();
    que1.pop();
    if(d1[now.se]<now.fi) continue;
    for(auto itr:g[now.se]){
      if(d1[itr.to]>d1[now.se]+itr.a){
        d1[itr.to]=d1[now.se]+itr.a;
        que1.push(P(d1[itr.to],itr.to));
      }
    }
  }
  while(!que2.empty()){
    P now=que2.top();
    que2.pop();
    if(d2[now.se]<now.fi) continue;
    for(auto itr:g[now.se]){
      if(d2[itr.to]>d2[now.se]+itr.b){
        d2[itr.to]=d2[now.se]+itr.b;
        que2.push(P(d2[itr.to],itr.to));
      }
    }
  }
  vector<ll> ans(n+1,(ll)1<<60);
  for(int i=n-1;i>=0;i--){
    ans[i]=min(ans[i+1],d1[i+1]+d2[i+1]);
  }
  rep(i,n) cout<<(ll)1e15-ans[i]<<endl;
}

Measured memory_bytes: 14200
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

constexpr double pi = 3.14159265359;

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int R; std::cin >> R;
  std::cout << std::fixed << std::setprecision(8) << 2.*R*pi << std::endl;
  return 0;
}



Measured memory_bytes: 3800
A, B = map(int, input().split())

#A<= x*0.08 <A+1
#B<= x*0.10 <B+1

x=int(B*10)
while x<10*(B+1):
	if A<=x*0.08 and x*0.08<A+1:
		print(x)
		exit()
	x+=1
print(-1)

Measured memory_bytes: 61872
h,w = map(int,input().split())
s = [input() for _ in range(h)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            flag = False
            for k in range(4):
                if 0<=j+dx[k]<w and 0<=i+dy[k]<h:
                    if s[i+dy[k]][j+dx[k]]=='#':
                        flag = True
            if not flag:
                print('No')
                exit()
print('Yes')

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

typedef long long ll;
const int N = 400 + 5;
const ll mod = (ll)1e9 + 7;

int n, c, num[N];
ll fac[N], facinv[N];
ll inv[N];
ll dp[N][N], psum[N][N];
ll a[N], b[N];

ll fp(ll x, ll k){
    if(k == 0) return 1;
    ll hf = fp(x, k/2);
    return k % 2 ? hf * hf % mod * x % mod: hf * hf % mod;
}

ll solve(int i, int sum) {
    if(i == 0) return sum == 0;
    if(dp[i][sum] != -1) return dp[i][sum];

    dp[i][sum] = 0;
    for(int k = 0; k <= sum; k++) {
        dp[i][sum] += solve(i-1, sum - k) * (psum[k][b[i]] - psum[k][a[i] - 1] + mod) % mod;
        dp[i][sum] %= mod;
    }
    return dp[i][sum];
}

int main(){
    inv[1] = 1;
    for(int i = 2; i < N; i++) inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
    fac[0] = 1;
    for(int i = 1; i <= N-1; i++) fac[i] = fac[i-1] * i % mod;
    facinv[N-1] = fp(fac[N-1], mod - 2);
    for(int i = N-1 - 1; i >= 0; i--) facinv[i] = facinv[i+1] * (i+1) % mod;

    memset(dp, -1, sizeof(dp));
    cin >> n >> c;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];


    for(int p = 0; p < N; p++) {
        for(int j = 1; j < N; j++) psum[p][j] = (psum[p][j-1] + fp(j, p)) % mod;
    }
    cout << solve(n, c) << endl;

}



Measured memory_bytes: 2816
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef complex<double> point;

#define X real()
#define Y imag()
#define angle(a) (atan2((a).imag(), (a).real()))
#define vec(a, b) ((b) - (a))
#define same(p1, p2) (dp(vec(p1, p2), vec(p1, p2)) < EPS)
#define dp(a, b) ((conj(a) * (b)).real())
#define cp(a, b) ((conj(a) * (b)).imag())
#define length(a) (hypot((a).imag(), (a).real()))
#define normalize(a) (a) / length(a)
#define rotateO(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotateO(vec(about, p), ang) + about)
#define reflectO(v, m) (conj((v) / (m)) * (m))
#define clr(a, b) memset(a, b, sizeof(a));

const ll N = 100005;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

ll n, h[N];
ll memo[N];

ll solve(int i)
{
	if(i == n - 1)
		return 0;

	ll& ret = memo[i];
	if(~ret)
		return ret;

	ret = solve(i + 1) + llabs(h[i] - h[i + 1]);

	if(i < n - 2)
		ret = min(ret, solve(i + 2) + llabs(h[i] - h[i + 2]));

	return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++)
    	cin >> h[i];
    clr(memo, -1);
    cout << solve(0) << endl;
}

Measured memory_bytes: 4992
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    private static Scanner in = new Scanner(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        String s = in.next();

        boolean toRight = true;
        int l = 0;
        int mid = 0;
        int r = 0;
        int[] ans = new int[s.length()];
        char[] ch = s.toCharArray();
        for (int i=0; i < s.length(); i++) {
            if (toRight && ch[i] == 'L') {
                mid = i - 1;
                toRight = false;
            } else if (!toRight && ch[i] == 'R') {
                r = i - 1;
                toRight = true;
                ans[mid] += (r - mid) / 2 + 1;
                ans[mid+1] += (r - mid + 1) / 2;

                ans[mid] += (mid - l) / 2;
                ans[mid+1] += (mid - l + 1) / 2;

                l = i;
            }
        }

        r = s.length() - 1;
        ans[mid] += (r - mid) / 2 + 1;
        ans[mid+1] += (r - mid + 1) / 2;

        ans[mid] += (mid - l) / 2;
        ans[mid+1] += (mid - l + 1) / 2;

        StringBuilder a = new StringBuilder();
        for (int i=0; i < s.length() - 1; i++) {
            a.append(ans[i]).append(" ");
        }
        a.append(ans[s.length()-1]);
        out.println(a);
    }

}


Measured memory_bytes: 26208
N, K = map(int, input().split())
d = [0]*(10**5+1)
sum_d = 0

for _ in range(N):
    a, b = map(int, input().split())
    d[a] += b

for i in range(1, 10**5+1):
    sum_d += d[i]
    if(sum_d >= K):
        print(i)
        break

Measured memory_bytes: 5736
#include <iostream>
#include <algorithm>

using namespace std;

int n, h[100000] = {}, dp[100010] = {};

int main() {

	for (int i = 0; i < 100010; i++) {
		dp[i] = 1e9;// = 10^9
	}
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}


	dp[1] = 0;

	for (int i = 2; i <= n; i++) {

		if (i == 2) {

			dp[i] = abs(h[i - 1] - h[i - 2]);//添え字が1ずれていることに注意!

		}
		else {

			dp[i]

				= min(dp[i - 1] + abs(h[i - 1] - h[i - 2]), dp[i - 2] + abs(h[i - 1] - h[i - 3]));

		}

	}

	cout << dp[n] << endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	vector<int> x(5);
	x.push_back(a); x.push_back(b); x.push_back(c);
	x.push_back(d); x.push_back(e);
	sort(x.rbegin(), x.rend());
	if (x[0] - x[4] <= k) cout << "Yay!";
	else cout << ":(";
	return 0;
}










Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<cstring>
const int maxn=1010,mod=1000000007;
int n,m;
long long k;
char s[maxn][maxn];
int p,q,r;
bool ta,tb;
struct Matrix {
	int a[3][3];
	void cls() {
		memset(a,0,sizeof a);
	}
}c;
Matrix operator * (const Matrix &a,const Matrix &b) {
	c.cls();
	for(register int i=0;i<3;++i)for(register int k=0;k<3;++k)for(register int j=0;a.a[i][k]&&j<3;++j)
	b.a[k][j]?c.a[i][j]=(c.a[i][j]+1ll*a.a[i][k]*b.a[k][j])%mod:0;
	return c;
}
Matrix f,x;
int pw(register int x,register long long y) {
	register int s=1;
	for(;y;y>>=1,x=1ll*x*x%mod)y&1?s=1ll*s*x%mod:0;
	return s;
}
void pw(register long long y) {
	for(;y;y>>=1,x=x*x)if(y&1)f=f*x;
}
int main() {
	scanf("%d%d%lld",&n,&m,&k);
	for(register int i=0;i<n;++i)scanf("%s",s[i]);
	if(!k) return puts("1"),0;
	--k;
	for(register int i=0;i<n;++i)for(register int j=0;j<m;++j)p+=s[i][j]=='#';
	for(register int i=0;i<n;++i)if(s[i][0]=='#'&&s[i][m-1]=='#') ta=1,++q;
	for(register int i=0;i<m;++i)if(s[0][i]=='#'&&s[n-1][i]=='#') tb=1,++q;
	if(ta&&tb) return puts("1"),0;
	if(!ta&&!tb) return printf("%d\n",pw(p,k)),0;
	f.a[0][0]=f.a[0][2]=1;
	if(ta) for(register int i=0;i<n;++i)for(register int j=1;j<m;++j)r+=s[i][j]=='#'&&s[i][j-1]=='#';
	else for(register int i=1;i<n;++i)for(register int j=0;j<m;++j)r+=s[i][j]=='#'&&s[i-1][j]=='#';
	x.a[0][0]=p,x.a[1][1]=p,x.a[2][1]=r,x.a[2][2]=q;
	pw(k);
	printf("%d\n",(f.a[0][0]-f.a[0][1]+mod)%mod);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> s;
  clr(d,0);
  rep(i,0,s.sz)d[s[i]-'a']++;
  s = "Yes";
  rep(i,0,26){
    if(d[i] % 2 != 0)s = "No";
  }
  print(s);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;


int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> cs_a(n + 1, 0), cs_b(m + 1, 0);
  rep(i, n)
  {
    int a;
    cin >> a;
    cs_a[i+1] = cs_a[i] + a;
  }
  rep(i, m)
  {
    int b;
    cin >> b;
    cs_b[i+1] = cs_b[i] + b;
  }
  int ans = 0;
  rep(i, n + 1)
  {
    if (cs_a[i] > k)
      break;
    int l = 0;
    int r = m + 1;
    while (l + 1 < r)
    {
      int mid = (l + r) / 2;
      if (cs_b[mid] <= k - cs_a[i])
        l = mid;
      else
        r = mid;
    }
    ans = max(ans, i + l);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

void solve()
{
  ll x; cin >> x;
  ll k1, k2;
  bool ok = false;
  k1 = x / 100;
  k2 = x / 105;
  //  cout << k2 << " - " << k1 << endl;
  for(ll i = k2; i <= k1; i++) {
    //cout << i * 100 << " - " << i * 105 << endl;
    if(i * 100 <= x && x <= i * 105) ok = true;
  }
  cout << (ok?"1":"0") << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e6+10;
struct w
{
    int x, y;
} w[100];

ll fun(ll n, ll k)
{
    ll s=1;
    while(k)
    {
        if(k&1)
        {
            s=s*n%1000000007;
        }
        n=n*n%1000000007;
        k=k/2;
    }
    return s;
}

int main()
{
    ll x, y;
    cin >> x >> y;
    ll x2=2*y-x;
    if(x2%3==0)
    {
        x2=x2/3;
        ll y2=y-2*x2;
        if(x2>=0&&y2>=0)
        {
            if(x2==0||y2==0)
            {
                printf("1\n");
            }
            else
            {
                ll n=x2+y2;
                ll z=1, v=1;
                if(n-x2<x2)
                {
                    x2=n-x2;
                }
                for(int ll i=0;i<x2;i++)
                {
                    z=z*(n-i)%1000000007;
                    v=v*(i+1)%1000000007;
                }
                z=z*fun(v,1000000005)%1000000007;
                printf("%lld\n",z);
            }
        }
        else
        {
            printf("0\n");
        }
    }
    else
    {
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  string str[8];
  
  for(int i=0 ; i < 8 ; i++)cin >>str[i];
  
  cout <<"90"<<endl;
  for(int i=0 ; i < 8 ; i++){
    for(int j=7 ; j >= 0 ; j--){
      cout <<str[j][i];
    }
    cout <<endl;
  }
  cout <<"180"<<endl;
  for(int i=7 ; i >=0 ; i--){
    for(int j=7 ; j >= 0 ;j--){
      cout <<str[i][j];
    }
    cout <<endl;
  }
  cout <<"270"<<endl;
  for(int i=7 ; i >= 0 ; i--){
    for(int j=0 ; j < 8 ; j++){
      cout <<str[j][i];
    }
    cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1184
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s;
		String[] temp = new String[2];
		HashMap<Integer,Integer> map = new HashMap<>();
		ArrayList<Integer> key = new ArrayList<>();
		int a,b;
		
		while (true) {
			s = sc.next();
			if (s.equals("0,0")) {break;}
			temp = s.split(",");
			a = Integer.parseInt(temp[0]);
			b = Integer.parseInt(temp[1]);
			
			map.put(a,b);
			if (!key.contains(b)) {key.add(b);}
		}
		
		int n;
		key.sort(Comparator.reverseOrder());
		
		while (sc.hasNext()) {
			out.println(key.indexOf(map.get(sc.nextInt()))+1);
		}
	}
}


Measured memory_bytes: 26012
package main

import "fmt"

import "strconv"

func main() {
	var N string
	fmt.Scan(&N)

	n := string([]rune(N)[0])

	var I int
	I, _ = strconv.Atoi(N)

	if I <= 1000 {
		fmt.Println(1000 - I)
	} else if I >= 10000 {
		fmt.Println(0)
	} else {
		m, _ := strconv.Atoi(n)
		tmp := 1000*(m+1) - I
		if tmp == 1000 {
			fmt.Println(0)
		} else {
			fmt.Println(tmp)
		}
	}

}


Measured memory_bytes: 1772
s = input()
ans1 = 0
ans2 = 0

for i in range(len(s)):
    if s[i] != str(i%2):
        ans1 += 1

for i in range(len(s)):
    if s[i] != str((i+1)%2):
        ans2 += 1

print(min(ans1,ans2))

Measured memory_bytes: 3188
N = int(input())
A = list(map(int, input().split()))
B = sorted(A)[::-1]

idx0 = 0
idx1 = N // 2

idx2 = 1
idx3 = (N + 1) // 2

print(sum(B[idx0:idx1]) + sum(B[idx2:idx3]))

Measured memory_bytes: 31440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d; 
  cin >>a>>b>>c>>d;
  if(a+b==c+d)cout<<"Balanced"<<endl;
  else if(a+b>c+d)cout<<"Left"<<endl;
  else cout<<"Right"<<endl;
  return 0;
}

Measured memory_bytes: 256
<?php

	$data = explode(" ", trim(fgets(STDIN)));
	$a = $data[0];
	$b = $data[1];
	$c = $data[2];
	$k = $data[3];
	if($k%2==0){
	    $ans = $a - $b;
	} else {
	    $ans = $b - $a;
	}
	echo $ans;
?>

Measured memory_bytes: 4604
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;

void main(){
    string[] input = readln().split();
    int a = input[0].to!int(), b = input[1].to!int();
    while(b != 0){
        a = a % b;
        swap(a, b);
    }
    a.writeln();
}

Measured memory_bytes: 972
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  string s; cin >> s;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    int a = i + 1, b = i + 2;
    if (a < n && s[i] == s[a]) {
      cout << i+1 << " " << a+1 << endl;
      return 0;
    }
    if (b < n && s[i] == s[b]) {
      cout << i+1 << " " << b+1 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
'use strict'

function main(input) {
	input = input.split('\n')
	const head = input[0].split(' ')
	const H = ~~head[0]
	const W = ~~head[1]

	const graph = input.slice(1, input.length) //.map(v => v.split(""))
	let rows = Array.apply(null, { length: H }).map(v => false)
	let cols = Array.apply(null, { length: W }).map(v => false)
	for (let r in graph) {
		//行のマークテスト
		if (/#/.test(graph[r])) {
			//r行に#あり
			rows[r] = true
			for (let c in graph[r]) {
				//この列に#あり
				if (!cols[c] && graph[r][c] == '#') cols[c] = true
			}
		}
	}
	let ans = ''

	for (let r in rows) {
		if (rows[r]) {
			//どちらもtrueならgraphから値を取得、
			for (let c in cols) {
				if (cols[c]) {
					ans += graph[r][c]
				}
			}
			ans += '\n'
		}
	}

	console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 11468
N = int(input())
def floor(x):
  if x == int(x):
    return x
  else:
    return int(x)+1
m = floor(((1+8*N)**0.5 - 1 ) /2)
S = ((m+1)*m) // 2
skip = S - N
for i in range(int(m)):
  if i+1 == skip:
    continue
  print(i+1)

Measured memory_bytes: 9444
N, K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
MOD = 10**9+7

#階乗テーブルと逆元テーブルを作成する
fac = [0]*(N+1) # 階乗テーブル
fac[0] = fac[1] = 1
inv = [0]*(N+1) # 逆元テーブル
inv[1] = 1
facinv = [0]*(N+1) # 階乗の逆元テーブル
facinv[0] = facinv[1] = 1
for i in range(2,N+1):
    fac[i] = fac[i-1]*i%MOD
    inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD
    facinv[i] = facinv[i-1] * inv[i] % MOD

def nCr(n, r, mod):
    if n < r or n < 0 or r < 0:return 0
    #毎回MODで割ってもいい。
    else:return fac[n] * (facinv[r] * facinv[n-r] % mod) % mod
    

# 各要素が最大値、最小値として何回使われるか考える
maxsum = 0
minsum = 0
for i,a in enumerate(A):
    maxsum += nCr(i, K-1, MOD)*a
    maxsum %= MOD
    minsum += nCr(N-i-1, K-1, MOD)*a
    minsum %= MOD
ans = (maxsum-minsum)%MOD

print(ans)




Measured memory_bytes: 18776
#include <stdio.h>

struct Dice
{
	int n[6];
};

Dice InputDice()
{
	Dice d;
	for(int i = 0; i < 6; ++i)
	{
		scanf("%d", &d.n[i]);
	}
	
	return d;
}

Dice SetDice(int a, int b, int c, int d, int e, int f)
{
	Dice dice;
	dice.n[0] = a;
	dice.n[1] = b;
	dice.n[2] = c;
	dice.n[3] = d;
	dice.n[4] = e;
	dice.n[5] = f;
	
	return dice;
}

Dice Roll(Dice dice, char dir)
{
	switch(dir)
	{
		case 'N':
			return SetDice(dice.n[1], dice.n[5], dice.n[2], dice.n[3], dice.n[0], dice.n[4]);
		case 'S':
			return SetDice(dice.n[4], dice.n[0], dice.n[2], dice.n[3], dice.n[5], dice.n[1]);
		case 'W':
			return SetDice(dice.n[2], dice.n[1], dice.n[5], dice.n[0], dice.n[4], dice.n[3]);
		case 'E':
			return SetDice(dice.n[3], dice.n[1], dice.n[0], dice.n[5], dice.n[4], dice.n[2]);
	}
}

bool IsSame(Dice a, Dice b)
{
	for(int i = 0; i < 6; ++i)
	{
		if(a.n[i] != b.n[i])
		{
			return false;
		}
	}
	
	return true;
}

bool IsEqual(Dice a, Dice b)
{
	char cmd[25] = "NNNNWNNNWNNNENNNENNNWNNN";
	
	for(int i = 0; i < 24; ++i)
	{
		b = Roll(b, cmd[i]);
		if(IsSame(a, b))
		{
			return true;
		}
	}
	
	return false;
}

int FindSide(Dice a, int top, int front)
{
	char cmd[25] = "NNNNWNNNWNNNENNNENNNWNNN";
	
	for(int i = 0; i < 24; ++i)
	{
		a = Roll(a, cmd[i]);
		if(a.n[0] == top && a.n[1] == front)
		{
			return a.n[2];
		}
	}
	
	return -1;
}

int main()
{
	int N;
	scanf("%d", &N);
	
	Dice D[128];
	bool ans = true;
	for(int i = 0; i < N; ++i)
	{
		D[i] = InputDice();
		
		for(int j = 0; j < i && ans; ++j)
		{
			if(IsEqual(D[i], D[j]))
			{
				ans = false;
			}
		}
	}
	
	if(ans)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
    return 0;
}



Measured memory_bytes: 2620
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <set>

using namespace std;

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

int main(void){
    int h, w;
    while (cin>>h>>w && h) {
        vector<string> s(h);
        for (int i = 0; i < h; i++) cin >> s[i];
        
        set<string> p;
        string ans = "";
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                for (int k = 0; k < 8; k++) {
                    int ny = i, nx = j;
                    string t = "";
                    t += s[ny][nx];
                    while ((ny+dy[k]+h)%h != i || (nx+dx[k]+w)%w != j) {
                        ny = (ny + dy[k] + h) % h;
                        nx = (nx + dx[k] + w) % w;
                        t += s[ny][nx];
                        
                        set<string>::iterator it = p.find(t);
                        if (it == p.end()) p.insert(t);
                        else if (t.size() > ans.size()) ans = t;
                        else if (t.size() == ans.size()) ans = min(ans, t);
                    }
                }
            }
        }
        if (ans.size() == 0) cout << 0 << endl;
        else cout << ans << endl;
    }
}

Measured memory_bytes: 35672
#include <bits/stdc++.h>
using namespace std;
#define int long long

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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n,m,a,b,c,d;
    cin >> n >> m >> a >> b >> c >> d;
    char g[n][m];
    int dis[n][m],vis[n][m];
    memset(vis,0,sizeof vis);
    for(int i=0;i<n;i++){
    	for(int j=0;j<m;j++){
    		cin >> g[i][j];
    		dis[i][j]=1e9;
    	}
    }
    a--,b--,c--,d--;
    deque <pair <int,int> > q;
    q.push_back({a,b});
    dis[a][b]=0;
    while(!q.empty()){
    	auto [x,y]=q.front();
    	q.pop_front();
    	if(vis[x][y])continue;
    	vis[x][y]=1;
    	for(int i=0;i<4;i++){
    		int nx=x+dx[i],ny=y+dy[i];
    		if(nx<0 or nx>=n or ny<0 or ny>=m or dis[nx][ny]<=dis[x][y])
    			continue;
    		if(g[nx][ny]=='.')q.push_front({nx,ny}),dis[nx][ny]=dis[x][y];
    	}
    	for(int xx:{-2,-1,0,1,2}){
    		for(int yy:{-2,-1,0,1,2}){
    			int nx=x+xx,ny=y+yy;
    			if(nx<0 or nx>=n or ny<0 or ny>=m or dis[nx][ny]!=1e9)
    				continue;
    			if(g[nx][ny]=='.')q.push_back({nx,ny}),dis[nx][ny]=dis[x][y]+1;
    		}
    	}
    }
    if(dis[c][d]==1e9)dis[c][d]=-1;
    cout << dis[c][d];
}

Measured memory_bytes: 20280
#include <bits/stdc++.h>
using namespace std;
int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{  
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A==5&&B==5&&C==7){
	printf("YES\n") ;
	} else if(A==7&&B==5&&C==5){
		printf("YES\n");
	} else if(A==5&&B==7&&C==5){
		printf("YES\n");
	}else {printf("NO\n");}
	 return 0; 
	
}



Measured memory_bytes: 128
N = int(input())
card_list = list(map(int, input().split()))


card_list.sort(reverse = True)

alice_list = []
bob_list = []
if N % 2 == 0:
    for i in range(0, N, 2):
        alice_list.append(card_list[i])
    for i in range(1, N, 2):
        bob_list.append(card_list[i])
else:
    for i in range(0, N + 1, 2):
        alice_list.append(card_list[i])
    for i in range(1, N, 2):
        bob_list.append(card_list[i])


alice_score = sum(alice_list)
bob_score = sum(bob_list)

ans = alice_score - bob_score
print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;

class Program {
  static void Main (string[] args) {
    string[] str = Console.ReadLine().Split(' ');
    var a = int.Parse(str[0]);
    var b = int.Parse(str[1]);
    float ab = 1.0f * a / b;
    Console.WriteLine(ab);
  }
}


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

int main(){
  int n, k;
  cin >> n >> k;
  int i;
  int ans = 1;

  for(i = 0; i < n; i++){
    if(ans < k){
      ans *= 2;
    } else{
      ans += k;
    }
  }
  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

N, M = map(int, input().split())

if M == 0:
    ans = 0
    if N == 2:
        ans = 10
    if N == 3:
        ans = 100
    print(ans)
    exit()

sc = []
dic = dict()
for _ in range(M):
    sc.append(list(map(int, input().split())))

sc.sort(key=lambda x:x[1])
sc.sort(key=lambda x:x[0])

if sc[-1][0] > N:
    print(-1)
    exit()

for i in range(M):
    if sc[i][0] not in dic.keys():
        dic[sc[i][0]] = [sc[i][1]]
    elif sc[i][1] not in dic[sc[i][0]]:
        dic[sc[i][0]].append(sc[i][1])

for value in dic.values():
    if len(value) > 1:
        print(-1)
        exit()

if N == 1:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(0)
        exit()
else:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(-1)
        exit()

ans = ['a'] * N

for i in range(M):
    ans[sc[i][0]-1] = sc[i][1] 

if ans[0] == 'a':
    ans[0] = 1
for i in range(len(ans)):
    if ans[i] == 'a':
        ans[i] = 0

out = ""
for i in range(len(ans)):
    out += str(ans[i])

print(int(out))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n;
  cin >> n;
  REP(i, 9) {
    REP(j, 9) {
      if(n == (i + 1) * (j + 1)) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    int N, M;  cin >> N >> M;
    vector<ll> dp(N+1,0);
    ll mod = 1e9+7;
    for(int i=0; i<M; i++){
        int a;  cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    for(int i=0; i<=N; i++){
        if(dp[i]==-1) continue;

        if(i+1<=N && dp[i+1] != -1){
            dp[i+1] = (dp[i+1] + dp[i])%mod;
        }
        if(i+2 <= N && dp[i+2] != -1){
            dp[i+2] = (dp[i+2] + dp[i])%mod;
        }
    }
    // for(int i=0; i<=N; i++){
    //     cout << i << " " << dp[i] << endl;
    // }
    
    if(dp[N]!=-1){
        cout << dp[N] << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N;
  cin >> N;
  N--;
  vector<int> C(N), S(N), F(N);
  REP(i, N) {
    cin >> C[i] >> S[i] >> F[i];
  }
  REP(i, N) {
    int t = 0;
    FOR(j, i, N-1) {
      if(t < S[j]) {
        t = S[j];
      } else if(t % F[j] == 0) {

      } else {
        t += F[j] - (t % F[j]);
      }
      t += C[j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv;

void main() {
  while(true) {
    int ans = 0, index = -1;
    for(int i = 0; i < 5; i++) {
      int a, b; readf("%d %d\n", &a, &b);
      if (a + b == 0) goto end;
      if (a + b > ans) {
        ans = a + b;
        index = i;
      }
    }
    writeln((index + 'A').to!char, " ", ans);
  }
end:;
}

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

n = int(input())
a = [int(x) for x in input().split()]

from collections import Counter

c = Counter(a)

b = [0, 0] # 偶数,奇数

for i in c.values():
    if i % 2 == 0:
        b[0] += 1
    else:
        b[1] += 1

ans = b[1]

if b[0] % 2 == 0:
    ans += b[0]
else:
    ans += b[0] - 1

print(ans)

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

const int maxN = 100010;
vector<int> p[maxN];
int a[maxN];
int c[maxN];
int n, m;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		c[a[i] % m]++;
	}
	sort(a, a + n);
	for (int i = 0, j = 0; i < n; i = j) {
		while (j < n && a[i] == a[j]) j++;
		p[a[i] % m].push_back(j - i);
	}
	int ans = 0;
	for (int i = 1; i < m / 2; i++) {
		int u = i, v = m - u;
		a[u] = a[v] = min(c[u], c[v]);
		ans += a[u];
	}
	ans += c[0] / 2;
	if (m % 2 == 0){
		a[m/2]=c[m/2]/2*2;
		ans += c[m / 2] / 2;
	}
	else {
		int u = m / 2, v = m - m / 2;
		a[u] = a[v] = min(c[m / 2], c[m - m / 2]);
		ans += a[u];
	}
	for (int i = 1; i < m; i++) {
		int le=c[i]-a[i];
		for(int j=0;j<p[i].size();j++){
			if(p[i][j]>=2 && le>=2){
				int tmp=min(le/2,p[i][j]/2);
				le-=2*tmp;
				ans+=tmp;
			}
			if(le<=1)break;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  
  int x = 1;
  
  for (int i = 0; i < N; i++){
   if (x < K){
     x *= 2;
   }
    else {
      x += K;
    }
  }
  cout << x << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if (a == 25) {
            System.out.println("Christmas");
        } else if (a == 24) {
            System.out.println("Christmas Eve");
        } else if (a == 23) {
            System.out.println("Christmas Eve Eve");
        } else if (a == 22) {
            System.out.println("Christmas Eve Eve Eve");
        }
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int k;
  cin >> k;
  ll ans = 0;
  vector<bool> t(k, false);
  int x = 7;
  while (true) {
      ans++;
      x %= k;
      if (x == 0) break;
      if (t[x]) {
          cout << -1 << endl;
          return 0;
      }
      t[x] = true;
      x = x*10 + 7;
  } 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3716
n, m = map(int,input().split())

done = [0]*n
WA_cnt = [0]*n
for _ in range(m):
  p, s = input().split()
  p = int(p)-1
  if done[p] == 1:
    continue
  else:
    if s=='AC':
      done[p] = 1
    elif s=='WA':
      WA_cnt[p] += 1

for i in range(n):
  if done[i]==0:
    WA_cnt[i] = 0
    
print(sum(done), sum(WA_cnt))
      


Measured memory_bytes: 45528
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define MOD 1000000007

typedef long long int llint;

vector<llint> fac, finv, inv;
void COMinit(llint N) {
	fac = vector<llint>(N);
	finv = vector<llint>(N);
	inv = vector<llint>(N);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int N, K;

int main() {
	cin >> N >> K;
	int blue = K;
	int red = N - K;
	COMinit(max(K, red + 2));

	llint now = 1;
	for (int i = 1; i <= K; i++) {
		cout << (COM(red + 1, i) * now) % MOD << endl;
		now = COM(K - 1, i);
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = IntStream.range(0, n).map(i -> scanner.nextInt()).sorted().toArray();
			System.out.println(IntStream.range(0, n).filter(i -> (i & 1) == 0).map(i -> a[n - 1 - i]).sum()
					- IntStream.range(0, n).filter(i -> (i & 1) == 1).map(i -> a[n - 1 - i]).sum());
		}
	}
}


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

int main(){
  long long int N,cen,ans=0;
  cin>>N;
  vector<long long int> vec(N);
  
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
    vec.at(i) -= i+1;
  }
  sort(vec.begin(),vec.end());
  if(N%2==1)
    cen = vec.at((N-1)/2);
  else
    cen = (vec.at(N/2)+vec.at((N-1)/2))/2;
  
  for(long long int v:vec)
    ans += abs(v-cen);
  cout<<ans<<endl;;
  
}


Measured memory_bytes: 1792
{-# LANGUAGE BangPatterns, OverloadedStrings #-}
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: B.ByteString -> B.ByteString -> B.ByteString
solve !s !t = walk
 where
  toIndex !i !j = j * succ (B.length s) + i
  sChars = V.unfoldrN (B.length s) (\(!k) -> Just (B.index s k, k + 1)) 0
  tChars = V.unfoldrN (B.length t) (\(!k) -> Just (B.index t k, k + 1)) 0

  dp :: V.Vector (VU.Vector Int16)
  dp = V.scanl'
    ( \(!prev) (!si) -> V.convert $ V.scanl'
      ( \(!cur) (!j, !tj) ->
        if si == tj then prev VU.! j + 1 else max cur (prev VU.! (j + 1))
      )
      0
      (V.indexed tChars)
    )
    (VU.replicate (B.length t + 1) 0)
    sChars

  walk =
    fst
      $ B.unfoldrN (fromIntegral $ dp V.! B.length s VU.! B.length t)
                   (\(x:xs) -> Just $ (,) (B.index s x) xs)
      $ fst
      $ fix
          ( \(!f) (!acc, (!i, !j)) -> if i == 0 || j == 0
            then (acc, (i, j))
            else if s `B.index` (i - 1) == t `B.index` (j - 1)
              then f ((i - 1) : acc, (i - 1, j - 1))
              else if dp V.! (i - 1) VU.! j < dp V.! i VU.! (j - 1)
                then f (acc, (i, j - 1))
                else f (acc, (i - 1, j))
          )
          ([], (B.length s, B.length t))

main = do
  s <- B.getLine
  t <- B.getLine
  B.putStrLn $ solve s t


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

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[5];
            a[0] = int.Parse(Console.ReadLine());
            a[1] = int.Parse(Console.ReadLine().Split('\n')[0]);
            a[2] = int.Parse(Console.ReadLine().Split('\n')[0]);
            a[3] = int.Parse(Console.ReadLine().Split('\n')[0]);
            a[4] = int.Parse(Console.ReadLine().Split('\n')[0]);
            int k = int.Parse(Console.ReadLine().Split('\n')[0]);

            for (int i = 0; i < a.Length; i++)
            {
                for (int j = i+1; j < a.Length; j++)
                {
                   if(a[j]- a[i] > k)
                   {
                       System.Console.WriteLine(":(");
                       return;
                   }
                }    
            }
            System.Console.WriteLine("Yay!"); 
        }
    }
}


Measured memory_bytes: 13140