akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector < vector < char > > array;
    array = vector < vector<char> > (2*N,vector<char>(2*N,0));
    for (int i = 0; i < N;i++) {
        for (int j = 0; j < N;j++) {
            cin >> array[i][j];
            array[i + N][j] = array[i][j];
            array[i][j + N] = array[i][j];
            array[i + N][j + N] = array[i][j];
        }
    }



    int count = 0;
    for (int i = 0; i < N; i++)
    {
        int found = 0;
        for (int row = 0; row < N; row++)
        {
            for (int col = row + 1; col < N; col++)
            {
                //cout << array[row][col + i] << array[col][row + i] << endl;
                if (array[row][col + i] != array[col][row + i])
                {
                    found = 1;
                    break;
                }
            }
            if (found == 1){
                break;
            }
        }
        if (found == 0){
            count += 1;
        }
    }
    cout << count * N << endl;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int a, b;
	cin >> a >> b;
	if(a < b)
		rep(i, b)
			cout << a;
	else
		rep(i, a)
			cout << b;
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if(a.equals(b)){
            System.out.println('H');
        }else{
            System.out.println('D');
        }
    }
}

Measured memory_bytes: 20820
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long 
using namespace std;

signed main() {
	int N;
	cin >> N;
	bool answer = true;
	int time = 0;
	int P = 0;
	int Q = 0;
	for(int i = 0;i < N;i++) {
		int A,B,C;
		cin >> A >> B >> C;
		if(abs(B - P) + abs(C - Q) > A - time) {
			answer = false;
			break;
		}
		else if((abs(B - P) + abs(C - Q)) % 2 != (A - time) % 2) {
			answer = false;
			break;
		} 
		else {
			time = A;
			P = B;
			Q = C;
		}
	}
	if(answer == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int P = scanner.nextInt();
        int Q = scanner.nextInt();
        int R = scanner.nextInt();

        int max = Math.max(Math.max(P, Q), R);

        System.out.println(P + Q + R - max);


    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;

const int mx=200010;
const ll mod=1e9+7;

int n, a[100010], b[100010];
ll ans = 0;

int main() {
  cin >> n;
  for(int i=0; i<n+1; i++){ 
    cin >> a[i];
  }
  for(int i=0; i<n; i++){ 
    cin >> b[i];
  }
  
  for(int t,i=0; i<n; i++){ 
    t = min(b[i],a[i]+a[i+1]);
    ans += t;
    a[i+1] -= t - min(b[i],a[i]);
  }
  
  cout << ans << endl;
  return 0;
}  


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b==c||a+c==b||b+c==a){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

bool ok(int cnt[20])
{
	for(int i = 0; i < 20; i++){
		if(cnt[i] > 1) return false;
	}
	return true;
}

int bit[200001][20] = {};

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		long long int a;
		cin >> a;
		for(int j = 19; j >= 0; j--){
			long long int tmp = (long long int)1 << j;
			if(a >= tmp){
				a -= tmp;
				bit[i][j] = 1;
			}
		}
	}
	int cnt[20] = {};
	long long int ans = 0;
	int r = 0;
	for(int l = 0; l < n; l++){
		while(r < n){
			for(int i = 0; i < 20; i++){
				cnt[i] += bit[r][i];
			}
			if(!ok(cnt)){
				for(int i = 0; i < 20; i++){
					cnt[i] -= bit[r][i];
				}
				break;
			}
			r++;
		}
		for(int i = 0; i < 20; i++){
			cnt[i] -= bit[l][i];
		}
		if(r == n && !ok(cnt)) continue;
		ans += r - l;
	}
	cout << ans << endl;
}

Measured memory_bytes: 15872
def main():
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))
    ans = 0
    for _ in range(N):
        A = list(map(int, input().split()))
        tmp = C
        for i in range(M):
            tmp += A[i] * B[i]
        if tmp > 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
n = int(input())
ls = []
for i in range(n):
    c,p = input().split()
    p = int(p)
    ls.append((c,p))
order = [i for i in range(n)]
order.sort(key = lambda x:(ls[x][0],-ls[x][1]))
for i in range(n):
    print(order[i]+1)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
int a[100000],b[100000],c[100000];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n;i++)scanf("%d",&b[i]);
    for(int i=0;i<n;i++)scanf("%d",&c[i]);
    std::sort(a,a+n);
    std::sort(b,b+n);
    std::sort(c,c+n);
    int ai=0,ci=0;
    long long sum=0;
    for(int bi=0;bi<n;bi++){
        while(ai<n&&a[ai]<b[bi])ai++;
        while(ci<n&&c[ci]<=b[bi])ci++;
        sum+=(long long)ai*(n-ci);
    }
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
using ll = long long;
using P = pair<ll, ll>;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void fail() {
    cout << -1 << endl;
    exit(0);
}

ll digit_sum(ll n){
    if(n < 10) return n;
    return digit_sum(n/10) + n%10;
}

int main(){
    ll n;
    cin >> n;
    ll ans = infll;
    for(ll a=1; a < n; a++){
        ll b = n - a;
        chmin(ans, digit_sum(a) + digit_sum(b));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int H, W;
  cin >> H >> W;
  int A[26][26] = {};
  for(int i = 1; i <= H; i++) {
    for(int j = 1; j <= W; j++) {
      int a;
      cin >> a; 
      A[i][j] = a; 
    }
  }

  int minTotal = INF;
  for(int m = 1; m <= H; m++) {
    for(int n = 1; n <= W; n++) {
      int total = 0;
      for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
          int moyori = min(abs(i - m), abs(j - n));
          total = total + (moyori * A[i][j]);
        }
      }
      minTotal = min(total, minTotal);
    }
  }

  cout << minTotal << endl;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define INF (1e18)

int main(){   
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string S[310];
    cin >> N;
    rep(i,0,N) cin >> S[i];
    ll ans = 0;
    rep(i,0,N){
        bool ok = true;
        char s2[310][310];
        rep(j,0,N){
            rep(k,0,N){
                s2[j][k] = S[j][(k-i+N)%N];
            }
        }
        rep(j,0,N){
            rep(k,0,N){
                if(s2[j][k] != s2[k][j]) ok = false;
            }
        }
        if(ok) ans += N - i;
    }
    rep(i,1,N){
        bool ok = true;
        char s2[310][310];
        rep(j,0,N){
            rep(k,0,N){
                s2[j][k] = S[(j-i+N)%N][k];
            }
        }
        rep(j,0,N){
            rep(k,0,N){
                if(s2[j][k] != s2[k][j]) ok = false;
            }
        }
        if(ok) ans += N - i;
    }
    print(ans);
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7


int main() {
  str s;
  cin>>s;
  ll count=0;
  FOR(i,0,3){
    FOR(j,i+1,4){
      if(s[i]==s[j]){
        count++;
      }
       // co(count);
    }
  }
  if(count==2){
    co("Yes");
  }
  else{
    co("No");
  }
}
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <math.h>
#include <iomanip>

typedef long long ll;
using namespace std;

int main(){
    string s;
    cin >> s;
    string ret = "Good";
    for(int i=1; i<4; ++i){
        if(s[i] == s[i-1]) ret = "Bad";
    }
    cout << ret << endl;
    return 0;
}


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

typedef long long int   ll;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 1e5 + 10;
const ll MOD  = 1e9 + 7;
const ll INF  = 1e18;

int n, k, A[N], H[N], ans;
vector<int> adj[N];

int DFS(int u) {
    int res = 0;
    for (int v : adj[u]) {
        H[v] = H[u] + 1;
        res = max(res, 1 + DFS(v));
    }
    if (H[u] > 1 && res == k - 1) {
        ans++;
        res = -1;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n >> k >> A[1];
    ans = (A[1] != 1);
    for (int i = 2; i <= n; i++) {
        cin >> A[i];
        adj[A[i]].push_back(i);
    }
    DFS(1);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int n,x,y,sum;

int sg(int x,int k){
	for (;x%k;x-=x/k+1){
		if (x<k) return 0;
		int i=x/k;
		x-=(x-k*i)/(i+1)*(i+1);
		if (x%k==0) break;
		
	}
	return x/k;
}

int main(){
	scanf("%d",&n);
	sum=0;
	for (int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		sum^=sg(x,y);
	}
	if (sum) puts("Takahashi");
	else puts("Aoki");
		
	return 0;
}
			

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    s, t = rl()
    a = [s[i]+t[i] for i in range(len(s))]
    print("".join(a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;

class HomeWork
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        int days = int.Parse(input[0]);

        var homework = Console.ReadLine().Split(' ');

        for(var i = 0; i < int.Parse(input[1]); i++)
        {
            days -= int.Parse(homework[i]);

            if(days <= -1)
            {
                days = -1;
                break;
            }
        }

        Console.WriteLine(days);
    }
}

Measured memory_bytes: 19216
quiznum=int(input())
timeline=input().split(" ")
timeline=[int(n) for n in timeline]
#print(timeline)
time_0=0
for i in range(quiznum):
    time_0+=timeline[i]
#print(time_0)

medinum=int(input())
for i in range(medinum):
    temp_line=input().split(" ")
    a=int(temp_line[0])
    b=int(temp_line[1])
    time=time_0 - timeline[a-1] + b
    print(time)

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

int main(){
  int N;
  cin >> N;
  string S[N];
  map<string, int> mp{};
  for(int i=0;i<N;i++){
    cin >> S[i];
    mp[S[i]]++;
  }
  int M;
  cin >> M;
  string T[M];
  for(int i=0;i<M;i++){
    cin >> T[i];
    mp[T[i]]--;
  }
  int ans = 0;
  for(pair<string, int> p : mp){
    ans = max(ans, p.second);
  }
  cout << ans << endl;
}

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

using namespace std;

const int maxN = 1005;
const int maxM = 1e5 + 5;
int s[maxN * 2][maxN * 2], N, K;

int calc(int x1, int y1, int x2, int y2) {
	//cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
	x2 = min(x2, 2 * K); y2 = min(y2, 2 * K);
	x1 = max(x1, 1); y1 = max(y1, 1);
	//	cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
	if(x1 > x2 || y1 > y2) return 0;
	//int ans = 0;
	//for(int i = x1; i <= x2; ++i)
	//for(int j = y1; j <= y2; ++j) ans += s[i][j];
	//return ans;
	//	cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
	return s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1];
}

int calc(int x, int y) {
	return calc(x, y, x + K - 1, y + K - 1);
}

int main() {
	//freopen("in.txt", "r", stdin);
	scanf("%d%d", &N, &K);
	int maxx = 0;
	bool flag = 0;
	for(int i = 1; i <= N; ++i) {
		int x, y; string c;
		cin >> x >> y >> c;
		if(i == 1 && x == 10898) flag = 1;
		maxx = max(maxx, max(x, y));
		//cout << x << ' ' << y << "%%%%%%%%%%%" << endl;
		if(c[0] == 'B') x += K;
		//cout << x << ' ' << y << "&&&&" << endl;
		x = x % (2 * K);
		y = y % (2 * K);
		//cout << x << ' ' << y << "*****" << endl;
		if(x == 0) x += (2 * K); if(y == 0) y += (2 * K);
		//cout << x << ' ' << y << endl;
		s[x][y]++;
		//cout << i << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55" << endl;
	}	
	//cout << maxx << endl;
	//for(int i = 1; i <= 2 * K; ++i) {
	//		for(int j = 1; j <= 2 * K; ++j) cout << s[i][j] << ' ';
	//		cout << endl;
	//}
	for(int i = 1; i <= 2 * K; ++i) {
		for(int j = 1; j <= 2 * K; ++j) s[i][j] += s[i][j - 1];
		for(int j = 1; j <= 2 * K; ++j) s[i][j] += s[i - 1][j];
	}
	int ans = 0;
	for(int i = 1; i <= 2 * K; ++i) {
		for(int j = 1; j <= 2 * K; ++j) {
			int t = 0;
			for(int i_ = -2; i_ <= 2; ++i_)
			for(int j_ = -2; j_ <= 2; ++j_) {
				if((i_ + j_) % 2 != 0) continue;
				t += calc(i_ * K + i, j_ * K + j);
			}
			//cout << t << endl;
			ans = max(ans, t);
			//ans = max(ans, calc(i, j) + calc(i + K, j + K) + calc(i - K, j - K) + calc(i + K, j - K) + calc(i - K, j + K));
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 16000
#include <stdio.h>
#include <string.h>
#include <math.h>

#define max 2

int* sortMaxmin(int*, int);
int* sortMinmax(int*, int);

int main()
{
    int m1, m2, d1, d2, ans;
    
    scanf("%d %d %d %d", &m1, &d1, &m2, &d2);
    
    if(m1+1==m2)
        ans=1;
    else
        ans=0;
    
    printf("%d", ans);
    
    return 0;
}

int* sortMaxmin(int *a, int b)
{
    int i, j, tmp;
    for(i=0; i<b; i++){
        for (j=i+1; j<b; j++) {
            if(a[i]>a[j]){
                tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    return a;
}

int* sortMinmax(int *a, int b)
{
    int i, j, tmp;
    for(i=0; i<b; i++){
        for (j=i+1; j<b; j++) {
            if(a[i]<a[j]){
                tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    return a;
}



Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
def nap(N,goods):
    dp=[-1*float('inf')]*(N+1)
    dp[0]=0
    for i in range(N):
        for w,v in goods:
            if i+w<=N:
                dp[i+w]=max(dp[i+w],dp[i]+v)
    return max([dp[i]+N-i for i in range(N+1)])
goods1=[(a,b) for a,b in zip(A,B) if a<b]
goods2=[(b,a) for a,b in zip(A,B) if a>b]
if len(goods1)>0:
    N=nap(N,[(a,b) for a,b in zip(A,B)])
if len(goods2)==0:
    print(N)
elif len(goods2)==1:
    print(N%goods2[0][0]+(N//goods2[0][0])*goods2[0][1])
elif len(goods2)==3:
    print(nap(N,goods2))
else:
    a,b,c,d=goods2[0][0],goods2[0][1],goods2[1][0],goods2[1][1]
    if (b-a)/a<(d-c)/c:
        a,b,c,d=c,d,a,b
    elif (b-a)/a==(d-c)/c and a>c:
        a,b,c,d=c,d,a,b
    bord=(N//a)*b+((N%a)//c)*d+(N%a)%c
    x=N//a
    ans=bord
    for i in range(1,1+x):
        now=(x-i)*b+((N-(x-i)*a)//c)*d+(N-(x-i)*a)%c
        if now+d<ans:
            break
        else:
            ans=max(ans,now)
    print(ans)

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    vector<ll> v(1,100);
    for(int i = 1;; ++i) {
        ll y = v.back();
        if(y>1'000'000'000'000'000'000LL) break;
        y *= 1.01;
        v.push_back(y);
    }
    ll x; cin >> x;
    cout << (lower_bound(ALL(v),x) - v.begin()) << endl;
    return 0;
}


Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    //int t = Integer.parseInt(sl[1]);

//    for(int i = 0; i < n; i++)
//    {
//      s = r.readLine();
//      sl = s.split(" ");
//      time[i] = Integer.parseInt(sl[0]);
//      deli[i] = Integer.parseInt(sl[1]);
//    }
//
//    int dp[][] = new int[3001][3001];
//
//    for(int i = 1; i <= t; i++)
//    {
//      dp[i][0] = deli[0];
//    }
//
//    for(int j = 0; j <= n; j++)
//    {
//      for(int i = time[j]; i <= t; i++)
//      {
//          dp[i][j] = Math.max(dp[i - time[j]][j - 1] + deli[j], dp[i - 1][j]);
//      }
//    }

    for(int i = 0; i < 50000; i++)
    {
      if((int)Math.floor(i * 1.08) == n)
      {
        System.out.println(i);
        System.exit(0);
      }
    }
    System.out.println(":(");
  }

}




class RemRing
{
 long module;
 public RemRing(long module)
 {
   this.module = module;
 }

 public long sum(long a, long b)
 {
   return (a + b + module) % module;
 }

 public long sub(long a, long b)
 {
   return (a - b + module) % module;
 }

 public long prod(long a, long b)
 {
   return (a * b) % module;
 }

 public long div(long a, long b)
 {
   return (a * inv(b)) % module;
 }

 public long inv(long a)
 {
   long b = this.module;
   long u = 1;
   long v = 0;
   while(b > 0)
   {
     long t = a / b;
     a -= t * b;
     u -= t * v;
     long z = a;
     a = b;
     b = z;
     z = u;
     u = v;
     v = z;
   }
   u %= this.module;
   if(u < 0) u += this.module;
   return u;
 }
}


Measured memory_bytes: 24780
#include <stdio.h>
int dp[101][10001];
int max(int a,int b){
  if(a<b)return b;
  else return a;
}
int main(){
  int i,j;
  int N,W;
  int w[1001];
  int v[1001];
  scanf("%d %d",&N,&W);
  for(i=1;i<=N;i++)scanf("%d %d",&v[i],&w[i]);
  for(i=0;i<=W;i++)dp[0][i]=0;
  for(i=1;i<=N;i++){
    for(j=0;j<=W;j++){
      if(w[i]>j)dp[i][j]=dp[i-1][j];
      else dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
    }
  }
  printf("%d\n",dp[N][W]);
  return 0;
}

Measured memory_bytes: 4544
s = int(input())


def f(n):
  if n%2==0:
    return n//2
  else:
    return 3*n+1

A = [s]
while True:
  a = f(A[-1])
  if a in A:
    ans = len(A) + 1
    break
  else:
    A.append(a)

# /print(A)
print(ans)



Measured memory_bytes: 9168
// -YDK- {{{
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <numeric>
#include <string>
#include <cstdio>
#include <vector>
#include <tuple>
#include <cmath>
#include <queue>
#include <regex>
#include <set>
#include <map>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
#define debug(...) fprintf(stderr, __VA_ARGS__ )
#define outl(x) cout << (x) << '\n'
#define outl2(x,y) cout << (x) << ' ' << (y) << '\n'
#define endl '\n'
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define ALL(x) x.begin(), x.end()
#define YES(f,y,n) cout << ((f)? (#y):(#n)) << '\n'
#define ODD(n) ((n)&1)
#define EVEN(n) (!ODD(n))
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
template<class T>using MaxHeap = priority_queue< T, vector<T>, greater<T> >;
using ll = long long;
using pii = pair<int, int>;
using byte= unsigned char;
inline bool inside(int x, int y, int W, int H) { return x>=0 && y>=0 && x<W && y<H; }
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};
struct Point: public pii {
    int &x = this->first,   &y = this->second;
    Point(int x, int y): pii(x, y) {}
};
// }}}
constexpr int LIM = (int)1e5 + 5;

signed main(void)
{
    cin.tie(nullptr), ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    outl2(a*b, 2*(a+b));

    return 0;
}




Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll MOD = 1e9 + 7;

ll modpow(ll a, ll b, ll m) {
  if (b == 0) return 1;
  ll ret;
  if (b % 2 == 0) {
    ll t = modpow(a, b / 2, m) % m;
    ret = t * t % m;
  } else {
    ll t = modpow(a, (b - 1) / 2, m) % m;
    ret = a * t % m * t % m;
  }
  ret %= m;
  return ret;
}

int main() {
  ll n;
  cin >> n;
  ll m = 60;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  // k bit 目の1の数
  vector<ll> cnt(m, 0);
  REP(i, n) {
    REP(j, m) {
      if ((1LL << j) & a[i]) cnt[j]++;
    }
  }

  ll ans = 0;
  REP(i, m) {
    ll k = modpow(2, i, MOD);
    (ans += ((k * cnt[i]) % MOD * (n - cnt[i])) % MOD) %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>

int main(){

    int a ,e;
    int sum = 0;
    std::cin >> a;

    int b = a / 100;
    int c = (a - b * 100) / 10;
    int d = a - b * 100 - c * 10;

    int masu[3] = {b ,c ,d};

    for(e = 0; e < 3; e++){
        if(masu[e] == 1){
            sum++;
        }
    }

    std::cout << sum << "\n";

    return 0;

}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    string s;
    cin>>s;
    string ans = "Good";
    for(int i=0; i<3; i++){
        if(s[i]==s[i+1]){
            ans="Bad";
        }
    }
    cout<<ans<<endl;
}


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

int main(){
  string s;
  cin >> s;
  vector<int> count(10);
  int ans = 0;
  for(int i = 0; i < s.size(); i++){
    int pre = 0;
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C'){
      pre++;
      for(int j = 1; j < s.size(); j++){
        if(s[i+j] == 'A' || s[i+j] == 'T' || s[i+j] == 'G' || s[i+j] == 'C'){
          pre++;
        }else{
          break;
        }
      }
    }
    ans = max(ans, pre);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
	
def main():
	K = int(input())
	tmp = 0
	tmp2 = K // 2
	if K % 2 == 1:
		tmp = K // 2 + 1
	else:
		tmp = K // 2
	print(tmp * tmp2)
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
// #include <local_debug.hpp>

using i64 = long long;

const int MAXN = 100005;
int fa[MAXN], id[MAXN];

int find(int x) {
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}

int main() {
    int n;
    scanf("%d", &n);
    std::iota(fa, fa + n, 0);
    std::iota(id, id + n, 0);

    std::vector<std::pair<int, int>> points;
    for (int i = 0, x, y; i < n; i++) {
        scanf("%d%d", &x, &y);
        points.emplace_back(x, y);
    }
    std::vector<std::tuple<int, int, int>> edges;

    for (int o = 0; o < 2; o++) {
        std::sort(id, id + n, [&](int x, int y) {
            return points[x].first < points[y].first;
        });

        for (int i = 1, u, v, w; i < n; i++) {
            u = id[i], v = id[i - 1];
            w = points[id[i]].first - points[id[i - 1]].first;
            edges.emplace_back(w, u, v);
        }
        for (int i = 0; i < n; i++) {
            std::swap(points[i].first, points[i].second);
        }
    }
    // debug(edges);
    std::sort(edges.begin(), edges.end());
    i64 ans = 0;
    int cnt = 0;
    for (auto& e : edges) {
        static int u, v, w;
        std::tie(w, u, v) = e;
        if (find(u) == find(v)) {
            continue;
        }
        ans += w;
        fa[find(u)] = find(v);
        if (++cnt == n - 1) {
            break;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 7152
#include <iostream>
#include <vector>
#include <algorithm>
#define pii pair<int, int>
#define fst first
#define snd second
#define pub push_back
#define vi vector<int>
#define ll long long

const ll MX = 1e18;

using namespace std;

int main()
{
	ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; long long cr = 1;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		long long x; cin >> x;
		if (x == 0) {cr = 0;}
		else if (cr <= MX / x && cr > -1) {cr *= x;}
		else {cr = -1;}
	}
	cout << cr << "\n";
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <sstream>
#include <queue>

using namespace std;

double const DOUBLE_MAX = 10000000;

double DP[12][10000];

// ?????????????????????????????§????????£???????????????
vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
	
    while(getline(ss, buffer, sep)){
        v.push_back(buffer);
    }
	
    return v;
}

long long int int_str(string str){
	long long int num = 0;
	bool minus = false;
	if(str[0] == '-'){
		str = str.substr(1);
		minus = true;
	}
	for(int i = 0; i < str.size(); i++){
		num *= 10;
		num += (str[i] - '0');
	}
	if(minus){
		num = -num;
	}
	return num;
}

int main(){
	
	while(true){
		
		int w_max;
		
		cin >> w_max;
		
		if(cin.eof()){
			break;
		}
		
		cin.ignore();
		
		string str;
		
		getline(cin, str);
		
		vector<string> v_str = split(str, ' ');
		
		vector<int> v_num;
		
		for(int i = 0; i < v_str.size(); i++){
			v_num.push_back(int_str(v_str[i]));
		}
		
		double cost[15][15];
		
		int n = v_num.size();
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cost[i][j] = sqrt((double)((v_num[i] + v_num[j]) * (v_num[i] + v_num[j]) - (v_num[i] - v_num[j]) * (v_num[i] - v_num[j])));
			}
		}
		
		for(int i = 0; i < 12; i++){
			for(int j = 0; j < 10000; j++){
				DP[i][j] = DOUBLE_MAX;
			}
		}
		
		for(int i = 0; i < (1 << n); i++){
			int hoge = i;
			int comp = 1;
			for(int j = 0; j < n; j++){
				if(hoge % 2 == 1){
					if(i - comp == 0){
						DP[j][i] = v_num[j];
					}else{
						int hoge2 = i - comp;
						for(int k = 0; k < n; k++){
							if(hoge2 % 2 == 1){
								DP[j][i] = min(DP[j][i], DP[k][i - comp] + cost[j][k]);
							}
							hoge2 /= 2;
						}
					}
				}
				hoge /= 2;
				comp *= 2;
			}
		}
		
		bool flag = false;
		
		for(int j = 0; j < n; j++){
			if(w_max >= DP[j][(1 << n) - 1] + v_num[j]){
				flag = true;
			}
		}
		
		if(flag){
			cout << "OK" << endl;
		}else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4056
#include <stdio.h>

int main(){

  int a,b,num,ans;

  while(scanf("%d %d",&a,&b)!=EOF){
    num=a+b;
    ans=0;
    while(num!=0){
      num/=10;
      ans++;
    }
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 600
#include <bits/stdc++.h>
#define fi first
#define se second
#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 rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define all(c) begin(c),end(c)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
 
 
 
 
int main() {
  string s;
  cin>>s;
  rep(i,sz(s)){
    int j=i+1;

  //奇数文字目のとき
    if(j%2==1){
      if(s[i]=='L'){
        cout<<"No";
        return 0;
      }
    }else{//偶数文字目のとき
      if(s[i]=='R'){
        cout<<"No";
        return 0;
      }
    }
  }
  cout<<"Yes";
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
 
int main(){
  int n;
  cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int dp[100100];
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  for(int i=1;i<n-1;i++){
    dp[i+1]=min(dp[i]+abs(h[i]-h[i+1]),dp[i-1]+abs(h[i-1]-h[i+1]));
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
    string s;
    int q;
    cin >> s >> q;
    string s1;
    for (int i = 0; i < q; i++)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            swap(s, s1);
        }
        else
        {
            int f;
            string c;
            cin >> f >> c;
            if (f == 1)
            {
                s1 = s1 + c;
            }
            else
            {
                s = s + c;
            }
        }
    }
    reverse(s1.begin(), s1.end());
    cout << s1 + s << endl;
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

	int N; cin >> N;
	vector<ld> A(N); rep(i,N) cin >> A[i];

	ld bunbo = 0;
	rep(i,N) bunbo += 1.0 / A[i];
	ld ans = 1.0 / bunbo;
	cout << fixed << setprecision(10) << ans << endl;
	return 0;

    
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;

const ll INF = 1e9+5;
const ll MOD = 1e9+7;

int main() {
	int a, b, c;
	cin >>a>>b>>c;
	int k;
	cin >>k;
	for (int i=0 ; i<k ; i++) {
		if (a>=b) b*=2;
		else if (b>=c) c*=2;
	}
	if (b>a and c>b) cout <<"Yes\n";
	else cout <<"No\n";
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
const ll INF=1LL << 60;
const ll MOD=1e9+7;

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*c, max(a*d, max(b*c, b*d))) << endl;

  return 0;
}

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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

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

    const int MOD = 1000000007;
    vector<long long> ex(N+1, 0); // exp[p] := p の指数
    for (long long n = 2; n <= N; ++n) {
        const auto &res = prime_factorize(n); // n の素因数分解
        for (auto p : res) ex[p.first] += p.second;
    }
    long long res = 1;
    for (int p = 2; p <= N; ++p) {
        res *= ex[p] + 1; // 約数の個数は (exp + 1) の積
        res %= MOD;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
c={}
while 1:
    try:
        a,b=input().split()
        if a in c.keys():c[a].append(int(b))
        else: c[a]=[int(b)]
    except:
        for i,j in sorted(c.items()):
            print(i)
            print(' '.join(map(str,sorted(j))))
        break

Measured memory_bytes: 7588
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
template<class T>
class UnionFind
{
private:
	vector<T> parentNo;
	vector<T> parentRank;
	vector<T> parentSize;

public:
	// コンストラクタ
	UnionFind(int n) 
	{
		parentNo.resize(n);
		parentRank.resize(n, 0);
		parentSize.resize(n, 1);
		for (int i = 0; i < n; i++) {
			// 始めは全部ROOT
			parentNo[i] = i;
		}
	}

	int root(T x) 
	{
		if (parentNo[x] == x) {
			return x;
		} else {
			T rootParentNo = root(parentNo[x]);
			parentNo[x] = rootParentNo;
			return rootParentNo;
		}
	}

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

	int size(T x) 
	{
		return parentSize[root(x)];
	}

	void unite(T xc, T yc) 
	{
		T xr = root(xc);
		T yr = root(yc);
		if (xr == yr) {
			return;
		}
		if (parentRank[xr] < parentRank[yr]) {
			parentNo[xr] = yr;
			parentSize[yr] += parentSize[xr];
		} else {
			parentNo[yr] = xr;
			parentSize[xr] += parentSize[yr];
			if (parentRank[xr] == parentRank[yr]) {
				parentRank[xr]++;
			}
		}
	}
};


int main()
{
	vector<int> p;
	int N, M;

	cin >> N >> M;
	REP(i, N) {
		int a;
		cin >> a;
		a--;
		p.emplace_back(a);
	}

	UnionFind<int> uTree(N + 1);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		uTree.unite(a, b);
	}

	int ans = 0;
	REP(i, N) {
		if (uTree.same(i, p[i])) {
			ans++;
		}
	}

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


Measured memory_bytes: 1912
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)
int n,m;
int p[11];
vector<int> v[11];

int can(int x){
  r(i,m){
    int cur=0;
    r(j,v[i].size()){
      cur+=(x&(1<<v[i][j]))>0;
    }
    if(cur%2 != p[i]%2) return 0;
  }
  return 1;
}


int main(){
  cin>>n>>m;
  r(i,m){
    int x;
    cin>>x;
    while(x--){
      int y;
      cin>>y;
      v[i].push_back(y-1);
    }
  }

  r(i,m)cin>>p[i];
    int ans=0;

    r(i,1<<n){
      ans +=can(i);
    }

    cout<<ans<<endl;

  
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    xy = [LI() for _ in range(N)]

    x = [(xy[i][0],i) for i in range(N)]
    y = [(xy[i][1],i) for i in range(N)]

    x.sort()
    y.sort()

    edge = []
    p,i = x[0]
    for q,j in x[1:]:
        edge.append((q-p,i,j))
        p,i = q,j

    p,i = y[0]
    for q,j in y[1:]:
        edge.append((q-p,i,j))
        p,i = q,j

    edge.sort()

    g = [i for i in range(N + 1)]
    g_num = [1 for i in range(N + 1)]

    def find(x):
        if g[x] == x: return x
        g[x] = find(g[x])
        return g[x]

    def union(x, y):
        if find(x) == find(y): return
        if g_num[g[x]] < g_num[g[y]]: x, y = y, x
        g_num[g[x]] += g_num[g[y]]
        g_num[g[y]] = 0
        g[g[y]] = g[x]

    ans = 0
    for v,i,j in edge:
        if find(i) != find(j):
            ans += v
            union(i,j)

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 137812
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

int main(){
  int A, B, C, ans;

  cin >> A >> B >> C;

  if( A == max({A, B, C}) ){
      ans = 10*A;
      ans += B + C;
  }else if(B == max({A, B, C}) ){
      ans = 10*B;
      ans += A + C;
  }else{
      ans = 10*C;
      ans += A + B;
  }
  

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int s[100010];
bool f[100010];
int ans;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)s[i]=1;
	f[1]=true;
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		s[x]--;
		s[y]++;
		if(f[x])
		{
			f[y]=true;
			if(!s[x])
			{
				f[x]=false;
			}
		}
	}
	for(int i=1;i<=n;i++)ans+=f[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;


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

    vector<int> d(n);
    for (int i=0 ; i<n; i++)
    {
        cin >> d.at(i);
    }
    
    sort(d.begin(),d.end());
    /*昇順*/
    cout << d.at(n/2)-d.at(n/2-1) << endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

vector<int>v[300000];
int main(){
	int h,w,n;scanf("%d%d%d",&h,&w,&n);
	int Min=h;
	rep(i,n){
		int x,y;scanf("%d%d",&x,&y);
		v[y].push_back(x);
	}
	for(int i=1;i<=w;i++){
		sort(v[i].begin(),v[i].end());
		v[i].push_back(h+1);
	}
	int tim=1;
	for(int i=1;i<=w;i++){
		int it=lower_bound(v[i].begin(),v[i].end(),tim)-v[i].begin();
		Min=min(Min,v[i][it]-1);
		if(i==w)break;
		do{
			tim++;
		}while(*lower_bound(v[i+1].begin(),v[i+1].end(),tim)==tim&&tim<=h);
		if(tim>h)break;
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 13696
#include "bits/stdc++.h"
using namespace std;
 
int n,t,c[100],x,mn=1001;
int main(){

	cin>>n>>t;
	for(int i=0;i<n;i++){
		cin>>c[i]>>x;
		if(x <= t && c[i] < mn)
			mn = c[i];
	}
	if(mn <= 1000)
		cout<<mn;
	else
		cout<<"TLE";
	return 0;
}

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

void dfs(long long now, long long previous, std::vector<std::vector<long long> >& tree, std::vector<long long>& cost, std::vector<bool>& visit)
{
	visit.at(now) = true;
	if (previous >= 0)
		cost.at(now) += cost.at(previous);
	for (int i = 0; i < tree.at(now).size(); i++)
	{
		long long next = tree.at(now).at(i);
		if (visit.at(next) == false)
		{
			dfs(next, now, tree, cost, visit);
		}
	}
	
}


int main()
{
	long long n, q;
	std::cin >> n >> q;
	std::vector<std::vector<long long> > tree(n);
	std::vector<long long> counter(n , 0);
	for (int i = 0; i < n - 1; i++)
	{
		long long a, b;
		std::cin >> a >> b;
		a--;
		b--;
		tree.at(a).push_back(b);
		tree.at(b).push_back(a);
	}
	std::vector<long long> cost(n, 0);
	std::vector<bool> visit(n, false);
	for (int i = 0; i < q; i++)
	{
		long long a, b;
		std::cin >> a >> b;
		a--;
		cost.at(a) += b;
	}

	dfs(0, -1, tree, cost, visit);
	for (int i = 0; i < n; i++)
	{
		std::cout << cost.at(i) << ' ';	
	}
	std::cout << '\n';
}

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

int main(){
    int n, count=1;
    cin >> n;
    vector<int> d(n);
    for (int i=0; i<n; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    for (int i=1; i<n; i++) {
        if (d.at(i-1)!=d.at(i)) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256