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

using namespace std;

int main(){
    int H, W;
    string str;

    while(1) {
        cin >> H; cin >> W;
        if(0 == H && 0 == W) { break; }

		for(int i = 0; i < H; ++i){
            for(int j = 0; j < W; ++j){
                if(0 == i % 2){
                    str = (0 == j % 2) ? "#": ".";
                    cout << str;
                }
				else{
                    str = (0 == j % 2) ? "." : "#";
                    cout << str;
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3144
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int N, M;
    cin >> N >> M;
    vector< vector<int> > nexts(N+1);
    vector<int> boards(N+1, -1);

    FOR(i, 1, M+1) {
        int room1, room2;
        cin >> room1;
        cin >> room2;
        nexts[room1].push_back(room2);
        nexts[room2].push_back(room1);
    }

    queue<int> que;
    que.push(1);
    while(!que.empty()) {
        int prev = que.front();
        que.pop();
        
        for (auto next = nexts[prev].begin(); next != nexts[prev].end(); next++) {
            if (boards[*next] != -1) {
                continue;
            }
            boards[*next] = prev;
            que.push(*next);
        }
    }

    FOR(i, 2, N+1) { 
        if (boards[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    FOR(i, 2, N+1) { 
        cout << boards[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 9768
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
#define mod2 20071027
#define mod 1000074259
#define base 139
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define tc(c) printf("Case %lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=500010;
ll n,k;
string s;
vector<ll>res;

int main()
{
    in2(n,k);
    cin>>s;
    reverse(s.begin(),s.end());
    ll sz=s.length(), i=1, j=0,baki=0;///j is landing
    while(j<sz-1)
    {
//        cout<<"i "<<i<<" j "<<j<<" baki "<<baki<<endl;
        ll last = j;
        for(ll cnt=0;cnt<k-baki && i<sz;cnt++,i++)
        {
            if(s[i]=='0')
                j=i;
        }
        if(j-last==0)
        {
            printf("-1\n");
            return 0;
        }
        res.pb(j-last);
        baki = i-j-1;
    }
    sz=res.size();
    reverse(res.begin(), res.end());
    for(int i=0;i<sz;i++)
    {
        if(i)
            printf(" ");
        printf("%lld",res[i]);
    }
    printf("\n");
    return 0;
}
/*

*/


Measured memory_bytes: 1528
#include<iostream>

int main(void){
    char in[4];
    std::cin >> in;
    int i = 0;
    int a = 0;
    while(true){
        if(i >= 3){
            break;
        };
        if(in[i] == 'R'){
            a = 1;
            ++i;
            while(i < 3){
                if(in[i] == 'R'){
                    ++a;
                }
                else{
                    break;
                };
                ++i;
            };
        };
        ++i;
    };
    std::cout << a << std::endl;
    return 0;
};


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;

int main(){
    ll N;
    cin >> N;
    int i = 1000;
    for (i; i < N; i += 1000);
    cout << i - N << endl;
    return 0;
}

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

int x[200010], y[200010];

int main() {
	int n;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
		y[i] = x[i];
	}

	sort(y + 1, y + n + 1);

	for (int i = 1; i <= n; i++) {
		if (x[i] < y[n / 2 + 1]) {
			cout << y[n / 2 + 1] << endl;
		}
		else {
			cout << y[n / 2] << endl;
		}
	}
}

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

//木の直径
const int max_edge = 2;
vector<int> G[max_edge]; //頂点情報のみのグラフ

//treeDFS(親,現在地,根から現在地までの距離,根からの最大距離,根から最大の距離をとる頂点)
void treeDFS(int from,int current,int dist,int &maxDist,int &maxVertex){
    //距離と終点の更新
    if (dist > maxDist){
        maxDist = dist;
        maxVertex = current;
    }
    for (auto to : G[current]){
        //逆流を防ぐ
        if (to == from) continue;
        treeDFS(current,to,dist+1,maxDist,maxVertex);
    }
}

//直径を求める
int TreeDiameter(){
    int start = 0, end = 0,maxDist = 0;
    treeDFS(-1,start,0,maxDist,end);
    start = end,end = 0,maxDist = 0;
    treeDFS(-1,start,0,maxDist,end);
    return start;
}



//2つ目
const int INF = 1e9;
int n; vector<vector<pair<int,int>>> V;
int dist[100010];

void Treebfs(int s){
    queue<pair<int,int> > que;
    for (int i = 0; i < n; i++){
        dist[i] = INF;
    }
    dist[s] = 0;
    int t,wei;
    que.push(make_pair(s,0));
    while (que.size()){
        t = que.front().first;
        wei = que.front().second;
        que.pop();

        for (int i = 0; i < V[t].size(); i++){
            if (dist[V[t][i].first] == INF){
                dist[V[t][i].first] = wei + V[t][i].second;
                que.push(make_pair(V[t][i].first, dist[V[t][i].first]));
            }
        }
    }
}

int main(){
    cin >> n;
    int s,t,w;
    V.resize(n);
    for (int i = 0; i < n-1; i++){
        cin >> s >> t >> w;
        V[s].push_back(make_pair(t,w));
        V[t].push_back(make_pair(s,w));
    }
    Treebfs(0);
    int x = -1,mx = 0;
    for (int i = 0; i < n; i++){
        if (dist[i] == INF) continue;
        if (mx < dist[i]){
            x = i;
            mx = dist[i];
        }
    }
    Treebfs(x);
    mx = 0;
    for (int i = 0; i < n; i++){
        if (dist[i] == INF) continue;
        if (mx < dist[i]){
            mx = dist[i];
        }
    }
    cout << mx << endl;
}


Measured memory_bytes: 9944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int prize[300];

int main() {
    prize[1] = 300000;
    prize[2] = 200000;
    prize[3] = 100000;
    int x, y;
    cin >> x >> y;
    int ans = prize[x] + prize[y];
    if (x == 1 && y == 1) ans += 400000;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int m,n,c,s2,s3,s5;
	while(scanf("%d",&m),m)
	{
		scanf("%d",&n);
		c=0;
		for(s2=1; s2<=n; s2*=2)
			for(s3=1; s2*s3<=n; s3*=3)
				for(s5=1; s2*s3*s5<=n; s5*=5)
					if(s2*s3*s5 >= m) c++;
		printf("%d\n",c);
	}
	return 0;
}

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

int main(){
    int s,ans;cin>>s;
    vector<int> a(1000005);
    a.at(0)=s;
    for(int i=0;i<1000000;i++){
        if(a.at(i)%2==0){
            a.at(i+1)=a.at(i)/2;
        }
        else{
            a.at(i+1)=3*a.at(i)+1;
        }
    }
    for(int i=0;i<1000000;i++){
        if(a.at(i)==4){
            ans=i+4;
            break;
        }
    }
    if(s!=2&&s!=1) cout<<ans<<endl;
    else cout<<4<<endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int a[10][10];
int num(int x){
	while(x>9)
		x/=10;
	return x;
}
int main(){
	long long n, ans=0;
	cin >> n;
	for(int i=1; i<=n; i++)
		a[num(i)][i%10]++;
	for(int i=1; i<=9; i++)
		for(int j=1; j<=9; j++)
			ans+=a[i][j]*a[j][i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind(object):
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.rank = [0] * n

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.p[x] = y
        else:
            self.p[y] = x

    def find(self, x):
        if self.p[x] == x:
            return x 
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

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

N, M = map(int, input().split())

ans = N
uf = UnionFind(N)
for i in range(M):
    X, Y, _ = map(int, input().split())
    if not uf.is_same(X-1, Y-1):
        uf.union(X-1, Y-1)
        ans -= 1

print(ans)

Measured memory_bytes: 7856
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int n, x;
    cin >> n >> x;
    int a[n];
    
    for (int i = 0; i < n; i++) cin >> a[i];
    
    sort(a, a + n);
    int cnt = 0;
    bool all = false;
    for (int i = 0; i < n; i++){
        x -= a[i];
        
        if(x < 0)break;
        cnt++;
        if(i == n -1){
            if(x != 0) all = true;
        }
    }
    if(all) cnt--;
    cout << cnt << endl;
    
}



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

namespace Physical_Experiments
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;
                double v = double.Parse(input);
                double t = v / 9.8;
                double y = 4.9 * t * t;
                double n = (y + 5) / 5;
                double ans = Math.Ceiling(n);
                Console.WriteLine(ans);



            }
        }
    }
}



Measured memory_bytes: 13864
#include<cstdio>
#include<algorithm>
using namespace std;
int N,K,Min=2e9,Ans=2e9,L=1;
int A[100005];
inline int read(){
	int Res=0;char ch=getchar();
	while (ch>'9'||ch<'0') ch=getchar();
	while (ch>='0'&&ch<='9') Res=Res*10+ch-'0',ch=getchar();
	return Res;
}
inline int Cal(int x,int y){
	if (x%y==0) return x/y;return x/y+1;
}
int main()
{
	N=read();K=read();
	for (int i=1;i<=N;i++){A[i]=read();if (Min>A[i]) Min=A[i],L=i;}
	for (int i=L;i<L+K&&i<=N;i++){
		int Sum=0; 
		if (i>K) Sum+=Cal(i-K,K-1);
		if (i<N) Sum+=Cal(N-i,K-1);
		Ans=min(Ans,Sum);
	}
	printf("%d\n",Ans+1);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int mul[3] = {0}; // 2の倍数でない、2の倍数の数、4の倍数の数
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if ((a&0x03)==0x00) mul[2]++;
    else if ((a&0x01)==0x00) mul[1]++;
    else mul[0]++;
  }

  if (mul[1]==0) {
    if ((mul[0]-1) <= mul[2]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  else {
    if ((mul[0]) <= mul[2]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#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(false); cin.tie(0); cout.tie(0);

    vi a(4); forn(i,4) cin >> a[i];
    forn(i,3) a[i+1] = min(a[i+1], 2*a[i]);
    int n; cin >> n; 

    ll ans = ll(n/2) * a[3] + ll(n%2) * a[2];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*input
200000
*/
#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 long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    ll ans = 0;
    vector<vector<ll>> c(10, vector<ll> (10, 0));
    for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) for(int k = 1; k < n + 1; k++)
    {
    	int first = k;
    	int last = k % 10;
    	while(first > 9) first /= 10;
    	if(first == i && last == j) c[i][j]++;
    }
    for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) ans += c[i][j] * c[j][i];
    cout << ans;

    return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    const int rows = 100, cols = 100;
    vector<vector<bool>> a(rows, vector<bool>(cols));
    for (int i = 0; i < rows / 2; ++i) {
        for (int j = 0; j < cols; ++j) {
            a[i][j] = 0;
            a[i + rows / 2][j] = 1;
        }
    }
    --A, --B;
    int cntb = 0, cnta = 0;
    [&]() {
        for (int i = 0; i < rows / 2; i += 2) {
            for (int j = 0; j < cols; j += 2) {
                if (cntb >= B) return;
                a[i][j] = 1;
                ++cntb;
            }           
        }
    }();
    [&]() {
        for (int i = rows - 1; i >= rows / 2; i -= 2) {
            for (int j = 0; j < cols; j += 2) {
                if (cnta >= A) return;
                a[i][j] = 0;
                ++cnta;
            }
        }
    }();
    cout << rows << " " << cols << '\n';
    for (int i = 0; i < rows; ++i) {
        for (int j = 0; j < cols; ++j) 
            cout << ".#"[a[i][j]];
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<sstream>

int toInt(std::string s){
	std::stringstream ss(s);
	int i;
	ss >> i;
	return i;
}

bool isTrue(int n, std::string s){
	std::string _s;
	if(n % 3 == 0)_s += "Fizz";
	if(n % 5 == 0)_s += "Buzz";
	if(n % 3 == 0 || n % 5 == 0){
		return s == _s;
	}
	return n == toInt(s);
}

int main(){
	int m, n;
	while(std::cin >> m >> n, m){
		std::vector<int> pv;
		for(int i=1;i<=m;i++){
			pv.push_back(i);
		}
	
		bool locked = false;//1人になった時点で無視しよう
		int who = 0;

		for(int i=1;i<=n;i++){
			std::string str;
			std::cin >> str;
			if(locked){//もう，ひとり
				continue;
			}
			if(isTrue(i, str)){

			}else{
				pv.erase(pv.begin() + who);
				if(pv.size() == 1){
					locked = true;
				}
				who--;
			}
			who = (who + 1) % pv.size();
		}

		std::cout << pv[0];
		for(int i=1;i<pv.size();i++){
			std::cout << " " << pv[i];
		}
		std::cout << "\n";
	}
}

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

int hoge[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int a;
int main()
{
  cin >> a;
  cout << hoge[a - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int cnt[100001] = { 0 };

int main()
{
	int N, A;
	int cards;
	set<int>::iterator front, back, it;
	set<int> nums;

	cin >> N;

	cards = N;

	rep(i, N) {
		cin >> A;

		nums.insert(A);

		cnt[A]++;
		if (cnt[A] >= 3) {
			cnt[A] -= 2;
			cards -= 2;
		}
	}

	front = nums.begin();
	back = nums.end();
	back--;

	while (true) {
		while (cnt[*front] < 2 && front != back) front++;
		while (cnt[*back] < 2 && back != front) back--;

		if (front == back) {
			if (cnt[*front] >= 2) {
				cnt[*front] -= 2;
				cards -= 2;
				continue;
			}
			else break;
		}

		cnt[*front]--;
		cnt[*back]--;
		cards -= 2;
	}

	cout << cards << endl;

	return 0;
}

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

long long calc(long long a, long long b, long long c)
{
	long long x = max({ a, b, c });
	long long y = min({ a, b, c });

	return abs(x - y);
}

int main(void)
{
	long long H, W;
	cin >> H >> W;

	if (H % 3 == 0 || W % 3 == 0) {
		cout << "0" << endl;
		return 0;
	}

	long long min = 999999999999;
	long long S1, S2, S3, ans;
	for (int j = 0; j < 2; ++j) {
		for (int i = 1; i < H; ++i) {
			S1 = i * W;
			S2 = (H - i) / 2 * W;
			S3 = (H - i + 1) / 2 * W;
			ans = calc(S1, S2, S3);
			if (min > ans)	min = ans;

			S2 = (H - i) * (W / 2);
			S3 = (H - i) * ((W + 1) / 2);
			ans = calc(S1, S2, S3);
			if (min > ans)	min = ans;
		}
		int tmp = H;
		H = W;
		W = tmp;
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
using namespace std;
int r,n,L,R,h,i,x;int main(){while(cin>>r>>n,r){map<int,int> A,B;for(i=0;i<n;i++){cin>>L>>R>>h;for(x=L;x<=R;x++){if(x!=R)A[x]=max(A[x],h);if(x!=L)B[x]=max(B[x],h);}}double res=99;for(i=-r;i<=r-1;i++){res=min(res,min(r-sqrt(r*r-i*i)+A[i],r-sqrt(r*r-(i+1)*(i+1))+B[i+1]));}cout<<res<<"\n";}}

Measured memory_bytes: 1272
#include <iostream>
#include <algorithm>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef pair<int, int> P;
#define REP(i,n) for(int i = 0; i < (int)n; ++i)
#define REP2(i,n) for(i = 0; i < (int)n; ++i)

#define DEBUG(x) cerr << #x << " = " << x << endl

int count_board(const vector<vector<int> >& board) {
    vector<vector<char> > vis(board.size(), vector<char>(board.begin()->size(), 0));
    const int color = board[0][0];
    int res = 1;
    queue<P> Q;
    Q.push(P(0, 0));
    vis[0][0] = 1;
    const int dx[4] = { 1, 0, -1, 0 };
    const int dy[4] = { 0, 1, 0, -1 };
    while(!Q.empty()) {
        P p = Q.front(); Q.pop();
        for(int i = 0; i < 4; i++) {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(0 <= ny && ny < (int)board.size() && 0 <= nx && nx < (int)board.begin()->size() && board[ny][nx] == color && vis[ny][nx] == 0) {
                vis[ny][nx] = 1;
                res++;
                Q.push(P(ny, nx));
            }
        }
    }
    return res;
}

void fill_board(const int c, vector<vector<int> >& board) {
    vector<vector<char> > vis(board.size(), vector<char>(board.begin()->size(), 0));
    const int old = board[0][0];
    queue<P> Q;
    Q.push(P(0, 0));
    board[0][0] = c;
    vis[0][0] = 1;
    const int dx[4] = { 1, 0, -1, 0 };
    const int dy[4] = { 0, 1, 0, -1 };
    while(!Q.empty()) {
        P p = Q.front(); Q.pop();
        for(int i = 0; i < 4; i++) {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(0 <= ny && ny < (int)board.size() && 0 <= nx && nx < (int)board.begin()->size() && board[ny][nx] == old && vis[ny][nx] == 0) {
                vis[ny][nx] = 1;
                board[ny][nx] = c;
                Q.push(P(ny, nx));
            }
        }
    }
}

void trace_board(const vector<vector<int> >& board) {
    for(int i = 0; i < (int)board.size(); i++) {
        for(int j = 0; j < (int)board[i].size(); j++) {
            cerr << board[i][j] << " \n"[j == board[i].size() - 1];
        }
    }
}

int main() {
    for(int H, W, C; cin >> H >> W >> C, H; ) {
        C--;
        vector<vector<int> > orig(H, vector<int>(W));
        REP(i,H) REP(j,W) {
            cin >> orig[i][j];
            orig[i][j]--;
        }
        int res = 0;
#if 1
        int cs[4];
        REP2(cs[0], 6) REP2(cs[1], 6) REP2(cs[2], 6) REP2(cs[3], 6) {
            vector<vector<int> > board = orig;
            fill_board(cs[0], board);
            // DEBUG(cs[0]);
            // trace_board(board);
            fill_board(cs[1], board);
            fill_board(cs[2], board);
            fill_board(cs[3], board);
            fill_board(C, board);
            res = max(res, count_board(board));
        }
#endif
        cout << res << endl;
    }
}

Measured memory_bytes: 1228
#include <stdio.h>

int main(void) {
	int n; scanf("%d",&n);
	int ary[n];
	
	int bry[n];
	int length = 0;
	for (int i=0; i<n; i++) {
		bry[i] = -1;
		scanf("%d",&ary[i]);
		int k = 0;
		while (bry[k] >= ary[i]) k++;
		if (bry[k] == -1) length++;
		bry[k] = ary[i];
	}
	printf("%d\n",length);
	
	return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
	int n; cin >> n;
	long long ans = 1;
	bool bad = false;
	while (n--) {
		long long a; cin >> a;
		if (a == 0) {
			cout << "0\n";
			return 0;
		}
		if (ans > 1000000000000000000LL / a)
			bad = true;
		if (!bad)
			ans *= a;
	}
	cout << (!bad ? ans : -1) << '\n';
	return 0;
}


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

typedef long long ll;

int main(){
  int n;
  char s[105],t[105];
  int cnt = 0;
  int ans,i;

  scanf("%d", &n);
  scanf("%s %s", s, t);
  ans = n*2;

  for(i = 0;i < n;i++){
    if(strncmp(s + i,t,n - i) == 0){
      cnt = n - i;
      break;
    }
  }

  printf("%d\n", ans - cnt);

  return 0;
}


Measured memory_bytes: 128
#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())

int main() {
  ll n;
  cin >> n;
  vector<P> a;
  REP(i,n){
    ll x, l;
    cin >> x >> l;
    a.push_back({x+l,x-l});
  }

  sort(ALL(a));

  ll ans = 0, cur = -1e18;
  REP(i,n){
    if(a[i].second >= cur){
      cur = a[i].first;
      ans++;
      continue;
    }
  }
  cout << ans << endl;
}

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

int main() {
    int h,m,s;
    cin >> s;
    h = s / 3600;
    m = (s % 3600)/60;
    s = s % 60;
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


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

int main(){
    int N, tmp;
    int f = 0;

    cin >> N ;
    tmp = N;

    while (tmp != 0){
        f = f + tmp % 10;
        tmp = tmp/10;
    }

    if (N % f == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}




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

int main(void)
{
	char a[50][101];
	int n = 0,i,j,str_length,flag=0,count=0;

	while (scanf("%s",a[n]) != EOF) {
		n++;
	}
	
	for(i=0; i<n; i++){
	  str_length = strlen(a[i]);
	  if(str_length == 1){
	    count++;
	  }else{
	  for(j=0; j<(str_length/2); j++)
	    {
	      if(a[i][j] != a[i][str_length-j-1]){
		flag = 0;
		break;
	      }else
	        flag = 1;
	    }
	  if(flag==1)count++;
	}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 548
#include<iostream>
#include<queue>
#include<cctype>


using namespace std;

int cnt;
char field[1002][1002];
int cost[1002][1002];
int factory[9][2];
int x[4] = {1, 0, -1, 0};
int y[4] = {0, 1, 0, -1};

int bfs(int sx, int sy, int gx, int gy) {
    queue< pair<int,int> > que;

    for(int i = 0; i < 1002; i++) {
        for (int j = 0; j < 1002; j++) {
            cost[i][j] = -1;
        }
    }

    que.push(make_pair(sx, sy));
    cost[sx][sy] = 0;

    while(!que.empty()) {
        pair<int, int> p;
        p = que.front();
        que.pop();
        
        if(p.first == gx && p.second == gy) {
            break;
        }

        for(int i = 0; i < 4; i++) {
            int tx = p.first + x[i]; int ty = p.second + y[i];
            if(field[tx][ty] != 'X' && cost[tx][ty] == -1) {
                que.push(pair<int, int>(tx, ty));
                cost[tx][ty] = cost[p.first][p.second] + 1;
            }
        }
    }
    return cost[gx][gy];
}

int main() {
    int w, h, n, sx, sy;

    cin >> h >> w >> n;

    for (int y = 1; y <= h; y++) {
        for (int x = 1; x <= w; x++) {
            cin >> field[x][y];
            if (field[x][y] == 'S') {
                sx = x;
                sy = y;
            } else if(isdigit(field[x][y])) {
                int tmp = field[x][y] - '0';
                factory[tmp][0] = x;
                factory[tmp][1] = y;
            }
        }
        field[0][y] = 'X';
        field[w + 1][y] = 'X';
    }

    for (int x = 0; x <= w + 1; x++) {
        field[x][0] = 'X';
        field[x][h + 1] = 'X';
    }

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        // 次の目的地へ行くで
        cnt += bfs(sx, sy, factory[i][0], factory[i][1]);
        sx = factory[i][0];
        sy = factory[i][1];
    }

    cout << cnt << endl;
}

Measured memory_bytes: 8032
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        s: String,
    }
    if s == "ABC".to_string() {
        println!("ARC");
    } else {
        println!("ABC");
    }
}


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

#define rep(i,x,y) for(int (i)=(x);(i)<(y);(i)++)

int main()
{

	while (true){
		vector<int> X, Y;
		vector<int>lengthX, lengthY;
		int x, y;
		int n, m;
		int sumx, sumy;
		int count = 0;

		cin >> n >> m;
		if (n == 0 && m == 0){
			break;
		}

		rep(i, 0, n){
			cin >> y;
			Y.push_back(y);
		}
		rep(i, 0, m){
			cin >> x;
			X.push_back(x);
		}

		rep(i, 0, n){
			sumy = 0;
			rep(j, i, n){
				sumy += Y[j];
				lengthY.push_back(sumy);
			}
		}
		rep(i, 0, m){
			sumx = 0;
			rep(j, i, m){
				sumx += X[j];
				lengthX.push_back(sumx);
			}
		}
		sort(lengthX.begin(), lengthX.end());
		sort(lengthY.begin(), lengthY.end());

		int i = 0;
		int j = 0;
		while (i < lengthY.size()&&j < lengthX.size()){
			if (lengthY[i] < lengthX[j]){
				i++;
			}
			else if (lengthY[i] > lengthX[j]){
				j++;
			}
			else{
				int k = j + 1;
				while (k < lengthX.size()){
					if (lengthX[k] != lengthX[j]){
						break;
					}
					k++;
				}
				count += k - j;
				i++;
			}
		}

		cout << count << endl;
	}

	return 0;
}

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

int main()
{
	int n,h[20],v=0,maxv=0;
	cin>>n;
	for(int i=0;i<n;i++) cin>>h[i];
	
	for(int i=0;i<n;i++){
		if(h[i]>=maxv){
			maxv=h[i];
			v++;
		}
	}
	
	cout<<v<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
#define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++)
#define rep2(CNT, START, GOAL) for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++)
#define rep3(CNT, START, GOAL) for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--)
#define all(CONT) begin(CONT), end(CONT)
template <typename T> void CERR(const T &ELEM) { cerr << ELEM; }
#define dbl(OBJ) cerr << #OBJ << ": "; CERR(OBJ); cerr << "\n"
template <typename T, typename ...Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); }
#define dbs(...) cerr << "(" << #__VA_ARGS__ << "): ("; CERR(__VA_ARGS__); cerr << ")\n"
#include <atcoder/all>
using namespace atcoder;

int main() {
	int N, M; cin >> N >> M;
	scc_graph g(N);
	while(M--) {
		int a, b; cin >> a >> b;
		g.add_edge(a, b);
	}
	vvi ls = g.scc();
	cout << ls.size() << endl;
	for (vi l : ls) {
		cout << l.size();
		for(int v : l) cout << " " << v;
		cout << endl;
	}
}

Measured memory_bytes: 40100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
using namespace std;

int main(void) {
	int x;
	cin >> x;
	if (x < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}
	return 0;
}

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

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

template <int K, class T>
struct Trie {
    struct Node {
        int id, sz;
        std::array<int, K> nxt;
        explicit Node() : id(-1), sz(0) { nxt.fill(-1); }
    };

    std::vector<Node> nodes;
    std::function<int(T)> enc;

    explicit Trie(T base) {
        nodes.emplace_back();
        enc = [=](T c) { return c - base; };
    }

    template <class Container>
    void add(const Container& s, int id) {
        int pos = 0;
        for (T c : s) {
            ++nodes[pos].sz;

            int ci = enc(c);

            int npos = nodes[pos].nxt[ci];
            if (npos == -1) {
                npos = nodes.size();
                nodes[pos].nxt[ci] = npos;
                nodes.emplace_back();
            }
            pos = npos;
        }

        ++nodes[pos].sz;
        nodes[pos].id = id;
    }

    template <class Container>
    int find(const Container& s) const {
        int pos = 0;
        for (char c : s) {
            int ci = enc(c);
            pos = nodes[pos].nxt[ci];
            if (pos == -1) return -1;
        }
        return pos;
    }

    Node& operator[](int pos) { return nodes[pos]; }
    Node operator[](int pos) const { return nodes[pos]; }
};

void solve() {
    int n;
    std::cin >> n;

    Trie<26, char> trie('a');
    std::vector<std::string> ss(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> ss[i];
        trie.add(ss[i], i);
    }

    auto comp = vec(n, vec(26, vec(26, 0)));
    std::vector<int> smaller(n, 0);

    for (int i = 0; i < n; ++i) {
        int pos = 0;

        for (char ci : ss[i]) {
            if (trie[pos].id != -1) ++smaller[i];
            int c = trie.enc(ci);

            for (int d = 0; d < 26; ++d) {
                if (c == d) continue;
                int npos = trie[pos].nxt[d];
                if (npos != -1) comp[i][c][d] += trie[npos].sz;
            }

            pos = trie[pos].nxt[c];
        }
    }

    int q;
    std::cin >> q;
    while (q--) {
        int k;
        std::cin >> k;
        --k;

        std::string p;
        std::cin >> p;

        int ans = smaller[k] + 1;
        for (int i = 0; i < 26; ++i) {
            for (int j = 0; j < i; ++j) {
                ans += comp[k][p[i] - 'a'][p[j] - 'a'];
            }
        }
        std::cout << ans << "\n";
    }
}

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

    solve();

    return 0;
}


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

int main(){
  int w,h,t,ha[51][51]={0},x,y,tt,p,u,sum=0;
  cin>>w>>h>>t>>p;
  for(int i=0;i<p;i++){
    cin>>x>>y>>tt;
    if(tt<=t)ha[x][y]++;
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>u;
      if(u==1)sum+=ha[j][i];
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}

int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a>b)swap(a,b);
	if(b==1){
		printf("1\n");return 0;
	}
	if(a==1){
		printf("%d\n",b-2);return 0;
	}
	long long ret=(long long)(a-2)*(b-2);

	printf("%lld\n",ret);
}

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

int main() {
	int n, m, a, b, sum=0, ans=0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		sum = 0;
		m = i;
		while (m != 0) {
			sum += m % 10;
			m /= 10;
		}
		if (a <= sum && sum <= b) {
			ans += i;
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> a(N + 1), b(N + 1);
	for (int i = 1; i <= N; i++) cin >> a[i];
	for (int i = N; i >= 1; i--){
		int s = 0;
		for (int j = i + i; j <= N; j += i){
			s ^= b[j];
		}
		b[i] = s ^ a[i];
	}
	vector<int> ans;
	for (int i = 1; i <= N; i++){
		if (b[i]) ans.push_back(i);
	}
	cout << ans.size() << endl;
	rep(i, ans.size()){
		cout << ans[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 5236
#def area#################
def zero(n,m):
	A=list()
	for i in range(n):
		A+=[[0]*m]
	return A
##########################

k=map(int,raw_input().split(" "))

A=zero(k[0],k[1])
B=zero(k[1],k[2])
C=zero(k[0],k[2])

#A_set
for i in range(k[0]):
	ipt=map(int,raw_input().split(" "))
	for j in range(k[1]):
		A[i][j]+=ipt[j]
#B_set
for i in range(k[1]):
	ipt=map(int,raw_input().split(" "))
	for j in range(k[2]):
		B[i][j]+=ipt[j]
#C_set
for i in range(k[0]):
	for j in range(k[2]):
		for l in range(k[1]):
			C[i][j]+=A[i][l]*B[l][j]
#print_C
for i in range(k[0]):
	for j in range(k[2]):
		if j==k[2]-1:
			print C[i][j]
		else:
			print C[i][j],

Measured memory_bytes: 7272
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
class Disk {
	int rotated;
	bool flipped;
	Disk rotateDisk(const int count) const {
		if (flipped) {
			return Disk((rotated + k - count) % k, flipped);
		}
		else {
			return Disk((rotated + count) % k, flipped);
		}
	}
	Disk flipDisk() && {
		flipped = !flipped;
		return *this;
	}
	constexpr Disk(const int rotate, const bool flip = false) : rotated{ rotate }, flipped{ flip }{}
public:
	Disk() :rotated{ 0 }, flipped{ false } {};
	Disk(const Disk &other) :rotated{ other.rotated }, flipped{ other.flipped }{}
	static Disk rotateLeft(const int count) {
		return Disk(count % k);
	}
	static Disk rotateRight(const int count) {
		return Disk((k - count % k) % k);
	}
	static Disk flip;
	static Disk stay;
	static int k;
	Disk operator>>(const Disk that) const {
		if (that.flipped) return rotateDisk(that.rotated).flipDisk();
		else return rotateDisk(that.rotated);
	}
	int top() const {
		if (flipped) return -(rotated + 1);
		else return rotated + 1;
	}
};
Disk Disk::flip{ 0, true };
Disk Disk::stay{ 0, false };
int Disk::k{ 0 };
class Cards {
	std::vector<Disk> cards;
	int length;
public:
	Cards(const std::vector<Disk> &vec) {
		int len = 1;
		while (len < vec.size()) len <<= 1;
		length = len;
		cards = std::vector<Disk>(len * 2, Disk::stay);
		for (auto i = 0; i < vec.size(); ++i) {
			cards[i + len] = vec[i];
		}
		for (auto i = len - 1; i > 0; --i) {
			cards[i] = cards[i * 2] >> cards[i * 2 + 1];
		}
	}
	void swap(int left, int right) {
		left += length;
		right += length;
		auto temp = cards[left];
		cards[left] = cards[right];
		cards[right] = temp;
		left >>= 1;
		while (left > 0) {
			cards[left] = cards[left * 2] >> cards[left * 2 + 1];
			left >>= 1;
		}
		right >>= 1;
		while (right > 0) {
			cards[right] = cards[right * 2] >> cards[right * 2 + 1];
			right >>= 1;
		}
	}
	int top() const {
		return cards[1].top();
	}
};
int main() {
	int n, q; 
	std::cin >> Disk::k >> n >> q;
	std::vector<Disk> vec(n);
	{
		int card;
		for (auto &v : vec) {
			std::cin >> card;
			if (card == 0) v = Disk::flip;
			else if (card > 0) v = Disk::rotateRight(card);
			else v = Disk::rotateLeft(-card);
		}
	}
	auto cards = Cards(vec);
	{
		int l, r;
		for (auto i = 0; i < q; ++i) {
			std::cin >> l >> r;
			cards.swap(l - 1, r - 1);
			std::cout << cards.top() << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5740
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	char string[11], *sample = { "YAKI" };
	scanf("%s", string);
	int match = 0;
	for (int i = 0; i < 4; i++)
		if (string[i] == sample[i])
			match++;
	printf("%s\n", (4 <= match ? "Yes" : "No"));
}

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

int main()
{
    string colors;
    cin >> colors;

    char prevColor = colors[0] == '0' ? '1' : '0';
    int count1 = 0;
    for (auto& color : colors)
    {
        if (color == prevColor)
        {
            prevColor = color == '0' ? '1' : '0';
            count1++;
        }
        else
        {
            prevColor = color;
        }
    }

    prevColor = colors[0];
    int count2 = 0;
    for (auto& color : colors)
    {
        if (color == prevColor)
        {
            prevColor = color == '0' ? '1' : '0';
            count2++;
        }
        else
        {
            prevColor = color;
        }
    }

    cout << min(count1, count2) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    s64 n;
    cin >> n;

    s64 ans = 0;
    vs64 f(n + 1, 0);
    for (int i = 1; i <= n; ++i)
    {
        s64 m = n / i;
        ans += m * (m + 1) / 2 * i;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 81348
a11,a12,a13 = map(int, input().split())
a21,a22,a23 = map(int, input().split())
a31,a32,a33 = map(int, input().split())
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))

if (a11 in b) and (a12 in b) and (a13 in b):
  print('Yes')
  exit()
if (a21 in b) and (a22 in b) and (a23 in b):
  print('Yes')
  exit()
if (a31 in b) and (a32 in b) and (a33 in b):
  print('Yes')
  exit()
if (a11 in b) and (a21 in b) and (a31 in b):
  print('Yes')
  exit()
if (a12 in b) and (a22 in b) and (a32 in b):
  print('Yes')
  exit()
if (a13 in b) and (a23 in b) and (a33 in b):
  print('Yes')
  exit()
if (a11 in b) and (a22 in b) and (a33 in b):
  print('Yes')
  exit()
if (a13 in b) and (a22 in b) and (a31 in b):
  print('Yes')
  exit()
print('No')

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

constexpr int MAX_N = 1e5;

int main() {
  // エラトステネスのふるい
  bitset<MAX_N + 1> isPrime;
  for (int i{2}; i <= MAX_N; ++i)
    isPrime.set(i);
  for (int i{2}; i <= MAX_N; ++i) {
    if (isPrime[i]) {
      for (int j{i * 2}; j <= MAX_N; j += i) {
        isPrime.reset(j);
      }
    }
  }

  bitset<MAX_N> a;
  for (int i{}; i < MAX_N; ++i) {
    if (isPrime[i] && isPrime[(i + 1) / 2])
      a.set(i);
  }

  // 累積和
  vector<int> s(MAX_N, 0);
  for (int i{}; i < MAX_N; ++i)
    s[i + 1] = s[i] + a[i];

  int Q;
  cin >> Q;
  for (int i{}; i < Q; ++i) {
    int l, r;
    cin >> l >> r;

    cout << s[r+1] - s[l] << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>

#define INF 0x3f3f3f3f

using namespace std;

int res[50000][10],n;
int temp[10],t1,t2;
int a[10],b[10],k=1,pos=0;
bool vis[10],flag;

bool same(int*x,int*y){
    for(int i=0;i<n;++i)
        if(x[i]!=y[i])return false;
    return true;
}

void dfs(int dep){
    if(flag)return;
    if(dep==n){
        ++pos;
        if(same(a,temp))
            t1=pos;
        if(same(b,temp))
            t2=pos;
        if(t1&&t2)
            flag=true;
        return;
    }
    for(int i=1;i<=n;++i){
        if(!vis[i]){
            temp[dep]=i;
            vis[i]=true;
            dfs(dep+1);
            vis[i]=false;
        }
    }
}

int main() {
    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=2;i<=n;++i)
        k*=i;
    dfs(0);
    printf("%d\n",t1-t2<0?t2-t1:t1-t2);
    return 0;
}

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

using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FOR(i, a) for (int i = 0; i < (a); i++)

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    printf("%d\n", min(min(a+b, c+b), a+c));
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<vector>
#include<queue>
#define int long long
#define rep(i,n) for(int i=0; i<n;i++)
using namespace std;
#define MAX 1e9
int INF=MAX*MAX;
 
typedef pair<int,int> pii;
typedef pair<pii,pii> piii;
//vector<vector<long long> >d(501,vector<long long>(51,INF));
int d[501][2][51];
signed main(){
	rep(i,501)rep(j,2)rep(k,51)d[i][j][k]=INF;
    int n,m;  cin>>n>>m;
    vector<vector<pii> >edge(n,vector<pii>());
    rep(i,m){
        int a,b,c; cin>>a>>b>>c;
        --a,--b;
        edge[a].push_back(pii(b,c));
        edge[b].push_back(pii(a,c));
    }
    int v0,a,b,c; cin>>v0>>a>>b>>c;
    priority_queue<piii>que;
    d[0][0][v0]=0;
    que.push(piii(pii(0,0),{0,v0}));
    while(!que.empty()){
        piii now=que.top(); que.pop();
		now.first.first*=-1;
        int v=now.second.second;
		int t=now.second.first;
        int _v=(v*a+b)%c;
        if(d[now.first.second][t][v]<now.first.first)continue;
        for(int i=0; i<edge[now.first.second].size();i++){
			int nt=t|edge[now.first.second][i].first==n-1;
            pii next=edge[now.first.second][i];
            if(d[next.first][nt][_v]<=now.first.first+next.second*v)continue;
            d[next.first][nt][_v]=now.first.first+next.second*v;
            que.push(piii(pii(-d[next.first][nt][_v],next.first),{nt,_v}));
        }
    }
    int ans=INF;
	rep(i,51)ans=min(ans,d[0][1][i]);
/*    rep(i,51)if(d[n-1][i]!=INF){
        vector<vector<long long> >_d(501,vector<long long>(51,INF));
        _d[n-1][i]=d[n-1][i];
        que.push(piii(pii(d[n-1][i],n-1),i));
        while(!que.empty()){
            piii now=que.top(); que.pop();
            int v=now.second;
            int _v=(v*a+b)%c;
            if(_d[now.first.second][v]<now.first.first)continue;
            for(int i=0; i<edge[now.first.second].size();i++){
                pii next=edge[now.first.second][i];
                if(_d[next.first][_v]<now.first.first+next.second*v)continue;
                _d[next.first][_v]=now.first.first+next.second*v;
                que.push(piii(pii(_d[next.first][_v],next.first),_v));
            }
        }
        rep(i,51)ans=min(ans,_d[0][i]);
    }	*/
    cout<<ans<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	if(S[2]==S[3]&&S[4]==S[5]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc153/tasks/abc153_b

import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer x = Integer.parseInt(scanner.next());
        Integer y = Integer.parseInt(scanner.next());
        Integer[] a = new Integer[y];
        for(int i=0; i < y; i++) {
            a[i] = Integer.parseInt(scanner.next());
        }

        int sum = Stream.of(a).mapToInt(Integer::intValue).sum();
        if (sum >= x) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 48276
import std.stdio;
alias L = long;
L M = 998244353, n, z, r;
L[] U;
L[L] R;
void main(){
	readf("%d\n", &n);
	foreach(c; readln[0 .. n]) U ~= c - '0';
	
	L h(L m){
		L f;
		foreach(u; U[0 .. m]) f = f * 2 % M + u;
		foreach(i, u; U) if(i / m & 1 ^ U[i % m] ^ u) return f + u;
		return f + 1;
	}
	
	foreach(m; 1 .. n + 1) if(n % m < n / m % 2){
		r = h(m);
		foreach(l, q; R) r += m % l? 0: M - q;
		z += r * m * 2 % M;
		R[m] = r % M;
	}
	
	writeln(z % M);
}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int A,B ;
  cin >> A >> B ;
  int ans =0 ;
  for(int i =A;i <= B;i++){
    if(i / 10000 == i % 10 && (i / 1000) % 10 == (i % 100)/10 )
      ans ++ ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <unordered_map>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <deque>

using namespace std;

typedef long long ll;

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

	score = (x / 500)*1000;
	x = x % 500;
	score +=(x/5)*5;

	cout << score << endl;

	return 0;
}

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

int main() {
  int A, B, C; cin >> A >> B >> C;
  int doubledRes = max(A, max(B, C)) * 3 - A - B - C;
  if (doubledRes % 2 != 0) {
    doubledRes += 3;
  }
  cout << (doubledRes / 2) << endl;
}

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

struct UnionFind {
    vector<int> par;
    vector<int> siz;
    UnionFind(int N) : par(N),siz(N) {
        for (int i=0; i<N; i++) {
            par[i]=i,siz[i]=1;
        }
    }
    int root(int x) {
        if (par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y) {
        int rx=root(x);
        int ry=root(y);
        if (rx==ry) return;
        par[rx]=ry;
        siz[ry]+=siz[rx];
    }
    bool same(int x,int y) {
        int rx=root(x);
        int ry=root(y);
        return rx==ry;
    }
    int size (int x) {
        return siz[root(x)];
    }
};
int main() {
   int N,M;
   cin >> N >> M;
   UnionFind tree(N);
   for (int i=0; i<M; i++) {
       int A,B;
       cin >> A >> B;
       tree.unite(A-1,B-1);
   }
   int m=0;
   for (int i=0; i<N; i++) {
       if (m<tree.size(i)) m=tree.size(i);
       //cout << m << endl;
   }
   cout << m << endl;
}

Measured memory_bytes: 10968
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

map<char, int> mp;
string S;

int main(){
    cin >> S;

    for(int i = 0; i < 3; i++) mp[S[i]]++;

    if(mp['a'] == 1 && mp['b'] == 1 && mp['c'] == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import fractions
a,b,c,d=map(int,input().split())
#C,Dで割り切れるもの
C=b//c-(a-1)//c
D=b//d-(a-1)//d

def lcm(x,y):
  return (x*y)//fractions.gcd(x,y)

e=lcm(c,d)
E=b//e-(a-1)//e

print((b-a+1)-(C+D-E))

Measured memory_bytes: 5048