akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    ll x, d;
    cin >> n >> x >> d;
    if (d == 0) {
        cout << (x == 0 ? 1 : n + 1) << endl;
        return;
    }
    map<int, vector<pll>> mp;
    if (d < 0) {
        d *= -1;
        x *= -1;
    }
    rep(m, n + 1) {
        ll a = x * m;
        ll l = d * (m - 1) * m / 2 + a;
        ll r = d * (2 * n - m - 1) * m / 2 + a + d;
        a %= d;
        a += d;
        a %= d;
        mp[a].push_back({l, r});
    }
    ll ans = 0;
    for (auto &p : mp) {
        auto vec = p.se;
        sort(all(vec));
        ll lim = vec[0].fi;
        for(auto &a : vec) {
            if (a.se <= lim) continue;
            chmax(lim, a.fi);
            ans += (a.se - lim) / d;
            lim = a.se;
        }
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 25492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
int a[105];
int b;
int ans=1;
int main(void){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		b=b+a[i];
		if(b<=m) ans++;
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DigitsParade solver = new DigitsParade();
        solver.solve(1, in, out);
        out.close();
    }

    static class DigitsParade {
        public static int MOD = 1_000_000_007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] chars = new StringBuilder(in.next()).reverse().toString().toCharArray();
            long[][] dp = new long[chars.length][13];

            if (chars[0] == '?') {
                for (int i = 0; i <= 9; i++) {
                    dp[0][i] = 1;
                }
            } else {
                int i = Integer.parseInt(String.valueOf(chars[0]));
                dp[0][i] = 1;
            }

            int num = 1;
            for (int i = 1; i < chars.length; i++) {
                num *= 10;
                num %= 13;

                if (chars[i] == '?') {
                    for (int j = 0; j <= 9; j++) {
                        for (int k = 0; k < 13; k++) {
                            int index = (k + (j * num)) % 13;
                            dp[i][index] += dp[i - 1][k];
                            dp[i][index] %= MOD;
                        }
                    }
                } else {
                    int j = Integer.parseInt(String.valueOf(chars[i]));
                    for (int k = 0; k < 13; k++) {
                        int index = (k + j * num) % 13;
                        dp[i][index] += dp[i - 1][k];
                        dp[i][index] %= MOD;
                    }
                }
            }
            out.println(dp[chars.length - 1][5]);
        }

    }
}



Measured memory_bytes: 67152
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


pi get_rl(int v){
  int r = v % 10;
  int l = 0;
  while (v){
    l = v % 10;
    v /= 10;
  }
  return pi(l, r);
}

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

  map<pi, int> cnt;
  for (int i=0;i<=10;i++){
    for (int j=0;j<=10;j++){
      cnt[pi(i, j)] = 0;
    }
  }
  for (int i=1;i<n+1;i++){
    pi v = get_rl(i);
    cnt[v]++;
  }

  ll ans = 0;
  for (int i=0;i<=10;i++){
    for (int j=0;j<=10;j++){
      ans += cnt[pi(i, j)] * cnt[pi(j, i)];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
k, x = map(int, input().split())
if abs(x + 1000000) < 2 and x<0:
  for i in range(-1000000, x + k):
    print(i,end=" ")
  exit()
elif abs(x - 1000000) < 2 and x > 0:
  for i in range(x - k + 1,1000000+1):
    print(i,end=" ")
  exit()
else:
  for i in range(x - k + 1, x + k):
    print(i,end=" ")
  exit()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define ll long long
#define max 200000
using namespace std;

int N, M;
int D[max], T[max];

void solve() {
  sort(D, D + N);
  sort(T, T + M);
  bool ans = true;
  int j0 = 0;
  for (int i = 0; i < M; i++) { // i ... M
    for (int j = j0; j < N; j++) { // j ... N
      if (T[i] == D[j]) {
        j0 = j + 1;
        break;
      } else {
        if (j == N - 1) {
          ans = false;
        }
      }
    }
  }
  if (ans) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> D[i];
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> T[i];
  }
  solve();
  return 0;
}


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

using namespace std;

typedef pair<int, int> PII;
typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

int main() {
	string s = "CODEFESTIVAL2016";
	string t;
	cin >> t;
	int l = s.length();
	int S = 0;
	for (int i = 0; i < l; i ++)
		if (s[i] != t[i]) S++;
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 384
// ABC050 B - Contest with Drinks Easy
#include <stdio.h>

int main(void) {
    int N, M;
    int T[100];
    int PX[100][2];

    // input
    scanf("%d", &N);
    int i = 0;
    for (i = 0; i < N; i++) {
        scanf("%d", &T[i]);
    }
    scanf("%d", &M);
    for (i = 0; i < M; i++) {
        scanf("%d %d", &PX[i][0], &PX[i][1]);
    }
    unsigned long long defaultTime = 0;
    for (i = 0; i < N; i++) {
        defaultTime += (unsigned long long)T[i];
    }

    for (i = 0; i < M; i++) {
        unsigned long long time = 0;
        int diff = T[PX[i][0] - 1] - PX[i][1];
        time = defaultTime - (unsigned long long)diff;
        printf("%lld\n", time);
    }
}

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

XY = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    d = XY[i][0]* XY[i][0] +  XY[i][1]* XY[i][1]
    if d <= D*D:
        ans += 1
print(ans)

Measured memory_bytes: 102400
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    int answer = k;
    REP(i,n-1)answer*=(k-1);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 1e9;
    REP(i,1<<n){
        int x = 1;
        REP(j,n){
            if ((i >> j) & 1) x *= 2;
            else x += k;
        }
        ans = min(ans, x);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(void) {
    int N, M;
    int A;

    cin >> N >> M;

    bool flg = false;
    for (int i = 0; i < M; i++) {
        cin >> A;
        N -= A;
        if (N < 0) {
            flg = true;
            break;
        }
    }

    if (flg) {
        cout << "-1" << endl;
    } else {
        cout << N << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  n,m=pM(split(readline()))
  g=[Int[] for i=1:n]
  for i=1:m;
    a,b=pM(split(readline()))
    push!(g[a],b)
    push!(g[b],a)
  end
  que=Int[1]
  depth=zeros(Int,n)
  depth[1]=1
  while !isempty(que)
    look=popfirst!(que)
    for next=g[look]
      if depth[next]==0
        depth[next]=look+1
        push!(que,next)
      end
    end
  end
  println("Yes")
  for i=depth[2:end];println(i-1);end
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


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

int isprime(int x){
    int i;
    
    if (x == 2) return 1;
    if (x < 2 || x%2 == 0) return 0;
      
    i = 3;
    while (i <= sqrt(x)){
        if (x%i == 0) {
            return 0;
        }
        i = i + 2;

    }
    return 1;
}
int main (){

    int  k, x, num;
    int Ans=0;

    scanf("%d",&num);
    
    for(k=0; k<num; k++){
        scanf("%d",&x);
        if(isprime(x)==1) Ans++;
    }
    printf("%d\n",Ans);
return 0;
}


Measured memory_bytes: 2024
#include<stdio.h>
int main() {
	int a, b, sum[20000];
	int i,j;
	char op;

	i = 0;
	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		if (op == '+') {
			sum[i] = a + b;
		}
		else if (op == '-') {
			sum[i] = a - b;
		}
		else if (op == '*') {
			sum[i] = a * b;
		}
		else if (op == '/') {
			sum[i] = a / b;
		}
		else {
			break;
		}
		i++;
	}
	for (j = 0;j < i;j++) {
		printf("%d\n", sum[j]);
	}
	return 0;
}


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main{
	static String[] button = {".,!? ", "abc", "def",
							  "ghi", "jkl", "mno",
							  "pqrs", "tuv", "wxyz"};

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int data = sc.nextInt();
		
		for(int i=0; i<data; i++){
			String str = sc.next();
			for(int j=0; j<str.length(); j++){
				int count = -1;
				int index = str.charAt(j) - '1';
				while(str.charAt(j)!='0'){
					count++;
					j++;
				}
				if(count>=0){
					System.out.print(button[index].charAt(count%button[index].length()));
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 29612
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int N,W;
int dp[110][10010];
vector<int> v(1100);
vector<int> w(1100);
int rec(int i, int j)
{
	if(dp[i][j] >= 0)
		return dp[i][j];
	int res;
	if (i == N)
		res = 0;
	else if (j < w[i])
		res = rec(i + 1, j);
	else
		res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]);
	return dp[i][j] = res;
}
int main()
{
	memset(dp, -1, sizeof(dp));
	cin >> N >> W;
	rep(i, N)
	{
		cin >> v[i] >> w[i];
	}
	cout << rec(0, W) << endl;
	return 0;
}
	


Measured memory_bytes: 7404
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
using namespace std;
int main(){
	int n,s,mn,mx,cnt;
	while(cin>>n){
			if(n==0){
				break;
			}
			cnt=0;
			cin>>s;
			mn=s;
			mx=s;
			cnt+=s;
		for(int i=1;i<n;i++){
			cin>>s;
			mn=min(mn,s);
			mx=max(mx,s);
			cnt+=s;
		}
		cout<<(cnt-mn-mx)/(n-2)<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    string S;
    cin >> S;
    int N = S.length();

    char last = S[0];
    int K = N;
    for(int i = 1; i < N; i++){
        char c = S[i];
        if(last != c){
            int front = i;
            int back = N-i;
            K = min(K, max(front, back));
        }
        last = c;
    }

    cout << K << endl;
    return 0;
}


Measured memory_bytes: 512
#coding:utf-8
#1_7_D 2015.4.7
n,m,l = map(int,input().split())
matrixA = [list(map(int,input().split())) for i in range(n)]
matrixB = [list(map(int,input().split())) for i in range(m)]

matrixAxB = [list(sum([matrixA[i][k] * matrixB[k][j] for k in range(m)]) for j in range(l)) for i in range(n)]

for row in matrixAxB:
    print(*row)

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

 int main() {
     ll N, M;
     cin >> N >> M;

     cout << min(M / 2, N + (M - 2 * N) / 4) << endl; 
 }


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int k, x;

	cin >> k >> x;

	int min = x - k + 1;
	int max = x + k - 1;

	if (min < -1000000) {
		min = -1000000;
	}
	if (max > 1000000) {
		max = 1000000;
	}

	for (int i = min; i <= max; i++) {
		cout << i << " ";
	}

}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;

    for (int i = a; i <= b; i++) {
        if (i % n == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}


Measured memory_bytes: 3652
log = console.log;
var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var lines = stdin.split("\n");
var N = lines[0].split(" ").map(Number)[0];
var Points = lines
  .slice(1)
  .filter(v => v !== "")
  .map(v => v.split(" ").map(Number));

var diffList = [];

Points.forEach((pointA, i) => {
  var Ax = pointA[0];
  var Ay = pointA[1];
  diffList[i] = [];
  Points.forEach(pointB => {
    var Bx = pointB[0];
    var By = pointB[1];
    if (Bx === Ax && By === Ay) return;
    diffList[i].push([Bx - Ax, By - Ay]);
  });
});

var dList = [];
var countList = {};
diffList.forEach(diff => {
  diff.forEach(d => {
    countList[d.toString()] = countList[d.toString()]
      ? countList[d.toString()] + 1
      : 1;
  });
});

var max = 0
Object.keys(countList).forEach(key=>{
  if(countList[key] > max) max = countList[key]
})
log(N - max)

Measured memory_bytes: 10060
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, W = iim()
    S = [iim() for i in range(N)]

    N1 = N + 1
    dp = [-1] * (W+1)
    dp[0] = 0

    for v, w in S:
        for i in range(W-w, -1, -1):
            if dp[i] == -1: continue
            j = i + w
            dp[j] = max(dp[j], dp[i] + v)

    print(max(*dp))

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 6080
#include <iostream>

using namespace std;

void call(int n) {
	for (int i = 1; i <= n; ++i) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
		}
		else {
			while (x!=0) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
}

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

	//system("pause");
	return 0;
}

Measured memory_bytes: 1160
import sys
def 解():
    input = sys.stdin.readline
    H,W,N = [int(_) for _ in input().split()]
    dT={}
    高橋 = H
    if N :
        for  _ in range(N):
            x,y = [int(_) - 1 for _ in input().split()]
            #系列毎に近いブロックを選ぶ
            #x=yの系列は隣接系列を見るために残す
            if x >= y:
                系列 = x-y
                距離 = x+y
                if 系列 in dT:
                    if 距離 < dT[系列][2] :
                        dT[系列] = (x,y,距離)
                else:
                    dT[系列] = (x,y,距離)
        aB = sorted(dT.items())
        iL = len(aB)
        if iL == 1:
            #x=yの系列でなければそこ
            if 0 < aB[0][0] :
                高橋 = aB[0][1][0]
        elif 1 < iL :
            aG= [aB[0][1]] #候補の配列
            #上に隣接系列がある系列を除く
            #隣接系列があっても上に来た系列の距離が大きいときは到達可能
            for i in range(1,iL):
                if aB[i][0]-1 == aB[i-1][0]:
                    if aB[i][1][2] < aB[i-1][1][2] :
                        aG.append(aB[i][1])
                else:
                    aG.append(aB[i][1])
            #最後にx=yの系列を除く
            if len(aG) and aG[0][0] - aG[0][1] == 0 :
                del aG[0]
            #xでソート
            if len(aG):
                #高橋,青木,距離 = sorted(aG,key=lambda x:x[0])[0]
                高橋 = sorted(aG)[0][0]
    print(高橋)
解()


Measured memory_bytes: 36176
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int n, c;
  int i;

  scanf ( "%d", &n );
  for ( c = 1; c <= n; ++c )
  {
    int d;

    scanf ( "%d", &d );

    printf ( "Case %d:\n", c );
    for ( i = 0; i < 10; ++i )
    {
      d = ( d * d / 100 ) % 10000;

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

  return ( 0 );
}

Measured memory_bytes: 0
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;

// 文字列 string s or char s[i];
int main(){
  int a=700;
  string s;
  cin>>s;
  for(int i=0;i<=2;i++){
    if(s[i]=='o')a+=100;
  }
  cout<<a;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        vector<int> x(N), y(N), h(N);
        rep(i, 0, N) {
            cin >> x[i] >> y[i] >> h[i];
        }


        for (int X = 0; X <= 100; ++X) {
            for (int Y = 0; Y <= 100; ++Y) {
                //(X,Y)が候補
                int H = -1;

                for (int i = 0; i < N; ++i) {
                    if (h[i] <= 0) continue;
                    int dist = abs(X - x[i]) + abs(Y - y[i]);
                    int kouhoH = dist + h[i];
                    if (H == -1) {
                        H = kouhoH;
                    } else if (H != kouhoH) {
                        H = -1;
                        break;
                    }
                }

                if (H != -1) {
                    for (int i = 0; i < N; ++i) {
                        int kouhoH = max(H - abs(X - x[i]) - abs(Y - y[i]), 0);
                        if (kouhoH != h[i]) {
                            H = -1;
                            break;
                        }
                    }

                    if (H != -1) {
                        cout << X << " " << Y << " " << H << endl;
                        return;
                    }
                }
            }
        }

    }
};


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

    Solve().solve();


    return 0;
}


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

        while( true ) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			
			if ( n == 0 && x == 0 ) {
				break;
			}
			
			int count = 0;
			
			for( int i = 1; i <= n; i++ ) {
				for( int j = 1; j <= n; j++ ) {
					if ( j == i ) break;
					
					for( int k = 1; k <= n; k++ ) {
						if ( k == i || k == j ) break;
						
						
						if ( ( i + j + k ) == x ) {
							count++;
							
						}
						
					}
				}
			}
			
			System.out.println(count);
			
		}
		
    }
	
}

Measured memory_bytes: 19608
// SeeAlso: https://atcoder.jp/contests/abc125/tasks/abc125_c

#include <bits/stdc++.h>

typedef long long ll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()


using namespace std;

int N;
int A[MAX];

int temp;
int removenum = MAX + 1;
int ans = 1;

int gcd(int a, int b) {
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

int main() {

    cin >> N;

    REP(i, N) {
        cin >> A[i];
    }

    int R[MAX+1], L[MAX+1];

    L[0] = 0;
    R[N+1] = 0;

    REP(i, N) {
        L[i+1] = gcd(L[i], A[i]);
        R[N-i-1] = gcd(R[N-i], A[N-i-1]);
    }

    REP(i, N) {
        ans = max(ans, gcd(R[i+1], L[i]));    
    }

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


Measured memory_bytes: 1408
#!/usr/bin/env python3
# -*- coding: utf-8-*-
if __name__ == '__main__':
    s = input()
    b = 0
    m = 0
    for i in range(len(s)):
        if not (s[i] in "AGTC"):
            if m < i-b:
                m = i-b
            b = i+1
    if m < len(s)-b:
        m = len(s)-b
    print(m)


Measured memory_bytes: 3060
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/

#include<bits/stdc++.h>
#define pll              pair<long,long>
#define pii              pair<int,int>
#define scn(a)           scanf("%d", &a)
#define scn2(a, b)       scanf("%d%d", &a, &b)
#define scn3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pairl            pair<ll , ll >
#define scnl(a)          scanf("%lld", &a)
#define scnl2(a, b)      scanf("%lld%lld", &a, &b)
#define scnl3(a, b, c)   scanf("%lld%lld%lld", &a, &b, &c)
#define scns(s)          scanf("%s",s)
#define prts(s)          printf("%s\n",s)
#define prt(a)           printf("%d\n", a)
#define prtl(a)          printf("%lld\n", a)
#define prs(a)           printf("%d ", a)
#define prt2(a, b)       printf("%d %d\n", a, b)
#define prt3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define prsl(a)          printf("%lld ", a)
#define prtl2(a, b)      printf("%lld %lld\n", a, b)
#define prtl3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define ptcs(a)          printf("Case %d: ", a)
#define pf               printf
#define sc               scanf
#define vi               vector<int >
#define vil              vector<ll >
#define pb               push_back
#define mem(a, b)        memset((a), (b), sizeof(a))
#define lg2(n)           (31-__builtin_clz(n))
#define inf              9999999
#define ll               long long
#define ull              unsigned long long
#define MIN              INT_MIN
#define MAX              INT_MAX
#define fast             ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int, int> , null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;
ll gcd(ll a, ll b){if(b==0) {return a;}return gcd(b, a % b);}
ll BigMod(ll B,ll P,ll M){     ll R=1; while(P>0)      {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
//___________________________________________________________________________________________________________________
const int N = 2e5 + 9;
const int mod = 1e9 + 7;
ll t,x,n,m,y,z,x1,x2,x3,k;
int main()
{
    fast;
    cin>>n;
    cout<<(n+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())
B = {}
for a in A:
    B[a] = B.get(a, 0) + 1
if len(B) == 2:
    p, q = sorted(B)
    if p+1 == q:
        if B[q] != 1 and B[p] + 1 <= q <= B[p] + B[q] // 2:
            print('Yes')
            exit(0)
elif len(B) == 1:
    p, = B
    if p <= N // 2 or p == N-1:
        print('Yes')
        exit(0)
print('No')


Measured memory_bytes: 17400
#include <stdio.h>

int main(){

    int a,count=0,i=2;

    scanf("%d",&a);

    while(1)

    {
        while(a>i){

            if(a%i==0 && a!=2){

                count++;


            }

        i++;

        }
            if(count==0)
            {
                break;

            }

    a++;
    i=2;
    count=0;

    }
        if(count==0){

        printf("%d\n",a);


    }



return 0;

}


Measured memory_bytes: 1700
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

class SCC:

    def __init__(self, n):
        self.n = n
        self.graph = [[] for i in range(n)]
        self.graph_rev = [[] for i in range(n)]
        self.used = [False]*n

    def add_edge(self, fr, to):
        if fr == to:
            return
        self.graph[fr].append(to)
        self.graph_rev[to].append(fr)

    def dfs(self, node, graph):
        self.used[node] = True
        for nex in graph[node]:
            if self.used[nex]:
                continue
            self.dfs(nex,graph)
        self.order.append(node)

    def first_dfs(self):
        self.used = [False]*self.n
        self.order = []
        for i in range(self.n):
            if self.used[i]:
                continue
            self.dfs(i,self.graph)
    
    def second_dfs(self):
        self.used = [False]*self.n
        self.ans = []
        for node in reversed(self.order):
            if self.used[node]:
                continue
            self.used[node] = True
            self.order = []
            self.dfs(node, self.graph_rev)
            self.order.reverse()
            self.ans.append(self.order)

    def scc(self):
        self.first_dfs()
        self.second_dfs()
        return self.ans
        
def main():
    n,m = map(int,input().split())
    scc = SCC(n)
    for _ in range(m):
        a,b = map(int,input().split())
        scc.add_edge(a,b)

    ans = scc.scc()

    print(len(ans))
    for i in ans:
        print(len(i),*i)

if __name__ == "__main__":
    main()

Measured memory_bytes: 200156
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
 
    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll k;
    ll w,x;
    cin>>str;
    rep(i,str.length()/2){
        if(str[i]!=str[str.length()-1-i]) f=1;
    }
    rep(i,str.length()/4){
        if(str[i]!=str[str.length()-1-i]) f=1;
    }
    rep(i,str.length()/4){
        if(str[i+str.length()/2+1]!=str[str.length()-1-i]) f=1;
    }
    if(f) No;
    else Yes;

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <utility>
#include <stdint.h>
#include <string>
#include <vector>

using namespace std;

int main()
{
  unsigned N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  unsigned happiness = 0;
  
  for (int n=0; n<N; ++n) {
    if ((n>0 && S[n]=='L' && S[n-1]=='L') ||
	(n<N-1 && S[n]=='R' && S[n+1]=='R'))
      ++happiness;
  }

  cout << min(N-1, happiness+2*K) << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdio>
using namespace std;
int A[30];
string s;
vector<int> v[100001];
bool f=true;
int main(){
  cin >> s;
  for(int i=0;i<s.length();i++){
    if(A[s[i]-'a']>0) f=false;
    A[s[i]-'a']++;
  }
  if(f==true)cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	int dp[n + 1][m + 1];
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (i == 0 || j == 0) {
				dp[i][j] = 0;
			} else if (s[i - 1] == t[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			} else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	int i = n, j = m;
	vector<char> ans;
	while (i > 0 && j > 0) {
		if (s[i - 1] == t[j - 1]) {
			ans.push_back(s[i - 1]);
			i--;
			j--;
		} else if (dp[i - 1][j] < dp[i][j - 1]) {
			j--;
		} else {
			i--;
		}
	}
	reverse(ans.begin(), ans.end());
	for (char ch : ans) {
		cout << ch;
	}
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
 
 
int main() {
  long long N,count=0,r=0,b=0,g=0;
  cin>>N;
  vector<char> S(N);
  rep(i,N){cin>>S[i];}
  for(int i=1;i<=N-2;i++){
    for(int n=1;2*n<=N-i&&n<=N-i-1;n++){
      
        int j=n+i,k=2*n+i;
          if((j-i)==(k-j)){
            if(!(S[i-1]==S[j-1])&&!(S[i-1]==S[k-1])&&!(S[j-1]==S[k-1])){
            count++;
            }
          
      }
    }
  }
  rep(i,N){if(S[i]=='R'){r++;} else if(S[i]=='B'){b++;} else {g++;}}
 
  cout<<r*b*g-count<<endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    vector<int> B(M);
    vector<int> C(M);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < M; ++i) cin >> B[i] >> C[i];

    priority_queue<P> q;
    for (int i = 0; i < N; ++i) {
        q.push(P(A[i], 1));        
    }
    for (int i = 0; i < M; ++i) {
        q.push(P(C[i], B[i]));
    }
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        P p = q.top();
        q.pop();
        ans += p.first;
        if (p.second > 1) {
            p.second--;
            q.push(p);
        } 
    }
    cout << ans << endl;
}


Measured memory_bytes: 3572
package main

import (
	"fmt"
	"math"
)

var (
	a int
)


func main() {
	fmt.Scanf("%d\n",&a)

	count := 0
	for i:=3;i<=a;i+=2{
		if prime(i)==3 {
			count++
		}
	}
	fmt.Println(count)
}

func prime(a int) int {
	count:=0
	n := int(math.Sqrt(float64(a)))
	for i:=3;i<=n;i++{
		if a%i==0{
			count++
		}
	}
	return count
}

/* base -2 number
var (
	a rune
)


func main() {
	fmt.Scanf("%d\n",&a)
	n := 1
	var s string
	if a%2!=0 {
		s = "1"
		a = a-1
	} else {
		s = "0"
	}
	if a==0 {
		s ="0"
	} else {
		for a!=0 {
			if (a/rune(math.Pow(2,float64(n))))%2!=0 {
				s = fmt.Sprintf("1%s",s)
				a = a-rune(math.Pow(-2,float64(n)))

			} else {
				s = fmt.Sprintf("0%s",s)
			}
			n++
		}
	}
	fmt.Println(s)
}
*/



Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int N, H[100000];
int dp[100000];

int min(int x, int y) {
    return x < y ? x : y;
}

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", H + i);
    }
    dp[0] = 0;
    dp[1] = abs(H[1] - H[0]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i - 1] + abs(H[i - 1] - H[i]), dp[i - 2] + abs(H[i - 2] - H[i]));
    }
    printf("%d\n", dp[N - 1]);
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
int h,w;
int a,b;
int main()
{
   cin>>a>>b>>h>>w;
    int ans=0;
    ans=a*b-h*b-w*a+h*w;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N, A;
  get(N, A);
  vector<int> x(N);
  getv(x);
  int just = 0;
  vector<int> less, more;
  FOR(i, N) {
    if (x[i] == A) {
      just++;
    } else if (x[i] < A) {
      less.push_back(A - x[i]);
    } else {
      more.push_back(x[i] - A);
    }
  }
  vector<int> dpl(2500), dpm(2500);
  dpl[0] = 1, dpm[0] = 1;
  for (int i = 0; i < less.size(); ++i) {
    int x = less[i];
    for (int j = 2499 - x; j >= 0; --j) {
      dpl[j + x] += dpl[j];
    }
  }
  for (int i = 0; i < more.size(); ++i) {
    int x = more[i];
    for (int j = 2499 - x; j >= 0; --j) {
      dpm[j + x] += dpm[j];
    }
  }
  ll ans = 0;
  for (int i = 0; i < 2500; ++i) {
    ans += dpl[i] * (ll)dpm[i];
    debug(ans);
  }
  FOR(i, just) ans *= 2;
  ans--;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
class SegTree():
    def segfunc(self, x, y):
        return x + y

    def __init__(self, ide, n, init_val):
        self.ide_ele = ide
        self.num = 2**(n-1).bit_length()
        self.seg = [self.ide_ele] * 2 * self.num
        for i in range(n):
            self.seg[i+self.num-1] = init_val[i]    
        for i in range(self.num-2,-1,-1):
            self.seg[i] = self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    def query(self, p, q):#p <= x < q
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res

def solve():
    n = int(input())
    camel = [list(map(int, input().split())) for _ in range(n)]
    camel_L = []
    camel_R = []
    for i in range(n):
        if camel[i][1] > camel[i][2]:
            camel_L.append([camel[i][0], camel[i][1], camel[i][2]])
        else:
            camel_R.append([camel[i][0], camel[i][1], camel[i][2]])
    ans = 0
    camel_L.sort(key=lambda x: (x[2]- x[1]))
    camel_R.sort(key=lambda x: (x[1]- x[2]))
    seg = SegTree(0, n, [0]*n)
    nex = [i for i in range(n)]
    for i in range(len(camel_L)):
        k, l, r = camel_L[i]
        q = seg.query(0, k)
        if q < k:
            p = nex[k-1]
            while p != nex[p]:
                pre = p
                p = nex[p]
                nex[pre] = nex[p]-1
            nex[p] = p-1
            seg.update(p, 1)
            ans += l
        else:
            ans += r
    seg = SegTree(0, n, [0]*n)
    nex = [i for i in range(n)]
    for i in range(len(camel_R)):
        k, l, r = camel_R[i]
        q = seg.query(k, n)
        if q < n-k:
            p = nex[k]
            while p != nex[p]:
                pre = p
                p = nex[p]
                nex[pre] = nex[p]+1
            nex[p] = p+1
            seg.update(p, 1)
            ans += r
        else:
            ans += l
    return ans

def main():
    t = int(input())
    ans = [None]*t
    for i in range(t):
        ans[i] = solve()
    for v in ans:
        print(v)

if __name__ == "__main__":
    main()

Measured memory_bytes: 158756
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;

int main() {FIN
	
	ll i, j, k, n, t, sm = 0;
	string s;
	cin >> s;
	n = s.size();
	
	for (i = 0; i < (1 << (n - 1)); i++) {
		t = 0;
		k = 0;
		for (j = 1; j < n; j++) {
			if ((1 << (j - 1)) & i) {
				t += stoll(s.substr(k, j - k));
				k = j;
			}
		}
		t += stoll(s.substr(k, j - k));
		sm += t;
	}
	
	cout << sm << "\n";
	
	return 0;
}


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

int main() {
	
	int n,m;
	cin>>n>>m;
	
	int a[n],i;
	for(i=0;i<n;i++)
	cin>>a[i];
	
	int ans = 0;
	double sum = 0;
	
	for(i=0;i<n;i++)
	sum += a[i];
	
	sum = sum /(4*m);
	
	for(i=0;i<n;i++){
		if(a[i]>=sum)
		ans++;
	}
	
	if(ans >= m)	
	cout<<"Yes";
	else
	cout<<"No";
	
	return 0;
}

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();
		int[] arr = new int[n];
		TreeMap<Integer, Integer> map = new TreeMap<>();
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		    map.put(arr[i], 0);
		}
		int idx = 1;
		for (int x : map.keySet()) {
		    map.put(x, idx);
		    idx++;
		}
		BinaryIndexedTree bit = new BinaryIndexedTree(idx);
		long total = 0;
		for (int i = 0; i < n; i++) {
		    total += bit.getSum(map.get(arr[i]), idx - 1);
		    bit.add(map.get(arr[i]), 1);
		}
		System.out.println(total);
	}
}

class BinaryIndexedTree {
    int size;
    int[] tree;
    
    public BinaryIndexedTree(int size) {
        this.size = size;
        tree = new int[size];
    }
    
    public void add(int idx, int value) {
        int mask = 1;
        while (idx < size) {
            if ((idx & mask) != 0) {
                tree[idx] += value;
                idx += mask;
            }
            mask <<= 1;
        }
    }
    
    public int getSum(int from, int to) {
        return getSum(to) - getSum(from - 1);
    }
    
    public int getSum(int x) {
        int mask = 1;
        int ans = 0;
        while (x > 0) {
            if ((x & mask) != 0) {
                ans += tree[x];
                x -= mask;
            }
            mask <<= 1;
        }
        return ans;
    }
}


Measured memory_bytes: 114948
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rsort(x) sort(x.rbegin(), x.rend())
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define fio(x) ios::sync_with_stdio(x), cin.tie(x), cout.tie(x);
#define znit(x) memset(x, 0, sizeof(x))
#define mnit(x) memset(x, -1, sizeof(x))
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db EPS = 1e-7;

const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 9;
ll mypow(ll x, ll y, ll p){ll ret = 1;while(y){if(y & 1) ret = (ret * x) % p;x = (x * x) % p; y /= 2;}return ret;}
ll inv(ll x, ll p){return mypow(x, p - 2, p);}
ll gcd(ll x, ll y){return y ? gcd(y, x % y) : x;}

const int MAX = 1e4 + 5;

ll N, a[MAX], b[MAX];

int main(){
	scanf("%lld",&N);
	ll x=0;
	for(int i=0;i<N;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=0;i<N;i++)
		scanf("%lld",&b[i]);
	for(int i=0;i<N;i++)
	{
		if(a[i]==b[i])continue;
		if(a[i]>b[i])
			x=x+a[i]-b[i];
		else if(a[i]<b[i])
			x=x-((b[i]-a[i])/2);
	}
	if(x<=0)puts("Yes");
	else puts("No");
}

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

int main()
{
    int N, K;
    vector<int> R(3);
    string T;

    cin >> N >> K;
    rep(i, 3) cin >> R.at(i);
    cin >> T;

    string S = "spr";
    ll ans = 0;

    vector<bool> reached(N, false);
    rep(i, N)
    {
        if (reached.at(i))
        {
            continue;
        }

        int cnt = 0;
        for (int j = i; j < N; j += K)
        {
            if (T.at(i) == T.at(j))
            {
                reached.at(j) = true;
                cnt++;
            }
            else
            {
                break;
            }
        }

        rep(j, 3)
        {
            if (T.at(i) == S.at(j))
            {
                ans += (cnt + 1) / 2 * R.at(j);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,ans;
	cin >> a >> b >> c;
	if(a == b)
		ans = c;
	else if(a == c)
		ans = b;
	else
		ans = a;
	cout << ans << endl;
	
	return 0;
}


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

const int inf = 1LL<<60;

void dfs(int node, vector<int>& a, const vector<vector<int>>& g) {
    for (int to : g[node]) {
        if (a[to] != inf) continue;
        a[to] = a[node] + 1;
        dfs(to, a, g);
    }
}
signed main() {
    int N;
    cin >> N;

    vector<vector<int>> g(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> a(N, inf), b(N, inf);
    a[0] = 0, b[N - 1] = 0;
    dfs(0, a, g);
    dfs(N - 1, b, g);

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        cnt += (a[i] <= b[i]);
    }
    cout << (cnt > N - cnt ? "Fennec" : "Snuke") << endl;

    return 0;
}


Measured memory_bytes: 13568
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int a = std.nextInt();
        int b = std.nextInt();
        int[] p = new int[n];

        for (int i = 0; i < n; i++) {
            p[i] = std.nextInt();
        }

        Map<Integer, Integer> map = new HashMap<>();

        map.put(b+1, 0);
        map.put(b, 0);
        map.put(a, 0);

        for (int i = 0; i < n; i++) {
            int point = p[i];
            if (point >= b + 1) {
                map.put(b+1, map.getOrDefault(b+1, 0) + 1);
            } else if (point > a) {
                map.put(b, map.getOrDefault(b, 0) + 1);
            } else {
                map.put(a, map.getOrDefault(a, 0) + 1);
            }
        }

        Iterator<Map.Entry<Integer, Integer>> it = map.entrySet().iterator();
        long min = Long.MAX_VALUE;
        while (it.hasNext()) {
            Map.Entry<Integer, Integer> e = it.next();
            min = Math.min(e.getValue(), min);
        }

        System.out.println(min);
    }
}


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

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;
 
using namespace std;
 
const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;
const double PI = acos(-1.0);
 
void go(ll &a, ll b) {
	a = b;
}
 
int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif
 
	int n;
	while (cin >> n) {
		vector<int> a(n);
		for (int i = 0; i < n; i++) cin >> a[i];
 
		vector<vector<ll> > dp(n + 1, vector<ll>(2, -1));
		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 2; j++) {
				if (dp[i][j] == -1) continue;
				if (j == 0) {
					go(dp[i + 1][a[i] % 2], dp[i][j] + a[i] / 2);
				}
				else {
					if (a[i] == 0) go(dp[i + 1][0], dp[i][j]);
					else {
						int cc = a[i] + 1;
						go(dp[i + 1][cc % 2], dp[i][j] + cc / 2);
					}
				}
				//int cc = a[i] + j;
				//dp[i + 1][cc % 2] = max(dp[i + 1][cc % 2], dp[i][j] + cc / 2);
			}
		}
		cout << max(dp[n][0], dp[n][1]) << endl;
	}
 
	return 0;
}


Measured memory_bytes: 6144
#include<stdio.h>
int main(){
  int n,ans = 0;
  scanf("%d",&n);
  int a[n];
  for(int i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  for(int i = 0;i < n - 1;i++){
    for(int j = 0;j < n - 1;j++){
      if(a[j] < a[j + 1]){
        int t = a[j + 1];
        a[j + 1] = a[j];
        a[j] = t;
      }
    }
  }
  for(int i = 0;i < n;i += 2){
    ans += a[i];
  }
  for(int i = 1;i < n;i += 2){
    ans -= a[i];
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
/*
BY: SAFWAAN SHAIKH
PROBLEM:https://atcoder.jp/contests/abc175/tasks/abc175_e
KEY IDEAS: dp
TIME COMPLEXITY: 
*/

#define r(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#define f first
#define endl "\n"
#define s second
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a))
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
char _;


ll dp[3002][3002][4];
int val[3002][3002];
int r,c,k;
int main(){
//	freopen("problemname.in", "r", stdin);
//  freopen("problemname.out", "w", stdout);
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	cin>>r>>c>>k;
	ms(dp,0);ms(val,0);
	for(int i=0;i<k;i++){
		int a,b,c;
		cin>>a>>b>>c;
		val[a][b] = c;
	}
	for(int i=1;i<=r;i++){
		for(int j=1;j<=c;j++){
			ll prevRow = max({dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]});
			dp[i][j][0] = max({prevRow,dp[i][j-1][0]});
			dp[i][j][1] = max({prevRow+val[i][j],dp[i][j-1][1],dp[i][j-1][0]+val[i][j]});
			dp[i][j][2] = max({dp[i][j-1][2],dp[i][j-1][1]+val[i][j],dp[i][j][0],dp[i][j][1]});
			dp[i][j][3] = max({dp[i][j-1][3],dp[i][j-1][2]+val[i][j],dp[i][j][1],dp[i][j][2]});
		}
	}
	cout << max({dp[r][c][0],dp[r][c][1],dp[r][c][2],dp[r][c][3]}) << endl;
	return 0;
}



Measured memory_bytes: 320476
n=int(input())
a=n
b=a//10
a=a//10
while a>=5:
  b=b+a//5
  a=a//5
a=n
c=0
while a>=5:
  c=c+a//5
  a=a//5
if n%2==0:
  print(b)
else:
  print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>


using namespace std;

int main(){
 int n;
  cin >> n;
 int a[2][n];
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
   cin >> a[i][j]; 
    }
  }
  
  int res=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<=i;j++){
    sum+=a[0][j];
   }
     for(int j=i;j<n;j++){
    sum+=a[1][j];
   }
    res=max(res,sum);
  }
  
 cout << res << endl;

}

Measured memory_bytes: 256