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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    string s,t; cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s < t){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100000];

LL ans = 0;

void solve(){
	sort(A,A+N);
	if(N%2==0){
		for(int i=N-1;i>=N/2 + 1;i--) ans += (2*A[i]);
		ans += A[N/2];
		for(int i=0;i<N/2-1;i++) ans -= (2*A[i]);
		ans -= A[N/2-1];
	}else{
		for(int i=N-1;i>=(N+1)/2;i--) ans += (2*A[i]);
		for(int i=0;i<=(N+1)/2-3;i++) ans -= (2*A[i]);
		ans -= (A[(N+1)/2-2] + A[(N+1)/2-1]);

		LL cand = 0;
		for(int i=N-1;i>=(N-1)/2 + 2;i--) cand += (2*A[i]);
		cand += (A[(N-1)/2+1] + A[(N-1)/2]);
		for(int i=0;i<=(N-1)/2-1;i++) cand -= (2*A[i]);
		ans = max(ans,cand);
	}
}
 
int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

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

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n; cin >> n;
    int h = n / 3600;
    int m = n % 3600 / 60;
    int s = n % 60;
    printf("%d:%d:%d\n", h, m, s);
    

    return 0;
}


Measured memory_bytes: 3228
// Confessions of a Dangerous Mind

/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

/*
	"With self-discipline most anything is possible."
*/	
	
	vector<long long> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	long long k; cin >> k;
	cout << a[k - 1];
	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
 
using namespace std;
 
#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define REP1(i,n) for(int (i)=(1);(i)<(n);++i)
#define ll long long
 
int main(){
    string s;
    bool ans = true;
    cin >> s;

    REP(i,4){
        if(s[i]==s[i+1])ans = false;
    }

    if(ans)cout << "Good" << endl;
    else cout << "Bad" << endl;

    return 0;
}

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

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

bool check(string s) {
        if (s.size() & 1) return false;
        int mid = s.size() / 2;
        rep(i, s.size() / 2) {
                if (s[i] != s[i + mid]) return false;
        }
        return true;
}

int main() {
        string s;
        cin >> s;
        while (true) {
                reverse(s.begin(), s.end());
                s = s.substr(1);
                reverse(s.begin(), s.end());
                if (check(s)) break;
        }
        cout << (int)s.size() << endl;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  int A, B;
  cin >> A >> B;
  if( A >= 13 ) cout << B << endl;
  else if( 6 <= A && A <= 12 ) cout << (int)(B/2) << endl;
  else cout << 0 << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;

public class Main {
	static int n;
	static int m;

	static long ans = 0;

	static boolean used[];
	static int color[];

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		n = Integer.parseInt(str[0]);
		m = Integer.parseInt(str[1]);

		ArrayList<ArrayList<Integer>> edge = new ArrayList<>();
		used = new boolean[n];
		color = new int[n];

		for (int i = 0; i < n; i++) {
			edge.add(new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");

			int a = Integer.parseInt(str[0]) - 1;
			int b = Integer.parseInt(str[1]) - 1;
			edge.get(a).add(b);
			edge.get(b).add(a);
		}

		if (isBipartiteGraph(edge, 0, 1)) {
			for (int i = 0; i < n; i++) {
				if (color[i] == 1) {
					ans++;
				}
			}
			System.out.println(ans * (n - ans) - m);
		} else {
			System.out.println(((long) n * (n - 1) / 2) - m);
		}
	}

	static boolean isBipartiteGraph(ArrayList<ArrayList<Integer>> edge, int now, int c) {
		color[now] = c;
		for (int next : edge.get(now)) {
			if (color[next] == c) {
				return false;
			}
			if (color[next] == 0 && !isBipartiteGraph(edge, next, -c)) {
				return false;
			}
		}
		return true;
	}
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n = 1, Abel SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, Abel SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	Abel weight(int x) {
		root(x);
		return diff_weight[x];
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, Abel w) {
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, m;
	cin >> n >> m;

	UnionFind<int> uf(n);
	rep(i, m) {
		int l, r, d;
		cin >> l >> r >> d;
		l--; r--;
		if (uf.issame(l, r)) {
			int diff = uf.diff(l, r);
			if (diff != d) {
				out("No");
				return 0;
			}
		}
		else {
			uf.merge(l, r, d);
		}
	}

	out("Yes");

	return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);
    ll n;
    cin >> n;
    vector<ll> h(n + 2);
    h[n + 1] = INF;
    rep1(i, n) { cin >> h[i]; }

    bool flg = false;
    for (int i = n; i >= 1; i--) {
        if (h[i - 1] - h[i] > 1) {
            flg = false;
            break;
        }
        if (h[i - 1] - h[i] == 1) {
            h[i - 1]--;
        }
        flg = true;
    }

    if (flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pii pair <int, int>
#define F first
#define S second
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define M_PI 3.14159265358979323846
const int N = 200005;
int main() {
    io;
    string s, z;
    cin >> s >> z;
    int n = s.size();
    int m = z.size();
    int ans = INT_MAX;
    for(int i = 0; i <= n - m; i++){
        int res = 0;
        for(int j = 0; j < m; j++){
            if(s[i + j] != z[j]) res++;
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3656
k, n = map(int, input().split())
A = list(map(int, input().split()))
dis = [0] * n
for i in range(n):
    if i == n - 1:
        l = k + A[0] - A[i]
        dis[i] = l
    else:
        l = A[i + 1] - A[i]
        dis[i] = l

print(k - max(dis))

Measured memory_bytes: 26060
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

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

	long long a, b, c;

	cin >> a >> b >> c;

	long long ans = b + min((a + b) + 1 , c);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e6+5;
char s[N];int a[N],q[N],h,t,n,res;
inline int min(R int x,R int y){return x<y?x:y;}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%s",s+1),n=strlen(s+1);
	fp(i,1,n)a[i]=s[i]-'0';
	a[n+1]=a[0]=23333;
	h=1,t=0;
	fp(i,1,n)if(a[i]!=a[i-1])q[++t]=i;
	while(233){
		++res,q[t+1]=n+1;
		while(h<=t&&a[q[h+1]]>a[q[h]])++h;
		if(h>t)break;
		fd(i,n,q[h]+1){
			if(a[i]==9){a[i]=0;continue;}
			++a[i];
			while(h<=t&&q[t]>=i)--t;
			if(i==q[h]+1||a[i-1]!=a[i])q[++t]=i;
			if(i+1<=n)q[++t]=i+1;
			break;
		}
		++h;
		if(q[h]!=q[h-1]+1)++q[h-1],--h;
		while(h<=t&&!a[q[h]])++h;
		if(h>t)break;
	}
	printf("%d\n",res);
	return 0;
}

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

int main() {
    int n, y;
    cin >> n >> y;
    int a=0,b=0,c=0;
    int cnt=0;
    for (int a = 0; a <=n ; a++) {
        for(int b=0;b<=n; b++){
            c=n-a-b;
            if (c>=0 && c<=n && (1000*c==y-10000*a-5000*b)){
                cout<<a<<" "<<b<<" "<<c<<" "<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;

}

Measured memory_bytes: 3572
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long gcd(long long x, long long y){
    return x % y == 0 ? y : gcd(y, x%y);
}

long long lcm(long long a, long long b){
    return a / gcd(a,b) * b; // Be careful not to overflow
}

int main(void){
    ll N,M; cin >> N >> M;
    ll a[N]; REP(i,N) cin >> a[i];

    ll fact = 2;
    while(a[0]%fact == 0){
        fact <<= 1;
    }
    fact >>= 1;
    bool flag = false;
    REP(i,N){
        if(a[i]%fact != 0 || a[i]%(2*fact) == 0){
            flag = true;
            break;
        }
    }
    if(flag){
        cout << 0 << endl;
        return 0;
    }
    
    REP(i,N) a[i] /= fact;

    ll l = 1;
    REP(i,N) l = lcm(l, a[i]);
    l *= fact/2;
    ll ans = M/l;
    ans = (ans+1)/2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import sys
from collections import Counter

s = input()
t = input()
s_list = []
t_list = []

for i in s:
    s_list.append(ord(i))

for i in t:
    t_list.append(ord(i))

s_list.sort()
t_list.sort(reverse=True)

for i in range(min(len(s_list), len(t_list))):
    if t_list[i] > s_list[i]:
        print('Yes')
        sys.exit()

if set(s_list) == set(t_list) and len(s_list) < len(t_list):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3316
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N, M = map(int, readline().split())
    if N == 0:
        return False
    *p, = range(N)
    def root(x):
        if x == p[x]:
            return x
        p[x] = y = root(p[x])
        return y
    def unite(x, y):
        px = root(x); py = root(y)
        if px == py:
            return 0
        if px < py:
            p[py] = px
        else:
            p[px] = py
        return 1

    E = []
    for i in range(M):
        a, b, c = map(int, readline().split())
        E.append((c, a, b))
    E.sort()
    ans = 0
    for c, a, b in E:
        if unite(a-1, b-1):
            ans += c
    write("%d\n" % ans)
    return True
while solve():
    ...


Measured memory_bytes: 5612
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];

    let mut works: Vec<(usize, usize)> = Vec::new();
    for _ in 0..n{
        let line: Vec<usize> = read_as_vec();
        works.push((line[0], line[1]));
    }

    works.sort_by_key(|x| x.1);
    //println!("{:?}", works);

    let mut current = 0;
    for work in works{
        current += work.0;
        if current > work.1{
            println!("No");
            return;
        }
    }

    println!("Yes");
}
    


Measured memory_bytes: 9412
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

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

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	int r;
    	cin>>r;
    	cout<<fixed<<setprecision(10);
    	
    	// cout<<x;
    	float ans=(2*3.14159*r);
    	cout<<ans<<endl;

    	
    	
    }
    return 0;
}

Measured memory_bytes: 3796
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if (a<b){
        printf("a < b\n");
    }else if (a==b){
        printf("a == b\n");
    }else{
        printf("a > b\n");
    }
    return 0;
}


Measured memory_bytes: 2568
N=int(input())
mylist=list(map(int,input().split()))
#print(mylist)
sq_mylist=[i*i for i in mylist]
#print(sq_mylist)

coord_max=max(mylist)
sum_list=sum(mylist)
point=sum_list//N
over_point=point+1

def fun1(p):
    total=p*p*N+sum(sq_mylist)-2*p*sum_list
    return total

print(min(fun1(point),fun1(over_point)))

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    String str = sc.next();
	    String[] ar = str.split("");
        int count = 0;
        String ans = (ar[0].equals(ar[1])&&ar[1].equals(ar[2]) || ar[1].equals(ar[2])&&ar[2].equals(ar[3])? "Yes": "No");
      	System.out.println(ans);
	}
}

Measured memory_bytes: 35572
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	public static void main(String args[]) {
		
		Scanner scan = new Scanner(System.in);
		ArrayList route = new ArrayList();
		
		int n = scan.nextInt();
		int t = scan.nextInt();
		
		for(int i = 0; i < n; i++) {
			int cost = scan.nextInt();
			int time = scan.nextInt();
			
			if(time <= t) {
				route.add(cost);
			}
		}
		
		if(route.size() == 0) {
			System.out.println("TLE");
		}else {
			route.sort(null);
			System.out.println(route.get(0));
		}
		
	}

}

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

int main(){
	string s;
	cin >> s;
	
	int count = 0;
	if(s[0] == 'A')
		count ++;
	int c = 0;
	for(int i = 2; i <= s.length()-2; i++){
		if(s[i] == 'C'){
			c ++;
		}
	}
	if(c == 1)
		count ++;
		
	bool up = false;
	int total_cs = 0;
	for(int i = 1; i < s.length(); i ++){
		{
			if(isupper(s[i])){
				if(s[i] == 'C' && total_cs == 0 && i >= 2 && i <= s.length()-2){
						total_cs ++;
				}else{
					up = true;
				break;
				}
			}
		}
	}
	if(!up)
		count ++;
	
	if(count == 3)
		cout << "AC" << endl;
	else
		cout << "WA" << endl;
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
  cin >> n;
  vector<long long> h(n);
  for(int i=0 ; i<n ; i++){
    cin >> h[i];
  }
  int ma = 0;
  for(int i=0 ; i<n ; i++){
    int st = i;
    while(h[i]>=h[i+1] && i+1<n){
      i++;
    }
    ma = max(ma, i-st);
  }
  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  int N,i,check;
  scanf("%d",&N);
  int a[N];
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  check=a[0];
  for(i=1;i<N;i++){
    check=check^a[i];
  }
  if(check==0){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 512
from itertools import*
N,K,Q,*A=map(int,open(0).read().split())
s=sorted
print(min((s(sum((v[:1-K or N]for v in(k*s(v)for k,v in groupby(A,lambda a:a>=Y))),[]))[Q-1:]+[2e9])[0]-Y for Y in A))

Measured memory_bytes: 101340
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans1=0,ans2=0,ans3=0,ans4=0,ans5=0;
	cin>>n;
	string s[n];
	for(int i=0; i<n; i++){
		cin>>s[i];
	}
	for(int i=0; i<n; i++){
		if(s[i][0]=='P')
			ans1++;
		if(s[i][0]=='W')
			ans2++;
		if(s[i][0]=='G')
			ans3++;
		if(s[i][0]=='Y')
			ans4++;
	}
	if(ans1!=0)
		ans5=ans5+1;
	if(ans2!=0)
		ans5=ans5+1;
	if(ans3!=0)
		ans5=ans5+1;
	if(ans4!=0)
		ans5=ans5+1;
	if(ans5==3)
		cout<<"Three"<<endl;
	if(ans5==4)
		cout<<"Four"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(0, c-(a-b)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	long long A[N], B[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	long long cnt = 0;
	for (int i = N - 1; i >= 0; i--) {
        A[i]+=cnt;
		if (A[i] % B[i] == 0) continue;
		else {
			long long div = A[i] / B[i] + 1;
			cnt += div * B[i] - A[i];
		}
	}
	cout << cnt << endl;
	return 0;
}


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

#define T 53
#define P 11

struct Team {
	int n, solve, penal;
	int prob[P];
	Team() : n(0), solve(0), penal(0) {
		for(int i=0; i<P; ++i) prob[i] = 0;
	}
	Team(int pn) : n(pn), solve(0), penal(0) {
		for(int i=0; i<P; ++i) prob[i] = 0;
	}
	bool operator<(const Team &t) const {
		if(solve != t.solve) return !(solve < t.solve);
		if(penal != t.penal) return penal < t.penal;
		return n < t.n;
	}
};

int main() {
	int t, p, r, tID, pID, time; string message;
	while(cin >> t >> p >> r && t && p && r) {
		vector<Team> teams;
		for(int i=1; i<=t; ++i) teams.push_back(Team(i));
		for(int i=0; i<r; ++i) {
			cin >> tID >> pID >> time >> message;
			--tID; --pID;
			if(teams[tID].prob[pID]>=0) {
				if(message=="WRONG") {
					teams[tID].prob[pID] += 1;
				}else {
					teams[tID].solve += 1;
					teams[tID].penal += teams[tID].prob[pID]*1200 + time;
					teams[tID].prob[pID] = -1;
				}
			}
		}
		sort(teams.begin(), teams.end());
		for(int i=0; i<teams.size(); ++i) {
			cout << teams[i].n << " " << teams[i].solve << " " << teams[i].penal << endl;
		}
	}
	return 0;
}

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

int main() {
	int P1, P2;
  	int N, A, B;
    
    cin >> N >> A >> B;

  	P1 = A * N;
  	P2 = B;
  
  	if (P1 > P2) {
      cout << P2 << endl;
    } else {
      cout << P1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
#define int long long
#define double long double
int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}
int keta(int n) {
    return to_string(n).length();
}

main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), h(n);
    rep(i, n) cin >> a[i] >> b[i] >> h[i];
    rep(y,101){
        rep(x,101){
            int check = -1;
            rep(i,n){
                if(h[i]>0){
                int high = abs(a[i] - x) + abs(b[i] - y) + h[i];
                if (check == -1) check = high;
                else{
                    if (check != high){
                        check = -2;
                        break;
                    }
                }
                }
            }
            rep(i,n){
                if(h[i]==0){
                        int check2 = abs(a[i] - x) + abs(b[i] - y);
                        if (check2 < check){
                            check = -2;
                            break;
                        }
                    }
            }
                if (check == -2) continue;
                cout << x << " " << y << " " << check << endl;
                return 0;
        }
    }
}

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

int main()
{
    int n;
    while(cin>>n){
        int x=111;
        while(n>x){
            x+=111;
        }
        cout<<x<<endl;
    }
    return 0;
}


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

ans = sum(B)
for i in range(N - 1):
    if (A[i] + 1) == A[i + 1]:
        ans += C[A[i] - 1]

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int n,m,cnt=0,aa[220000],ans=0;
pair<int,int> pp[220000];
string s,sa[220000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        if(i%2==0&&aa[i]%2==1){
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 10512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;
struct po{int l,r,u,d;};
po al[31];
int h,w,u[31],d[31];
string mp[51];

bool check1(int num,po t){
  if(t.l==100)return 1;
  for(int i=t.u;i<=t.d;i++)
    for(int j=t.l;j<=t.r;j++){
      if(mp[i][j]==num+'A')continue;
      if(mp[i][j]=='.')return 0;
      u[num] |= (1<<(mp[i][j]-'A'));
      d[mp[i][j]-'A'] |= (1<<num);
    }
}

bool topological(){
  queue <int> Q;
  for(int i=0;i<30;i++)if(!d[i])Q.push(i);
  while(!Q.empty()){
    int t=Q.front(); Q.pop();
    for(int i=0;i<30;i++)
      if(((1<<i)&u[t])){
	d[i] -= (d[i]&(1<<t));
	if(!d[i])Q.push(i);
      }
  }
  for(int i=0;i<30;i++)if(d[i])return 0;
  return 1;
}

int main() {
  int q;
  cin>>q;
  while(q--){
    cin>>h>>w;
    for(int i=0;i<h;i++)cin>>mp[i];
    for(int i=0;i<30;i++){
      u[i]=d[i]=0;
      al[i].l=al[i].u=100;
      al[i].r=al[i].d=-1;
    }
    
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(mp[i][j]!='.'){
	  int k=mp[i][j]-'A';
	  al[k].u=min(al[k].u,i);
	  al[k].l=min(al[k].l,j);
	  al[k].d=max(al[k].d,i);
	  al[k].r=max(al[k].r,j);
	}
    bool ans=1;
    for(int i=0;i<30;i++)ans = min(ans,check1(i,al[i]));
    ans = min(ans,topological());
    if(ans)cout<<"SAFE"<<endl;
    else cout<<"SUSPICIOUS"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
using System;    
     
class sample12{    
    static void Main(string[] args){
        int result = 0 ;
        int remainder = 0;
        decimal fresult = 0;
        int[] int_number = new int[2];
        string[] str_number = Console.ReadLine().Split(' '); 
        
        //入力された数字をintへ変換
        for(int i = 0 ; i < 2; i++){
                    int_number[i] = int.Parse(str_number[i]);
        }
        
        //バリデーション
 
        if(int_number[0] < 1 || int_number[1] < 1 || int_number[0] > 1000000000 || int_number[1] > 1000000000 ){
            
                    Console.WriteLine("入力した値は範囲外です。");
                    Environment.Exit(0);
        } 
                
        //約数ならカウントする
        result = int_number[0] /int_number[1];
        remainder = int_number[0] %int_number[1];
        fresult = (decimal)int_number[0] /int_number[1];
        
        Console.WriteLine("{0} {1} {2}",result,remainder,fresult);
    }    
}  


Measured memory_bytes: 18008
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int m, n;
    cin >> m >> n;
    int ans = 1;
    while(n){
        if(n & 1)   ans = (ll)ans * m % mod;
        m = (ll)m * m % mod;
        n >>= 1;
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)*(b))/__gcd((a), (b)))
#define MAXN 110

int v[MAXN];
int n;

int main() {
	cin.tie(0);
	cin.sync_with_stdio(0);
	
	int res = 0;
	int n, x, y;
	
	cin >> n >> x >> y;
	
	for(int i=0; i<n; i++){
		int a, b;
		cin >> a >> b;

		if( (a >=x) and (b>=y) )
			res++;
	}
	
	cout << res << endl;
		
	return 0;
}


Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 3*1e5+5;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

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

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);
    int n;
    cin>>n;
    cout<<((n%s(n)==0)?"Yes":"No")<<enl;


    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    string s;
    cin >> s;
    int len = s.size();
    int ans = 0;
    string str = "AGCT";
    for(int i = 0; i < len; i++){
        for(int j = 1; j <= len-i; j++){
            string t = s.substr(i, j);
            bool ok = true;
            for(auto c: t){
                if(str.find(c) == string::npos)
                    ok = false;
            }
            if(ok){
                int l = t.size();
                ans = max(ans, l);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

	int D,N;
	scanf("%d %d",&D,&N);

	int i;

	if(D==0){
		if(N==100){
			printf("101\n");
		}
		else{
			printf("%d\n",N);
		}
	}
	else if(D==1){
		if(N==100){
			printf("10100\n");
		}
		else{
			printf("%d\n",N*100);
		}
	}
	else{
		if(N==100){
			printf("1010000\n");
		}
		else{
			printf("%d\n",N*100*100);
		}
	}

	return 0;
}

Measured memory_bytes: 128
import itertools
N = int(input())
L = list(range(1,N+1))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
P = tuple(p)
Q = tuple(q)
A = [v for v in itertools.permutations(L,N)]
for i in range(len(A)):
  if A[i] == P:
    ans1 = i+1
  if A[i] == Q:
    ans2 = i+1
print(abs(ans1-ans2))

Measured memory_bytes: 7924
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;


namespace AtCoder
{
	class Program
	{
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[,] tmp = new int[10,10];
            for(int i = 1; i <= N; i++)
            {
                int first, last;
                if (i > 99999) first = i / 100000;
                else if (i > 9999) first = i / 10000;
                else if (i > 999) first = i / 1000;
                else if (i > 99) first = i / 100;
                else if (i > 9) first = i / 10;
                else first = i;
                last = i % 10;
                tmp[first, last]++;
            }
            long ans = 0;
            for (int i = 1; i <= N; i++)
            {
                int first, last;
                if (i > 99999) first = i / 100000;
                else if (i > 9999) first = i / 10000;
                else if (i > 999) first = i / 1000;
                else if (i > 99) first = i / 100;
                else if (i > 9) first = i / 10;
                else first = i;
                last = i % 10;
                ans += tmp[last,first];
            }
            Console.WriteLine(ans);
            
            Console.ReadLine();
        }
    }
    
}


Measured memory_bytes: 13140
S = input()

front = int(S[:2])
back = int(S[2:])

if front > 12:
    if back>=1 and back<=12:
        print("YYMM")
    else:
        print("NA")
elif front>=1 and front<=12:
    if back>=1 and back<=12:
        print("AMBIGUOUS")
    elif back>12 or back==0:
        print("MMYY")
else:
    if back>=1 and back<=12:
        print("YYMM")
    elif back>12 or back==0:
        print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long double ld;									// XD
#define int long long
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int>
#define vii vector< ii >
#define F first
#define S second
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
#define mem(a,x) memset(a,x,sizeof(a))   
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
typedef tree<int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;  

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

const int mod = 1e9+7;
const int inf = 1e18;
const int maxn = 5e5+5;

void solve(){
	string s; cin>>s;
	int n = sz(s);
	cout<<s;
	if(s[n-1] == 's') cout<<"es"; else cout<<"s";
}

signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); //io();
    //cout<<setprecision(16);
    int tc=1; //cin>>tc; 
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}



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

int main(){
    int N, K;
    cin >> N >> K;
    
    vector<bool> snuke(N,true);
    
    for(int i=0; i<K; i++){
        int d; cin >> d;
        for(int j=0; j<d; j++){
            int a; cin >> a;
            snuke[a-1] = false;
        }
    }
    
    int ans=0;
    
    for(int i=0; i<N; i++){
        if(snuke[i])ans++;
    }
    
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        boolean flagA = false;
        boolean flagB = false;
        boolean flagC = false;
        for (int i = 0; i < 3; i++) {
            if (str.charAt(i) == 'a') {
                flagA = true;
            }
            if (str.charAt(i) == 'b') {
                flagB = true;
            }
            if (str.charAt(i) == 'c') {
                flagC = true;
            }
        }
        String ans;
        if (flagA && flagB && flagC) {
            ans = "Yes";
        } else {
            ans = "No";
        }
        System.out.println(ans);

    }
}

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

int main()
{
	int N, W;
	cin >> N >> W;
	vector<int> dp(W + 1, 0);
	for (int i = 0, v, w; i < N; i++) {
		cin >> v >> w;
		vector<int> t = dp;
		for (int j = w; j <= W; j++) {
			if (dp[j] < t[j - w] + v) {
				dp[j] = t[j - w] + v;
			}
		}
	}
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 3228
package main

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

func Solve() {
  var N, K int
  NextInt(&N, &K)
  var A []int
  NextIntSlice(&A)
  sel, ltl := MaxInt(A...), 0
  for sel - ltl > 1 {
    med := (sel + ltl) / 2
    k := 0
    for _, a := range A { k += Ceil(a, med) - 1 }
    if k > K {
      ltl = med
    } else {
      sel = med
    }
  }
  Write(sel)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}
func Ceil(x, y int) int {
  a := x / y
  if x % y > 0 { a++ }
  return a
}

Measured memory_bytes: 13208
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


N = int(input())
L = []
for i in range(N):
    L.append(list(map(int,input().split())) + [i])
L.sort()

SUM1 = 0
SUM2 = 0
UFT = UnionFind(N)
for i in range(N-1):
    SUM1 += N - i
    SUM2 += L[i][1]
    if SUM1 != SUM2:
        UFT.union(i, i+1)
ans = [0] * N
for i in range(N):
    ans[L[i][2]] = UFT.size(i)
for i in range(N):
    print(ans[i])

Measured memory_bytes: 58156
n = int(input())

li = [int(input()) for _ in range(n)]

check_li = [1]
s = 1
cnt = 0

while True:
    cnt += 1
    s = li[s-1]
    if cnt >= n:
        print(-1)
        break
    if s == 2:
        print(cnt)
        break
    

Measured memory_bytes: 7084
#include<cstdio>

int n;
int a[21],v[21];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d%d",&a[i],&v[i]);
	int mid=a[0],m=v[0];
	for(int i=1;i<n;i++){
		if(m<v[i]){
			mid=a[i];
			m=v[i];
		}
		if(m==v[i] && mid>a[i])mid=a[i];
	}
	printf("%d %d\n",mid,m);
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int max=0;
    int index=0;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        if(max<a)
        {
            max=a;
            index=b;
        }
    }
    cout<<index+max;
}

Measured memory_bytes: 3640
//
//  main.c
//  ITP1_6_B
//
//  Created by k16031kk on 2018/05/24.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int n, m;
    scanf("%d", &n);
    int cards[4][13];
    for(int i=0; i<4; i++) {
        for(int j=0; j<13; j++) {
            cards[i][j]=0;
        }
    }
    char ch;
    //今あるカードを入力
    for(int i=0; i<n; i++) {
        scanf("%c", &ch);
        scanf("%c %d", &ch, &m);
        if(ch=='S') cards[0][m-1]=m;
        if(ch=='H') cards[1][m-1]=m;
        if(ch=='C') cards[2][m-1]=m;
        if(ch=='D') cards[3][m-1]=m;
    }
    for(int i=0; i<4; i++) {
        for(int j=0; j<13; j++) {
            if(cards[i][j]==0) {
                if(i==0) {
                    printf("S %d\n",j+1);
                }
                if(i==1) {
                    printf("H %d\n",j+1);
                }
                if(i==2) {
                    printf("C %d\n",j+1);
                }
                if(i==3) {
                    printf("D %d\n",j+1);
                }
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

int main() {
	int a,b,c;
	ll k;
	scanf("%d%d%d%lld", &a, &b, &c, &k);
	if (k%2 == 0) printf("%d\n", a-b);
	else printf("%d\n", b-a);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
    
int main(){
 int W,H;
    
 while(1){
  cin >> H >>W;
    
  if(W == 0 && H == 0)break;
    
  for(int i = 0; i < H; i++){
   for(int j = 0; j < W; j++){
    if((i +j) % 2 == 0){
     cout << "#";
    }else{
     cout << "." ;
    }
   }
   cout << "\n";
  }
    
  cout << endl;
 }
    
 return 0;
}

Measured memory_bytes: 1156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ALDS1_2_A
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x));

            BubbleSort(a, n);
        }

        public static IEnumerable<Type>  BubbleSort<Type>(IEnumerable<Type> A, int N)
            where Type : IComparable
        {
            var flag = true;
            var a = A.ToArray();
            var count = 0;

            while (flag) 
            {
                flag = false;
                for(int i = N - 1; i > 0; i--)
                {
                    if(a[i].CompareTo(a[i - 1]) < 0)
                    {
                        var temp = a[i];
                        a[i] = a[i - 1];
                        a[i - 1] = temp;
                        flag = true;
                        count++;
                    }
                }
            }

            Console.WriteLine(OutputArray(a));
            Console.WriteLine(count);

            return A;
        }

        public static string OutputArray<Type>(IEnumerable<Type> array)
            where Type : IComparable
        {
            string aa = "";
            var a = array.ToArray();

            for (int k = 0; k < a.Length; k++)
            {
                aa += a[k];

                if (k != a.Length - 1)
                {
                    aa += " ";
                }
            }

            return aa;
        }
    }
}



Measured memory_bytes: 8412