akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int mod=1e9+7;
int dp[1<<15],G[20][20];
int s1[20],s2[20],t1,t2;
int Pw[20*20],C[20][20];
int main(){
	int n=read(),m=read();
	REP(i,1,m){
		int x=read(),y=read();
		G[x][y]=1;
	}
	Pw[0]=1;
	REP(i,1,n*n) Pw[i]=(Pw[i-1]<<1)%mod;
	C[0][0]=1;
	REP(i,1,n){
		C[i][i]=C[i][0]=1;
		REP(j,1,i-1) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	dp[0]=1;
	REP(i,1,(1<<n)-1){
		for(int j=i;j;j=(j-1)&i){
			int k=(i^j);
			if((j&3)!=3 && (j&3)!=0) continue;
			if((k&3)!=3 && (k&3)!=0) continue;
			t1=t2=0;
			REP(l,0,n-1) if(j&(1<<l)) s1[++t1]=l+1;
			REP(l,0,n-1) if(k&(1<<l)) s2[++t2]=l+1;
			int num=0;
			REP(l1,1,t1) REP(l2,1,t2) num+=G[s1[l1]][s2[l2]];
			int res=Pw[num];
			REP(l1,1,t2){
				num=0;
				REP(l2,1,t1) num+=G[s2[l1]][s1[l2]];
				res=(ll)res*(Pw[num]-1)%mod;
			}
			dp[i]=(dp[i]+(ll)res*dp[k])%mod;
		}
	}
//	cerr<<dp[(1<<n)-1]<<endl;
	printf("%d\n",(Pw[m]-dp[(1<<n)-1]+mod)%mod);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void preParse(int u) {
    if ( u == NIL ) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u) {
    if ( u == NIL ) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

void postParse(int u) {
    if ( u == NIL ) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main() {
    int i, v, l, r, root;
    
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
        T[i].p = NIL;
    }
    
    //親、左右の子の情報を構造体として保存
    for ( i = 0; i < n; i++ ) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if ( l != NIL ) T[l].p = v;
        if ( r != NIL ) T[r].p = v;
    }
    
    //根の節点番号を保存
    for ( i = 0; i < n; i++ ) if ( T[i].p == NIL ) root = i;
    
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2736
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())

ans = 10 ** 15
div_list = make_divisors(n)
for temp in div_list:
    temp2 = n//temp
    ans = min( temp + temp2 - 2 ,ans    )
print(ans)

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

main() {
  int H, W; cin >> H >> W;
  int N; cin >> N;
  vi a(N); rep(i, N) cin >> a[i];
  vi b = a;
  vvi c(H, vi(W));
  int pos = 0;
  rep(i, H) {
    rep(j, W) {
      if (b[pos] == 0) pos++;
      if (i % 2 == 0) {
        c[i][j] = pos + 1;
      } else {
        c[i][W - j - 1] = pos + 1;
      }
      b[pos]--;
    }

    cout << c[i][0];
    rep(j, W - 1) {
      cout << " " << c[i][j + 1];
    }
    cout << endl;
  }
}

Measured memory_bytes: 384
def main():
    n,k=map(int,input().split())
    h=list(map(int,input().split()))
    dp=[0]*n

    for i in range(1,n):
        dp[i] = min([dp[j] + abs(h[i]-h[j]) for j in range(max(0,i-k),i)])
    print(dp[n-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int k,a,b; cin >> k >> a >> b;
    int x = (a+k-1)/k*k;;
    if (x <= b) cout << "OK";
    else cout<< "NG";
    return 0;
}


Measured memory_bytes: 3708
//AtCoder Grand Contest 017 E - Jigsaw

#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

int qr(){int ret = 0,f=1;char ch =getchar();while(!isdigit(ch))f=ch=='-'?-1:1,ch=getchar();while(isdigit(ch))ret=ret*10+ch-'0',ch=getchar();return ret*f;}

#define maxN 100005
#define maxH 205

int indegree[maxH<<2],outdegree[maxH<<2];
int active[maxH<<2];
void read(int x,int y){
    indegree[y]++;
    outdegree[x]++;
}
int f[maxH<<1],pd[maxH<<1];
int gf(int x){
    if(f[x] == x) return x;
    else return f[x] = gf(f[x]);
}
int main(){
    int N = qr(),H = qr();
    for(int i = 0;i<=(H<<1);i++)
        f[i] = i;
    int t1,t2,t3,t4,t5,t6;//上 t + maxN 下 t + maxN + maxH
    for(int i = 1;i<=N;i++){
        t1 = qr(),t2 = qr(),t3 = qr(),t4 = qr();
        if(!t3) t5 = t1;else t5 = -t3;
        if(!t4) t6 = -t2;else t6 = t4;
        t5 += H,t6 += H;
        active[t5] = active[t6] = 1;
        indegree[t6]++;outdegree[t5]++;
        f[gf(t5)] = gf(t6);
    }
    int mark=1;
    for(int i = 0;i<=H;i++){
        if(indegree[i]<outdegree[i])
            mark=0;
    }
    for(int i = H+1;i<=(H<<1);++i){
        if(indegree[i]>outdegree[i])
            mark=0;
    }
    for(int i = 0;i<=(H<<1);i++){
        pd[gf(i)] |= (indegree[i] != outdegree[i]);
    }
    pd[H] = 1;
    for(int i = 1;i<=(H<<1);i++){
        if(active[i] && !pd[gf(i)])
            mark=0;
    }
    if(mark)
        cout << "YES";
    else cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

VI flag(100000, 0);

int main() {
	int n, m; CI n >> m;
	VI L(m), R(m);
	REP(i, m) {
		CI L[i] >> R[i];
	}

	sort(all(L), greater<int>());
	sort(all(R));

	if (R[0] - L[0] < 0) CO 0 EN;
	else CO R[0] - L[0] + 1 EN;

	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(void)
{
	int n,c,box[10],i,j;
	while(1){
	scanf("%d",&n);
	if(n==0){
		break;
	}
	for(i=0;i<10;i++){
		box[i]=0;
	}
	for(i=0;i<n;i++){
		scanf("%d",&c);
		box[c]++;
	}
	for(i=0;i<10;i++){
		if(box[i]==0){
			printf("-\n");
		}
	    else{
		    for(j=1;j<=box[i];j++){
			    printf("*");
		    }
		     printf("\n");
		}
	}
	}
	return 0;
}


Measured memory_bytes: 2040
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

// a/n <= x となるnのmin
ll calc(ll a, double x)
{
  ll n = ceil(a / x);
  return n;
}

void solve()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  auto simulate = [&](double x) {
    ll cnt = 0;
    rep(i, n)
    {
      cnt += (ll)ceil(a[i] / x) - 1;
    }
    return cnt <= k;
  };

  double lo = 0, hi = 2e9;
  rep(ti, 300)
  {
    double mi = (lo + hi) / 2.0;
    if (simulate(mi))
      hi = mi;
    else
      lo = mi;
  }
  cout << (ll)ceil(hi) << "\n";
}

int main()
{
  init_main();
  solve();
}


Measured memory_bytes: 4772
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String a = stdIn.next();
		
		if (a.charAt(0) == a.charAt(2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

typedef vector<ll> vec;
typedef vector<vec> mat;

ll M;

mat mul (mat &A, mat &B) {
    mat C(A.size(), vec(B[0].size()));
    Rep (i, A.size()) {
        Rep (k, B.size()){
            Rep (j, B[0].size()) {
                C[i][j] = (C[i][j] + (A[i][k] * B[k][j]) % M) % M;
            }
        }
    }
    return C;
}

mat matpow(mat A, ll n) {
    mat B(A.size(), vec(A.size()));
    Rep (i, A.size()) {
        B[i][i] = 1;
    }
    while (n > 0) {
        if (n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

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

    ll L, A, B;
    cin >> L >> A >> B >> M;

    vector<ll> d(19, 0);
    for (ll i = 1; i <= 18; i++) {
        d[i] = min(((ll)pow(10, i) - A + B - 1) / B, L);
        d[i] = max((ll)0, d[i]);
    }

    for (ll i = 18; i >= 1; i--) {
        d[i] -= d[i-1];
    }

    // for (ll e : d) cout << e << "\n";

    ll X = 0, s = A % M;
    for (ll i = 1; i <= 18; i++) {
        // cout << i << "\n";
        mat a(3, vec(3)), b(3, vec(1));
        a[0][0] = (ll)pow(10, i) % M, a[0][1] = 1, a[0][2] = 0;
        a[1][0] = 0, a[1][1] = 1, a[1][2] = B % M;
        a[2][0] = 0, a[2][1] = 0, a[2][2] = 1;
        b[0][0] = X % M, b[1][0] = s % M, b[2][0] = 1;
        a = matpow(a, d[i]);
        b = mul(a, b);
        X = b[0][0];
        s = b[1][0];
        // cout << X << "\n";
    }

    cout << X << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;

	return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i = 1, n = 0;
		try (Scanner sc = new Scanner(System.in)) {
			while (true) {
				n = sc.nextInt();
				if(n == 0) {
					break;
				}
				System.out.println("Case " + i + ": " + n);
				i++;
			}
		}
	}
}



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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int MAX = 5e5 + 5;


struct Query
{
	int l, r, idx;
};

int bit[MAX], arr[MAX], ans[MAX];
Query queries[MAX];

bool cmp(Query x, Query y)
{
	return x.r < y.r;
}

void update(int idx, int val, int n)
{
	for (; idx <= n; idx += idx & -idx)
		bit[idx] += val;
}

int query(int idx, int n)
{
	int sum = 0;
	for (; idx > 0; idx -= idx & -idx)
		sum += bit[idx];
	return sum;
}

void answeringQueries(int n, int q)
{
	int bit[n + 1];
	memset(bit, 0, sizeof(bit));
	int last_visit[MAX];
	memset(last_visit, -1, sizeof(last_visit));

	int ans[q];
	int query_counter = 0;
	for (int i = 0; i < n; i++)
	{
		if (last_visit[arr[i]] != -1)
			update (last_visit[arr[i]] + 1, -1, n);
		last_visit[arr[i]] = i;
		update(i + 1, 1, n);
		while (query_counter < q && queries[query_counter].r == i)
		{
			ans[queries[query_counter].idx] =
			    query(queries[query_counter].r + 1, n) -
			    query(queries[query_counter].l, n);
			query_counter++;
		}

	}

	// print answer for each query
	for (int i = 0; i < q; i++)
		cout << ans[i] << endl;
}

int32_t main()
{
	GO;
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	for (int i = 0; i < q; i++) {
		cin >> queries[i].l >> queries[i].r;
		queries[i].l--; queries[i].r--;
		queries[i].idx = i;
	}

	sort(queries, queries + q, cmp);
	answeringQueries(n, q);
	return 0;
}

//!

Measured memory_bytes: 35092
#include <bits/stdc++.h>
using namespace std;
int a[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
int b,c;

int main(){
  cin>>b>>c;
  if(a[b] == a[c]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 384
// In the name of Allah the Lord of the Worlds.

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

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

    int n , x , tot = 1 , now = 0;
    cin >> n >> x;
    for(int i=0;i<n;i++){
        int in;
        cin >> in;
        now+=in;
        if(now<=x)tot++;

    }
    cout << tot << endl;

    return 0;
}


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

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

        int ma=0, sum=0;

        while(n--)
        {
                int a, b;
                cin >> a >> b;

                if(ma<a)
                {
                        ma=a;
                        sum=ma+b;
                }
        }

        cout << sum << endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

vector<ll> V;

int main(){
    ll N,x,c=0;
    ll A[107];
    cin >> N >> x;
    rep(i,N){
        cin >> A[i];
    }
    sort(A,A+N);
    ll i=0;
    rep(i,N){
        if(x>=A[i]){
            x-=A[i];
            c++;
        }
        else{
            break;
        }
        if(i==N-1 && x==0){
            break;
        }
        else if(i==N-1){
            c--;
            break;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H[301],W[301],i=1,n,j,k;
	scanf("%d %d",&H[i],&W[i]);
	while(H[i]!=0&&W[i]!=0){
		i++;
		scanf("%d %d",&H[i],&W[i]);
	}
	n=i-1;
	for(i=1;i<=n;i++){
		for(j=1;j<=H[i];j++){
			for(k=1;k<=W[i];k++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


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

int main() {
	int N; cin >> N;
	int a=N;
	int b=0;
	while(a!=0){
	    b += a%10;
	    a /= 10;
	}
	if(N%b) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
import math

#x = int(input())
#a = int(input())
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
#a,b = list(map(int,input().split(" ")))
#a,b,c = list(input().split())
string = input()

if string[0] == string[1] == string[2] or  string[1] == string[2] == string[3]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 2940
#include<stdio.h>

int main(void)
{
	int a, b, i;
	int acont = 0, bcont = 0;
	
	for(i = 0; i < 4; i++){
		scanf("%d",&a);
		acont += a;
	}
	for(i = 0; i < 4; i++){
		scanf("%d",&b);
		bcont += b;
	}
	if(acont > bcont){
		printf("%d\n",acont);
	}
	else{
		printf("%d\n",bcont);
	}
	
	return 0;
}

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

int main(int argc, char *argv[])
{
	int a, b, c;
	vector<int> target;
	cin >> a >> b >> c;
	target.push_back(a);
	target.push_back(b);
	target.push_back(c);

	sort(target.begin(), target.end());

	cout << (target[1] - target[0]) + (target[2] - target[1]);

	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
*x,=map(int,input().split())
*y,=map(int,input().split())
mod=10**9+7
vx,vy=0,0
for i in range(n):
  vx+=(i*x[i]-(n-i-1)*x[i])
for j in range(m):
  vy+=(j*y[j]-(m-j-1)*y[j])
print(vx*vy%mod)

Measured memory_bytes: 18624
#整数nを入力
n = int(input())
#10で割った余りで一の位を判定
if n%10 == 0 or n%10 == 1 or n%10 == 6 or n%10 == 8:
  print('pon')
elif n%10 == 3:
  print('bon')
else:
  print('hon')

Measured memory_bytes: 9172
#include<stdio.h>

unsigned long powi(unsigned long n, unsigned long m){
        if(m == 0) return 1;
        else {
                unsigned long buff = powi(n, m/2);
                return buff*buff*( m%2 == 0 ? 1 : n );
        }
}

int main(){
        unsigned long N, K;
        
        scanf("%lu %lu", &N, &K);

        printf("%lu\n", K*powi(K-1, N-1));

        return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
a = [int(n) - 1 for n in input().split()]  # indexに合うように調整する
v = [-1] * n  # 到達してるかどうかを格納するリスト

D = [0]  # Dは循環するもののindexを格納する
v[0] = 0  # 初期スタート位置の到達ステータスは0

cur = a[0]  # 初期位置はindex=0
i = 1

while v[cur] == -1:
    D.append(cur)
    v[cur] = i # 到達済みに変更(iは何番目に到達したか）
    if k == i:  # 循環が発生する前にkの上限に達してしまった場合
        print(cur + 1)
        exit()

    i += 1
    cur = a[cur]

# 循環している場合を考える
k -= v[cur]  # 1回目の到達点を引く
k %= (i - v[cur])  # kを循環する回数で割った余りを考える = 循環した中でどれかという事が分かる

print(D[v[cur] + k] + 1)  # v[cur]で循環しない部分を表し、kで循環した中でどこかを表す

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

// ABC118B - Foods Loved by Everyone
// https://atcoder.jp/contests/abc118/tasks/abc118_b
void ABC118B() {
	int N, M;
	cin >> N >> M;

	vector<int> K(N);
	vector<vector<int>> A(N, vector<int>());

	for (int i = 0; i < N; i++)
	{
		cin >> K[i];
		vector<int> tmp(K[i]);
		for (int j = 0; j < K[i]; j++)
		{
			cin >> tmp[j];
		}

		A[i] = tmp;
	}

	
	//全員が好きなメニューを探す
	vector<int> like(31); //メニューの配列 添字がメニューの番号
	for (int i = 0; i < N; i++)
	{
		//i番目の人が好きなメニューがあれば、配列[メニュー番号]をインクリメント
		for (int j = 0; j < K[i]; j++)
		{
			int index = A[i][j]; //メニュー番号を取得
			like[index]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < 31; i++)
	{
		if (like[i] == N) { //全員が好きなメニューは値がN
			ans++;
		}
	}

	cout << ans << endl;
}

int main() {
	ABC118B();

	return 0;
}


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

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


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int n;
    cin >>n;
    vector<int> a(4,0);
    rep(i,n){
        string s;
        cin>>s;
        if(s=="AC")a[0]++;
        if(s=="WA")a[1]++;
        if(s=="TLE")a[2]++;
        if(s=="RE")a[3]++;
    }


    cout<<"AC"<<" "<<"x"<<" "<<a[0]<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<a[1]<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<a[2]<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<a[3]<<endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

V dist;
using Graph = vector<vector<int>>;
Graph G;
void dfs(int u, int p=-1) {
  if (p == -1) dist[u] = 0;
  else dist[u] = dist[p] + 1;
  for (auto v : G[u]) {
    if (v == p) continue;
    dfs(v, u);
  }
}

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

  G = Graph(N);
  for (int i = 0; i < N-1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dist = V(N, INF);
  dfs(0, -1);

  int i = max_element(all(dist)) -dist.begin();
  dist = V(N, INF);
  dfs(i, -1);
  int diam = *max_element(all(dist));

  if (diam % 3 != 1) cout << "First" << endl;
  else cout << "Second" << endl;
  return 0;
}


Measured memory_bytes: 21760
#include <bits/stdc++.h>
using namespace std;
const int CUBE = 100005, MAXN = 100005;
typedef long long int LL;

bool isComp[CUBE]; int pcnt, n, ord[MAXN];
LL a[MAXN], p1[CUBE], p2[CUBE], p3[CUBE], reci[MAXN], val[MAXN];

inline bool cmp(const int &u, const int &v){
	return a[u] < a[v];
}
int main(){
	int i, j, ans = 0; LL mx = 0LL, c, d, t;
	scanf("%d", &n);
	for(i = 1; i <= n; ++ i){
		scanf("%lld", &a[i]);
		if(a[i] > mx) mx = a[i];
		reci[i] = 1;
	}
	for(c = 1; LL(c) * c * c <= mx; ++ c) ;
	for(i = 2; i < c; ++ i){
		if(!isComp[i]) p1[++ pcnt] = i;
		for(j = 1; i * p1[j] < c; ++ j)
			isComp[i * p1[j]] = true;
	}
	for(i = 1; i <= pcnt; ++ i){
		p2[i] = p1[i] * p1[i];
		p3[i] = p2[i] * p1[i];
	}
	for(i = 1; i <= n; ++ i){
		for(j = 1, t = a[i]; j <= pcnt && t >= p3[j]; ++ j){
			while(t % p3[j] == 0)
				t /= p3[j], a[i] /= p3[j];
			if(t % p2[j] == 0)
				t /= p2[j], reci[i] *= p1[j];
			else if(t % p1[j] == 0)
				t /= p1[j], reci[i] *= p2[j];
		} d = int(sqrt(double(t)) + 1e-5);
		if(d * d == t) reci[i] *= d;
		else reci[i] *= t * t;
		ord[i] = i;
	} sort(ord + 1, ord + 1 + n, cmp);
	for(i = 1; i <= n; ++ i) val[i] = a[ord[i]];
	ans = int(val[1] == 1LL) * 2;
	for(i = 1; i <= n && val[i] == 1; ++ i) ;
	for(; i <= n; i = j){
		for(j = i; val[i] == val[j]; ++ j) ;
		t = upper_bound(val + 1, val + 1 + n, reci[ord[i]]) - lower_bound(val + 1, val + 1 + n, reci[ord[i]]);
		if(t) ans += max(LL(j - i), t);
		else ans += (j - i) * 2;
	} printf("%d\n", ans / 2);
	return 0;
}

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

int main() {
  int N,minn=1000;
  cin >> N;
  for(int i=0;i<N;i++) {
    int sum=0,A;
    cin >> A;
    while(A>0) {
      if(A%2==0) {
	    A/=2;
	    sum++;
      }
      else break;
    }
    if(minn>sum) minn=sum;
  }
  cout << minn << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string.h>

using namespace std;
 
int main(){
  int N;
  int ju = 0;
  cin >> N;
  
  for(int i = 1;i <= 9;i++){
    if(N % i == 0 && N / i <= 9){
      ju = 1;
    }
  }
  
  if(ju == 1)
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////




int main() {

	ll N;
	cin >> N;
	vector<ll> a(N + 1);
	repn(i, N) {
		cin >> a[i];
	}

	vector<ll> b(9,0);

	repn(i, N) {
		b[min(a[i] / 400, 8)]++;
	}

	ll mx = 0;
	ll mn = 0;

	rep(i, 8) {
		if (b[i] >= 1) { mx++; mn++; }
	}

	mx += b[8];
	mn = max(mn, 1);

	cout << mn << " " << mx;


	system("PAUSE");
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < N; i++)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
using ll = long long;

int main() {
  int A, B;
  cin >> A >> B;

  int ans = 0;
  FOR(i, A, B) {
    string str = to_string(i);
    // auto s = set<char>();
    // s.insert(str[i]);
    bool p = true;
    int len = str.size();
    for (int j = 0; j < len / 2; j++) {
      if (str[j] != str[len - j - 1]) {
        p = false;
        break;
      }
    }
    if (p) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

vector<char> str;

void dfs(int idx, int used, int N) {
    if (idx == N) {
        for(auto ch: str) cout << ch;
        cout << endl;
        return;
    }
    REP(i, used + 1) {
        str[idx] = 'a' + i;
        dfs(idx + 1, max(used, i + 1), N);
    }
}


int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    str.resize(N);

    dfs(0, 0, N);

    return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n,q,s,t;
  ll a[SIZE];
  ll dif[SIZE];
  
  scanf("%d%d%d%d",&n,&q,&s,&t);

  for(int i=0;i<n+1;i++){
    scanf("%lld",a+i);
  }

  for(int j=1;j<n+1;j++){
    dif[j] = a[j] - a[j-1];
  }

  ll temp = 0;

  t *= -1;
  s *= -1;
  
  for(int i=1;i<n+1;i++){
    if(dif[i] < 0){
      temp += t * dif[i];
    }else{
      temp += s * dif[i];
    }
  }
  
  for(int i=0;i<q;i++){
    int r,l,x;

    scanf("%d%d%d",&l,&r,&x);
    r += 1;

    if(r <= n){
      if(dif[r] < 0){
        temp -= t * dif[r];
      }else{
        temp -= s * dif[r];
      }
    }
    
    if(dif[l] < 0){
      temp -= t * dif[l];
    }else{
      temp -= s * dif[l];
    }

    dif[r] -= x;
    dif[l] += x;

    if(r <= n){
      if(dif[r] < 0){
        temp += t * dif[r];
      }else{
        temp += s * dif[r];
      }
    }
    
    if(dif[l] < 0){
      temp += t * dif[l];
    }else{
      temp += s * dif[l];
    } 

    printf("%lld\n",temp);
  }
  
  
  return 0;
}

Measured memory_bytes: 6340
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
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 sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int keta(int n) {
	int k = 0;
	for (int i = n; i > 0; i /= 10)++k;
	return k;
}

string re2(char c, int n) {
	string ret; ret.assign(n, c);
	return ret;
}

int re(int n) {
	int NxN = n * n;
	string s = re2('0', 8 - keta(NxN)) + to_string(NxN);
	string r = s.substr(2, 4);
	return stoi(r);
}

int main() {
	int n; cin >> n;
	rep(i, n) {
		int x; cin >> x;
		cout << "Case " << i + 1 << ":\n";
		rep(loop, 10) {
			x = re(x);
			Cout(x);
		}
	}
}


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

int main() {
	int d = 0, n = 0;
	cin >> d >> n;
	if (n == 100) {
		if (d == 0) {
			printf("101\n");
		}
		else if (d == 1) {
			printf("10100\n");
		}
		else {
			printf("1010000\n");
		}
	}
	else if (d == 0) {
		printf("%d\n", n);
	}
	else if (d == 1) {
		printf("%d\n", n * 100);
	}
	else {
		printf("%d\n", n * 10000);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

ll func(ll b, ll m){
  if(m < b){
    return m;
  } else{
    return func(b, m / b) + (m % b);
  }
}

int main(){
  ll n, s;
  cin >> n >> s;

  if(n < s){
    cout << -1 << endl;
    return 0;
  } else if(n == s){
    cout << n + 1 << endl;
    return 0;
  }

  ll sqn = 1;
  while(sqn * sqn < n) sqn++;

  rep2(b, 2, sqn + 1){
    if(func(b, n) == s){
      cout << b << endl;
      return 0;
    }
  }

  rep_inv(a1, sqn, 0){
    if((n - s) % a1 != 0) continue;
    
    ll b = (n - s) / a1 + 1;
    if(func(b, n) == s){
      cout << b << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}

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

int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H == 0 && W ==0){
            break;
        }
        else{
            for(int i = 0;i < H;i++){
                for(int j = 0;j < W;j++){
                    if(i % 2 == 0){
                        if(j % 2 == 0){
                            cout << "#";
                        }
                        else if(j % 2 == 1){
                            cout << ".";
                        }
                    }
                    else if(i % 2 == 1){
                        if(j % 2 == 0){
                            cout << ".";
                        }
                        else if(j % 2 == 1){
                            cout << "#";
                        }
                    }
                }
                cout << "" << endl;
            }
            cout << "" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3104
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
LL mypow(LL x,LL y){
    x%=MOD;
    LL res=1%MOD;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
LL inv(LL x){
    return mypow(x,MOD-2);
}
LL dp[SIZE];
int main(){
    MOD=998244353;
    int N,s;
    R(N,s);
    dp[0]=mypow(2,N);
    LL mul=inv(2);
    REP(i,N){
        int x;
        R(x);
        for(int j=s-x;j>=0;j--){
            ADD(dp[j+x],dp[j]*mul);
        }
    }
    W(dp[s]);
    return 0;
}


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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9)+7>;

const int MAXN = 1.1e5;
int N;
vector<int> pos[MAXN];
num fact[MAXN];
num ifact[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i <= N; i++) {
		int a; cin >> a; a--;
		pos[a].push_back(i);
	}
	fact[0] = 1;
	for (int i = 1; i <= N+1; i++) fact[i] = fact[i-1] * num(i);
	ifact[N+1] = fact[N+1].inv();
	for (int i = N+1; i >= 1; i--) ifact[i-1] = ifact[i] * num(i);
	auto choose = [&](int n, int r) -> num {
		if (0 <= r && r <= n) return fact[n] * ifact[r] * ifact[n-r];
		else return 0;
	};

	vector<int> vals = *max_element(pos, pos+N, [&](const vector<int>& a, const vector<int>& b) { return a.size() < b.size(); });
	int rem = N+1-(vals[1] - vals[0] + 1);
	for (int k = 1; k <= N+1; k++) {
		cout << choose(N+1, k) - choose(rem, k-1) << '\n';
	}

	return 0;
}


Measured memory_bytes: 7808
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
ll n;
vector<ll>a;
void input(){
    cin>>n;
    scan(n,a);
}
void src(){
    int ans=0;
    rep(i,n){
        if(a[a[i]-1]-1==i) ans++;
    }
    cout<<ans/2;
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n;
int main(){
    cin>>n;
    vector<int> t(n);
    vector<string> s(n);
    int sum=0;
    rep(i,n){cin>>s.at(i)>>t.at(i);sum+=t.at(i);}
    string x;
    cin>>x;
    int i=0;
    int ans=0;
    while(s.at(i)!=x){
        ans+=t.at(i);
        i++;
    }
    cout<<sum-ans-t.at(i)<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int a, b;
   cin >> a >> b;
   int ans;
   if (a >= 13) {
      ans = b;
   } else if (a >= 6) {
      ans = b / 2;
   } else {
      ans = 0;
   }
   cout << ans << endl;
   return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int n;
vector<ll> v;

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

	cin>>n;
	REP(i,n) {
		ll a;cin>>a;
		v.pb(a);
	}
	sort(ALL(v));
	int cnt=1;
	ll sum=v[0];
	FOR(i,1,n) {
		if(v[i]<=sum*2) cnt++,sum+=v[i];
		else cnt=1,sum+=v[i];
	}
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    ll a, b;
    cin >> a >> b;
    if(a > 0 && b > 0){
        cout << "Positive" << endl;
    }else if(a < 0 && b < 0){
        if((b-a)%2 == 1){
            cout << "Positive" << endl;
        }else{
            cout << "Negative" << endl;
        }
    }else{
        cout << "Zero" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
cn=1
while True:
	try:
		if cn ==1:
			n = int(input())
			cn+=1
		if cn ==2:
			nums = input().split()
		
		nums = list(map(int, nums))
		nums.reverse()
		l = ''
		for x in nums:
			l+= ' {}'.format(x)
		print(l[1:])
		
	except EOFError:
		break


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

 long long modpow(long long n, long long k,long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    int n;cin >> n;
    int cnt = 0;
    for(int a = 1;a<n;a++){
        for(int b = 1;b<n;b++){
            if(a*b<n) cnt++;
            else break;
        }
    }
    cout << cnt;
}

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

Measured memory_bytes: 3576
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!

    var max = 0
    var cnt = 0
    for (i in 0 until N) {
        if (S[i] == 'I') {
            cnt++
            max = Math.max(max, cnt)
        } else {
            cnt--
        }
    }
    println(max)
}



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

int main() {
   int N;
   cin >> N;
   vector<int> A(N);
   for(int &x : A){
       cin >> x;
   }
   reverse(A.begin(), A.end());
   for(int i; i<N; i++){
       cout << A.at(i);
       if(i<N-1) cout << " ";
   }
   cout << endl;
    return 0;
}




Measured memory_bytes: 3096
K = int(input())
word_dic = {"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9,"j":10}
l_word = ["a","b","c","d","e","f","g","h","i","j"]
L = ["a"]
if K == 1:
  print("a")
else:
  for i in range(K-1):
    M = []
    for x in L:
      k_x = 0
      for y in list(x):
        if k_x < word_dic[y]:
          k_x = word_dic[y]
      for j in range(k_x+1):
        M.append(x + l_word[j])
    L = M[:]
  else:
    for x in L:
      print(x)

Measured memory_bytes: 13896
using System;
 
 
namespace Application{
   class Program{
    
    
        public static void Main(string[] args){
             
            string line = Console.ReadLine();
            string[] vals = line.Split(' ');
            int a = int.Parse(vals[0]);
            int b = int.Parse(vals[1]);
             
            Console.WriteLine(a*b + " " + (a*2+b*2));
        }   
   }
}

Measured memory_bytes: 9092
from sys import stdin, setrecursionlimit


def main():
    n, m = map(int, stdin.readline().split())
    sc = [list(map(int, stdin.readline().split())) for _ in range(m)]

    ans = [-1] * n

    for s, c in sc:
        if ans[s - 1] == -1:
            ans[s - 1] = c
        elif ans[s - 1] != c:
            print(-1)
            exit()

    for i in range(n):
        if i == 0 and ans[i] == -1 and n > 1:
            ans[i] = 1
        elif i == 0 and ans[i] == 0 and n > 1:
            print(-1)
            exit()
        elif ans[i] == -1:
            ans[i] = 0
        ans[i] = str(ans[i])

    print(''.join(ans))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Measured memory_bytes: 38256
#include<stdio.h> 
int main(void) 
{ 
int a,b;
    scanf("%d %d\n",&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: 584