akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    int h,w,x,y;
    cin >> w >> h >> x >> y;
    cout << 1.0*h*w/2 << " " << ((2*x==w)&&(2*y==h)) << endl;
}


Measured memory_bytes: 3756
N= int(input())
D= list(map(int, input().split()))
M= int(input())
T= list(map(int, input().split()))

Ddic = {}
for d in D:
    if d in Ddic:
        Ddic[d] += 1
    else:
        Ddic[d] = 1

Tdic = {}
for t in T:
    if t in Tdic:
        Tdic[t] += 1
    else:
        Tdic[t] = 1

ans = True

for t in Tdic:
    if not t in Ddic:
        ans = False
    elif Tdic[t] > Ddic[t]:
        ans = False

if ans:
    print("YES")

else:
    print("NO")

Measured memory_bytes: 56724
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var num = Input.numL;
        var s = Input.numL;var min = long.MaxValue;
        if (num == s) { min = num + 1;goto end; }
        for(var i = 2L; i * i <= num; i++)
        {
            if (f(i, num) == s) { min = i;goto end; }
        }
        for(var i = 1L; i * i <= num; i++)
        {
            var b = (num - s) / i+1;
            if (b > 1 && f(b, num) == s) min = Min(min, b);
        }
        end:;WriteLine(min == long.MaxValue ? -1 : min);
    }
    static long f(long b,long num)
    {
        var s = 0L;
        while (num >= b) { s += num % b;num /= b; }
        return s + num;
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13268
from collections import deque

s = deque(input())
query_num = int(input())
query_li = list()
for _ in range(query_num):
    query_li.append(input().split())

rev_flag = False
for query in query_li:
    if query[0] == '1':
        rev_flag = not rev_flag
    elif (query[1] == '1' and rev_flag) or (query[1] == '2' and not rev_flag):
        s.append(query[2])
    else:
        s.appendleft(query[2])

if rev_flag:
    print(''.join(deque(reversed(s))))
else:
    print(''.join(s))


Measured memory_bytes: 119640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

int h,w,s;
vector<vi> in,v;
pii dp[35][35][35][35];

void init(){
    v = in;
    rep(i,h)rep(j,w-1)v[i][j+1] += v[i][j];
    rep(i,h-1)rep(j,w)v[i+1][j] += v[i][j];
}
int sum(int ax, int ay, int bx, int by){
    int ret = v[bx][by];
    if(ax)ret -= v[ax-1][by];
    if(ay)ret -= v[bx][ay-1];
    if(ax && ay)ret += v[ax-1][ay-1];
    return ret;
}

pii f(int a, int b, int c, int d){//最大グループ数、グループ需要のうち最大
    if(dp[a][b][c][d] != pii(-1,-1))return dp[a][b][c][d];
    if(sum(0,0,h-1,w-1) - sum(a,b,c,d) > s)return pii(-1,-1);
    int group = 1, ret = sum(a,b,c,d);//分割しないとき
    loop(i,b,d){//たて
        pii x = f(a,b,c,i), y = f(a,i+1,c,d);
        if(group < x.first + y.first || (
            group == x.first + y.first && ret < min(x.second, y.second))){
            group = x.first + y.first;
            ret = min(x.second, y.second);
        }
    }
    loop(i,a,c){//よこ
        pii x = f(a,b,i,d), y = f(i+1,b,c,d);
        if(group < x.first + y.first || (
            group == x.first + y.first && ret < min(x.second, y.second))){
            group = x.first + y.first;
            ret = min(x.second, y.second);
        }
    }
    return dp[a][b][c][d] = pii(group, ret);
}

signed main(void) {
    while(cin >> h >> w >> s, h){
        in = vector<vi>(h,vi(w));
        rep(i,h)rep(j,w)cin >> in[i][j];
        init();
        rep(a,35)rep(b,35)rep(c,35)rep(d,35)dp[a][b][c][d] = pii(-1,-1);
        pii ans = f(0,0,h-1,w-1);
        cout << ans.first << " " << s-sum(0,0,h-1,w-1)+ans.second << endl;
    }
}



Measured memory_bytes: 26548
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
  string s;
  
  cin>>s;
  
  if(s=="ABC")
  {
    cout<<"ARC"<<endl;
  }
  else
  {
    cout<<"ABC"<<endl;
  }

  return 0;
}

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;
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 dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

// 繰り返し二乗法
ll power(ll a, ll b){
    if(a==1)return a;
    // if(a==0)re
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int MAX=2100000;

ll fact[MAX], fact_inv[MAX];

void init_fact(ll n){
    fact[0]=1;
    // 階乗の計算
    for(ll i=0; i<n; i++) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

ll perm(ll n, ll r){
    return (fact[n]*fact_inv[n-r])%MOD;
}

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

    ll A,B,C,D,E,F; cin>>A>>B>>C>>D>>E>>F;

    double maxval = -1.0;
    pint ans = mp(0,0);
    rep(a, 31){
        rep(b, 31){
            if(a+b==0) continue;
            rep(c, 3001){
                ll water = 100*(A*a + B*b);
                ll d = min((F - water - C*c )/D, (water/100*E - C*c )/D);
                if(d < 0) continue;
                // cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
                ll sugar = C*c + D*d;
                if((water+sugar) > F) continue;
                if(sugar > water/100*E) continue;
                if(water+sugar == 0) continue;
                double noudo = (100.0*sugar)/(water+sugar);
                if(chmax(maxval, noudo)) ans = mp(water+sugar, sugar);
            }
        }
    }
    cout<<ans.first<<" "<<ans.second<<endl;


    return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int A, B, C, D, i = 0;
    cin >> A >> B >> C >> D;
    while (A > 0 && C > 0)
    {
        if (i % 2 == 0)
        {
            C -= B;
            i++;
        }
        else
        {
            A -= D;
            i++;
        }
    }
    if (A <= 0)
        cout << "No";
    else
        cout << "Yes";
    return 0;
}


Measured memory_bytes: 3520
#include<cstdio>
int main(void){
  int a0,a,b0,b,r;
  while(scanf("%d %d",&a,&b)!=EOF){
    b0=b;
    a0=a;
    r=a%b;
    while(r!=0){
      a=b;
      b=r;
      r=a%b;
    }
    printf("%d %d\n",b,(a0/b)*b0);
  }
  return 0;
}

Measured memory_bytes: 1024
def resolve():

    n=int(input())
    H=list(map(int,input().split()))
    def main():
        if n == 1:
            return 'Yes'
        maxval=0
        for i in range(n):
            if maxval-2>=H[i]:
                return 'No'
            else:
                maxval=max(maxval,H[i])
        return 'Yes'
    print(main())


resolve()


Measured memory_bytes: 85348
import sys
from itertools import accumulate

def main():
    input = sys.stdin.readline
    N, H = map(int, input().split())
    K = []
    A = 0
    B = []
    for _ in range(N):
        a, b = map(int, input().split())
        K.append([a, b])
        A = max(A, a)
        B.append(b)
    B = sorted(B, key=lambda x: -x)
    B = [0] + list(accumulate(B))

    ans = 10**9
    for i in range(N+1):
        if B[i] > H:
            ans = min(ans, i)
            break
        if (H-B[i]) % A == 0:
            ans = min(ans, i + (H - B[i]) // A)
        else:
            ans = min(ans, i + (H - B[i]) // A + 1)
    print(ans)
 

if __name__ == '__main__':
    main()


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

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

	int k;
	cin >> k;
    string s;
    cin >> s;
    int n = s.size();
    if(n <= k) {
    	cout << s;
	}
	else {
		for(int i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "..." ;
	}
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL<<62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {

	int n;
	cin >> n;
	vector<pair<string, int>> sp(n);
	set<string> s;
	map<string, vector<pair<int,int>>> p;
	FOR(i, n) {
		cin >> sp[i].first >> sp[i].second;
		s.insert(sp[i].first);
		p[sp[i].first].push_back({ sp[i].second,i + 1 });
	}
	auto itr = s.begin();
	FOR(i, s.size()) {
		SORT(p[*itr]);
		FOR(j, p[*itr].size()) {
			cout << p[*itr][p[*itr].size() - 1 - j].second << endl;
		}
		itr++;
	}
}


Measured memory_bytes: 256
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
string s = "aeiou";
void solve() {
    char ch;
    while(cin >> ch) {
        if(s.find(ch) == string::npos) cout << "consonant" << endl;
        else cout << "vowel" << endl;
    }
}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    if (s.charAt(2) == s.charAt(3) &&
        s.charAt(4) == s.charAt(5)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int memo = 0;
    int m = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'I')
        {
            memo++;
        }
        if (s[i] == 'D')
        {
            memo--;
        }
        m = max(m, memo);
    }
    cout << m << endl;
}


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

bool AC[105000];
int WA[105000];
using namespace std;
void solve(){
	int N, M;
	cin >> N >> M;
	for(int i = 1; i <= N; i++){
		AC[i] = false;
		WA[i] = 0;
	}
	int acNumber = 0;
	int awNumber = 0;
	while(M--){
		int p;
		string s;
		cin >> p >> s;
		if(AC[p]) continue;
		if(s == "AC"){
			AC[p] = true;
			acNumber += 1;
			awNumber +=  WA[p];
		}
		else{
			 WA[p] += 1;
	    }
	}
	cout << acNumber << " " << awNumber << endl;
       return;
 }  

int main (){
	solve();
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int n,l;
	static int a[100010];
	scanf("%d%d",&n,&l);
	rep1(i,n)scanf("%d",&a[i]);
	
	rep1(i,n-1){
		if(a[i]+a[i+1] >= l){
			puts("Possible");
			rep1(j,i-1)printf("%d\n",j);
			for(int j = n-1 ; j >= i+1 ; j --)printf("%d\n",j);
			printf("%d\n",i);
			return 0;
		}
	}
	puts("Impossible");
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;

//1-indexed DSU
struct DSU {
    int n;
    vector<int> siz, par;
    int init_calls;
    DSU() {
	init_calls = 0;
    }
    void init(int n) {
	assert(++init_calls == 1);
	this->n=n;
	siz.resize(n+10, 1);
	par.resize(n+10);
	for (int i=1; i<=n; i++) par[i] = i;
    }
    int parent(int x) {
	assert(init_calls == 1);
	assert(x>=1 && x<=n);
	if (x == par[x]) return x;
	return par[x] = parent(par[x]);
    }
    bool join(int x, int y) {
	assert(init_calls == 1);
	x = parent(x);
	y = parent(y);
	if (x == y) return false;
	if (siz[x]<siz[y]) swap(x,y);
	par[y] = x;
	siz[x] += siz[y];
	return true;
    }
    void clear() {
	init_calls = 0;
	n = 0;
	siz.clear();
	par.clear();
    }
};

int n, k, l;
vector<int> g[maxn], g2[maxn];

DSU dsu;

bool viz[maxn];
set<int> v;
int ans[maxn];


void dfs(int at) {
    if (viz[at]) return;
    viz[at]=true;
    v.insert(at);
    for (int to: g[at]) {
	dfs(to);
    }
}



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

    cin>>n>>k>>l;
    dsu.init(n);
    for (int i=0; i<k; i++) {
	int u,v; cin>>u>>v;
	g[u].push_back(v);
	g[v].push_back(u);
    }
    for (int i=0; i<l; i++) {
	int u,v; cin>>u>>v;
	g2[u].push_back(v);
	g2[v].push_back(u);
	dsu.join(u,v);
    }

    for (int i=1; i<=n; i++) {
	if (viz[i]) continue;
	v.clear();
	dfs(i);
	map<int,vector<int>> mp;
	for (int x: v) {
	    mp[dsu.parent(x)].push_back(x);
	}
	for (int x: v) {
	    ans[x]=mp[dsu.parent(x)].size();
	}
    }

    for (int i=1; i<=n; i++) {
	cout<<ans[i]<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 67592
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

p = 0
for i in range(N):
    p += B[A[i] - 1]
    # print("ba", B[A[i] - 1])
    if i > 0 and A[i] - 1 == A[i - 1]:
        p += C[A[i - 1] - 1]
        # print("c", C[A[i - 1] - 1])
print(p)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,d,a;cin >> n >>d >>a;
    vpl en(n);
    rep(i,n)cin >> en[i].fi >> en[i].se;
    sort(all(en));
    vl z(n),hp(n);
    rep(i,n){
        z[i]=en[i].fi;hp[i]=en[i].se;
    }
    ll ans=0;
    vl cus(n,0);
    rep(i,n){
        if(i!=0)cus[i]+=cus[i-1];
        if(cus[i]>=hp[i])continue;
        else{
            ll h=hp[i]-cus[i];
            ll times=(h+a-1)/a;
            ll dam=a*times;
            ll range=z[i]+d*2;
            ans+=times;
            auto ind=upper_bound(all(z),range)-z.begin();
            cus[i]+=dam;
            if(ind<n)cus[ind]-=dam;
        }
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 8064
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))

using namespace std;
int n;
long long int a[200000];
long long int kisuu;
long long int zer;
long long int b[200000];
long long int ans;

int main(){
  cin >> n;
  REP(i,n){
    long long int k;
    cin >> k;
    a[i]=k;
    if(k<0) kisuu ++;
    if(k==0) zer ++;
    b[i] = abs(k);
  }
  sort(b,b+n);
  if(zer>0){
    REP(i,n) ans += b[i];
    cout << ans << endl;
    return 0;
  }
  if(kisuu%2 == 0){
    REP(i,n) ans += b[i];
    cout << ans << endl;
    return 0;
  }
  else{
    REP(i,n) ans += b[i];
    ans -= 2*b[0];
    cout << ans << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int n,i;
double res=0,a[100];
int main()
{
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    res=(a[0]+a[1])/2.0;
    for(i=2;i<n;i++)
    {
        res=(res+a[i])/2.0;
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <vector>
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 200000 + 5;
int n, m, k;
vector<int> col[N];

void solve() {
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        col[y].push_back(x);
    }
    for (int i = 1; i <= m; i++) {
        sort(col[i].begin(), col[i].end());
    }

    int ans = n;
    int x = 1, y = 1;
    for (int i = 0; i < n; i++) {
        auto ptr = lower_bound(col[y].begin(), col[y].end(), x);
        if (ptr != col[y].end()) {
            ans = min(ans, *ptr - 1);
            if (*ptr == x + 1) {
                break;
            }
        }
        x++;
        if (y < m && !binary_search(col[y + 1].begin(), col[y + 1].end(), x)) {
            y++;
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 8832
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))
n,m=l_in()

edges= [[] for _ in range(n)]

for _ in range(m):
    a,b=l_in()
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

from collections import deque    
vis = set()
vis.add(0)

marks = [-1]*n

q = deque()
q.append(0)

while len(q) > 0:
    u = q.popleft()

    for v in edges[u]:
        if v not in vis:
            q.append(v)
            marks[v] = u
            vis.add(v)


print("Yes")
[print(u+1) for u in marks[1:]]



    


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

using namespace std;

#define INF 1e9

typedef long long ll;

struct Edge {
	int to, cost;
};

ll dp[1001][200];

ll min(ll a, ll b) { return a > b ? b : a; }

int main() {
	int N, M;
	while ( cin >> N >> M, N || M ) {
		ll m[200][200];
		ll s[200][200];

		fill(&m[0][0], &m[0][0]+200*200, INF);
		fill(&s[0][0], &s[0][0]+200*200, INF);

		for (int i = 0; i < N; ++i) {
			s[i][i] = m[i][i] = 0;
		}

		for (int i = 0; i < M; ++i) {
			int x, y, t; char sl; cin >> x >> y >> t >> sl; --x, --y;
			if (sl == 'S') {
				s[x][y] = s[y][x] = min(s[y][x], t);
			}
			else {
				m[x][y] = m[y][x] = min(m[y][x], t);
			}
		}

		for (int k = 0; k < N; ++k) {
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
					s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
				}
			}
		}

		fill(&dp[0][0], &dp[0][0]+1001*200, INF);
		int R; cin >> R;
		vector<int> v(R);
		for (int i = 0; i < R; ++i) {
			cin >> v[i]; --v[i];
		}
		dp[0][v[0]] = 0;
		for (int t = 1; t < R; ++t) {
			for (int b = 0; b < N; ++b) {
				for (int nb = 0; nb < N; ++nb) {
					ll cost = b == nb ? m[v[t-1]][v[t]] : m[v[t-1]][b]+s[b][nb]+m[nb][v[t]];
					dp[t][nb] = min(min(dp[t][nb], dp[t-1][b]+cost), INF);
				}
			}
		}

		int ans = INF;
		for (int i = 0; i < N; ++i) {
			ans = min(ans, dp[R-1][i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3384
#include <stdio.h>

int cnt[1024];

int main(void)
{
	int i, j;
	int a[1024];
	int b;
	int n, m;
	int ans = 0;

	scanf("%d %d", &n, &m);

	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for (j = 0; j < m; j++){
		scanf("%d", &b);
		for (i = 0; i < n; i++){
			if (b >= a[i]){
				cnt[i]++;
				
				break;
			}
		}
	}

	for (i = 0; i < n; i++){
		if (cnt[ans] < cnt[i]){
			ans = i;
		}
	}

	printf("%d\n", ans + 1);

	return (0);
}

Measured memory_bytes: 604
#include <iostream>

using namespace std;

int main()
{
    int A, B, K, count=0, num;
    cin >> A >> B >> K;
    int minAB = min(A, B);
    for(int i=minAB;i>0;i--){
        if(A % i == 0 && B % i == 0){
            ++count;
            num = i;
        }
        if(count >= K) break;
    }

    cout << num << endl;
}


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

using namespace std;

int main()
{
    string inputString;
    string atgc = "ATGC";
    cin >> inputString;
    int length = inputString.length();
    int max_length = 0;
    int p_length = 0;
    for (int i = 0; i < length; i++)
    {
        p_length = 0;
        for (int j = 0; j < length - i; j++)
        {
            if (atgc.find(inputString[i + j]) != string::npos)
            {
                p_length += 1;
            }
            else
            {
                break;
            }
        }
        if (p_length >= max_length)
        {
            max_length = p_length;
        }
    }
    cout << max_length << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
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<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int n = s.length();
    REP(i,n){
        if (s[i] != s[n - 1 - i]){
            ans++;
            s[i] = s[n - 1 - i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

/*void dfs(int u, int c)
{
    connect[u] = c;
    rep(i, G[u].size())
    {
        if (connect[G[u][i]] == -1)
        {
            dfs(G[u][i], c);
        }
    }
    return;
}*/

int main()
{
    int n, m;
    cin >> n >> m;
    int p[n] = {};
    vector<vector<int>> G(n, vector<int>());
    vector<int> connect(n, -1);
    rep(i, n)
    {
        cin >> p[i];
        p[i]--;
    }

    rep(i, n)
        connect[i] = -1;

    rep(i, m)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int cnt = 0;

    rep(u, n)
    {
        if (connect[u] != -1)
            continue;
        queue<int> q;
        q.push(u);
        cnt++;
        while (!q.empty())
        {

            int v = q.front();
            connect[v] = cnt;
            q.pop();
            rep(i, G[v].size())
            {
                if (connect[G[v][i]] == -1)
                    q.push(G[v][i]);
            }
        }
    }

    int ans = 0;
    rep(i, n) if (connect[i] == connect[p[i]]) ans++;

    OP(ans);

    return 0;
}

Measured memory_bytes: 6528
inp = input()
nStr = len(inp)
ret = nStr//2


if(inp[nStr//2] == "1"):
    for i in reversed(range((nStr-1)//2 + 1)):
        if((inp[i] == inp[nStr-i-1]) and (inp[i] == "1")):
            ret += 1
        else:
            break
    print(ret)

else:            
    for i in reversed(range((nStr-1)//2 + 1)):
        if((inp[i] == inp[nStr-i-1]) and (inp[i] == "0")):
            ret += 1
        else:
            break
    print(ret)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int N;
	lint ans_a = 1, ans_b = 1;
	lint max_a = 1, max_b = 1;
	lint mul;
	lint a, b;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a >> b;
		max_a = max(a, ans_a);
		max_b = max(b, ans_b);
		mul = max((max_a - 1 + a) / a, (max_b - 1 + b) / b);
		ans_a = a * mul;
		ans_b = b * mul;
	}
	cout << ans_a + ans_b << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int n;
	cin>>n;
	vector<long long> a(n);
	long long tmp;
	for(int i=0;i<n;i++) {
		cin>>a[i];
	}
	cout<<a[n-1];
	for(int i=n-3;i>=0;i-=2){
		cout<<" "<<a[i];
	}
	if(n%2==0){
		for(int i=0;i<n-1;i+=2)cout<<" "<<a[i];
	}else{
		for(int i=1;i<n-1;i+=2) cout<<" "<<a[i];
	}
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////
std::vector<int> Eratosthenes( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

int main(){
    int n;
    cin>>n;
    vi p=Eratosthenes(55555);
    vi ans;
    for(auto x:p){
        if((x-1)%5==0)ans.push_back(x);
    }
    rep(i,n){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <tuple>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <iostream>
namespace loquat {
template <typename T, typename F = std::plus<T>>
class fenwick_tree {
public:
	using value_type = T;
private:
	std::vector<T> m_data;
	F m_func;
public:
	explicit fenwick_tree(
		size_t n,
		const value_type& x = value_type(),
		const F& f = F())
		: m_data(n + 1)
		, m_func(f)
	{
		m_data[0] = value_type();
		for(size_t i = 1; i <= n; ++i){
			m_data[i] = x;
			for(size_t j = i; (j & 1) == 0u; j >>= 1){
				m_data[i] = m_func(m_data[j], m_data[i]);
			}
		}
	}
	value_type query(size_t i) const {
		value_type s = m_data[i];
		for(i -= i & -i; i > 0; i -= i & -i){
			s = m_func(m_data[i], s);
		}
		return s;
	}
	void modify(size_t i, const value_type& x){
		const auto n = m_data.size();
		for(++i; i < n; i += i & -i){
			m_data[i] = m_func(m_data[i], x);
		}
	}
};
}
using namespace std;
using pii = pair<int, int>;
int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<pii> segs;
	for(int i = 0; i < n; ++i){
		int l, r;
		cin >> l >> r;
		++r;
		segs.emplace_back(r - l, l);
	}
	sort(segs.begin(), segs.end());
	loquat::fenwick_tree<int> ft(m + 2);
	for(int i = 1, j = 0; i <= m; ++i){
		while(j < n && segs[j].first < i){
			const auto p = segs[j];
			ft.modify(p.second, 1);
			ft.modify(p.second + p.first, -1);
			++j;
		}
		int answer = n - j;
		for(int k = i; k <= m; k += i){
			answer += ft.query(k + 1);
		}
		cout << answer << "\n";
	}
	return 0;
}


Measured memory_bytes: 4464
while True:
	n = int(raw_input())
	if n == 0:
		break
	dict = {}
	date = []
	for i in xrange(n):
		num,a,b = map(int,raw_input().split())
		if num in dict:
			dict[num] += a * b
		else:
			dict[num] = a * b
			date.append(num)
	
	judge = True
	for var in date:
		if dict[var] >= 1000000:
			print var
			judge = False
	
	if judge:
		print "NA"

Measured memory_bytes: 6476
#include<iostream>
using namespace std;
int main(){
  int N;
  string S;
  cin >> N >> S;
  if(N%2==1){
    cout << "No";
    return 0;
  }
  for(int i=0;i<N/2;i++){
    if(S[i]!=S[i+N/2]){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b;
    scanf("%d",&a);
  scanf("%d",&b);
    if (2*a <= b && b <= 4*a && b%2 == 0){
        printf("Yes");
    }
    else{
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int a,b; cin>>a>>b;
  if(a*b%2==0)
  cout<<"Even"<<endl;
  else
  cout<<"Odd"<<endl;
  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  set<int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.insert(a);
  }
  cout << A.size() - (A.size() % 2 == 0 ? 1 : 0) << '\n';
  return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;
class Main 
{
  public static void main(String[] args) 
  {
    Scanner input=new Scanner(System.in);
    int x=input.nextInt();
    int a=input.nextInt();
    int b=input.nextInt();
    if(x>=1 && a>=1 && b>=1 && a<=1000 && b<=1000 && x<=1000 && a!=b)
    {
      int tempa=(int)Math.abs(x-a);
      int tempb=(int)Math.abs(x-b);
      if(tempa>tempb)
      {
        System.out.println("B");
      }else
      System.out.println("A");
    }
  }
}

Measured memory_bytes: 21972
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline ll read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll a[maxn],mp[maxn];

int main()
{
	ll n=read();
	ll ans=0;
	for(int i=1;i<=n;i++) a[i]=read(),mp[a[i]]++;
	for(int i=1;i<=n;i++) ans+=(mp[i]*(mp[i]-1))/2;
	for(int i=1;i<=n;i++) printf("%lld\n",ans-(mp[a[i]]-1));
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define speed                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define oprecision                                                             \
  cout.precision(30);                                                          \
  cerr.precision(7);
#define bb bool
#define ii int
#define ll long long
#define ff float
#define dd double
#define cc char
#define ss string
#define forn(sz) for (int i = 1; i <= sz; i++)
#define forni(i, sz) for (int i = 1; i <= sz; i++)
#define fornid(i, m, sz) for (int i = m; i <= sz; i++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vii vector<ii>
#define vii64 vector<ll>
#define vb vector<bb>
using namespace std;
ii a, b;
ii main() {
  speed;
  oprecision;
  /*#ifndef ONLINE_JUDGE
    freopen("outd.txt", "rt", stdin);
  #endif*/
  // code
  cin >> a >> b;
  cout << max({a + b, a - b, a * b});
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 256
N = gets.to_i

tn = []
xn = []
yn = []

N.times {
  t, x, y = gets.split.map(&:to_i)
  tn << t
  xn << x
  yn << y
}

t_prev = 0
x_prev = 0
y_prev = 0
(0..(N-1)).each { |i|
  t_next = tn[i]
  x_next = xn[i]
  y_next = yn[i]

  # 次の地点までの距離
  d = (x_next - x_prev).abs + (y_next - y_prev).abs

  # 移動に使える時間
  t = t_next - t_prev

  # 時間が足りないか、時間ちょうどにたどり着けない場合はアウト
  if t < d || (t - d) % 2 == 1
    puts "No"
    exit
  end

  t_prev = t_next
  x_prev = x_next
  y_prev = y_next
}

puts "Yes"


Measured memory_bytes: 4216
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

bool compair(pair<long long, long long> a, pair<long long, long long> b){
    return a.second < b.second;
}

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

    vector<pair<long long, long long> > v;

    for(long long i = 0; i < n; i++){
        long long a, b;
        cin >> a >> b;

        v.push_back(make_pair(a, b));
    }

    sort(v.begin(), v.end(), compair);

    long long time = 0;

    bool flag = true;

    for(long long i = 0; i < v.size(); i++){
        time += v[i].first;
        if(time > v[i].second){
            flag = false;
            break;
        }
    }

    if(flag == true){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 6384
N, M = map(int, input().split())
A = list(map(int, input().split()))

mod_dict = dict()
S_mod = [0]
s = 0
for a in A:
    s += a
    mod = s % M
    S_mod.append(mod)
    if not mod in mod_dict.keys():
        mod_dict[mod] = 1
    else:
        mod_dict[mod] += 1

if 0 in mod_dict.keys():
    count = mod_dict[0]
else:
    count = 0
for key in mod_dict.keys():
    count += (mod_dict[key] - 1) * mod_dict[key] / 2

print(int(count))


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

int main() {
  int N, L, Min=200, Sum=0;
  cin >> N >> L;
  rep(i, N){
    if(abs(L+i)<abs(Min)) Min=L+i;
    Sum=Sum+L+i;
  }
  cout << Sum-Min << endl;
}

Measured memory_bytes: 256
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18

void solve(){
	int r,g,a,b,c; cin>>r>>g>>a>>b>>c;
	ll arr1[a], arr2[b], arr3[c];
	f(i,a) cin>>arr1[i];
	f(i,b) cin>>arr2[i];
	f(i,c) cin>>arr3[i];
	sort(arr1, arr1+a);
	sort(arr2, arr2+b);
	sort(arr3, arr3+c);
	ll ans = 0;
	vector<ll> v;
	int cnt = 0;
	for(int i=a-1;i>=0;i--){
		cnt++;
		ans += arr1[i];
		v.pb(arr1[i]);
		if(cnt == r) break;
	}
	cnt = 0;
	for(int i=b-1;i>=0;i--){
		cnt++;
		ans += arr2[i];
		v.pb(arr2[i]);
		if(cnt == g) break;
    }
    sort(all(v));
    int j=0;
    for(int i=c-1;i>=0;i--){
    	if(j == v.size()) break;
    	if(arr3[i] >= v[j]){
    		ans += arr3[i] - v[j];
    		j++;
		}
		else break;
	}
	cout<<ans<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 4852
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror

#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率
ll mod = 1e9 + 7;


//提出コード↓

ll n;
ll a[1000000],ans[1000000];


int main() {
	cin >> n;
	rep(i, n - 1) {
		cin >> a[i];
		ans[a[i]]++;
	}
	REP(i,1, n + 1) cout << ans[i] << endl;


	return 0;
}



Measured memory_bytes: 6648
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,a[100005];
ll dp[2][100005];
ll rec(ll i,ll j)
{
	if(i>n)
		return 0;
	if(dp[j][i]!=-1)
		return dp[j][i];
	ll an=0;
	if(a[i]==0)
		an=rec(i+1,0);
	else if(a[i]==1)
		an=rec(i+1,(j^1))+j;
	else
	{
		if(j)
		{
			an=max(an,1+rec(i+1,0)+(a[i]-1)/2);
			an=max(an,1+rec(i+1,1)+(a[i]-2)/2);
		}
		else
		{
			an=max(an,rec(i+1,1)+(a[i]-1)/2);
			an=max(an,rec(i+1,a[i]%2)+a[i]/2);
		}
	}
	return dp[j][i]=an;
}
int main()
{
	memset(dp,-1,sizeof dp);
	SPEED;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	cout<<rec(1,0)<<endl;
	return 0;
}

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

int main(void) {
  vector<int> a(3);
  for (int i = 0; i < 3; i++) cin >> a[i];

  sort(a.begin(), a.end());
  cout << abs(a[0] - a[1]) + abs(a[1] - a[2]) << endl;

  return 0;
}

Measured memory_bytes: 256
// ITP1_4_C: Simple Calculator.c
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a, b, x;
	char buf[256], *p;
	char op;

	for (;;) {
		gets(buf);

		p = buf;
		a = atoi(p);
		while (isspace(*p)) p++;
		while (isdigit(*p)) p++;
		while (isspace(*p)) p++;
		op = *p++;
		b = atoi(p);

		if      (op == '+') x = a + b;
		else if (op == '-') x = a - b;
		else if (op == '*') x = a * b;
		else if (op == '/') x = a / b;
		else break;
		printf("%d\n", x);
	}
	return 0;
}

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

if B-A <= K:
  for i in range(A, B+1):
    print(i)
else:
  C = []
  for i in range(A, A+K):
    C.append(i)
  
  D = []  
  for i in range(B, B-K, -1) :
    D.append(i)
    
  E = set(C) | set(D)
  F = sorted(E)
  
  for i in range(len(F)):
      print(F[i])


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		System.out.println(t+s);
		sc.close();
	}
}


Measured memory_bytes: 21844
n,k = map(int,input().split())
if k % 2 ==1:
    a = n // k 
    print(a ** 3)
else:
    a = n // k
    if (a * k + k // 2) > n:
        print(2 * (a ** 3))
    else:
        print((a + 1) ** 3 + a ** 3)
        

Measured memory_bytes: 2940