akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
typedef long long ll;

int main(){
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	REP(i,n) cin >> a[i];
	
	vector<ll> visited(n,-1);
	vector<ll> way;
	ll i, machi = 1;
	visited[machi-1] = 0;
	way.push_back(1);
	for(i=1; i<=n; i++){
		machi = a[machi-1];
		way.push_back(machi);
		
		if(visited[machi-1] != -1) break;
		else visited[machi-1] = i;
		
		if(i==k){
			cout << machi << endl;
			return 0;
		}
	}
	
	ll loop = i - visited[machi-1];
	ll ans = way[visited[machi-1] + (k-visited[machi-1])%loop];
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,c=0,ps1=-1,ps2=-1,cnt1,cnt2;
    cin>>n;
    int a[n],b[n],p[n];
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<n;i++)
    {
        cin>>b[i];
        p[i]=i+1;
    }

    do
    {


           c++;
           cnt1=0;
           cnt2=0;


               if(a[0]==p[0])
               {
                   cnt1++;
                   for(i=1;i<n;i++)
                   {
                       if(a[i]==p[i]) cnt1++;
                       else break;
                   }
                   if(cnt1==n) ps1=c;
               }

               if(b[0]==p[0])
               {
                   cnt2++;
                   for(i=1;i<n;i++)
                   {
                       if(b[i]==p[i]) cnt2++;
                       else break;
                   }
                   if(cnt2==n) ps2=c;
               }



    }while(next_permutation(p,p+n));
    cout<<abs(ps1-ps2)<<endl;

    return 0;
}


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

int main(){
    //input
    string S,T;
    cin >> S >> T;

    //calc
    int dp[S.length()+1][T.length()+1];
    int i,j;
    for(i=0; i<=S.length(); i++){
        dp[i][0]=i;
    }
    for(j=0; j<=T.length(); j++){
        dp[0][j]=j;
    }
    for(i=1; i<=S.length(); i++){
        for(j=1; j<=T.length(); j++){
            dp[i][j] = min(dp[i-1][j]+1,dp[i][j-1]+1);
            dp[i][j] = min(dp[i][j],dp[i-1][j-1]+(S[i-1]!=T[j-1]));
        }
    }

    //answer
    cout << dp[S.length()][T.length()] << endl;
    return 0;
}


Measured memory_bytes: 7060
n, m = map(int, input().split())
*xlines, = map(int, input().split())
*ylines, = map(int, input().split())

modulo = 10 ** 9 + 7
vs = 0
for i in range(len(xlines) - 1):
    vs += (xlines[i + 1] - xlines[i]) * (1 + i) * (len(xlines) - i - 1)
    vs %= modulo

s = 0
for j in range(len(ylines) - 1):
    s += vs * (ylines[j + 1] - ylines[j]) * (1 + j) * (len(ylines) - j - 1)
    s %= modulo
print(s)






Measured memory_bytes: 99048
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

/****************** ビット演算 ******************/
// n 個の要素から r 個とる部分集合を辞書順に列挙
// for (auto x : comb(5, 3)) cout << bitset<5>(x) << endl;
// 00111 01011 ... 11100
class comb {
private:
    struct Set {
        lint S;
        Set(lint s) : S(s) {}
        lint operator*() const { return S; }
        bool operator!= (const Set& o) const { return S < o.S; }
        void operator++() {
            lint a = S & -S, b = S + a, c = b & -b;
            S = b | (((c / a) >> 1) - 1);
        }
    };
    Set i, n;

public:
    comb(int n, int r) : i((1LL << r) - 1), n(1LL << n) {}
    Set begin() { return i; }
    Set end() { return n; }
};

int main(void) {
    lint n; cin >> n;
    vector<lint> a(5, 0);
    rep (n) {
        string s;
        cin >> s;
        char c = s[0];
        if (c == 'M') ++a[0];
        else if (c == 'A') ++a[1];
        else if (c == 'R') ++a[2];
        else if (c == 'C') ++a[3];
        else if (c == 'H') ++a[4];
    }
    
    lint ans = 0;
    for (bitset<5> x: comb(5, 3)) {
        lint tmp = 1;
        if (x[0]) tmp *= a[0];
        if (x[1]) tmp *= a[1];
        if (x[2]) tmp *= a[2];
        if (x[3]) tmp *= a[3];
        if (x[4]) tmp *= a[4];
        ans += tmp;
    }
    cout << ans << endl;
}
    


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

using namespace std;

int main(){
  int N, M;
  int x,y;
  vector< pair<int,int> > a[100001];
  cin>>N>>M;
  for(int i=0;i<M;i++){
    scanf("%d %d",&x,&y);
    a[x-1].push_back(make_pair(y,i)); //make_pair -> pairの生成
  }
  int p[100001],q[100001];
  for(int i=0;i<N;i++){
    sort(a[i].begin(),a[i].end());
    for(int j=0;j<a[i].size();j++){
      p[a[i][j].second]=i+1;
      q[a[i][j].second]=j+1;
    }
  }
  for(int i=0;i<M;i++){
    printf("%06d%06d\n",p[i],q[i]);
  }
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int l[10];
int N,A,B,C;

int calc(vector<int> v){
  int a=0,b=0,c=0;
  int idx=0;
  for(auto it=v.begin();it!=v.end();it++){
    if(*it==0) a+= l[idx];
    if(*it==1) b+= l[idx];
    if(*it==2) c+= l[idx];
    idx++;
  }
  if(a*b*c==0) return INF;
  else return (abs(A-a)+abs(B-b)+abs(C-c)-30);
}

int dfs(int depth, vector<int> v){
  if(depth==N) return calc(v);
  else{
    int res;
    v.push_back(0);
    res = dfs(depth+1,v)+10;

    v.pop_back();
    v.push_back(1);
    res = min(res, dfs(depth+1,v)+10);

    v.pop_back();
    v.push_back(2);
    res = min(res, dfs(depth+1,v)+10);

    v.pop_back();
    v.push_back(3);
    res = min(res, dfs(depth+1,v));

    return res;
  }
}


int main()
{
  int res=0;
  cin >> N >>A >> B>> C;

  rep(i,N) cin >> l[i];

  vector<int> vv;

  res = dfs(0,vv);

  cout << res << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int x;
    cin >> x;
    if(x%7 == 0)cout << "thu\n";
    else if(x%7 == 1)cout << "fri\n";
    else if(x%7 == 2)cout << "sat\n";
    else if(x%7 == 3)cout << "sun\n";
    else if(x%7 == 4)cout << "mon\n";
    else if(x%7 == 5)cout << "tue\n";
    else if(x%7 == 6)cout << "wed\n";
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


const ll INF = 1e16;

int main(){
    int n,k;
    cin >> n >> k;
    double ans = 0;
    rep(i,n){
        int cnt = 0;
        int temp=i+1;
        while(temp<k){
            temp*=2;
            cnt++;
        }
        ans+=pow(0.5,cnt);
    }
    ans/=n;
    printf("%.10lf",ans);
    return 0;
}

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

int dp[100];
int cost[6] = {380, 550, 850, 1520, 1870, 2244};
int amo[6] = {2, 3, 5, 10, 12, 15};

int main() {
    for(int i=0; i<100; ++i) dp[i] = 1<<29;
    dp[0] = 0;

    for(int i=0; i<6; ++i)
        for(int j=0; j+amo[i]<100; ++j)
            if(dp[j] != 1<<29)
                dp[j+amo[i]] = min(dp[j+amo[i]], dp[j] + cost[i]);

    int n;
    while(cin>>n, n) cout<<dp[n/100]<<endl;
}

Measured memory_bytes: 0
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
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)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = readInts()
# G = [[] for _ in range(n)]
# for i in range(m):
#     a,b = readInts()
#     a-=1;b-=1;
#     G[a].append(b)
#     G[b].append(a)
uni = UnionFind(n)
for i in range(m):
    a,b = map(lambda x:int(x)-1,input().split())
    uni.union(a,b)
ans = -1
for i in range(n):
    a = uni.size(i)
    ans = max(ans,a)
print(ans)


Measured memory_bytes: 15908
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int f[50];
int32_t main()
{
	int n=in();int m=in();int k,x;
	for(int i=0;i<n;i++)
	{
		cin>>k;
		for(int j=0;j<k;j++){x=in();f[x]++;}
	}
	int ans=0;
	for(int i=0;i<50;i++)
	{
		if(f[i]==n)ans++;
	}
	cout<<ans;
	
	
	
}

Measured memory_bytes: 3664
use io::*;
use std::cmp::max;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let aa: Vec<usize> = (0..n).map(|_| sc.next()).collect();

    if aa[0] != 0 {
        println!("-1");
        return;
    }

    let mut ans = 0;
    for i in 1..n {
        if aa[i] >= aa[i - 1] + 2 {
            println!("-1");
            return;
        } else if aa[i] == aa[i - 1] + 1 {
            ans += 1;
        } else {
            ans += aa[i];
        }
    }

    println!("{}", ans);
}

//-----

pub mod io {
    use std;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T>(&mut self) -> T
        where
            T: std::str::FromStr,
            <T as std::str::FromStr>::Err: std::fmt::Debug,
        {
            let s = self.iter.next().unwrap();
            s.parse::<T>().unwrap()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 8444
S = input()
N = len(S)
S1 = S[:(N-1)//2]
S2 = S[(N+3)//2-1:]


def isloop(S):
    i = 0
    N = len(S)
    if i == N-1-i:
        return True
    while S[i] == S[N-1-i]:
        i += 1
        if i == N-1-i or i == N-i:
            return True
    return False


if isloop(S) and isloop(S1) and isloop(S2):
    print("Yes")
else:
    print("No")


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

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> ten(n);
    vector<int> bad(n);
    rep(i,n) cin >> ten[i];
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        if(ten[a]>ten[b]){
            bad[b]++;
        }else if(ten[a]<ten[b]){
            bad[a]++;
        }else if(ten[a]==ten[b]){
            bad[a]++;
            bad[b]++;
        }
    }
    for(int i=0;i<n;i++){
        if(bad[i]!=0) ten[i]=0;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(ten[i]>0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4000
#include<iostream>
#include<vector>
using namespace std;
#define NODE_MAX 100001
typedef long long ll;
ll par[NODE_MAX],rk[NODE_MAX],size[NODE_MAX];
void init(){
  for(int i=0;i<NODE_MAX;i++){
    par[i]=i;
    rk[i]=0;
    size[i]=1;
  }
}
int root(int x){
  if(x==par[x]) return x;
  return par[x]=root(par[x]);
}
int r_size(int x){
  return size[root(x)];
}
void unite(int x,int y){
  int sz;
  x = root(x);
  y = root(y);
  sz = r_size(x)+r_size(y);
  size[x]=size[y]=sz;
  if(x==y) return;

  if(rk[x]<rk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rk[x]==rk[y]) rk[x]++;
  }
}
bool same(int x,int y){
  return root(x)==root(y);
}
int main(){
  ll n,m,tmp,num;
  cin >> n >> m;
  ll a[m],b[m],ans[m];
  init();
  for(int i=0;i<m;i++){
    cin >> a[i]>>b[i];
  }
  tmp = ((n-1)*n)/2;
  for(int i=0;i<m;i++){
    if(!same(a[m-1-i],b[m-1-i])){
      tmp -= r_size(a[m-1-i])*r_size(b[m-1-i]);
      unite(a[m-1-i],b[m-1-i]);
    }
    ans[i]=tmp;
  }
  for(int i=m-2;i>=0;i--){
    cout << ans[i]<<endl;
  }
  cout << ((n-1)*n)/2<<endl;
}


Measured memory_bytes: 6016
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static int N;
	static int M;
	static int[] X;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		X = new int[M];
		if (N-1 > M-1) {
			System.out.println(0);
			return;
		}
		// 区間幅の大きい N-1子を削除
		for(int i=0;i<M;i++) {
			X[i] = sc.nextInt();
		}
		Arrays.sort(X);
		int[] band = new int[M-1];
		for(int i=0;i<M-1;i++) {
			band[i] = X[i+1]-X[i];
		}
		Arrays.parallelSort(band);
		int sum = 0;
		for(int i=0;i<M-N;i++) {
			sum += band[i];
		}
		System.out.println(sum);
	}
		
}

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

using mint = modint998244353;
const mint inv9 = mint(1)/9;

struct S {
  mint x, w;
  S(mint x=0, mint w=1):x(x),w(w) {}
};

S op(S a, S b) {
  return S(a.x*b.w + b.x, a.w*b.w);
}
S e() { return S();}

S mapping(int f, S a) {
  if (f == 0) return a;
  return S((a.w-1)*inv9 * f, a.w);
}
int composition(int f, int g) {
  if (f == 0) return g;
  return f;
}
int id() { return 0;}

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

  lazy_segtree<S,op,e,int,mapping,composition,id> t(n);
  rep(i,n) t.set(i, S(1,10));
  rep(qi,q) {
    int l, r, d;
    cin >> l >> r >> d;
    --l;
    t.apply(l,r,d);
    S ans = t.prod(0,n);
    printf("%d\n", ans.x.val());
  }
  return 0;
}

Measured memory_bytes: 9844
while True :
    a, b = map(int, input().split())
    if a == 0 and b == 0 :
        break
    
    cost = b - a
    ans_1000 = cost // 1000
    cost = cost % 1000
    ans_500 = cost // 500
    cost = cost % 500
    ans_100 = cost // 100
    print(ans_100, ans_500, ans_1000)


Measured memory_bytes: 5612
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <cstring>
#define MAX_N 1000 + 16

using namespace std;

int N, H, W;
int X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];
int fld[2 * MAX_N][2 * MAX_N],
    dx[4] = { 1, -1, 0, 0 }, dy[4] = { 0, 0, 1, -1 };

int compress(int *x1, int *x2, int w) {
    vector<double> xs;

    for (int i = 0; i < N; ++i) {
        for (double id = -0.5; id <= 0.5; id += 0.5) {
            double tx1 = x1[i] + id, tx2 = x2[i] + id;
            if (0 <= tx1 && tx1 <= w) xs.push_back(tx1);
            if (0 <= tx2 && tx2 <= w) xs.push_back(tx2);
        }
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    //for (double x : xs) cout << x << "-";cout << endl;
    for (int i = 0; i < N; ++i) {
        x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
        x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
    }//cout<<xs.size()<<"**********"<<endl;
    return xs.size();
}
int main() {
    while (cin >> W >> H, W | H) {
        cin >> N;
        for (int i = 0; i < N; ++i) {
            cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
        }

        memset(fld, 0, sizeof(fld));

        W = compress(X1, X2, W);
        H = compress(Y1, Y2, H);

        for (int i = 0; i < N; ++i) {
            //cout << X1[i] << ends << X2[i] << ends << Y1[i] << ends << Y2[i] << endl;
            for (int j = X1[i]; j <= X2[i]; ++j) {
                for (int k = Y1[i]; k <= Y2[i]; ++k) fld[j][k] = 1;
            }
        }
        //for (int i = 0; i < W; ++i) {for (int j = 0; j < H; ++j)cout << fld[i][j] << ends;cout << endl;}
        int ans = 0;
        //cout << 123 << endl;
        for (int i = 0; i < W; ++i) {
            for (int j = 0; j < H; ++j) {
                if (!fld[i][j]) {
                    fld[i][j] = 1;
                    ++ans;
                    queue<int> q;
                    q.push(i * H + j);
                    while (!q.empty()) {
                        int ii = q.front() / H, jj = q.front() % H;
                        q.pop();
                        for (int k = 0; k < 4; ++k) {
                            int ni = ii + dx[k], nj = jj + dy[k];
                            if (ni >= 0 && ni < W && nj >= 0 && nj < H && !fld[ni][nj]){
                                fld[ni][nj]=1;
                                q.push(ni * H + nj);
                            }
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

int main(){
	long long N, D;
	cin >> N >> D;
	long long X[N], Y[N];
	int ans = 0;
	for(int i=0;i<N;i++){
		cin >> X[i] >> Y[i];
		if(X[i] * X[i] + Y[i] * Y[i] <= D * D)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 6720
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (long long int i = 0; i < (n); i++)
#define rep1(i,n) for (long long int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

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

    if (x < 100) {
        cout << 0 << endl;
        return 0;
    }

    rep1(i,x) {
        if (100 * i <= x && x <= 100 * i + 5 * i) {
            cout << 1 << endl;
            return 0;
        }
    }

    cout << 0 << 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()))

sum = 0
prev = -1010
for i in A:
    sum += B[i-1]
    if prev == i-1:
        sum += C[i-2]
    prev = i
print(sum)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(){
	string word[3];

	cin >> word[0] >> word[1] >> word[2];

	cout << word[0][0] << word[1][1] << word[2][2] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int h, w;
int a[15][15];
int M;

int check(int sx, int sy, int tx, int ty)
{
	int minbd = 10, maxin = 0;
	for(int x = sx; x <= tx; x++){
		for(int y = sy; y <= ty; y++){
			if(x == sx || x == tx || y == sy || y == ty){
				minbd = min(minbd, a[x][y]);
			}
			else{
				maxin = max(maxin, a[x][y]);
			}
		}
	}
	if(minbd <= maxin) return 0;
	return minbd;
}

int calc(int sx, int sy, int tx, int ty, int maxbd)
{
	int ret = 0;
	for(int x = sx+1; x < tx; x++){
		for(int y = sy+1; y < ty; y++){
			ret += maxbd - a[x][y];
		}
	}
	return ret;
}

int main(void)
{
	while(1){
		cin >> h >> w;
		if(h == 0 && w == 0) break;
		for(int y = 1; y <= h; y++){
			for(int x = 1; x <= w; x++){
				cin >> a[x][y];
			}
		}
		
		int ans = 0, bd;
		for(int sx = 1; sx <= w-2; sx++){
			for(int sy = 1; sy <= h-2; sy++){
				for(int tx = 3; tx <= w; tx++){
					for(int ty = 3; ty <= h; ty++){
						if(tx < sx+2 || ty < sy+2) continue;
						if(!(bd = check(sx, sy, tx, ty))) continue;
						ans = max(ans, calc(sx, sy, tx, ty, bd));
					}
				}
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3080
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];
    for(int x = 0; x < N - M + 1; x++) {
        for(int y = 0; y < N - M + 1; y++) {
            int flag = 1;
            for(int i = x; i - x < M; i++) {
                for(int j = y; j - y < M; j++) {
                    if(A[i][j] != B[i - x][j - y])
                        flag = 0;
                }
            }
            if(flag) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main(){
    string s, t;
    
    /* input */
    cin >> s >> t;

    /* sort */
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    /* compare */
    if(s < t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

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

  int A,B,C,D; cin>>A>>B>>C>>D;

  int res = min(B,D)-max(A,C);
  cout << max(0, res) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<list>
#include<climits>
#include<sstream>
#define endl '\n'
#define ll long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define mod 1000000007
#define mod1 998244353
#define PI acos(-1)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    int k;
    cin>>k;
    string str;
    cin>>str;
    if(str.length()>k)
    {
        cout<<str.substr(0,k)<<"...";
    }
    else
    {
        cout<<str;
    }
    
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;

vector<int> G[8];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,M;
    cin>>N>>M;
    rep(i,0,M){
        int a,b;
        cin>>a>>b;
        a--; b--;
        G[a].push_back(b); G[b].push_back(a);
    }
    int x[N];
    rep(i,0,N) x[i]=i;
    int ans=0;
    do{
        bool t=true;
        rep(i,0,N-1){
            if(find(G[x[i]].begin(),G[x[i]].end(), x[i+1])==G[x[i]].end()) t=false;
        }
        if(t) ans++;
    }while(next_permutation(x+1,x+N));
    cout <<ans <<"\n";
}


Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); ++i)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();++i) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();++i) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

const ll MOD = 1000000007;

ll modpow(ll a, ll b){
    if(b == 1) return a;
    if(b&1) return modpow(a, b-1) * a % MOD;
    ll tmp = modpow(a, b/2);
    return tmp*tmp%MOD;
}

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> da(k+1);
    rip(i,k+1,1) da[i] = modpow(k/i, n);
    vector<bool> isPrime(k+1, true);
    rip(i,k+1, 2){
        if(isPrime[i]){
            for(int now = 1;now < k/i+1; ++now){
                isPrime[now*i] = false;
                da[now] -= da[now*i];
            }
        }
    }
    ll ans = 0;
    rip(i,k+1,1){
        ans += (da[i] * i)%MOD;
    }
    cout << (ans%MOD+MOD)%MOD << endl;
}

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

using namespace std;
using i64 = long long int;
using ui64 = unsigned long long int;
using EDGE = vector<int>;
using GRAPH = vector<EDGE>;

////////////////////////////////
template <typename T>
class segtree_min
{
  public:
    vector<T> data;
    int size;
    segtree_min<T>(int size_) : size(1)
    {
        while (size < size_)
            size <<= 1;
        data.assign(size * 2, numeric_limits<T>::max());
    }
    segtree_min<T>(vector<T> &src) : size(1)
    {
        while (size < src.size())
            size <<= 1;
        data.assign(size * 2, numeric_limits<T>::max());
        for (int i = 0; i < src.size(); i++)
        {
            update(i, src[i]);
        }
    };
    void update(int idx, int v)
    {
        int f = idx + size - 1;
        data[f] = v;
        while (f)
        {
            --f /= 2;
            data[f] = min(data[f * 2 + 1], data[f * 2 + 2]);
        }
    }
    T rmin(int l, int r)
    { //return min[l,r)
        int f = l + size - 1;
        int k = 1;
        while (f % 2 && l + k * 2 <= r)
        {
            f /= 2;
            k *= 2;
        }
        if (l + k > r)
            return numeric_limits<T>::max();
        if (l + k == r)
            return data[f];
        else
            return min(data[f], rmin(l + k, r));
    }
    void dump(){
        for(int i=0;i<size*2;i++){
            cout << data[i] << " ";
        }cout << endl;
    }
};

int main()
{
    int n,q;
    cin >> n >> q;
    segtree_min<int> st(n);
    for(int i=0;i<q;i++){
        int c,x,f;
        cin >> c >> x >> f;
        if(c)cout << st.rmin(x,f+1) << endl;
        else st.update(x,f);
    }
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  ll ans = 0;
  for(int bit = 0; bit < (1 << (s.size() - 1)); bit++){
    ll keepa = 0, keep = s[0] - '0';
    for(int i = 0; i < s.size() - 1; i++){
      if(bit & (1 << i)){
        keepa += keep;
        keep = s[i + 1] - '0';
      }
      else{
        keep *= 10;
        keep += s[i + 1] - '0';
      }
    }
    keepa += keep;
    ans += keepa;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int main() {
    string s;
    cin >> s;
    cout << "2018";
    for (int i = 4; i < 10; i++) cout << s[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
// Aizu Vol-2 0286: Computation of Salary
// 2017.8.20 bal4u@uu
// 2017.11.5
// 2018.1.5

#include <stdio.h>

#define MAX 10000
#define MAX2 500000

typedef struct { int n, nxt, end; } WAK;
typedef struct { int nxt, t, e; } LNK;

WAK wak[MAX+5];
LNK lnk[MAX2+5]; int used;
int b[MAX+5];
char buf[100002], *p;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

void pr(int n)
{
	char *q;
	static char tmp[13] = { 0, ' ' };
	q = tmp+1; while (n >= 10) {
		*++q = '0' + (n % 10);
		n /= 10;
	}
	*p++ = n + '0';
	while (*q) *p++ = *q--;
}

int main()
{
	int N, M, L, i, j, k, s, ans;
	WAK *w;

	N = in(), M = in();
	while (1) {
		s = in(), w = wak + s,
		lnk[used].t = in(), lnk[used].e = in();
		if (!s) break;
		if (w->n == 0) w->nxt = used;
		else lnk[w->end].nxt = used;
		w->end = used++, w->n++;
	}
	L = in();
	while (L--) {
		for (i = 1; i <= M; i++) b[i] = in();
		for (p = buf, w = wak+1, i = N; i--; w++) {
			if (w->n == 0) { *p++ = '0', *p++ = ' '; continue; }
			for (ans = 0, k = w->nxt, j = w->n; j--; k = lnk[k].nxt)
				if (b[lnk[k].t]) ans += lnk[k].e * b[lnk[k].t];
			pr(ans);
		}
		*--p = 0, puts(buf);
	}
	return 0;
}



Measured memory_bytes: 2332
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
#include<sstream>
using namespace std;
int  main()
{
    int n;
    bool b;
    int cc;
    string s;
    cin>>n;
    cin>>s;
    int ans=0;
    while(n--)
    {
        string t;
        string k;
        cin>>t;
        int len=t.size();
        for(int i=0;i<len;i++)
        {
            for(int j=1;j<len;j++)
            {
                for(int l=0;l*j+i<len;l++)
                {
                    k+=t[i+j*l];
                    if(k==s)
                    {
                    ans++;
                    goto A;
                    
                    }
                }
                //if(k==s)ans++;
                k.clear();
            }
        }
    A:;
    k.clear();   
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1216
<?php
// 「8 0 4」みたいなの取得
$in = file_get_contents('php://stdin');

// 空白区切りで分割
$inarr = explode(" ", $in);

$n = intval($inarr[0]);
$a = intval($inarr[1]);
$b = intval($inarr[2]);

$abn = intdiv($n, $a + $b);
$cnt = $a * $abn;

$mod = $n - $abn * ($a + $b);
$cnt += min($a, $mod);

echo $cnt . PHP_EOL;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> S;
  ;
}

void solve() {
  int N = S.size();
  vi ans(N + 1, -1);
  rep(i, 0, N - 1) {
    // S[i] .... ans[i], ans[i+1]
    if (S[i] == '<') {
      if (ans[i] == -1) {
        ans[i] = 0;
        ans[i + 1] = 1;
      } else {
        ans[i + 1] = ans[i] + 1;
      }
    }
  }
  // rep(i, 0, N - 1) {
  //   cout << ans[i];
  //   cout << " ";
  //   cout << S[i];
  //   cout << " ";
  // }
  // cout << ans[N] << endl;
  rrep(i, N - 1, 0) {
    // S[i] .... ans[i], ans[i+1]
    if (S[i] == '>') {
      if (ans[i + 1] == -1) {
        ans[i + 1] = 0;
        ans[i] = 1;
      } else {
        chmax(ans[i], ans[i + 1] + 1);
      }
    }
  }
  //  debugv(ans);
  int a = 0;
  // rep(i, 0, N - 1) {
  //   cout << ans[i];
  //   cout << " ";
  //   cout << S[i];
  //   cout << " ";
  // }
  // cout << ans[N] << endl;
  for (auto x : ans) {
    a += x;
  }
  cout << a << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 4740
S= input()

if S[0] != 'A':
    print('WA')
    exit()
if S[2:-1].count('C') !=1:
    print('WA')
    exit()
C_posi = S[2:-1].index('C')+2

SS = S[1:C_posi] + S[C_posi+1:]

if SS.islower() == False:
    print('WA')
    exit()

print('AC')

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

typedef pair<int, int> P;

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a >= b and a >= c)
        print(a * 10 + b + c);
    else if (b >= a and b >= c)
        print(b * 10 + a + c);
    else
        print(c * 10 + a + b);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

class BGreedyTakahashi {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int a,b,k;
	    s3(a,b,k);
	    int eaten = min(a+b,k);
	    int temp =  min(a,eaten);
	    a-=temp;
	    eaten-=temp;
	    b-=eaten;
	    out<<a<<" "<<b<<endl;

	}
};


main() {
	BGreedyTakahashi solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


struct UnionFind{
    // par[i] >= 0 --> 親
    // par[i] < 0  --> size
    // rank --> 深さ
    vector<int> par, rank;
    UnionFind(int n){
        par.resize(n,-1);
        rank.resize(n,0);
    }

    int root(int x){
        if(par[x]<0) return x;
        else return par[x]=root(par[x]);
    }

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

    int size(int x){
        return -par[root(x)];
    }

    void merge(int x,int y){
        x = root(x);
        y = root(y);
        if(x==y) return;
        if(rank[x] < rank[y]) swap(x,y);

        // x <-- y
        par[x]+=par[y]; // fix size
        par[y]=x;
        rank[x]+=(rank[x]==rank[y]);
    }
};

int main(){
    int n,m; cin >> n >> m;
    UnionFind uf(2*n);
    vector<int> p(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
        uf.merge(p[i], i+n);
    }


    rep(i,m){
        int x,y; cin >> x >> y;
        x--; y--;
        uf.merge(x, y);
    }

    int ans = 0;
    rep(i,n){
        if(uf.same(i, i+n)){
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 5044
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int  grid[1001][1001];
ll dp[1001][1001];

int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            char ch;
            cin>>ch;
            if(ch=='.')
            grid[i][j]=1;
            else
            {
                grid[i][j]=0;
            }
            
        }
    }
    
    dp[0][0]=1;
    for(int i=1;i<m;i++){
        if(grid[0][i]==1)
        dp[0][i]=dp[0][i-1];
        else{
            dp[0][i]=0;
        }
    }
    for(int i=1;i<n;i++){
        if(grid[i][0]==1){
            dp[i][0]=dp[i-1][0];
        }else{
            dp[i][0]=0;
        }
    }
    ll mod=1000000007;
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(grid[i][j]==1){
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
            
        }
    }
    cout<<dp[n-1][m-1]<<endl;


}

Measured memory_bytes: 12032
#include <stdio.h>

int main(void) {

    int a, b, c;

    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: 2068
#include<bits/stdc++.h>
const int MAXN=4200000;
using namespace std;

void mainp()
{
    int n;
    cin>>n;
    int ans=1e9;
    for(int i=1; i<n; i++)
    {
		int a=i, b=n-i, temp=0;
		while(a) temp+=a%10, a/=10;
		while(b) temp+=b%10, b/=10;
		ans=min(ans, temp);
	}
	cout<<ans<<endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mainp();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using graph = vector<vector<int>>;
using wgraph = vector<vector<pair<int, lint>>>;
const lint INF = 1001001001001001LL;
const lint MOD = 1000000007LL;
const double PI = 3.1415926535897932;
int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
void possible(){ cout << "possible" << endl; }
void Possible(){ cout << "Possible" << endl; }
void POSSIBLE(){ cout << "POSSIBLE" << endl; }
void impossible(){ cout << "impossible" << endl; }
void Impossible(){ cout << "Impossible" << endl; }
void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()


int main(){
  
  lint n; cin >> n;
  vector<lint> a(n);
  lint cntNeg = 0;
  rep(i, n){
    cin >> a[i];
    if(a[i] < 0) cntNeg++;
    a[i] = (lint)abs(a[i]);
  }

  cntNeg %= 2;
  lint ans = 0;
  sort(rall(a));
  rep(i, n - cntNeg){
    ans += (lint)abs(a[i]);
  }
  if(cntNeg == 1) ans -= a[n - 1];
  cout << ans << endl;
  return 0;
}


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

int a,b,q,pt1,pt2,pt3;
long long x,ans,s[100010],t[100010];

int main()
{
	scanf("%d %d %d",&a,&b,&q);
	s[0]=-5e10;for (int i=1;i<=a;i++) scanf("%lld",&s[i]);s[a+1]=5e10;
	t[0]=-5e10;for (int i=1;i<=b;i++) scanf("%lld",&t[i]);t[b+1]=5e10;
	while (q--)
	{
		scanf("%lld",&x);ans=~(1LL<<63);
		pt1=lower_bound(s+1,s+a+1,x)-s;
		pt2=lower_bound(t+1,t+b+1,s[pt1])-t;
		pt3=lower_bound(t+1,t+b+1,s[pt1-1])-t;
		ans=min(ans,s[pt1]-x+min(t[pt2]-s[pt1],s[pt1]-t[pt2-1]));
		ans=min(ans,x-s[pt1-1]+min(t[pt3]-s[pt1-1],s[pt1-1]-t[pt3-1]));
		pt1=lower_bound(t+1,t+b+1,x)-t;
		pt2=lower_bound(s+1,s+a+1,t[pt1])-s;
		pt3=lower_bound(s+1,s+a+1,t[pt1-1])-s;
		ans=min(ans,t[pt1]-x+min(s[pt2]-t[pt1],t[pt1]-s[pt2-1]));
		ans=min(ans,x-t[pt1-1]+min(s[pt3]-t[pt1-1],t[pt1-1]-s[pt3-1]));
		printf("%lld\n",ans);
	}
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

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

int main(void)
{
    vector<int> num(3);
    rep(i, 3)
    {
        cin >> num[i];
    }
    sort(all(num));
    cout << (num[1] - num[0]) + (num[2] - num[1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a[4];
	while(1){
    	for(int i = 0; i < 4; ++i){
        	scanf("%d", &a[i]);
    	}
        if(a[0] == 0){ break; }
        
		for(int i = 0; i < 110000; ++i) putchar('(');
		printf("%d+%d+%d+%d", a[0], a[1], a[2], a[3]);
//		for(int i = 0; i < 110000; ++i) putchar(')');
		putchar('\n');
	}
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
// O(sqrt(N))

int main() {
	int n = ri();
	int m = sqrt(n);
	auto calc = [&] (int n) { // sum [1, n]
		return (int64_t) n * (n + 1) / 2;
	};
	int64_t res = 0;
	for (int i = 1; i <= m; i++) res += i * calc(n / i);
	for (int i = 1; i <= m; i++) res += (calc(n / i) - calc(std::max(m, n / (i + 1)))) * calc(i);
	printf("%" PRId64 "\n", res);
	return 0;
}


Measured memory_bytes: 3744
a, b = map(int, input().split())
if a == b:
    print('Draw')
    exit()
if a < b:
    if a == 1 and b == 13:
        print('Alice')
        exit()
    else:
        print('Bob')
        exit()
if b == 1 and a == 13:
    print('Bob')
    exit()
print('Alice')


Measured memory_bytes: 2940