akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int a[200005], b[200005];

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

    int n;
    cin >> n;
    for (int i=0; i<n; i++)
        cin >> a[i];
    for (int i=0; i<n; i++)
        cin >> b[i];
    reverse(b, b + n);

    int l = INT_MAX, r = INT_MIN;
    for (int i=0; i<n; i++)
        if (a[i] == b[i]) {
            l = min(l, i);
            r = max(r, i);
        }
    if (l == INT_MAX) {
        cout << "Yes\n";
        for (int i=0; i<n; i++)
            cout << b[i] << " \n"[i==n-1];
        return 0;
    }

    vector<int> v;
    for (int i=0; i<n; i++)
        if ((i < l || i > r) && a[i] != a[l] && b[i] != a[l])
            v.push_back(i);
    if ((int) v.size() < r - l + 1) {
        cout << "No\n";
        return 0;
    }

    for (int i=l; i<=r; i++) {
        swap(b[i], b[v.back()]);
        v.pop_back();
    }
    cout << "Yes\n";
    for (int i=0; i<n; i++)
        cout << b[i] << " \n"[i==n-1];

    return 0;
}


Measured memory_bytes: 5824
#include<iostream>
#include<algorithm>
using namespace std;
int te[114514];
pair<int,int> ii[114514];
pair<int,int> pp[114514];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  for(int n=1;n<=9;n++){
    for(int m=1;m<=9;m++){
      cout <<n<<'x'<<m<<"="<<n*m<<'\n';
    }
  }
  return (0);
}



Measured memory_bytes: 4912
#include <stdio.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
	int H,W,M;
  	cin >> H >> W >> M;
  	vector<pair<int, int>> hb(H);
  	vector<pair<int, int>> wb(W);
  	vector<vector<int>> bomb(H);
  	
  	for(int i=0; i<M; i++){
    	int h,w;
      	cin >> h >> w;
      	pair<int, int> ph = hb[h-1];
      	pair<int, int> pw = wb[w-1];
      	hb[h-1] = pair<int, int>(ph.first+1, h-1);
      	wb[w-1] = pair<int, int>(pw.first+1, w-1);
      	bomb[h-1].push_back(w-1);
    }
    sort(hb.begin(), hb.end());
  	reverse(hb.begin(), hb.end());
    sort(wb.begin(), wb.end());
  	reverse(wb.begin(), wb.end());
  
    int max_hb = 0;
  	vector<pair<int, int>> h_bomb;
	for(auto bom: hb){
    	int index = bom.second;
      	int num = bom.first;
        if(num < max_hb) break;
        max_hb = num;
        pair<int, int> p(index, num);
        h_bomb.push_back(p);
    }
    int max_wb = 0;
  	vector<pair<int, int>> w_bomb;
	for(auto bom: wb){
    	int index = bom.second;
      	int num = bom.first;
        if(num < max_wb) break;
        max_wb = num;
        pair<int, int> p(index, num);
        w_bomb.push_back(p);
    }
  	int max_bomb = max_hb+max_wb;
    bool found = false;
    for(auto hbom: h_bomb){
    	for(auto wbom: w_bomb){
        	int h_index = hbom.first;
        	int w_index = wbom.first;
          	auto result = std::find(bomb[h_index].begin(), bomb[h_index].end(), w_index);
            if(result == bomb[h_index].end()){
              found = true;
              break;
            }
          
        }
        if(found) break;
    }
    if(found)
    	cout << max_bomb << endl;
    else
    	cout << max_bomb-1 << endl;
}

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

int main(){
  int X, Y, Z;
  int ans = 0;
  cin >> X >> Y >> Z;

  while(Y + Z < X){
    ans++;
    X -= Y + Z;
  }

  if(X < Z) ans--;

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


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

struct edge{
	int to;
	int cost;
	ll dist;
};


int N,M,S;
ll C[50],D[50],T[50][3001];
vector<edge>E[50];

int main(){
	cin>>N>>M>>S;
	while(M--){
		int u,v,a,b;
		cin>>u>>v>>a>>b;
		u--;
		v--;
		E[u].push_back({v,a,b});
		E[v].push_back({u,a,b});
	}
	for(int i=0;i<N;i++){
		cin>>C[i]>>D[i];
	}
	for(int i=0;i<50;i++){
		for(int j=0;j<=3000;j++){
			T[i][j]=-1;
		}
	}
	priority_queue<pair<ll,pair<int,int>>,vector<pair<ll,pair<int,int>>>,greater<pair<ll,pair<int,int>>>>pq;
	pq.push({0,{0,S}});
	while(!pq.empty()){
		ll t=pq.top().first;
		int x=pq.top().second.first;
		int m=min(3000,pq.top().second.second);
		pq.pop();
		if(T[x][m]==-1){
			T[x][m]=t;
			pq.push({t+D[x],{x,m+C[x]}});
			for(edge e:E[x]){
				if(e.cost<=m){
					pq.push({t+e.dist,{e.to,m-e.cost}});
				}
			}
		}
	}
	for(int i=1;i<N;i++){
		ll res=0xE869120E869120;
		for(int j=0;j<=3000;j++){
			if(T[i][j]!=-1){
				res=min(res,T[i][j]);
			}
		}
		cout<<res<<endl;
	}
}


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

using namespace std;

const double EPS = 1e-7;
const int N = 4e5+5, M = 1e5+5, OO = 0x3f3f3f3f;
typedef long long ll;

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


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



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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	cout << fixed << setprecision(18);

	string s, t;

	cin >> s >> t;

	rep(i, s.size()) {
		if (s[i] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3588
n,m=map(int,input().split())
x=[0]*n
y=[0]*n
for i in range(m):
  P,s=input().split()
  p=int(P) 
  if x[p-1]==0:
    if s=="WA":
      y[p-1]+=1
    if s=="AC":
      x[p-1]+=1

sx=0
sy=0
for i in range(n):
  sx+=x[i]
  if x[i]==1:
    sy+=y[i]
  
print(str(sx),str(sy))

Measured memory_bytes: 45528
#! /usr/lib/python3

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

while True:
    try:
        a, b=map(int, input().split())
        s=gcd(a,b)
        print("{0} {1:.0f}".format(s,a*b/s))
    except:
        break

Measured memory_bytes: 6732
n, m = map(int, input().split())
list_1 = []
for i in range(m):
  s, c = input().split()
  list_1.append([int(s), int(c)])

if m == 0:
  if n == 1:
    print(0)
    exit(0)
  elif n == 2:
    print(10)
    exit(0)
  else:
    print(100)
    exit(0)
  
# -1の条件
for k in range(m):
  if n == 1 and list_1[k][0] == 1 and list_1[k][1] == 0:
    print(0)
    exit(0)
  elif list_1[k][0] == 1 and list_1[k][1] == 0:
    print(-1)
    exit(0)
    
def check(x):
  if x >= m:
    return
  for j in range(m-x):
    if list_1[j][0] == list_1[j+1][0]:
      if list_1[j][1] != list_1[j+1][1]:
        print(-1)
        exit(0)
  check(x+1)

check(1)
  
# 数作成
if n == 1:
  for _ in range(m):
    print(list_1[_][1])
elif n == 2:
  num = list('10')
  for _ in range(m):
    num[list_1[_][0]-1] = str(list_1[_][1])
  print("".join(num))
else:
  num = list('100')
  for _ in range(m):
    num[list_1[_][0]-1] = str(list_1[_][1])
  print("".join(num))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q) 
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


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

    int H,W,cnt = 0;
    cin>>H>>W;
    vector<vector<char>> board(H,vector<char>(W));
    FOR(i,0,H){
        FOR(j,0,W){
            cin>>board[i][j];
            if(board[i][j] == '.') ++cnt;
        }
    }

    vector<vector<int>> step(H,vector<int>(W,-1));
    queue<pair<int,int>> Q;
    Q.push(MP(0,0));
    step[0][0] = 0;

    while(!Q.empty()){
        pair<int,int> P  = Q.front(); Q.pop();
        FOR(i,0,4){
            int x = P.second + dx[i];
            int y = P.first + dy[i];
            if(x>=0 && x<W && y>=0 && y<H && board[y][x] == '.' && step[y][x] == -1){
                step[y][x] = step[P.first][P.second] +1;
                Q.push(MP(y,x));
            }
        }
    }

    int ans;
    if(step[H-1][W-1] == -1) ans = -1;
    else ans = cnt - step[H-1][W-1] - 1;

    put(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,W;
  cin >> N >> W;
  vp vw(N);
  rep(i,N) {
    int we,va;
    cin >> we >> va;
    vw[i] = P(we,va);
  }
  v(ll) dp(10e5,LINF);
  dp[0] = 0;
  rep(i,N) {
    ll we = vw[i].first;
    ll va = vw[i].second;
    v(ll) dp2(10e5,LINF);
    dp2[0] = 0;
    rep(v,10e5) {
      if(v - va < 0) {
        dp2[v] = dp[v];
        continue;
      }
      dp2[v] = min(dp[v],dp[v-va]+we);
    }
    dp = dp2;
  }
  ll ans = -LINF;
  rep(i,10e5) {
    if(dp[i] <= W) {
      ans = max(ans,(ll)i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15872
def main():
    n = input().split()

    a = int(n[0])
    b = int(n[1])
    c = int(n[2])

    if (a > b):
        temp = a
        a = b
        b = temp

    if (b > c):
        temp = b
        b = c
        c = temp

    if (a > b):
        temp = a
        a = b
        b = temp

    print("{0} {1} {2}".format(a,b,c))
if __name__ == '__main__':
    main()

Measured memory_bytes: 5600
import java.util.*;

public class Main {
    private static final long INF = 1L << 60;
    private static final int MAX_N = 110;
    private static final int MAX_V = 100100;
    private static long[][] dp = new long[MAX_N][MAX_V];
    public static void main(String[] args) throws Exception {
        for(int i=0;i<MAX_N;i++){
            Arrays.fill(dp[i],INF);
        }
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        long[] weight = new long[MAX_N];
        int[] value = new int[MAX_N];
        for(int i=0;i<N;i++){
            weight[i] = Long.parseLong(sc.next());
            value[i] = Integer.parseInt(sc.next());
        }
        dp[0][0] = 0;
        for(int i=0;i<N;i++){
            for(int sumV=0;sumV<MAX_V;sumV++){
                if(sumV -value[i] >= 0){
                    dp[i+1][sumV] = Math.min(dp[i+1][sumV],dp[i][sumV-value[i]] + weight[i]);
                }
                dp[i+1][sumV] = Math.min(dp[i+1][sumV],dp[i][sumV]);
            }
        }
        long res = 0;
        for(int sumV=0;sumV<MAX_V;sumV++){
            if(dp[N][sumV] <= W)res = sumV;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 126932
N, x = map(int, input().split())

a = list(map(int, input().split()))

a.sort()

current = x
result = 0

for i in range(N):
    if  current >= a[i]:
        current -= a[i]
        result += 1

if result == N and current > 0:
    result -= 1

print(result)

Measured memory_bytes: 3060
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, k ] <- readInts
	s <- getLine
	putStrLn $ map ( \( c, i ) -> if i == k then toLower c else c ) $ zip s [ 1 .. ]

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int ans = 0;
  for (int i = 0; i <= N; i++) {
    int t = i;
    int tmp = 0;
    for (int j = 0; j < 5; j++) {
      tmp += t%10;
      t /= 10;
    }
    if (tmp>=A && tmp<=B) ans += i;
  }
  
  cout << ans << endl;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N=3;
  vector<int> v(N); rep(i, 0, N){ cin >> v[i]; }
  sort(all(v));
  reverse(all(v));
  cout<<10*v[0]+v[1]+v[2]<<endl;


    return 0;
}


Measured memory_bytes: 256
#B - Trick or Treat
N,K = map(int, input().split())
D =[]
A =[]
for _ in range(K):
    d = int(input())
    a =list(map(int, input().split()))

    D.append(d)
    A.append(a)
# print(D,A)

for i in range(1,K):
    A[0].extend(A[i])
# print(A[0])

print(N-len(set(A[0])))

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

using namespace std;

using i64 = int64_t;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    string s;cin >> s;
    string zyunnkan;
    string not_junkan_syousu;
    string not_junkan_seisuu;
    bool f = false;
    bool f2 = false;

    for(auto a : s){
        if(a == '('){
            f2 = true;
            continue;
        }
        if(a == '.'){
            f = true;
            continue;
        }
        if(f2){
            if(a == ')'){
                continue;
            }
            zyunnkan.push_back(a);
        }else if(f){
            not_junkan_syousu.push_back(a);
        }else{
            not_junkan_seisuu.push_back(a);
        }
    }
    if(zyunnkan.size() == 0){
        i64 ans = stoi(not_junkan_seisuu);
        ans *= pow(10, not_junkan_syousu.size());
        ans += stoi(not_junkan_syousu);
        i64 bunnbo = pow(10, not_junkan_syousu.size());
        i64 gcd = __gcd(ans, bunnbo);
        cout<<ans/gcd<<"/"<<bunnbo/gcd<<endl;
    }else{
        i64 ans = stoi(not_junkan_seisuu);
        if(not_junkan_syousu.size())ans *= pow(10, not_junkan_syousu.size());
        if(not_junkan_syousu.size())ans += stoi(not_junkan_syousu);
        ans *= pow(10, zyunnkan.size());
        ans += stoi(zyunnkan);

        i64 bunnbo = pow(10, zyunnkan.size()) - 1;
        i64 bunsi  = ans * pow(10, zyunnkan.size()) + stoi(zyunnkan) - ans;
        bunnbo *= pow(10, not_junkan_syousu.size() + zyunnkan.size());
      //  cout<<bunnbo<<endl;

        i64 gcd = __gcd(bunnbo, bunsi);
        cout<<bunsi/gcd<<"/"<<bunnbo/gcd<<endl;
    }
}



Measured memory_bytes: 3356
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int w, n, t, a, b;
	char c;
	cin >> w;
	if (w <= 0) return -1;
	vector<int> state(w);
	for (int i = 1; i <= w; i++)
		state[i-1] = i;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> c >> b;
		t = state[a - 1];
		state[a - 1] = state[b - 1];
		state[b - 1] = t;
	}
	for (int i = 0; i < w; i++)
		cout << state[i] << endl;
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

const int MAX_V=1000000;
int prime[MAX_V+1];//1?´???°,0?´???°??§??????
int sum[MAX_V+1];
int main(){
    int i,k,v;
    for(i=2;i<=MAX_V;i++){
        prime[i]=1;//2??\???????´???°??¨??????
    }
    for(i=2;i*i<=MAX_V;i++){
        if(prime[i]){
            for(k=2*i;k<=MAX_V;k+=i){
                prime[k]=0;//?´???°???2?????\???????????°????´???°??§??????
            }
        }
    }
    for(i=0;i<MAX_V+1;i++){
        sum[i+1]=sum[i]+prime[i];
    }
    while(scanf("%d",&v)!=EOF){
        printf("%d\n",sum[v+1]);
    }
    return 0;
}

Measured memory_bytes: 10396
#include<stdio.h>
int main(void)
{
	int n;
	int k[10001];
	int i;
	int cnt,cnt01;
	
	scanf("%d",&n);
	while(n!=0){
		cnt=0;
		cnt01=0;
		for(i=0;i<n;i++){
			scanf("%d",&k[i]);
			if(k[i]==0){
				cnt01++;
			}
			else if(k[i]==1){
				cnt++;
				cnt01++;
			}
			else if(k[i]>=2){
				cnt++;
			}
		}
		if(cnt01==n){
			printf("NA\n");
		}
		else {
			printf("%d\n",cnt+1);
		}
		scanf("%d",&n);
	}
	return 0;
}

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

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

int main()
{
    int N;
    cin >> N;
    vector<int>t(N);
    vector<int>x(N);
    vector<int>y(N);
    rep(i,N) cin >> t[i] >> x[i] >> y[i];
   
    int T = 0;
    int X = 0;
    int Y = 0;
    rep(i,N)
    {
        if(abs(X-x[i]) + abs(Y-y[i]) == abs(T-t[i]))
        {
            T = t[i];
            X = x[i];
            Y = y[i];
        }
        else
        {
            int tmp = abs(X-x[i]) + abs(Y-y[i]) - abs(T-t[i]);
            if(tmp%2 == 0 && tmp < 0)
            {
                T = t[i];
                X = x[i];
                Y = y[i];
            }
            else
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


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

using namespace std;

void scan() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

#define ll long long
#define fir first
#define sec second
int vis[10000];

int solve(int T) {
    ll n;
    cin >> n;

    ll ans = n;

    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {

            ll zx1 = i, zx2 = n / i;
            //1 10
            // 2 5

            ans = min(zx1 + zx2 - 2, ans);

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


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

    memset(vis, 0, sizeof(vis));
    int T = 1;
//    cin >> T;
    for (int i = 1; i <= T; i++) solve(i);
    return 0;
}

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

using myPair = std::pair<long long, long long>;

int main()
{
	long long D, G;
	std::cin >> D >> G;

	std::vector<myPair> v;
	for ( int i = 0; i < D; i++ )
	{
		long long p, c;
		std::cin >> p >> c;
		v.emplace_back( std::make_pair( p, c ) );
	}


	long long totalQ = 0;	//	解いた問題数

	std::vector<long long> vD( 1000 );	//	出題される可能性のある最大問題数

	for ( int i = v.size() - 1; i >= 0; i-- )
	{
		for ( int j = 0; j < v[i].first; j++ )
		{
			long long tmpScore = ( ( i + 1 ) * ( j + 1 ) ) * 100;
			if ( j == v[i].first - 1 )	//	Piを全問解いた
			{
				tmpScore += v[i].second;	//	コンプリートボーナス
			}

			for ( int k = totalQ + j; k > j; k-- )	//	同じ問題数でも、今回の方がスコアが良くなる場合
			{
				if ( vD[k] < vD[k - (j + 1)] + tmpScore )
				{
					vD[k] = vD[k - (j + 1)] + tmpScore;
				}
			}
			if ( vD[j] < tmpScore )
			{
				vD[j] = tmpScore;
			}
		}

		totalQ += v[i].first;	//	累積問題数
	}

	for ( int i = 0; i < vD.size(); i++ )
	{
		if ( vD[i] >= G )
		{
			std::cout << i + 1 << std::endl;
			break;
		}
	}

	return ( 0 );
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(string n) {
    for (int i = 0; i < 8; i++) {
        n.pop_back();
    }
    std::cout << n << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    string n;

    gettimeofday(&start,NULL);

    std::cin >> n;
    solve(n);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	cout << fixed << setprecision(18);

	ll n;
	cin >> n;
	vector<ll> a(n), p;
	multiset<ll> m;
	map <ll, ll> mp;
	ll ans = 0;

	rep(i, n)
	{
		cin >> a[i];
		mp[a[i] + i + 1]++;
	}

	rep(i, n)
		ans += mp[i + 1 - a[i]];

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 27328
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<bool> vb;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 1000000007;
const int inf = 1000000000;
const int N = 2000007, M = N;
ll i,j,cnt,par;
vi vec[N];



void solve() {
  ll n;
  cin>>n;

  ll x, m = INT_MIN , g = 0 , p = 0;
  map<int,int>mp;

  bool f = 0;

  for(int j=0;j<n;j++) {
    cin>>x;

    for(int i=2;i*i<=x;i++) {
        if(x%i == 0) {
            mp[i]++;
            if(mp[i] > 1) f = 1;
            while(x%i == 0) x/=i;
        }
    }
    if(x > 1) mp[x]++;
    if(mp[x] > 1) f = 1;

  }

  if(!f) cout<<"pairwise coprime\n";
  else {
    for(auto p : mp) {
        if(p.ss == n) {
            cout<<"not coprime\n";
            return;
        }
    }
    cout<<"setwise coprime\n";
  }
}


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

    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }

    return 0;
}




Measured memory_bytes: 54148
#include <stdio.h>

int main(void)
{
	int a,b;
	char op;
	
	scanf("%d %c %d",&a,&op,&b);
	
	if(op=='+'){
		printf("%d\n",a+b);
	}else{
		printf("%d\n",a-b);
	}
	
	return 0;
	
}

Measured memory_bytes: 128
using System;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			// 整数の入力
			long a = long.Parse(Console.ReadLine());
			long b = long.Parse(Console.ReadLine());
			long c = long.Parse(Console.ReadLine());
			long x = long.Parse(Console.ReadLine());

			int conbination = 0;
			for (int i = 0; i <= a; ++i) {
				for (int j = 0; j <= b; ++j) {
					for (int k = 0; k <= c; ++k) {
						if (x == i * 500 + j * 100 + k * 50) {
							++conbination;
						}
					}
				}
			}

			Console.WriteLine(conbination.ToString());

			Console.Out.Flush();

			//Console.ReadLine();
		}
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

const ll MOD = 1e9 + 7;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }

ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128

ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}

void __sol(){
    int x,n; cin >> x >> n;
    int f[110]; memset(f,0,sizeof(f));
    forr(i,n){
        int k; cin >> k; f[k]++;
    }
    int ans = 0 , mn = abs(x);
    for(int i=1;i<=101;i++){
        if(f[i]==0 && abs(x-i)<mn){
            mn = abs(x-i);
            ans = i;
        }
    }
    cout << ans;
    return;
}


int main(){
    fastio
    ll tc=1;// cin >> tc;
    while(tc--) __sol();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

int main() {
    int K, S;
    cin >> K >> S;

    int cou = 0;
    rep(x, K + 1) {
        rep(y, K + 1) {
            int z = S - x - y;
            if (0 <= z&&z <= K)cou++;
        }
    }
    cout << cou << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int A,B,C;
    cin >>A>>B>>C;
    for(int i=0;i<=B;i++){
        if((i*A)%B==C){
            cout<<"YES"<<endl;return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}   



Measured memory_bytes: 256
s = input()
if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
else:
    print(1)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int ans[N];
#define wzh(x) cerr<<#x<<' '<<x<<endl
int main() {
  ios::sync_with_stdio(false);
  // (x+y)^2 +(y+z)^2 + (x+z)^2 =n
  for(int x=1;x<=100;x++){
  	for(int y=1;y<=100;y++){
  		for(int z=1;z<=100;z++){
  			ans[x*x+y*y+z*z+x*y+x*z+z*y]++;
  		}
  	}
  }
  int n;cin>>n;
  for(int i=1;i<=n;i++){
  	cout<<ans[i]<<'\n';
  }
 	return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<veci> mati;
typedef vector<vecd> matd;
#define A first
#define B second
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T> vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T> vector<T> getEmptyVector() { return vector<T>(); }
template<typename T> void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1<<7;
const int inf = 1<<28;
const int NIL = -inf;
int popcount(int x)  { return __builtin_popcount(x); }
#define DUMP(a) \
    do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) \
    do { std::cout << #a " = " << (a) << std::endl; } while(false)

int N, K;
mati G;

int construct_graph() {
    G.resize(N);
    FORI(i, N - 1) G[0].EB(i);
    int num_of_p = (N - 1) * (N - 2) / 2;
    int num_of_e = N - 1;
    if(num_of_p == K) return num_of_e;
    FORI(i, N - 1) {
        for(int j = i + 1;j < N;j++) {
            G[i].EB(j);
            num_of_e++;
            num_of_p--;
            if(num_of_p == K) return num_of_e;
        }
    }
    return num_of_e; // exception
}

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

    cin >> N >> K;

    if(K > (N - 1) * (N - 2) / 2) {
        cout << -1 << endl;
        return 0;
    }

    cout << construct_graph() << endl;
    
    FORO(i, N) {
        FORIT(it, G[i]) {
            cout << i + 1 << " " << (*it) + 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 998244353LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

ll extgcd(ll a, ll b, ll &x, ll &y) {  // extended Euclidean algorithm, used for
                                       // modular multiplicative inverse
    ll d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;  // return gcd(a,b)
}

ll mod_inv(ll a, ll m = MOD) {  // return inv(a) mod m, ax+my=gcd(a,m)=1, m is
                                // prime int, ax-1=mq equiv. ax-mq=1
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;  // From (possibly) negative x to positive x
}

vector<ll> fact, invfact;
void calc_fact(int n, ll m = MOD) {  // Calculate factorial up to n
    fact.resize(n + 1);
    invfact.resize(n + 1);
    fact[0] = invfact[0] = 1;
    REP(i, n) {
        fact[i + 1] = fact[i] * (i + 1) % m;
        invfact[i + 1] = invfact[i] * mod_inv(i + 1) % m;
    }
}
ll perm(int n, int k, ll m = MOD) {
    if (n < 0 || k < 0 || k > n) return 0;
    return fact[n] * invfact[n - k] % m;
}
ll comb(int n, int k, ll m = MOD) {
    if (n < 0 || k < 0 || k > n) return 0;
    return (fact[n] * invfact[n - k] % m) * invfact[k] % m;
}

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    if (m == 1){
        cout << (n - 1 > k ? 0 : 1) << endl;
        return 0;
    }

    vll pows;
    ll nownum = 1;
    REP(i,n+1){
        pows.push_back(nownum);
        nownum = nownum*(m - 1) % MOD;
    }
    calc_fact(n-1);
    ll ans = 0;
    REP(i,k+1){
        ll num = n - i;
        ans = (ans + (((pows[num - 1] * m) % MOD) * comb(n-1, i) % MOD)) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 7860
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
inline LL read(){
	LL x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const LL MAXN = 300010;
const LL INF = 1e16;

LL N,Q; LL a[MAXN+1]; 

struct data{
	LL mn[MAXN<<2],adm[MAXN<<2],tag[MAXN<<2];
	inline void tage_lazy(LL rt){
		if(tag[rt]){
			mn[rt<<1]+=tag[rt]; mn[rt<<1|1]+=tag[rt];
			adm[rt<<1]+=tag[rt]; adm[rt<<1|1]+=tag[rt];
			tag[rt<<1]+=tag[rt]; tag[rt<<1|1]+=tag[rt];
			tag[rt]=0;
			return ;	
		}
	}inline void update(LL rt){
		mn[rt]=min(mn[rt<<1],mn[rt<<1|1]); adm[rt]=min(adm[rt<<1],adm[rt<<1|1]); return ;
	}void build(LL rt,LL l,LL r){
		if(l==r) {mn[rt]=adm[rt]=INF; tag[rt]=0; return ;} LL mid=(l+r)>>1;
		build(rt<<1,l,mid); build(rt<<1|1,mid+1,r); mn[rt]=adm[rt]=INF; tag[rt]=0;
	} void Add(LL rt,LL l,LL r,LL k,LL x,LL n){
		if(l==r) {mn[rt]=min(mn[rt],x); adm[rt]=min(adm[rt],x+n); return ;} LL mid=(l+r)>>1;
		tage_lazy(rt); if(k<=mid) Add(rt<<1,l,mid,k,x,n); else Add(rt<<1|1,mid+1,r,k,x,n); update(rt);
	} void Addk(LL k){mn[1]+=k; adm[1]+=k; tag[1]+=k;}
	LL Query(LL rt,LL l,LL r,LL L,LL R){
		if(L>R) return INF;
		//cout<<"Query:"<<l<<" "<<r<<" "<<L<<" "<<R<<": "<<mn[rt]<<endl;
		if(L<=l&&R>=r) return mn[rt]; LL mid=(l+r)>>1,ans=INF; tage_lazy(rt);
		if(L<=mid) ans=Query(rt<<1,l,mid,L,R); if(R>mid) ans=min(ans,Query(rt<<1|1,mid+1,r,L,R));
		update(rt); return ans;
	} LL Query2(LL rt,LL l,LL r,LL L,LL R){
		if(L<=l&&R>=r) return adm[rt]; LL mid=(l+r)>>1,ans=INF; tage_lazy(rt);
		if(L<=mid) ans=Query2(rt<<1,l,mid,L,R); if(R>mid) ans=min(ans,Query2(rt<<1|1,mid+1,r,L,R));
		update(rt); return ans;
	} 
}T1,T2;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(),Q=read(); a[1]=read(),a[2]=read();
	T1.build(1,1,N); T1.Add(1,1,N,a[1],a[1],-a[1]);
	T2.build(1,1,N); T2.Add(1,1,N,a[1],-a[1],a[1]); Q+=2; 
	for(LL i=3;i<=Q;i++){
		a[i]=read();
		LL x=T1.Query(1,1,N,a[i]+1,N)-a[i],y=T2.Query(1,1,N,1,a[i])+a[i];
		T1.Addk(abs(a[i]-a[i-1])); T2.Addk(abs(a[i]-a[i-1]));
		T1.Add(1,1,N,a[i-1],min(x,y)+a[i-1],-a[i-1]); T2.Add(1,1,N,a[i-1],min(x,y)-a[i-1],a[i-1]);
		//T1.dfs(1,1,N); T2.dfs(1,1,N); cout<<endl;
	} printf("%lld\n",min(T1.Query2(1,1,N,1,N),T2.Query2(1,1,N,1,N)));
	return 0;
}


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

#define pi 2 * acos(0.0)

using namespace std;

int main()
{
    int n, m, x, sum = 0;

    cin >> n >> m;

    for(int i = 0; i < m; i++) {
        cin >> x;
        sum += x;
    }

    if(sum > n)
        cout << -1 << endl;
    else
        cout << n - sum << endl;

    return 0;
}



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

int sumOfDigit(int n)
{
    int sum = 0;
    while(n > 0)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(void)
{
    int N;

    cin >> N; 

    if(N % sumOfDigit(N) == 0)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.println(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)?"Yes":"No");
    }

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

Measured memory_bytes: 22612
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  As = list(map(int, input().strip().split()))
  Bs = list(map(int, input().strip().split()))
  ne = sum(As)
  for i in range(n):
    if As[i] >= Bs[i]:
      As[i] -= Bs[i]
    else:
      As[i+1] = max(As[i+1] - (Bs[i] - As[i]), 0)
      As[i] = 0
  print(ne - sum(As))
    
if __name__=='__main__':
  main()



Measured memory_bytes: 81892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int N, P;
    cin >> N >> P;
    vector<int> S(N);
    rep(i, N) {
        char c;
        cin >> c;
        S[i] = c - '0';
    }
    if (P == 2 || P == 5) {
        lint ans = 0;
        rep(i, N) {
            if (S[i] % P == 0) ans += (i + 1);
        }
        cout << ans << "\n";
        return 0;
    }
    reverse(S.begin(), S.end());
    vector<int> T(N);
    int d = 1;
    rep(i, N) {
        T[i] = S[i] * d % P;
        d = d * 10 % P;
    }
    map<int, int> mp;
    lint ans = 0;
    int sum = 0;
    ++mp[sum];
    rep(i, N) {
        sum = (sum + T[i]) % P;
        ans += mp[sum];
        ++mp[sum];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>

int main(void)
{
    int n,m,a,b,t[50]={0},i;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        t[a-1]++;
        t[b-1]++;
    }
    for(i=0;i<n;i++)printf("%d\n",t[i]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#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 mkp make_pair
#define mkt make_tuple
#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;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int h, w;
char c[1005][1005];
int ok[1005][1005];
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
signed main() {
	queue<P>que;
	cin >> h >> w;
	rep(i, h)rep(j, w) {
		ok[i][j] = inf;
	}
	rep(i, h)rep(j, w) {
		cin >> c[i][j];
		if (c[i][j] == '#') {
			ok[i][j] = 0;
			que.push({ i,j });
		}
	}
	int ans = 0;
	while (que.size()) {
		P p = que.front(); que.pop();
		rep(i, 4) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || nx >= h || ny < 0 || ny >= w)continue;
			if (ok[nx][ny] == inf) {
				ok[nx][ny] = ok[p.first][p.second] + 1;
				que.push({ nx,ny });
			}
		}
	}
	rep(i, h)rep(j, w) {
		ans = max(ans, ok[i][j]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 25524
#include<stdio.h>
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)==3)
    {
        if(a==b&&b==c&&a==c)
            printf("No\n");
        else if(a==b||b==c||a==c)
            printf("Yes\n");
        else
            printf("No\n");
        fflush(stdin);
    }
    return 0;
}


Measured memory_bytes: 128
d = raw_input()
a, b, c =  d.split()
a = int(a)
b = int(b)
c = int(c)
if (a==b):
  if c == a:
    print("No")
  else:
    print("Yes")
else:
  if a==c or b == c:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 2568
import java.util.Scanner;

//A Traveler
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] s = new int[n+1];
		s[1] = 0;
		for(int i=2;i<=n;i++)s[i]=s[i-1]+sc.nextInt();
		int r = 0;
		int k = 1;
		while(m--!=0){
			int x = sc.nextInt();
			r += Math.abs(s[k+x]-s[k]);
			r %= 100000;
			k += x;
		}
		System.out.println(r);
	}
}

Measured memory_bytes: 0
#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;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];

  int ans = 0;
  for(int i = 1; i <= 100; i++) {
    bool streak = false;
    rep(j,n) {
      if(h[j] >= i) {
        if(!streak) ans++;
        streak = true;
      } else {
        streak = false;
      }
    }
  }

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


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


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

  cout<<t/a*b<<endl;

return 0;}


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

if n%2:
  k1, k2 = n//2, n//2+1
  for i in range(m):
    print(k1, k2)
    k1 -= 1
    k2 += 1
else:
  key = [False]*(n)
  key[0] = True
  for i in range(1, n):
    if i == n//2-1 or key[i-1] or key[n-2-i]:
      continue
    key[i] = True
  k1, k2 = n//2, n//2+1
  count = 0
  for i in range(n-1):
    if key[i]:
      print(k1, k2)
      count += 1
    if i%2:
      k1 -= 1
    else:
      k2 += 1
    if count == m:
      break

Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
typedef pair < int , int > pii;
typedef long long LL;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > T MAX(T a,T b){return (a>b)?a:b;}
template < typename T > T MIN(T a,T b){return (a<b)?a:b;}
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
int readint(){
	char c=getchar();
	int ret=0;
	while(!(c>='0' && c<='9')) c=getchar();
	while(c>='0' && c<='9'){
		ret=ret*10+c-'0';
		c=getchar();
	}
	return ret;
}
void putint(int v){
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10) putint(v/10);
	putchar('0'+(v%10));
}
LL N,A,B;
int main(){
	scanf("%lld%lld%lld",&N,&A,&B);
	if(A%2ll==B%2ll)
		printf("%lld\n",(B-A)/2ll);
	else
		printf("%lld\n",min(A+B-1ll,(N-A)+(N-B)+1ll)/2ll);
	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
#pragma warning(disable : 4996)
using namespace std;
void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writer(int x) {
	int s = 0; char f[8];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
int N, M, Q, a[200009], b[200009], r[200009], f[200009], dist[200009], ret[200009]; vector<int> g[200009], gt[200009]; bool vis[100009];
int main() {
	reader(&N), reader(&M), reader(&Q);
	for (int i = 0; i < M; i++) {
		reader(&a[i]), reader(&b[i]), a[i]--, b[i]--;
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	fill(f, f + M, -1);
	for (int i = 0; i < Q; i++) reader(&r[i]), r[i]--, f[r[i]] = i;
	queue<int> que1; que1.push(0);
	fill(dist, dist + N, -1); dist[0] = 0;
	while (!que1.empty()) {
		int u = que1.front(); que1.pop();
		for (int i : g[u]) {
			if (dist[i] == -1) {
				dist[i] = dist[u] + 1;
				que1.push(i);
			}
		}
	}
	for (int i = 0; i < M; i++) {
		if (dist[a[i]] == dist[b[i]]) continue;
		if (dist[a[i]] > dist[b[i]]) swap(a[i], b[i]);
		if (f[i] == -1) gt[a[i]].push_back(b[i]);
	}
	int cnt = N - 1;
	vector<bool> vis(N); vis[0] = true;
	queue<int> que2; que2.push(0);
	while (!que2.empty()) {
		int u = que2.front(); que2.pop();
		for (int i : gt[u]) {
			if (!vis[i]) {
				vis[i] = true; cnt--;
				que2.push(i);
			}
		}
	}
	for (int i = Q - 1; i >= 0; i--) {
		ret[i] = cnt;
		if (dist[a[r[i]]] == dist[b[r[i]]]) continue;
		gt[a[r[i]]].push_back(b[r[i]]);
		if (vis[a[r[i]]] && !vis[b[r[i]]]) {
			vis[b[r[i]]] = true; cnt--;
			queue<int> que; que.push(b[r[i]]);
			while (!que.empty()) {
				int u = que.front(); que.pop();
				for (int j : gt[u]) {
					if (!vis[j]) {
						vis[j] = true, cnt--;
						que.push(j);
					}
				}
			}
		}
	}
	for (int i = 0; i < Q; i++) printf("%d\n", ret[i]);
	return 0;
}

Measured memory_bytes: 23196