akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--, v--;

  vector<vector<int>> G(n);
  rep(i,n - 1) {
    int a,b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> dist_u(n, -1), dist_v(n, -1);
  queue<int> que_u;
  que_u.push(u);
  dist_u[u] = 0;

  while(!que_u.empty()) {
    int cur = que_u.front();
    que_u.pop();

    for (auto nxt: G[cur]) {
      if(dist_u[nxt] == -1) {
        dist_u[nxt] = dist_u[cur] + 1;
        que_u.push(nxt);
      }
    }
  }
  queue<int> que_v;
  que_v.push(v);
  dist_v[v] = 0;

  while(!que_v.empty()) {
    int cur = que_v.front();
    que_v.pop();

    for (auto nxt: G[cur]) {
      if(dist_v[nxt] == -1) {
        dist_v[nxt] = dist_v[cur] + 1;
        que_v.push(nxt);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if(dist_u[i] >= dist_v[i]) {
      continue;
    }
    ans = max(ans, dist_v[i] - 1);
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 6656
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int x,c=0,i;
	char a;
	if(EOF==scanf("%d",&x)) exit(1);
	for(i=0;i<x;i++) {
		if(EOF==scanf("%c",&a)) exit(1);
		if(a=='Y') {
			printf("Four\n");
			c++;
			break;
		}
	}
	if(c==0) printf("Three\n");
	return 0;
}

Measured memory_bytes: 128
/*input

*/

#include<bits/stdc++.h>
using namespace std;
//#define int 					ll
#define ios	    				ios_base::sync_with_stdio(false); cin.tie(0)
#define hell 					1000000007
#define inf 					9e18

// Data Structures //
#define ull 					unsigned long long
#define ll 						long long
#define p_q 					priority_queue
#define pii         			pair<ll,ll>
#define vi          			vector<ll>
#define vii         			vector<pii>
#define mi          			map<ll,ll>
#define mii         			map<pii,ll>
// Functions //
#define pb 						push_back
#define ppb						pop_back
#define all(a)      			(a).begin(),(a).end()
#define gcd(a,b)    			__gcd((a),(b))
#define lcm(a,b)    			((a)*(b)) / gcd((a),(b))
#define mp 						make_pair
#define bs						binary_search
#define lb 						lower_bound
#define ub						upper_bound
#define F						first
#define S						second
#define take(a,n)				for(ll i=0;i<n;i++) cin>>a[i];
#define dbg(x) 					cout << #x << " = " << x << '\n'
#define endl					"\n"
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

#define N  1000005



void solve()
{
	ll n,k=0,t,cnt=0,prev=-1;
	cin>>n;
	vi v[3];
	ll dp[3][n+1];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>t;
			v[j].pb(t);
		}
	}
	
	for(int i = 1; i<=n;i++)
	{
		dp[0][i] = max(dp[1][i-1],dp[2][i-1]) + v[0][i-1];
		dp[1][i] = max(dp[0][i-1],dp[2][i-1]) + v[1][i-1];
		dp[2][i] = max(dp[0][i-1],dp[1][i-1]) + v[2][i-1];
	}
	cout<<max(max(dp[0][n],dp[1][n]),dp[2][n]);
}


signed main()
{
	ios;
	ll n,tests=1,prev=0,i=0;

	//cin>>tests;
	while(tests--)
	{
		solve();
	}
	time
	return 0;
}


Measured memory_bytes: 8136
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n;
    cin>>n;
    vector<int> x(n);
    rep(i,n)cin>>x[i];
    sort(x.begin(),x.end());
    ll min=INF;
    for(ll i=1;i<=100;i++){
        ll tmp=0;
        rep(j,n){
            tmp+=llpow(i-x[j],2LL);
        }
        chmin(min,tmp);
    }
    cout<<min<<endl;
    return 0;
}




Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;

            var Sdic = cin.ReadStrArray(N);
            var Sset = Sdic.Distinct();

            var M = cin.ReadInt;

            var Tdic = cin.ReadStrArray(M);

            var ans = 0;

            foreach (var elem in Sset)
            {
                var plus = Sdic.Count(item => item == elem);
                var minus = Tdic.Count(item => item == elem);
                var tmp = plus - minus;
                if (tmp > ans) ans = tmp;
            }

            WriteLine(ans);

            return;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13524
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	
	int x1,x2,y1,y2,x,y;
	string s = "",memo = "";
	
	cin >> x1 >> y1 >> x2 >> y2;
	x = x1;y = y1;
	while(1){
		if(y < y2){
			y++;
			memo += 'U';
		}
		else if(x < x2){
			x++;
			memo += 'R';
		}
		else{
			break;
		}
	}
	s += memo;
	
	rep(i,0,memo.size()){
		if(memo[i] == 'U'){
			s += 'D';
		}
		else if(memo[i] == 'R'){
			s += 'L';
		}
	}
	
	memo = "L";x = x1-1;y = y1;
	
	while(1){
		if(y < y2+1){
			y++;
			memo += 'U';
		}
		else if(x < x2){
			x++;
			memo += 'R';
		}
		else{
			break;
		}
	}
	memo += 'D';
	s += memo;
	
	s += 'R';
	
	rep(i,0,memo.size()){
		if(memo[i] == 'U'){
			s += 'D';
		}
		else if(memo[i] == 'R'){
			s += 'L';
		}
	}
	s += 'U';
  
	cout << s << endl;
  	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
dp = [[0,0] for _ in range(N+1)]
dp[0][1] = -float('inf')
for i in range(1,N+1):
    dp[i][0] = max(dp[i-1][0]+A[i-1],dp[i-1][1]-A[i-1])
    dp[i][1] = max(dp[i-1][0]-A[i-1],dp[i-1][1]+A[i-1])
print(dp[-1][0])


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

typedef long long ll;
const int MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  map<string, int> m;
  for(int i = 0; i < N; i++){
    cin >> S[i];
    m[S[i]]++;
  }
  int res = 0;
  for(auto itr = m.begin(); itr != m.end(); itr++){
    res = max(res, itr->second);
  }
  for(auto itr = m.begin(); itr != m.end(); itr++){
    if(itr->second == res){
      cout << itr->first << endl;
    }
  }
}


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

int main()
{
    int n;
    cin>>n;
    int arr[n+3];
    map<int,int>m1;
    int m2=INT_MIN;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        m2=max(m2,arr[i]);
        if(m1.find(arr[i])==m1.end())
        {
            m1[arr[i]]=1;
        }
        else
            m1[arr[i]]=2;
    }
    sort(arr,arr+n);
    int cnt1=0;
    map<int,int>m,cnt;
    for(int i=0;i<n;i++)
    {
        if(cnt[arr[i]]==0){
        for(int j=2;arr[i]*j<=m2;j++)
        {
            cnt[arr[i]*j]++;

        }
        if(m1[arr[i]]==1)
            cnt1++;
        }


    }
    cout<<cnt1<<endl;
}


Measured memory_bytes: 58100
#include <bits/stdc++.h>
#define int long long
#define moder 1234567
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;


signed main() {
	int d;
	cin>>d;
	if(d==25)cout<<"Christmas"<<endl;
	else if(d==24)cout<<"Christmas Eve"<<endl;
	else if(d==23)cout<<"Christmas Eve Eve"<<endl;
	else cout<<"Christmas Eve Eve Eve"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
	int n, m; cin >> n >> m;
	vector<vector<int> > s(m);
	REP(i, m) {
		int k; cin >> k;
		s[i].resize(k);
		REP(j, k) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	vector<int> p(m);
	REP(i, m) cin >> p[i];

	int res = 0;
	REP(bit, (1 << n)) {
		bool ok = true;
		REP(j, m) {
			int cnt = 0;
			for (int id : s[j])
				if ((bit >> id) & 1)
					cnt++;
			cnt %= 2;
			if (cnt != p[j])
				ok = false;
		}
		if (ok) res++;
	}
	cout << res << '\n';
	return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int A = sc.nextInt();

        int[] X=new int[N];

        int sum=0;
        for (int i = 0; i < N; i++) {
            X[i]=sc.nextInt();
            sum+=X[i];
        }

        long[][][] dp=new long[N+1][N+1][sum+1];

        dp[0][0][0]=1;

        for (int j = 1; j < N+1; j++) {
            for (int k = 0; k < N+1; k++) {
                    for (int s = 0; s <sum+1; s++) {

                    if(s<X[j - 1]) {
                        dp[j][k][s]=dp[j-1][k][s];
                    }else if(k>=1 && s>=X[j - 1]) {
                        dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-X[j - 1]];
                    }else {
                        dp[j][k][s]=0;
                    }

                }
            }
        }

        long ans=0;
        for (int k = 1; k < N+1 && k * A < sum + 1; k++) {
            ans+=dp[N][k][k*A];
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 86464
def main():
    A, B, C = map(int, input().split())
    K = int(input())
    for i in range(K):
        if A >= B and A >= C:
            A = 2*A
        if B >= A and B >= C:
            B = 2*B
        if C >= A and C >= B:
            C = 2*C
    print(sum([A, B, C]))
main()

Measured memory_bytes: 3060
#include <iostream>			//cout,endl,cin
#include <string>			//string,to_string,stoi
#include <vector>			//vector
#include <algorithm>		//min,max,swap,sort,reverse,lower_bound,upper_bound
#include <utility>			//pair,make_pair
#include <tuple>			//tuple,make_tuple
#include <cstdint>			//int64_t,int*_t
#include <cstdio>			//printf
#include <map>				//map
#include <queue>			//queue,priority_queue
#include <set>				//set
#include <stack>			//stack
#include <deque>			//deque
#include <unordered_map>	//unordered_map
#include <unordered_set>	//unordered_set
#include <bitset>			//bitset
#include <cctype>			//isupper,islower,isdigit,toupper,tolower
#include <math.h>
#include <cstdio>
#include <cstring>
#include <iomanip>

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

int main() {
    ld a;
    ld b;
    ld c;
    cin >> a >> b;
    c = floor(a * b);
    cout << fixed << (ll)c << endl;
}

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}

ll const N=(ll)2e5+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
       
       cin>>n;
       
       vll a(n);
       for(i=0;i<n;i++){
               cin>>a[i];
       }
       ll ans=1;
       ll mx=a[0];
       for(i=1;i<n;i++){
               if(a[i]>=mx){
                       ans++;
                       mx=a[i];
               }
       }
       cout<<ans<<endl;
       
       
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        for(ll tc=1;tc<=q;tc++){
                // cout<<"Case #"<<tc<<": ";
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i = 0; i < n; i++)
#define for1(i,n) for(int i = 1; i <= n; i++)
#define ford(i,n) for(int i = n-1; i >= 0; i--)
#define fore(i,a,b) for(int i = a; i <= b; i++)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
 
 
const  int MAXn= 3e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;
 
 
int main(){
		ll n, d, a;
		cin >> n >> d >> a;
		vector<pll> v(n);
		vll w(n), cum(n, 0);
		forn(i, n) {
			cin >> v[i].fi >> v[i].se;
			w[i] = v[i].fi;
		}
		sort(all(v));
		sort(all(w));
		ll ans  = ceil((double)v[0].se/a) ;
		cum[0] = ans;
		
		for(int i = 1; i < n; i++) {
			ll temp = v[i].fi - 2 * d;
			temp = max(temp, 0LL);
			int pos = lower_bound(w.begin(), w.end(), temp) - w.begin();			
			ll bomb;
			if(pos == 0) bomb = cum[i - 1];
			else bomb = cum[i - 1] - cum[pos - 1];
			ll req = max((ll)ceil((double)v[i].se/a) - bomb , 0LL);
			ans += req;
			cum[i] = req + cum[i - 1];
		}
		cout << ans;
	}
		
		
				
		


Measured memory_bytes: 6528
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define MAXN 100500

int n, v;
int f[MAXN][3];

int main() {
    scanf("%i", &n);
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j < 3; ++j) {
            scanf("%i", &v);
            for(int z = 0; z < 3; ++z)
                if (z != j && f[i][j] < f[i - 1][z] + v) f[i][j] = f[i - 1][z] + v;
        }
    }

    printf("%i\n", *max_element(f[n], f[n] + 3));
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(){
  int data[10];
  int i,j;
  int top3[3];
  int max,idx;

  for(i=0;i<10;i++){
    scanf("%d", &data[i]);
  }

  for(j=0;j<3;j++){
    max=data[0];
    idx=0;
    for(i=1;i<10;i++){
      if(max<data[i]){
        max = data[i];
        idx = i;
      }
    }
    top3[j] = max;
    data[idx] = 0;
  }
  
  for(j=0;j<3;j++){
    printf("%d\n", top3[j]);
  }

  return 0;
}

Measured memory_bytes: 600
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=[],o=0;o<t;o++){var u=r[o+1];n.push(u)}for(var f=Number(r[t+1]),i=[],l=0;l<f;l++){var a=r[l+t+2];i.push(a)}for(var c=0,p=0;p<t;p++){for(var d=0,s=n[p],v=0;v<t;v++)n[v]==s&&(d+=1);for(var b=0;b<f;b++)i[b]==s&&(d-=1);d>c&&(c=d)}console.log(c)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 7372
chomp (my $n = <STDIN>);
chomp (my $s = <STDIN>);
my (@e, @w);
$e[0] = (substr($s, 0, 1) eq 'E' ? 1 : 0);
$w[0] = (substr($s, 0, 1) eq 'W' ? 1 : 0);
for my $i (1..$n-1) {
  if (substr($s, $i, 1) eq 'E') {
    $e[$i] = $e[$i - 1] + 1;
    $w[$i] = $w[$i - 1];
  } else {
    $e[$i] = $e[$i - 1];
    $w[$i] = $w[$i - 1] + 1;
  }
}
unshift @w, 0;
my $min = inf;
for my $i (0..$n-1) {
  $min = $e[-1] - $e[$i] + $w[$i] - $w[0] if $min > $e[-1] - $e[$i] + $w[$i] - $w[0];
}
print "$min\n";

Measured memory_bytes: 22604
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

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

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()

#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en

#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define pll pair<lli, lli>
#define pii pair<int, int>
#define pil pair<int, lli>

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (int i = n; i >= m; i--)

#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)

#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/

#define lb lower_bound
#define ub upper_bound
#define er equal_range

#define findnot find_first_not_of

#define maxe *max_element
#define mine *min_element

#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements sbtriectly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD funcions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m) { return power(a, m - 2, m); }
/*CODE BEGINS*/
int main()
{
    kira;
    lli a,b;
    cin>>a>>b;
    cout<<a*b/gcd(a,b);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<math.h>
#include<set>
#include<iomanip>
#include<stdio.h>
#include<deque>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	int i,j=-1,o=0;
	vector<int> pos[26];
	for(i=0;i<s.length();i++)
		pos[s[i]-'a'].pb(i);
	for(i=0;i<t.length();i++)
	{
		if(pos[t[i]-'a'].size()==0)
		{
			cout<<"-1"<<endl;
			return 0;
		}
		int k=upper_bound(pos[t[i]-'a'].begin(),pos[t[i]-'a'].end(),j)-pos[t[i]-'a'].begin();
		if(k==pos[t[i]-'a'].size())
		{
			o=o+s.length()-j+pos[t[i]-'a'][0];
			j=pos[t[i]-'a'][0];
		}
		else
		{
			o=o+pos[t[i]-'a'][k]-j;
			j=pos[t[i]-'a'][k];
		}
	}
	cout<<o<<endl;
}

Measured memory_bytes: 1736
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
const int N=101;
long long arr[N];
int a[N],b[N];
vector<double> slope;
bool bo[N];
int main()
{




int n;
cin>>n;
int t=n;
n--;
long long int mini=10e5;
for(int i=0;i<n;i++)cin>>arr[i];
long long res=arr[n-1]+arr[0];
for(int i=0;i<n-1;i++){res+=min(arr[i],arr[i+1]);
//cout<<arr[i]<<" ";}
}
cout<<res;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const char key[8] = "keyence";

int main()
{
    char S[105];
    cin >> S;
    int n = strlen(S);
    if(strcmp(S, key) == 0) { cout << "YES" << endl; return 0; }

    char TMP[105];
    for(int i = 0; i < n; ++i) {
        for(int j = i; j < n; ++j){
            //i, i+1, ... , jまでの文字列を削除する。
            int cur = 0;
            for(int k = 0; k < i; ++k) {
                TMP[cur] = S[k]; ++cur;
            }
            for(int k = j + 1; k < n; ++k) {
                TMP[cur] = S[k]; ++cur;
            }
            TMP[cur] = '\0';
            
            if(strcmp(TMP, key) == 0) { cout << "YES" << endl; return 0; }
        }
    }

    cout << "NO" << endl; return 0;
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    string before, now;
    long long ans = 0;
    for (long long i = 0; i < S.length(); i++) {
        now += S[i];
        if (now != before) {
            before = now;
            now = "";
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
# include <cstdio>
# include <iostream>
# include <queue>
# include <algorithm>
# include <cstring>
# include <string>
# define R register int
# define ll long long

using namespace std;

const int maxn=200005;
char s[maxn],t[maxn];
int a[30],b[30],len,ans=0;

int main()
{
	scanf("%s",s+1);
	scanf("%s",t+1);
	len=strlen(s+1);
	for (R i=1;i<=len;++i)
	{
		if(a[ s[i]-'a'+1 ]==0) a[ s[i]-'a'+1 ]=t[i]-'a'+1;
		else if(a[ s[i]-'a'+1 ]!=t[i]-'a'+1) ans=1;
		if(b[ t[i]-'a'+1 ]==0) b[ t[i]-'a'+1 ]=s[i]-'a'+1;
		else if(b[ t[i]-'a'+1 ]!=s[i]-'a'+1) ans=1;
	}
	if(ans) printf("No");
	else printf("Yes");
    return 0;
}

Measured memory_bytes: 640
N = int(raw_input())
A = map(int, raw_input().split())

count = {}
ans = 1
def INC(x):
    global count
    if x in count:
        count[x] += 1
    else:
        count[x] = 1

for x in A:
    INC(x-1)
    INC(x)
    INC(x+1)

for a, b in count.items():
    ans = max(ans, b)
print ans

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

using namespace std;

int mod3sum(int a, int b){
    int ans = (a+b)%3;
    if(ans < 0){ans+=3;}
    return ans;
}
int main(){
    string S, T;
    cin >> S >> T;
    int s[S.size()+1], t[T.size()+1]; //how many more A than B
    int queries;
    cin >> queries;
    s[0] = 0;
    t[0] = 0;
    for(int one = 0; one < S.size(); one++){
        if(S[one] == 'A'){s[one+1] = mod3sum(s[one], 1);}
        else{s[one+1] = mod3sum(s[one], -1);}
    }
    for(int one = 0; one < T.size(); one++){
        if(T[one] == 'A'){t[one+1] = mod3sum(t[one], 1);}
        else{t[one+1] = mod3sum(t[one], -1);}
    }

    for(int one = 0; one < queries; one++){
        int s1, s2, t1, t2;
        cin >> s1 >> s2 >> t1 >> t2;
        int sval = mod3sum(s[s2], -s[s1-1]);
        int tval = mod3sum(t[t2], -t[t1-1]);
        if(sval == tval){cout << "YES" << endl;}
        else{cout << "NO" << endl;}
    }
}

Measured memory_bytes: 1664
def F(s, target):
    cnt = 0
    while s.count(target) != len(s):
        cnt += 1
        s = ''.join(y if x != target else x for x, y in zip(s[:-1], s[1:]))
    return cnt

def main():
    s = input()
    ans = min(F(s,t) for t in set(s))
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n = gets.to_i
MOD = 1000000007
def my_pow(x,y)
  rst = 1
  y.times do |i|
    rst = rst * x
    rst %= MOD
  end
  rst
end
puts (my_pow(10, n) - my_pow(9, n) * 2 + my_pow(8, n)) % MOD

Measured memory_bytes: 14388
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func search(in [9]byte) int {
	for i := 0; i < 9; i++ {
		if in[i] == byte(0) {
			return i
		}
	}
	panic("not found 0")
}

func up(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	if pos > 2 {
		in[pos], in[pos-3] = in[pos-3], in[pos]

	} else {
		return false, in
	}
	return true, in

}

func down(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	if pos < 6 {
		in[pos], in[pos+3] = in[pos+3], in[pos]
	} else {
		return false, in

	}
	return true, in

}

func left(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	// mod(pos, 3) == 0
	if pos != 0 && pos != 3 && pos != 6 {
		in[pos], in[pos-1] = in[pos-1], in[pos]
	} else {
		return false, in
	}
	return true, in

}
func right(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	// mod(pos, 3) == 2
	if pos != 2 && pos != 5 && pos != 8 {
		in[pos], in[pos+1] = in[pos+1], in[pos]
	} else {
		return false, in

	}
	return true, in

}

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i

}

var goal = [9]byte{1, 2, 3, 4, 5, 6, 7, 8, 0}

func pp(s [9]byte) {

	for i := 0; i < 3; i++ {
		fmt.Printf("%d %d %d\n", s[0+3*i], s[1+3*i], s[2+3*i])
	}
	fmt.Println("----------------------")

}

type item struct {
	d *[9]byte
	c int
}

var queue = []item{}
var closed = map[[9]byte]bool{}

func bfs(cost int) int {
	for {

		top := queue[0]
		queue = queue[1:]

		if *top.d == goal {
			return top.c
		}
		closed[*top.d] = true

		ok, ur := up(*top.d)
		ok2, _ := closed[ur]
		if ok && !ok2 {
			queue = append(queue, item{&ur, top.c + 1})
		}
		ok, dr := down(*top.d)
		ok2, _ = closed[dr]
		if ok && !ok2 {
			queue = append(queue, item{&dr, top.c + 1})
		}
		ok, lr := left(*top.d)
		ok2, _ = closed[lr]
		if ok && !ok2 {
			queue = append(queue, item{&lr, top.c + 1})
		}
		ok, rr := right(*top.d)
		ok2, _ = closed[rr]
		if ok && !ok2 {
			queue = append(queue, item{&rr, top.c + 1})
		}
	}

}

func main() {
	sc.Split(bufio.ScanWords)
	var state [9]byte
	for i := 0; i < 9; i++ {
		state[i] = byte(next())
	}
	queue = append(queue, item{&state, 0})
	cost := bfs(0)
	fmt.Println(cost)
}



Measured memory_bytes: 23120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;


const ll N = 1e5+10;
const ll mod = 1e9+7;
ll a[N];


int main() {
	ll n;
	scanf("%lld",&n);
	for(ll i=2; i<=n; i++) {
		ll x=i;
		for(ll j=2; j<=x; j++) {
			while(x%j==0) {
				a[j]++;
				x/=j;
			}
		}
		if(x!=1) a[x]++;
	}
	ll ans=1;
	for(ll i=1; i<=n; i++) {
		if(a[i]!=0) ans=(ans*(a[i]+1))%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import bisect
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

a_r = [0 for _ in range(n+1)]
for i in range(n):
	a_r[i+1] = a_r[i] + a[i]

b_r = [0 for _ in range(m+1)]
for i in range(m):
	b_r[i+1] = b_r[i] + b[i]

ans = 0

for i in range(n+1):
	targ = a_r[i]
	if targ > k:
		break
	ans = max(ans, i-1+bisect.bisect_right(b_r, k-targ))

print(ans)

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

int main() {
  int N, T;
  cin >> N >> T;
  int t[N];
  for (int i=0; i<N; i++)
    cin >> t[i];
  long ans = 0, start = t[0], prev = t[0];
  for (int i=1; i<N; i++) {
    if (t[i]>prev+T) {
      ans += prev+T-start;
      start = t[i];
    }
    prev = t[i];
  }
  ans += prev+T-start;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		BigDecimal a = BigDecimal.valueOf(sc.nextDouble());
		BigDecimal rate = BigDecimal.valueOf(Math.PI);
		
		BigDecimal beforeArea = a.multiply(a).multiply(rate);
		BigDecimal beforeLength = a.multiply(BigDecimal.valueOf(2.0)).multiply(rate);
		
		String afterArea = String.format("%.6f",beforeArea);
		String afterLength = String.format("%.6f",beforeLength);
		
		System.out.println(afterArea + " " + afterLength);
	}

}

Measured memory_bytes: 19096
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()
int marked[1000001],pr[1000001];
int32_t main()
{ 
  IOS

  int n;
  cin >> n;
  int a[n];
  for(int i = 0;i<n;i++){
    cin >> a[i];
    marked[a[i]] += 1;
  }
  for(int i = 1;i<=1e6;i++){
    pr[i] = true;
  }
  bool shit = false;
  for(int i = 2;i<=1e6;i++){
    if(pr[i]){
      int temp = 0;
      for(int j = i;j<=1e6;j+=i){
        pr[j] = false;
        temp += marked[j];
      }
      pr[i] = true;
      
      if(temp>=2){
        shit = true;
      }
    }
  }
  if(!shit){
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int g= 0;
  for(int i = 0;i<n;i++){
    g = __gcd(g,a[i]);
  }
  if(g == 1){
    cout << "setwise coprime" << endl;
  }
  else{
    cout << "not coprime" << endl;
  }

  










  
    
} 



Measured memory_bytes: 26944
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//Chain-Confined Path
public class Main{

	final double EPS = 1e-8;
	
	double cross(double[] a, double[] b){
		return a[0]*b[1]-a[1]*b[0];
	}
	double norm(double[] a, double[] b){
		return Math.hypot(a[0]-b[0], a[1]-b[1]);
	}
	double[] sub(double[] a, double[] b){
		return new double[]{a[0]-b[0], a[1]-b[1]};
	}
	double ex(double[] a, double[] b, double[] c){
		double[] s1 = sub(b, a), s2 = sub(c, a);
		return cross(s1, s2);
	}
	double[][] circleCrossPoint(double x1, double y1, double r1, double x2, double y2, double r2){
		double vx = x2-x1, vy = y2-y1, D = Math.sqrt(vx*vx+vy*vy);
		vx/=D; vy/=D;
		vx*=r1; vy*=r1;
		double thita = Math.acos((r1*r1+D*D-r2*r2)/(2*r1*D));
		double px = Math.cos(thita)*vx-Math.sin(thita)*vy, py = Math.sin(thita)*vx+Math.cos(thita)*vy;
		double px2 = Math.cos(-thita)*vx-Math.sin(-thita)*vy, py2 = Math.sin(-thita)*vx+Math.cos(-thita)*vy;
		double[][] res = new double[2][2];
		res[0][0] = x1+px; res[0][1] = y1+py;
		res[1][0] = x1+px2; res[1][1] = y1+py2;
		return res;
	}
	
	int INF = 1<<29;
	double[][] dist;
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			double[] cx = new double[n], cy = new double[n], r = new double[n];
			for(int i=0;i<n;i++){
				cx[i] = sc.nextDouble(); cy[i] = sc.nextDouble(); r[i] = sc.nextDouble();
			}
			double[][] x = new double[n+1][2], y = new double[n+1][2];
			x[0][0] = x[0][1] = cx[0];
			y[0][0] = y[0][1] = cy[0];
			x[n][0] = x[n][1] = cx[n-1];
			y[n][0] = y[n][1] = cy[n-1];
			for(int i=0;i+1<n;i++){
				double[][] p = circleCrossPoint(cx[i], cy[i], r[i], cx[i+1], cy[i+1], r[i+1]);
				x[i+1][0] = p[0][0]; y[i+1][0] = p[0][1];
				x[i+1][1] = p[1][0]; y[i+1][1] = p[1][1];
			}
			double[][][][] adj = new double[n+1][2][n+1][2];
			for(int i=0;i<=n;i++)for(int j=0;j<2;j++)for(int k=0;k<=n;k++)for(int l=0;l<2;l++)adj[i][j][k][l] = INF;
			for(int i=0;i<=n;i++)for(int j=0;j<2;j++)for(int k=i+1;k<=n;k++)for(int l=0;l<2;l++){
				boolean ok = true;
				double[] A = new double[]{x[i][j], y[i][j]}, B = new double[]{x[k][l], y[k][l]};
				for(int m=i+1;m<k;m++){
					if(ex(A, B, new double[]{x[m][0], y[m][0]}) * ex(A, B, new double[]{x[m][1], y[m][1]}) > -EPS)ok = false;
				}
				if(ok)adj[i][j][k][l] = norm(A, B);
			}
			dist = new double[n+1][2];
			for(double[]d:dist)Arrays.fill(d, INF);
			dist[0][0] = dist[0][1] = 0;
			PriorityQueue<int[]> q = new PriorityQueue<int[]>(n, new Comparator<int[]>() {
				public int compare(int[] o1, int[] o2) {
					return (int)Math.signum(dist[o1[0]][o1[1]] - dist[o2[0]][o2[1]]);
				}
			});
			q.add(new int[]{0, 0});
			while(!q.isEmpty()){
				int[] V = q.poll();
				int i = V[0], j = V[1];
				for(int k=i+1;k<=n;k++)for(int l=0;l<2;l++){
					double w = dist[i][j] + adj[i][j][k][l];
					if(w < dist[k][l]){
						dist[k][l] = w; q.add(new int[]{k, l});
					}
				}
			}
			System.out.printf("%.8f\n", dist[n][0]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17000
// 2014/07/21 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, x;
		cin >> n >> x;

		if(n==0 && x==0)
			break;

		int cnt = 0;

		for(int i=1; i<=n; i++){
			for(int j=i+1; j<=n; j++){
				for(int k=j+1; k<=n; k++){
					if(i+j+k==x){
						cnt++;
					}
				}
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
long double dp[310][310][310];
bool vis[310][310][310];
int cnt[4];
int n;
int a;
long double solve(int a,int b,int c){//记搜 
	if(vis[a][b][c])
		return dp[a][b][c];
	vis[a][b][c]=true;
	long double res=1.00*n/(a+b+c);
	if(a>0){
		res+=1.00*a/(a+b+c)*solve(a-1,b,c);
	}
	if(b>0){
		res+=1.00*b/(a+b+c)*solve(a+1,b-1,c);
	}
	if(c>0){
		res+=1.00*c/(a+b+c)*solve(a,b+1,c-1);
	}
	return dp[a][b][c]=res;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		cnt[a]++;
	}
	vis[0][0][0]=true;
	cout<<fixed<<setprecision(20)<<solve(cnt[1],cnt[2],cnt[3]);
	return 0;
}


Measured memory_bytes: 481536
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  p=new Array(N);
  var pmax=0;
  for(i=0;i<N;i++){
    p[i]=parseInt(input[i+1]);
    pmax=Math.max(pmax,p[i]);
  }
  var ans=0;
  var flag=0;
  for(i=0;i<N;i++){
    if(p[i]==pmax&&flag==0){
      ans+=p[i]/2;;
      flag=1;
    }else{
      ans+=p[i];
    }
  }

  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,m;
	while(cin>>n>>m,n){
		vector<string>in(n,"");
//		rep(i,n)cin>>in[i];//
//		rep(i,n)if(in[i]=="0")in[i]="";
		rep(q,m){
			string s;cin>>s;
			if(s=="A"){
				rep(i,n)if(in[i]==""){
					in[i]="A";
					break;
				}
			}else if(s=="B"){
				vector<string>tmp=in;
				rep(i,n)if(in[i]=="A"){
					if(i)tmp[i-1]="!";
					if(i!=n-1)tmp[i+1]="!";
				}
				int I=inf;
				for(int i=n-1;i>=0;i--)if(tmp[i]==""){I=i;break;}
				if(I==inf){
					rep(i,n)if(in[i]==""){
						I=i;
						break;
					}
				}
				in[I]="B";
			}else if(s=="C"){
				if(!q){
					in[n/2]="C";
					continue;
				}
				rep(i,n)if(in[i]!=""){
					if(i!=n-1&&in[i+1]==""){
						in[i+1]="C";
						break;
					}else if(i&&in[i-1]==""){
						in[i-1]="C";
						break;
					}
				}
			}else{
				if(!q){
					in[0]="D";
					continue;
				}
				vi t;
				rep(i,n)if(in[i]!="")t.pb(i);
				int ma=t[0],mai=0;
				rep(i,t.size()-1){
					if(ma<(t[i+1]-t[i])/2){
						ma=(t[i+1]-t[i])/2;
						mai=t[i]+(t[i+1]-t[i])/2;
					}
				}
				if(ma<n-t[t.size()-1]-1){
					mai=n-1;
				}
				in[mai]="D";
			}
		}
		rep(i,n)cout<<(in[i]==""?"#":in[i]);
		cout<<endl;
	}
}

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

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

  double ans = 0;
  for (int i = 0; i < n; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      ans += x;
    } else {
      ans += x * 380000;
    }
  }
  cout << fixed << setprecision(5) << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] prime = new long[200];
		prime[0] = 2;
		prime[1] = 3;
		int a = 2;
		for( int i=3; i<1000; i+=2 ){
			for( int j=i-1; j>=3; j-- ){
				if( i%j==0 ){
					break;
				}
				if( j==3 ){
					prime[a]=i;
					a++;
				}
			}
		}
		long[] countPrime = new long[a];
		for( int i=2; i<=N; i++ ){
			for( int j=0; j<a; j++ ){
				long b = i;
				for( int k=0; k<i/2; k++ ){
					if( b%prime[j]==0 ){
						countPrime[j]++;
						b = b/prime[j];
					}else{
						break;
					}
				}	
			}         
		}
		long ans = 1;
		long mod = 1000000007L;      
		for( int i=0; i<a; i++ ){
			countPrime[i]++;          
			ans = ((ans%mod)*(countPrime[i]%mod))%mod;
		}    
		System.out.println(ans);
	}
}


Measured memory_bytes: 22100
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():
    A =INT()
    B =INT()
    c=[1,2,3]
    c.remove(A)
    c.remove(B)
    print(c[0])
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
N = input()
S1 = list(raw_input())
S2 = list(raw_input())

if N == 1:
    ans = 3
else:
    if S1[0] == S1[1]:
        index = 2
        ans   = 6
        vertical = False
    else:
        index = 1
        ans = 3
        vertical = True
    while True:
        if (N - index) == 1:
            if vertical:
                ans *= 2
            index += 1
        elif (N - index) == 0:
            break
        else:
            if S1[index] == S1[index+1]:
                index += 2
                if vertical:
                    ans *= 2
                else:
                    ans *= 3
                vertical = False
            else:
                index += 1
                if vertical:
                    ans *= 2
                vertical = True

print(ans % 1000000007)

Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n;
    cout << n/3 << endl;
    
}

Measured memory_bytes: 256
n=int(input())
if n<10:
    print('Yes')
else:

    k=0
    for i in range(9,0,-1):
            if n%i==0:
                n=n//i
                if n>9:
                    k+=1
                    break
    if k>0:
            print('No')
    else:
            print('Yes')


Measured memory_bytes: 2940
N = int(input())
a = list(map(int, input().split()))

S = sum(a)
_min  = 10000000000000000000
x = 0
for i in range(0,N-1):
  x += a[i]
  tmp = abs(S - 2*x)
  if tmp < _min:
    _min = tmp

print(_min)

Measured memory_bytes: 24836
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	cout<<"##########"<<endl
#define M			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii>

// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;

/*int power(int x,int p)
{
	if(p==0) return 1;
	int nn=power(x,p/2);
	
	if(p&1) return(nn*nn*x)%M;
	else return (nn*nn)%M;
}

int get_inv(int x)
{
	return power(x,M-2);
}
*/
ll fac[10000000];
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    //debug(3);
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%p; 
    return ((fac[n]* modInverse(fac[r], p) % p )* 
            modInverse(fac[n-r], p) % p) % p; 
} 

/*void get_ans(int n,int r)
{
	int am=max(n,r);
	int fact[am+1];
	fact[1]=1;
	rep(i,2,am+1) fact[i]=(fact[i]*i%M)%M;
	
	cout<<(fact[n]*get_inv(fact[r])*get_inv(n-r))%M<<endl;
}*/

void solve()
{
	ll x,y;
	cin>>x>>y;
	
	if((x+y)%3!=0)
	{
		cout<<"0"<<endl;
		return;
	}
	ll d=(x+y)/3;
	ll n=y-d;
	ll m=x-d;
	//cout<<n<<" "<<m<<endl;
	if(m<0||n<0)
	{
		cout<<"0"<<endl;
		return;
	}
	cout<<nCrModPFermat(n+m,m,M);
}

signed main()
{
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		ll t;
		t=1;
		while(t--)
		{
			solve();
		}
}

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

int main()
{
	int n,a[101],tot=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",a+i);
	for (int i=2;i<=n;i++) if (a[i]==a[i-1]) a[i]=0,tot++;
	printf("%d\n",tot);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define abs(x) ((x) < 0 ? (-(x)) : (x))
#define rep(i,a,m) for((i) = (a) ; (i) < (m) ; ++(i))
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.end(),x.begin()
#define sz(x) ((int)x.size())
#define PI 3.14159265

using namespace std;
/*
#ifdef JUDGE
#include <fstream>
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
#include <iostream>
using std::cin;
using std::cout;
#endif
*/
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pi;
int a, b, c, i, j, k;
long long ans = 0LL;
long double eps = 1.0E-14;
long long MOD = 1000000007;
/*
bool comparator(const MyStruct& lhs, const MyStruct& rhs) {
   return lhs.key < rhs.key;
}
*/
int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	const double pi=acos(-1.0);
	int t,T;
	cin >> T;	
    cin >> a >> b;
    int x  = a/T;
    if (a%T == 0) {
        cout << "OK" << endl;
        return 0;
    }
    if ((x+1)*T <= b) {
        cout << "OK" << endl;
        return 0;
    }
    cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3648
<?php
fscanf(STDIN, '%d %d', $N, $K);
$p = array_map('intval', explode(' ', trim(fgets(STDIN))));
$x = array_sum(array_slice($p, 0, $K));
$max = $x;
for ($i = $K; $i < $N; $i++) {
    $x += $p[$i] - $p[$i - $K];
    $max = max($x, $max);
}
$ans = ($max + $K) / 2;
printf('%.f', $ans);


Measured memory_bytes: 27120