akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i=0;i<n;i++){
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
        }
        long plus = 0;
        for (int i=n-1;i>=0;i--){
            long instance = a[i];
            instance+=plus;
            if (instance%b[i]!=0){
                plus+=b[i]-(instance%b[i]);
            }
        }
        System.out.println(plus);
    }
}


Measured memory_bytes: 60300
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif

typedef std::pair<int, int> IntPair;

template <class _Ty> inline _Ty tp_abs(const _Ty& a)
{
	//	usage:  tp_abs<type name>(a);

	return ((a < 0) ? (a * -1) : a);

}

template <class _Ty> inline void tp_swap(_Ty & right, _Ty & left) 
{
	//	usage:  tp_swap<type name>(a, b);

	_Ty tmp = right;
	right = left;
	left = tmp;
}


//static void ABC120D_DecayedBridges();
static void ABC117D_XXOR();


#if 1
int main()
{
	//ABC120D_DecayedBridges();
	ABC117D_XXOR();

	fflush(stdout);
	return 0;
}
#endif



static void ABC117D_XXOR()
{
	int N;
	U_L_LONG K;

	scanf(" %d %llu", &N, &K);

	auto seqA = new U_L_LONG[N];
	int bitCount[64] = { 0 };
	
	for (int i = 0; i < N; i++) {
		scanf(" %llu", &seqA[i]);
		
		for (int sft = 0; sft < 64; sft++) {
			if (seqA[i] & (1LLU << sft)) {
				bitCount[sft]++;
			}
		}
	}
	
	U_L_LONG xorMax = 0;
	for (int sft = 63; sft >= 0; sft--) {
		if (bitCount[sft] > (N / 2)) {
			continue;
		}

		U_L_LONG tmp = xorMax + (1LLU << sft);
		if (tmp <= K) {
			xorMax = tmp;
		}
	}
	
	U_L_LONG sum = 0;
	for (int i = 0; i < N; i++) {
		sum += xorMax ^ seqA[i];
	}

	printf("%llu\n", sum);

	delete[] seqA;
}


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

int main(){
    ll W,H;
    cin >> W >> H;
    if(W == 1 || H == 1){
        cout << 1 << endl;
        return 0;
    }
    if(H % 2 == 0) cout << (H/2) * W << endl;
    else{
        ll pair = (H/2) * 2 + 1;
        ll ans = 0;
        if(W % 2 == 1) ans += H/2+1;
        ans += pair * (W/2);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 2e5 + 40;

int n, h, m = 0;
struct Node{
	int w, t;
	bool operator < (const Node &rhs) {
		return w > rhs.w;
	}
}a[N];

int main()
{
	int i, j;
	int x, y;
	scanf("%d%d", &n, &h);
	for(i = 0; i < n; ++i) {
		scanf("%d%d", &a[m].w, &a[m + 1].w);
		a[m].t = 0, a[m +1].t = 1;
		m = m + 2;
	}
	sort(a, a + m);
	int ans = 0, tmp;
	for(i = 0; i < m; ++i) {
		if(h <= 0) break;
		if(a[i].t == 1) {
			ans ++;
			h -= a[i].w;
		} else {
			tmp = (h%a[i].w == 0)? (h/a[i].w) : (h/a[i].w + 1);
			ans += tmp;
			break;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

signed main() {
	int a, b; cin >> a >> b;
	if (a == 0 || (a < 0 && b > 0)) {
		cout << "Zero" << endl;
	} else if (a >= 1) {
		cout << "Positive" << endl;
	} else {
		if ((b - a) % 2 == 0) {
			cout << "Negative" << endl;
		} else {
			cout << "Positive" << endl;
		}
	}
	system("pause");
}

Measured memory_bytes: 504
//
//  main.cpp
//  AOJ_V0_0000
//
//  Created by anzai on 2015/08/06.
//  Copyright (c) 2015??´ anzai. All rights reserved.
//

#include<iostream>
using namespace std;

int main(){
    
    int i;
    int j;
    int k;
    
    for (i = 1; i < 10; i++ ){
        for (j = 1; j < 10; j++){
            k = i*j;
            cout << i << "x" << j << "=" << k << endl;
        }
    }
    
    
    
    
    return 0;
}

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

long long f(long long x)
{
  long long count = 0;
  
  if(x == 1)
  {
    count++;
    return count;
  }
  else
  {
    count++;
    long long A = f(x/2);
    long long B = f(x/2);
    return count + A + B;
  }
}
int main(){
  long H;
  cin >> H;
  cout << f(H) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int chk[105][10];
int prf[105][105];
int cnt[105];
int main()
{
    int n;
    scanf("%d",&n);
    int i,j,ti=10,k;
    for(i=0;i<n;i++)
    {
        for(j=0;j<ti; j++)
            scanf("%d",&chk[i][j]);
    }
    for(i=0;i<n;i++)
        for(j=0;j<=ti;j++)
                scanf("%d",&prf[i][j]);
    int  ans = -1000000000;
    int tot = 1<<11;
    int mask;
    for(mask = 0; mask< tot; mask++)
    {
        int c = 0;
        for(j=0;j<n;j++)cnt[j] = 0;
        
        for(i=0;i<10;i++)
            if(mask & (1<<i))
            {
                for(j=0; j<n; j++)
                    if(chk[j][i])cnt[j]++;
            }
        int cur = 0;
        int fo = 0;
        for(j=0; j<n; j++){
            cur += prf[j][cnt[j]];
            if(cnt[j])fo = 1;
        }
       
        if(mask && fo){
           // printf("for mask %d %d \n",mask,cur);
        if(cur > ans)ans = cur;
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << val << endl

using namespace std;

typedef long long int lli;

int bitcount(int n) {
    int res = 0;
    while (n) {
        res += (n % 2);
        n /= 2;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> F(N);
    REP (i, 0, N) {
        int tmp = 0;
        REP (j, 0, 10) {
            int a;
            cin >> a;
            tmp = tmp * 2 + a;
        }
        F[i] = tmp;
    }
    vector<vector<int>> P(N, vector<int>(11));
    REP (i, 0, N) REP (j, 0, 11) cin >> P[i][j];
    lli ans = -(1LL << 60);
    REP (st, 1, 1 << 10) {
        lli tmp = 0;
        REP (i, 0, N) {
            int bt = bitcount(st & F[i]);
            tmp += P[i][bt];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int now;
  int flag;

  for(now = 0; now < N - 1; now++){
    if(A[now] == A[now + 1])continue;
    else break;
  }
  if(A[now] < A[now + 1])flag = 1;
  else flag = -1;

  int ans = 1;
  for(int i = now; i < N - 1; i++){
    if(flag == 1 && A[i] <= A[i + 1])continue;
    else if(flag == -1 && A[i] >= A[i + 1])continue;
    else{
      ans++;
      for(now = i + 1; now < N - 1; now++){
        if(A[now] == A[now + 1])continue;
        else break;
      }
      if(A[now] < A[now + 1])flag = 1;
      else flag = -1;
      i = now;
    }
  }
  cout << ans << endl;
}


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

int main()
{
    ll k;
    cin >> k;
    if(k%2 == 0){
        cout << -1 << endl;
        return 0;
    }
    ll mod = 0;
    int ans = 0;
    map<ll, int> mp;
    while(true){
        mod = (mod*10 + 7)%k;
        ans++;
        if(mod == 0){
            cout << ans << endl;
            return 0;
        }
        if(mp[mod]){
            cout << -1 << endl;
            return 0;
        }
        mp[mod]++;
    }
}


Measured memory_bytes: 66072
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
    os<<'[';
    rep(i,a.size()) os<<(i?" ":"")<<a[i];
    return os<<']';
}



int main() {
    for(; ; ) {
        int p;
        int ans = 0;
        rep(i, 5) {
            int s1, s2; cin >> s1 >> s2;
            if (s1 == 0 && s2 == 0) goto end;
            if (ans < s1 + s2) {
                ans = s1 + s2;
                p = i;
            }
        }
        cout << (char)('A' + p) << ' ' << ans << endl;
    }
    
end:;
    return 0;
}

Measured memory_bytes: 1160
N = int(input())
count=0
for i in range(26):
  for j in range((100-4*i)//7+1):
    M = N-4*i-7*j
    if(M==0):
      print('Yes')
      count+=1
      break
  if(count==1):
    break
if(count==0):
  print('No')



Measured memory_bytes: 2940
n, k = [int(item) for item in input().split()]
s = input() + "#"

series = []
prev = "#"
for i, c in enumerate(s):
    if prev != c:
        series.append(i) 
        prev = c

ans = 0
if s[0] == "1":
    for i in range(0, len(series) -1 -2*k, 2):
        ans = max(ans, series[i + 2*k + 1] - series[i])
    ans = max(ans, series[min(k*2+1, len(series)-1)])
else:
    for i in range(1, len(series) -1 -2*k, 2):
        ans = max(ans, series[i + 2*k + 1] - series[i])
    ans = max(ans, series[min(k*2, len(series)-1)])
if s[-2] == "0":
    ans = max(ans, series[-1] - series[max(0, len(series)-1-2*k)])
print(ans)

Measured memory_bytes: 7164
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    s=STR()
    sl=len(s)
    ans=[]
    if sl%2==0:
        for i in range(sl//2):
            ans.append(s[2*i])
    else:
        for i in range(sl//2+1):
            ans.append(s[2*i])
            
    print(*ans, sep='')
        
if __name__ == '__main__':
    do()

Measured memory_bytes: 5876
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 1e5+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/

main(){
    fast();per(0);
    //get_fact();
	int n;cin>>n;
	int t=n,sum=0;
	while(t>0)
		sum+=t%10,t/=10;
	if(n%sum==0)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 256
/*  CREATED BY
    STREAM_CIPHER
    29-aug-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout << fixed << setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        int n;
        cin>>n;
        vector<int>a(n);
        for(auto &i:a)
        	cin>>i;
        int suf[n+1]={0};
        suf[n-1]=a[n-1];
        for(int i=n-2;i>=0;i--)
        {
        	suf[i]+=suf[i+1]+a[i];
        	suf[i]%=mod;
        }
        int ans=0;
        for(int i=0;i<n;i++)
        {
        	// debug2(a[i],suf[i+1]);
        	ans+=(a[i]*suf[i+1])%mod;
        	ans%=mod;
        }
        cout<<ans<<endl;

}

Measured memory_bytes: 6360
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define rite(x) freopen(x,"w",stdout);
#define read(x) freopen(x,"r",stdin);
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define clr clear()
#define inf (1<<30)
#define ins insert
#define xx first
#define yy second
#define eps 1e-9
typedef long long i64;
typedef unsigned long long ui64;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef map<int,int> mii;
typedef map<st,int> msi;
typedef set<int> si;
typedef set<st> ss;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
#define mx 0
int main() {
   	ios_base::sync_with_stdio(0);cin.tie(NULL);
   	//Solution
	int a, b, c;
	cin >> a >> b >> c;

	for (int i = 0; i < 100000000; ++i)
	{
		if(a%2 || b%2  || c%2){
			cout << i << endl;
			return 0;

		}
		int a11, a22;
		a11 = a/2;
		a22 = a/2;
		int b11, b22;
		b11 = b/2;
		b22 = b/2;

		int c11, c22;

		c11 = c/2;
		c22 = c/2;

		a = b11 + c11;
		b = a11 + c22;
		c = a22 + b22;
		
		

	}
	cout << "-1" << endl;

   	
   	
   	return 0;
}


//g++-4.9 agc014_a.cpp -o agc014_a && ./agc014_a < agc014_a.in > agc014_a.out








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<char,int> mp;
    int ans = 0;
    int can = 0;
    for(int i = 1; i < n; i++){
        mp.clear();
        can = 0;
        string t = s.substr(0,i);
        string u = s.substr(i);
        for(int j = 0; j < i; j++){
            mp[t[j]]++;
        }
        for(auto p:u){
            if(mp[p] > 0){
                can++;
                mp[p] = 0;
            }
        }
        if(ans < can) ans = can;
    }    
    cout << ans << endl;
}

Measured memory_bytes: 256
open Batteries
let () =
  let s,t = Scanf.scanf "%s %s " (fun a b -> a,b) in
  let s_lst = String.to_list s in
  let t_lst = String.to_list t in
  let s_s = List.sort compare s_lst |> String.of_list in
  let t_s = List.sort (fun x y -> compare y x) t_lst |> String.of_list in
  Printf.printf "%s\n" @@
  if s_s < t_s then "Yes" else "No"


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

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

  int ans[3] = {a + b, a - b, a*b};
  sort(ans, ans+3, greater<int>());

  cout << ans[0] << endl;

  return 0;
}

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


int main(){
  int n;
  cin >> n;
  int *p = new int[n];

  for(int i=0;i<n;++i) cin >> p[i];

  int max = p[0];
  for(int i = 1;i< n;++i){
    if(p[i] > max){
      max = p[i];
    }
  }
  
  int a;
  int pcounter = 0;
  for(a=max; a>0; --a){
    for(int i=0;i<n;++i){
      if(p[i] >= a){
	++pcounter;
      }
    }

    if(pcounter >= a){
      break;
    }else{
      pcounter = 0;
    }
  }
  
  delete[] p;

  cout << a << endl;

  return 0;
}



Measured memory_bytes: 3096
using System;

// Snippet: FastPower
abstract class FastPower<T> {
    protected abstract T One();
    protected abstract T Times(T t1, T t2);

    public T Get(T n, long exp) {
        var answer = One();
        for (; exp != 0; exp >>= 1) {
            if ((exp & 1) != 0) answer = Times(answer, n);
            n = Times(n, n);
        }
        return answer;
    }
}

// Snippet: FastPowerModulo
class FastPowerModulo: FastPower<long> {
    public long M;
    protected override long One() => 1L;
    protected override long Times(long t1, long t2) => t1 * t2 % M;
}

// Snippet: ChooseModuloBigPrime
class ChooseModuloBigPrime {
    public static long Get(long n, long k, long modulo) {
        var fastPower = new FastPowerModulo{M = modulo};
        long answer1 = 1L, answer2 = 1L;
        for (long i = 1; i <= k; ++i) {
            answer1 = answer1 * (n + 1 - i) % modulo;
            answer2 = answer2 * i % modulo;
        }
        return answer1 * fastPower.Get(answer2, modulo - 2) % modulo;
    }

    public static long[] GetMultiple(long n1, long n2, long k, long modulo) {
        if (n2 < n1) {
            var answer2 = GetMultiple(n2, n1, k, modulo);
            Array.Reverse(answer2);
            return answer2;
        }
        var fastPower = new FastPowerModulo{M = modulo};
        var answer = new long[n2 - n1 + 1];
        answer[0] = Get(n1, k, modulo);
        for (int i = 1; i < answer.Length; ++i) {
            var answer1 = answer[i - 1] * (n1 + i) % modulo;
            var answer2 = answer1 * fastPower.Get(n1 + i - k, modulo - 2);
            answer[i] = answer2 % modulo;
        }
        return answer;
    }
}

class D {
    const long M = 1000000007;

    public static void Main() {
        var line = Console.ReadLine().Split();
        var h = long.Parse(line[0]);
        var w = long.Parse(line[1]);
        var a = long.Parse(line[2]);
        var b = long.Parse(line[3]);
        var c1 = ChooseModuloBigPrime.GetMultiple(
            h - a - 2 + w, h - a - 1 + b, h - a - 1, M);
        var c2 = ChooseModuloBigPrime.GetMultiple(
            a - 1, a - 2 + w - b, a - 1, M);
        var answer = 0L;
        for (int i = 0; i < c1.Length; ++i)
            answer = (answer + c1[i] * c2[i] % M) % M;
        Console.WriteLine(answer);
    }
}


Measured memory_bytes: 11488
nseq = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

no_str = int(input())
print(nseq[no_str-1])

Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    ll n, x;
    cin >> n >> x;
    ll ans = n;
    ll a = x, b = n - x;
    while (b % a != 0)
    {
        ans += 2 * a * (b / a);
        ll tmp = a;
        a = b % a;
        b = tmp;
    }
    ans += a * (2 * (b / a) - 1);
    cout << ans << endl;
}

Measured memory_bytes: 3620
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

n = lines[3][0]

result = [[0,0,0],[0,0,0],[0,0,0]]

for i in 0..2 do
  for j in 0..2 do
    for k in 1..n do
      if lines[i][j] == lines[k+3][0] then
        result[i][j] = 1
      end
    end
  end
end

yoko1 = result[0][0] * result[0][1] * result[0][2]
yoko2 = result[1][0] * result[1][1] * result[1][2]
yoko3 = result[2][0] * result[2][1] * result[2][2]
tate1 = result[0][0] * result[1][0] * result[2][0]
tate2 = result[0][1] * result[1][1] * result[2][1]
tate3 = result[0][2] * result[1][2] * result[2][2]
naname1 = result[0][0] * result[1][1] * result[2][2]
naname2 = result[0][2] * result[1][1] * result[2][0]
  
answer = yoko1 + yoko2 + yoko3 + tate1 + tate2 + tate3 + naname1 + naname2
  
if answer == 0 then
  print "No"
else
  print "Yes"
end

Measured memory_bytes: 1788
package main

import (
	"fmt"
)

func main() {
	var _S string
	var w int
	fmt.Scanf("%s", &_S)
	fmt.Scanf("%d", &w)
	S := []rune(_S)
	lenS := len(S)
	for i := 0; i < lenS; i++ {
		if i%w == 0 {
			fmt.Printf("%s", string(S[i]))
		}
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	
	static int[] a;
	static int[] b;
	static boolean[] k;
	static int z;
	
	static void dfs(int x, int pa, int pb) {
		if(x == 9) {
			z += pb<pa?1:0;
			return;
		}
		for(int i=0; i<9; i++) {
			if(k[i]) continue;
			k[i] = true;
			dfs(x + 1, pa + (b[x]<a[i]?a[i]+b[x]:0), pb + (b[x]<a[i]?0:a[i]+b[x]));
			k[i] = false;
		}
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			while(N-- != 0) {
				a = new int[9];
				b = new int[9];
				k = new boolean[9];
				
				for(int i=0; i<9; i++) a[i] = sc.nextInt();
				for(int i=0; i<9; i++) b[i] = sc.nextInt(); 
				
				z = 0;
				dfs(0, 0, 0);
				
				int bb = 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1;
				double t = z * 1.0 / bb;
				
				System.out.printf("%.5f %.5f\n", t, 1-t);
			}
		}
	}
}


Measured memory_bytes: 28668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define arrlen(arr) (sizeof(arr)/sizeof(arr[0]))
#define Sort(arr) sort(arr, arr+arrlen(arr))
#define For(i,s,n) for(int i=s;i<n;i++)

	
int main(){
	int N,M;
	cin >> N >> M;
	int k[M],s[M][12];
	For(i,0,M){
		cin >> k[i];
		For(j,0,k[i]){
			cin >> s[i][j];
		}
	}
	int p[M];
	//cout << "p:";
	For(i,0,M) cin >> p[i];
	
	int ans=0;
	For(i,0,pow(2,N)){
		bool sw[N];
		For(j,0,N){
			sw[j]=(i/(int)pow(2,j))%2;
			//cout << sw[j] << " ";
		}
		//cout << endl;
		
		int count=0;
		For(j,0,M){
			int num=0;
			For(l,0,k[j]){
				if(sw[s[j][l]-1]) num++;
			}
			if(num%2==p[j]) count++;
		}
		//cout << count << endl;
		if(count==M) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int N;
  cin >> N;

  int result = 0;
  rep(i, N) {
    int a;
    cin >> a;
    if (i % 2 == 0 && a % 2 == 1) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3192
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/04/22  Problem: ARC 072 C / Link: http://arc072.contest.atcoder.jp/tasks/arc072_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N;

ll ans = 0LL;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	ll a[100010];
	cin >> N;
	FOR(i, 0, N) {
		cin >> a[i];
	}
	ans = LINF;
	ll cnt = 0;
	ll sum = 0;
	FOR(i, 0, N) {
		if (i == 0) {
			sum += a[i];
			if (sum < 0) {
				cnt = (-sum + 1);
				sum = 1;
			}
			else if (sum == 0) {
				cnt++;
				sum = 1;
			}
			continue;
		}
		if (sum > 0) {
			sum += a[i];
			if (sum >= 0) {
				cnt += (sum + 1);
				sum = -1;
			}
		}
		else {
			sum += a[i];
			if (sum <= 0) {
				cnt += (-sum + 1);
				sum = 1;
			}
		}
	}
	ans = min(ans, cnt);
	sum = 0;
	cnt = 0;
	FOR(i, 0, N) {
		if (i == 0) {
			sum += a[i];
			if (sum > 0) {
				cnt = (sum + 1);
				sum = -1;
			}
			else if (sum == 0) {
				cnt++;
				sum = -1;
			}
			continue;
		}
		if (sum > 0) {
			sum += a[i];
			if (sum >= 0) {
				cnt += (sum + 1);
				sum = -1;
			}
		}
		else {
			sum += a[i];
			if (sum <= 0) {
				cnt += (-sum + 1);
				sum = 1;
			}
		}
	}

	ans = min(ans, cnt);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
char A[1<<8|1];
int op[333333],cnt;
void make(int S,int ty){
	if(!S)return;
	int i=0;while(!(S>>i&1))i++;
	if(S==(1<<i)){
		op[cnt++]=ty&2?-i-1:i+1;
		return;
	}
	if(ty&1){
		op[cnt++]=ty&2?i+1:-i-1;
		make(S^1<<i,ty^3);
		op[cnt++]=ty&2?-i-1:i+1;
		make(S^1<<i,ty);
	}
	else{
		make(S^1<<i,ty);
		op[cnt++]=ty&2?-i-1:i+1;
		make(S^1<<i,ty^3);
		op[cnt++]=ty&2?i+1:-i-1;
	}
}
int x[333333],y[333333],L; 
int main(){
	int N;scanf("%d%s",&N,A);
	for(int S=1;S<1<<N;S++)if(A[S]=='1')
		for(int T=S;T;T=T-1&S)if(A[T]=='0')return puts("Impossible"),0;
	for(int S=1;S<1<<N;S++)if(A[S]=='0'){
		bool fl=1;
		for(int T=S-1&S;T&&fl;T=T-1&S)if(A[T]=='0')fl=0;
		if(fl)make(S,0),make(S,1);
	}
	for(int i=0;i<cnt;i++){
		int x1=op[i]>0?op[i]-1:-op[i],x2=op[i]>0?x1+1:x1-1;
		for(;x[L]!=x1;L++)x[L]<x1?x[L+1]=x[L]+1:x[L+1]=x[L]-1;
		x[++L]=x1;y[L]=1;
		x[++L]=x2;y[L]=1;
		x[++L]=x2;y[L]=0;
	}
	for(;x[L];L++)x[L+1]=x[L]-1;
	printf("Possible\n%d\n",L);
	for(int i=0;i<=L;i++)printf("%d %d\n",x[i],y[i]);
}

Measured memory_bytes: 3320
# -*- coding: utf-8 -*-
def main():
    flg = 0
    answer = ['NA','AMBIGUOUS','YYMM','MMYY']
    data = list(input())
    front = data[0] + data[1]
    back = data[2] + data[3]
    front = int(front)
    back = int(back)
    if 1<=front<=12 and 1<=back<=12:
        flg = 1
    elif 0<=front<=99 and 1<=back<=12:
        flg = 2
    elif 1<=front<=12 and 0<=back<=99:
        flg = 3
    print(answer[flg])
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = list(map(int, input().split()))
data= []
rs = []
cs = []
for i in range(h):
    c = input()
    if "S" in c:
        start = (i, c.index("S"))
    if "T" in c:
        goal = (i, c.index("T"))
    for j in range(w):
        if c[j] in ("o"):#, "S", "T"):
            data.append(1)
            rs.append(i)
            cs.append(h+j)
            data.append(1)
            rs.append(h+j)
            cs.append(i)
s = h+w
t = h+w+1
V = 10**9
data.append(V)
rs.append(s)
cs.append(start[0])
# data.append(V)
# rs.append(start[0])
# cs.append(s)

data.append(V)
rs.append(s)
cs.append(start[1]+h)
# data.append(V)
# rs.append(start[1]+h)
# cs.append(s)

data.append(V)
rs.append(goal[0])
cs.append(t)
# data.append(V)
# rs.append(t)
# cs.append(goal[0])

# data.append(V)
# rs.append(t)
# cs.append(goal[1]+h)
data.append(V)
rs.append(goal[1]+h)
cs.append(t)

import scipy.sparse
m = scipy.sparse.csr_matrix((data, (rs, cs)), shape=(h+w+2,h+w+2))
val = scipy.sparse.csgraph.maximum_flow(m, s, t).flow_value
if val>=10**9:
    val = -1
print(val)

Measured memory_bytes: 43892
#include <stdio.h>

main(void)
{
  int	a;
  int	b;
  scanf("%d%d", &a, &b);
  if(a < b)
  {
    for(int i = 0;i < b; i++)
      printf("%d",a);
  }else
  {
    for(int i = 0;i < a; i++)
      printf("%d",b);
  }
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define ll long long

using namespace std;

#ifdef DEBUG
#else
#endif

int main(int argc, const char *argv[]) {
   int n,m;
   cin>>n>>m;
   int sum=0;
   for(int i=0;i<m;i++){
      int tmp;
      cin>>tmp;
      sum+=tmp;
   }
   if(n-sum>=0){
      cout<<n-sum<<endl;
   }else{
      cout<<-1<<endl;
   }
   return 0;
}

Measured memory_bytes: 3192
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define MAX ((ll)1<<(ll)31)-1


int main(void) {
	ll n; cin >> n;
	if (n % 2 == 1) {
		cout << 0 << endl;
	}
	else {
		ll ans=0;
		ll k = 5;
		while (k <= n) {
			ans += (n / k) / 2;
			
			k *= 5;
		}
		cout << ans << endl;
	}
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vec a(n);
    init(a);

    vec l(n), r(n);
    l[0] = a[0], r[n - 1] = a[n - 1];
    For(i, 1, n - 1) { l[i] = gcd(l[i - 1], a[i]); }
    Forr(i, n - 2, 0) { r[i] = gcd(r[i + 1], a[i]); }

    int ma = max(l[n - 2], r[1]);
    For(i, 1, n - 2) ma = max(ma, gcd(l[i - 1], r[i + 1]));
    print(ma);

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

template <typename T>
struct WeightedGraph {
  struct Edge {
    int to;
    T cost;
  };
  vector<vector<Edge>> edges;
  int n;
  WeightedGraph(int n) : n(n) {
    edges = vector<vector<Edge>>(n);
  }
  void add_edge(int from, int to, T cost = 0) {
    edges[from].push_back((Edge) { to, cost });
  }
};

template <typename T>
vector<T> bellman_ford(WeightedGraph<T> &g, int s) {
  const T INF = numeric_limits<T>::max();

  vector<T> dist(g.n, INF);
  dist[s] = 0;

  rep(i, g.n) rep(v, g.n) each(e, g.edges[v]) {
    if (dist[v] == INF) continue;
    if (dist[e.to] <= dist[v] + e.cost) continue;
    dist[e.to] = dist[v] + e.cost;
    if (i == g.n - 1) {
      return vector<T>();
    }
  }

  return dist;
}

void solve() {
  int V, E, r; cin >> V >> E >> r;;
  auto g = WeightedGraph<i64>(V);
  rep(i, E) {
    int s, t, d; cin >> s >> t >> d;
    g.add_edge(s, t, d);
  }
  auto ans = bellman_ford(g, r);
  if (ans.size() == 0) {
    cout << "NEGATIVE CYCLE" << '\n';
    return;
  }
  rep(i, V) {
    if (ans[i] == numeric_limits<i64>::max()) {
      cout << "INF" << '\n';
    } else {
      cout << ans[i] << '\n';
    }
  }
}



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

int main(void) {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	if (N > K) {
		cout << K * X + (N - K) * Y << endl;
	}
	else if (N <= K) {
		cout << N * X << endl;
	}
}


Measured memory_bytes: 256
class Dice():
    def __init__(self, nums):
        self.nums = nums
        self.top, self.front, self.right = 0, 1, 2

    def __eq__(self, dice):
        for x in "NNNNEEE":
            dice.move(x)
            for _ in range(4):
                dice.move("ESW")
                if self.nums[self.top] == dice.nums[dice.top] and \
                        self.nums[self.front] == dice.nums[dice.front] and \
                        self.nums[self.right] == dice.nums[dice.right] and \
                        self.nums[5 - self.top] == dice.nums[5 - dice.top] and \
                        self.nums[5 - self.front] == dice.nums[5 - dice.front] and \
                        self.nums[5 - self.right] == dice.nums[5 - dice.right]:
                    return True
        return False

    def move(self, op):
        for c in op:
            if c == 'N':
                self.top, self.front = self.front, 5 - self.top
            elif c == 'S':
                self.top, self.front = 5 - self.front, self.top
            elif c == 'E':
                self.top, self.right = 5 - self.right, self.top
            else:
                self.top, self.right = self.right, 5 - self.top

dice1 = Dice([int(n) for n in input().split()])
dice2 = Dice([int(n) for n in input().split()])
if dice1 == dice2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7816
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn=1e5;
int n,t,a;
char c[11];
int main(){
	scanf(" %s",c);
	n=700;
	if(c[0]=='o')n+=100;
	if(c[1]=='o')n+=100;
	if(c[2]=='o')n+=100;
	printf("%d\n",n);
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
string ar[2][3050]={};
string a,b;
string bg(string l,string r)
{
	if (l.size()>r.size()) {return l;}
	else {return r;}
}
int main()
{
	cin>>a>>b;
	for (int i=1;i<=a.size();i++)
	{
		for (int j=1;j<=b.size();j++)
		{
			ar[i%2][j] = bg(ar[(i-1)%2][j],ar[i%2][j-1]);
			if (a[i-1]==b[j-1])
			{
				ar[i%2][j] = bg(ar[i%2][j],ar[(i-1)%2][j-1]+a[i-1]);
			}
		}
	}
	cout<<ar[a.size()%2][b.size()]<<"\n";
	return 0;
}

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

using namespace std;

int f[201][201][2];
char str[201][201];
int n, m;
int main( ) {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i ++)
			scanf("%s", str[i] + 1);
	memset(f, 0x3f, sizeof(f));
	if (str[1][1] == '.') f[1][1][0] = 0;
	else f[1][1][1] = 1;
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= m; j ++) {
			if (i == 1 && j == 1) continue;
			if (str[i][j] == '#') {
				f[i][j][1] = min(min(f[i - 1][j][1], f[i][j - 1][1]), min(f[i - 1][j][0] + 1, f[i][j - 1][0] + 1));
			}
			else {
				f[i][j][0] = min(min(f[i - 1][j][1], f[i - 1][j][0]), min(f[i][j - 1][1], f[i][j - 1][0]));
			}
		}
	printf("%d\n", min(f[n][m][0], f[n][m][1]));
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
/**
*   author: j o s e m a g o
*   date:
**/
using namespace std;
#pragma GCC optimize ("Ofast")
#define f first
#define s second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"

typedef double db;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;







int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

    ios_base::sync_with_stdio(0); cin.tie(0);



    int n,m;
    cin >> n >> m;
    int nn = n*(n-1)/2;
    int mm = m*(m-1)/2;

    cout<<nn+mm;








    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//タプルのソート
fn main() {
    let n: u64 = read();
    let mut tasks: Vec<(u64, u64)> = (0..n).map(|_| (read(),read())).collect();
    let mut spent_time: u64 = 0;
    let mut ans = "Yes";
    tasks.sort_by(|a,b| a.1.partial_cmp(&b.1).unwrap() );

    for i in 0..tasks.len() {
        spent_time += tasks[i].0;
        if spent_time > tasks[i].1 {
            ans = "No";
            break;
        }
    }

    println!("{}",ans);

}


Measured memory_bytes: 10492
n,m=map(int,input().split())
p=[0]*m
s=['0']*m
wa = [0]*n
ac = [0]*n
for i in range(m):
    p[i],s[i]=input().split()
    p[i]=int(p[i])
for i in range(m):
    if s[i]=='WA' and ac[p[i]-1]==0:
        wa[p[i]-1]+=1
    elif s[i]=='AC' and ac[p[i]-1]==0:
        ac[p[i]-1]=1
for i in range(n):
    if ac[i]==0:
        wa[i]=0
ans=[sum(ac),sum(wa)]
for i in range(len(ans)):
    print(ans[i], end=' ')

Measured memory_bytes: 14836
#include<cstring>
#include <limits.h>
#include<iostream>
#include<map>
using namespace std;

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,x; cin>>n>>x;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		/* code */
		int b;
		cin >> b;
		a[i] = x>b?x-b:b-x;
	}

	int result = a[0]; 
    for (int i = 1; i < n; i++) 
        result = gcd(a[i], result); 
	// int min = INT_MAX;
	// for (int i = 0; i < n; ++i)
	// {
	// 	if(min > a[i])
	// 		min = a[i];
	// }
	cout << result << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	int64_t A, B, N;
	int64_t x;
	if (scanf("%" SCNd64 "%" SCNd64 "%" SCNd64, &A, &B, &N) != 3) return 1;
	x = N >= B - 1 ? B - 1 : N;
	printf("%" PRId64 "\n", (A * x / B) - A * (x / B));
	return 0;
}

/*

gnuplotでの実験により、周期がBで、Bの直前が最大値になりそう

*/


Measured memory_bytes: 1732
def insertion_sort(n, nums):
    print(' '.join(map(str,nums)))
    for i in range(1, n):
        v = nums[i]
        j = i -1
        while j>=0 and v < nums[j]:
            nums[j+1] = nums[j]
            j-=1
        nums[j+1] = v
        print(' '.join(map(str,nums)))


def main():
    n = int(input())
    line = input()
    nums = list(map(int, line.split()))

    insertion_sort(n, nums)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5604
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    int A = input<int>(), B = input<int>();
    int res = A - 2 * B;
    cout << (res > 0 ? res : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt int Q[100005]={0}
#define mp make_pair
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<int>()) 
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(int i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
 
int main()
{                       
    fastio();
    ll K,N;
    cin>>K>>N;
    ll ar[N];
    cn(ar,N);
    ll dis[N];
    for(ll i=1;i<N;i++)
    {
        dis[i]=ar[i]-ar[i-1];
    }
    dis[0]=ar[0]+K-ar[N-1];
    cout<<K-maxa(dis,N)<<endl;
}

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

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+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;}

int c[3][3];

int main() {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) cin >> c[i][j];
    }
    bool flag = true;
    if (c[0][0] - c[1][0] != c[0][1] - c[1][1] || c[0][1] - c[1][1] != c[0][2] - c[1][2]) flag = false;
    if (c[1][0] - c[2][0] != c[1][1] - c[2][1] || c[1][1] - c[2][1] != c[1][2] - c[2][2]) flag = false;
    if (c[0][0] - c[0][1] != c[1][0] - c[1][1] || c[1][0] - c[1][1] != c[2][0] - c[2][1]) flag = false;
    if (c[0][1] - c[0][2] != c[1][1] - c[1][2] || c[1][1] - c[1][2] != c[2][1] - c[2][2]) flag = false;
    
    
    if (flag) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string A,B,C;
  cin >> A >> B >> C;
  int i=0;
  int j=0;
  
  int size_a = A.size()-1;
  int size_b = B.size()-1;
  
  if (A.at(size_a) == B.at(0)){
    i=1;
  }
  if (B.at(size_b) == C.at(0)){
    j=1;
  }
  
  if (i==1 && j==1){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 2e5+5;
const int MOD = 1e9+7;


int arr[MSIZE][3];
int dp[MSIZE][3];

int main(){
    FIO
    int n; cin>>n;
    f(i,0,n-1)  cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    copy(arr[0],arr[0]+3,dp[0]);
    f(i,1,n-1)  
        f(j,0,2) {
            int val = dp[i-1][j];
            dp[i-1][j] = 0;
            dp[i][j] = arr[i][j] + *max_element(dp[i-1],dp[i-1]+3);
            dp[i-1][j] = val;
        }
    cout<<*max_element(dp[n-1],dp[n-1]+3)<<endl;
    return 0;

}
    


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	
	public static void runSchedule(Queue<String[]> tasks, int quantum) {
		int totalTime = 0;
		
		while (!tasks.isEmpty()) {
			String[] elem = tasks.poll();
			int reqTime = Integer.valueOf(elem[1]);
			int timeElapsed = quantum - reqTime;
			
			if (timeElapsed >= 0) {
				totalTime += reqTime;
				System.out.println(elem[0] + " " + totalTime);
			} else {
				totalTime += quantum;
				elem[1] = String.valueOf(timeElapsed * -1);
				tasks.add(elem);
			}
		}
		
		
	}
	

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int nTasks = scan.nextInt();
		int quantum = scan.nextInt();
		scan.nextLine();
		
		Queue<String[]> tasks = new ArrayDeque<>();
		
		for (int i = 0; i < nTasks; i++) {
			String[] str = scan.nextLine().split(" ");
			tasks.add(str);
		}
		scan.close();
		
		runSchedule(tasks, quantum);
	}

}



Measured memory_bytes: 109028
import * as fs from "fs"

const main = (input: string) => {
  const values = input.split(" ")
  const n = parseInt(values[0])
  const l = parseInt(values[1])
  let array: number[] = []
  for (var i = 0; i < n; i++) {
    array.push(l + i)
  }
  const sum = array.reduce((a, c) => a + c)
  let result: number | null = null
  let min: number | null = null
  for (var i = 0; i < n; i++) {
    let s = 0
    for (var j = 0; j < n; j++) {
    	if (j != i) {
          s += l + j
        }
  	}
    const diff = Math.abs(sum - s)
    if (min === null) {
      min = diff
      result = s
    } else {
      if (min > diff) {
        min = diff
        result = s
      }
    }
  }
  console.log(result)
}

main(fs.readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7372