akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#define MAX_N 21
#define INF 10000000
using namespace std;

typedef pair<int, int> P;

typedef struct {
  int to, cost;
} edge;

vector<edge> G[MAX_N];
int d[2][MAX_N];

void dijkstra(int s, int index) {
  priority_queue<P, vector<P>, greater<P> > que;
  for (int j = 0; j < MAX_N; j++) {
    d[index][j] = INF;
  }
  d[index][s] = 0;
  que.push(P(0, s));

  while (que.empty() == false) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (d[index][v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[index][e.to] > d[index][v] + e.cost) {
	d[index][e.to] = d[index][v] + e.cost;
	que.push(P(d[index][e.to], e.to));
      }
    }
  }
}

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

  for (int i = 0; i < m; i++) {
    int a, b, c, d;
    scanf("%d,%d,%d,%d", &a, &b, &c, &d);
    edge e;
    e.to = b;
    e.cost = c;
    G[a].push_back(e);
    e.to = a;
    e.cost = d;
    G[b].push_back(e);
  }

  int s, g, money, p;
  scanf("%d,%d,%d,%d", &s, &g, &money, &p);

  dijkstra(s, 0);
  dijkstra(g, 1);
  cout << money - p - d[0][g] - d[1][s] << endl;

  return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int k;
    cin>>k;
    cin>>s;
    if(s.size()<=k)
    {
        cout<<s<<endl;
    }else{
        for(int i=0;i<k;i++)
        {
            cout<<s.at(i);
        }
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}
   

Measured memory_bytes: 256
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
m=[[0 for _ in range(w)] for _ in range(h)]
c=0
for y in range(h):
    for x in range(w):
        if y%2==0:
            m[y][x]=c+1
            a[c]-=1
        else:
            m[y][w-1-x]=c+1
            a[c]-=1
        if a[c]==0:
            c+=1
for v in range(h):
    s=str(m[v][0])
    for u in range(1,w):
        s+=" "+str(m[v][u])
    print(s)


Measured memory_bytes: 3572
#!/usr/bin/env python3

n = int(input())

string_dict = {}

for i in range(n):
    s = str(input())
    if s in string_dict.keys():
        string_dict[s] += 1
    else:
        string_dict[s] = 1

ans = []
ans_value = 0
for key, value in string_dict.items():
    if ans_value < value:
        ans = [key]
        ans_value = value
    elif ans_value == value:
        ans.append(key)

ans.sort()

for i in ans:
    print(i)


Measured memory_bytes: 32096
import math


def index(array, indexes):
    if not len(array):
        return 0
    s = array.pop()
    count = 0
    for i in range(s - 1):
        if indexes[i]:
            count += 1
    indexes[s - 1] = False
    return count * math.factorial(len(array)) + index(array, indexes)


n = int(input())
p =list(map(int, input().split()))
q = list(map(int, input().split()))
p.reverse()
q.reverse()
pi = index(p, [True for _ in range(n)])
qi = index(q, [True for _ in range(n)])
print(abs(pi - qi))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c;
    
    cin >> a >> b >> c;
    
    int ans = c-(a - b);
    
    if(ans<0){
        
        cout<<"0"<<endl;
        
    }
    else{
        
        cout<<ans<<endl;
        
    }
 
    
}

Measured memory_bytes: 3140
#include <iostream>
using namespace std;
int main(void){
 int a,b;
 int ans;
 
 cin >> a >> b;
 
 if(a > b*2){
     ans = a-b*2;
 }else{
     ans = 0;
 }
 
 cout << ans << endl;
 
 return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())

    A.sort()
    i = 0
    j = N-1
    ans = A[j] - A[i]
    while j - i > 2:
        ans += A[j] - A[i+1] + A[j-1] - A[i]
        i += 1
        j -= 1
    if j - i == 2:
        ans += max(A[i+1] - A[i], A[i+2] - A[i+1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41564
function main(line) {
	for(var i = 0; i < line.length; i++){
		temp = line[i].split(' ')
		if(temp[0]==0 & temp[1]==0){
			break;
		}else if(parseInt(temp[0]) <= parseInt(temp[1])){
			console.log(temp[0] + " " + temp[1])
		}else{
			console.log(temp[1] + " " + temp[0])
		}	
	}
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});

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

int main() 
{ 
    int a,b;
    cin>>a>>b;
    if(a==b){
    	cout<<"Draw";
	}
   else if(a==1){
    	cout<<"Alice";
	}
	else if(b==1){
		cout<<"Bob";
	}
    
    else if(a>b){
   	cout<<"Alice";
   }
   else if(b>a){
   	cout<<"Bob";
   }
  
   
   
} 

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

using namespace std;

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

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

char mozi[53];
int main(){
	while(1){
		int n;
		int ikey[110] = {0};
		cin>>n;
		if(n==0) break;
		rep(i,n){
			cin>>ikey[i];
		}
		int tmm=0;
		rep(i,52){
			if(i==26) tmm+=6;
			mozi[i]='A'+tmm;
			tmm++;
		}
		// rep(i,52){
		// 	cout<<mozi[i]<<"*";
		// }
		string skey;
		cin>>skey;
		string ans = "";
		rep(i,skey.size()){
			if(char(skey[i]>='a')){
				skey[i] = char(char(skey[i])-6);
			}
			// cout << char(char(skey[i])-'A'+(52*2-ikey[i%n])%52)<< endl;
			ans += mozi[(char(skey[i])-'A'+(52*2-ikey[i%n]))%52];
		}
		cout<<ans<<endl;

	}
	return 0;
}

Measured memory_bytes: 3112
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], M = I[1];
		var p = G.Select(i => i - 1).ToArray();
		var uf = new UnionFindTree(N);
		for (var i = 0; i < M; i++)
		{
			I = G;
			uf.UniteCategory(I[0] - 1, I[1] - 1);
		}
		var ans = 0;
		var cmps = new Dictionary<int, HashSet<int>>();
		for (var i = 0; i < N; i++)
		{
			var r = uf.GetRootOf(i);
			if (!cmps.ContainsKey(r)) cmps[r] = new HashSet<int>{ i };
			cmps[r].Add(i);
		}
		foreach (var s in cmps.Values) foreach (var i in s) if (s.Contains(p[i])) ans++;
		WriteLine(ans);
	}
}
class UnionFindTree
{
	int N;
	int[] parent, rank, size;
	public UnionFindTree(int capacity)
	{
		N = capacity;
		parent = new int[N];
		rank = new int[N];
		size = new int[N];
		for (var i = 0; i < N; i++) { parent[i] = i; size[i] = 1; }
	}
	public int GetSize(int x) => size[GetRootOf(x)];
	public int GetRootOf(int x) => parent[x] == x ? x : parent[x] = GetRootOf(parent[x]);
	public bool UniteCategory(int x, int y)
	{
		if ((x = GetRootOf(x)) == (y = GetRootOf(y))) return false;
		if (rank[x] < rank[y]) { parent[x] = y; size[y] += size[x]; }
		else
		{
			parent[y] = x; size[x] += size[y];
			if (rank[x] == rank[y]) rank[x]++;
		}
		return true;
	}
	public bool IsSameCategory(int x, int y) => GetRootOf(x) == GetRootOf(y);
}


Measured memory_bytes: 46020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

void solve(int n) {
	string s,a;
	map<string, vector<string>> m;
	rep(i, n) {
		cin >> s;
		int k = 0;
		vector<string> ss;
		string stra;
		rep(j, s.size()) {
			if (s[j] == ':') {
				stra = s.substr(0,j);
				k = j + 1;
			}
			if (s[j] == ','|| s[j] == '.') {
				string str = s.substr(k, j-k);
				ss.push_back(str);
				//cout << str << endl;
				k = j + 1;
			}
		}
		if (i == 0)a = stra;
		m[stra] = ss;
	}
	bool sw = true;
	vector<string> ss=m[a];
	set<string> ans;
	rep(i, ss.size()) {
		ans.insert(ss[i]);
	}
	for (auto itr = ans.begin(); itr != ans.end(); itr++) {
		//cout << *itr << endl;
	}
	while (sw) {
		sw = false;
		for (auto itr = m.begin(); itr != m.end(); itr++) {
			//cout << itr->first << endl;
			if (ans.find(itr->first) != ans.end()) {
				sw = true;
				ans.erase(itr->first);
				vector<string> ss = m[itr->first];
				rep(i, ss.size()) {
					ans.insert(ss[i]);
				}
			}
		}
		//cout <<endl<<sw<< endl;
	}
	for (auto itr = ans.begin(); itr != ans.end(); itr++) {
		//cout << *itr << endl;
	}
	cout << ans.size() << endl;

}

int main() {
	int n;
	while (cin >> n, n) {
		solve(n);
	}
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 60;
const double EPS = 1e-10;

struct edge {
  int from, to, cost;
  edge() {}
  edge(int t, int c) : from(-1), to(t), cost(c) {}
  edge(int f, int t, int c): from(f), to(t), cost(c) {}
};

const int MAX_V = 100010;
int N, M;
vector<edge> G[MAX_V];
int dis[MAX_V];

void dijkstra(int s) {
  fill(dis, dis+MAX_V, INF);
  using P = pair<int, int>;
  priority_queue<P, vector<P>, greater<P>> que;
  dis[s] = 0;
  que.emplace(0, s);
  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (dis[v] < p.first) continue;
    for (edge& e : G[v]) {
      if (dis[e.to] > dis[v] + e.cost) {
        dis[e.to] = dis[v] + e.cost;
        que.emplace(dis[e.to], e.to);
      }
    }
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N-1) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    G[a].EMPB(b, c);
    G[b].EMPB(a, c);
  }
  int Q, K;
  cin >> Q >> K;
  dijkstra(--K);
  REP(i, Q) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    cout << dis[x] + dis[y] << endl;
  }

  return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n * a, b);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){
    int n, x, count;

    while(true){
        cin >> n >> x;
        if(n==0 && x==0){
            break;
        }
        count = 0;
        for(int i=1; i<=n-2; i++){
            for(int j=i+1; j<=n-1; j++){
                for(int h=j+1; h<=n; h++){
                    if(i+j+h==x){
                        count += 1;
                    }
                }
            }
        }
        cout << count << endl;
    }





    return 0;
}



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

#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ll long long int
 
using namespace std;

 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a,b;
	cin>>a>>b;
	int c=0;
	for(int i=0;i<a.length();i++)
	{
	     if(a[i]!=b[i])
	     c++;
	}
	cout<<c;

	return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve()
{
    int n;cin>>n;
    cout<<((n/100*5<n%100)?0:1)<<endl;
}

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

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a,b;
	cin>>a>>b;
	cout<<max(0,(a-1)*(b-1));
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a)) 
vl edge[220000];
ll seen[110000];
ll sizee[220000];
void dfs(ll i,ll j){    
    for(ll v:edge[i]){
        if(v==j)continue;
       sizee[v]+=sizee[i];
       dfs(v,i);
    }
}
int main(){
    int n,m;
    cin>>n>>m;
    rep(i,n-1){
        ll u,v;cin>>u>>v;u--;v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    rep(i,n)sizee[i]=0;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;
        sizee[a]+=b;
    }
    dfs(0,-1);
    rep(i,n){
        cout<<sizee[i]<<endl;
    }

}

Measured memory_bytes: 25216
x,y,n=list(map(int,input().split()))
xx=x
yy=y
S=[]
a1=0
b1=0
for _ in range(n):
    S.append(list(map(int,input().split())))
for a in S :
    if a[2]==1:
        a1 = max(a1,a[0])
    elif a[2]==2:
        xx = min(xx,a[0])
    elif a[2]==3:
        b1 = max(b1,a[1])
    elif a[2]==4:
        yy = min(yy,a[1])
print( (xx-a1)*(yy-b1) if a1<xx and b1<yy else 0)

Measured memory_bytes: 3064
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <iostream>
using namespace std;

int main()
{
    int n;
    cin>>n;
    bool ans = false;
    while(n!=0){
        int temp = n%10;
        if(temp == 7){
            ans = true;
        }
        n/=10;
    }
    if(ans) cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3620
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    res = 0
    if len(r) == 4:
        print('ABD')
    else:
        print('ABC')

if __name__ == '__main__':
    main()



Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 1000010
#define mod 1000000007
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
void solve(){
	ll n;
	in(n);
	ll p=n%10;
	if(p==3){
		cout<<"bon\n";
	}else if(p==0||p==1||p==6||p==8){
		cout<<"pon\n";
	}else{
		cout<<"hon\n";
	}
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	#endif
	clock_t t1=clock();
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
	clock_t t2=clock();
	cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}	

Measured memory_bytes: 3800
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    while( 1 ) {
        int h,w;
        scanf("%d%d", &h, &w);
        if(h==0 && w==0) break;
        int i,j;
        for(i=0; i<h; i++) {
            for(j=0; j<w; j++) {
                if((i+j)%2==0) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2548
from functools import reduce
n,a,b = map(int,input().split())
mod = 10 ** 9 + 7

def f(a):
    num = reduce(lambda x,y:x * y % mod,range(n,n-a,-1))
    den = reduce(lambda x,y:x * y % mod,range(1,a+1))
    return num * pow(den,mod-2,mod)%mod

ans = pow(2,n,mod)-f(a)-f(b)-1
ans %= mod
print(ans)


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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

int main()
{
    LL a,b;
    cin >> a >> b;
    LL g = __gcd(a,b);
    LL ans = 0;
    LL sq = sqrt(g);
    for(int i = 2;i <= sq;i++){
        if(g % i == 0){
            ans++;
            while(g % i == 0)g/=i;
        }
    }
    if(g > 1)ans++;
    cout << ans + 1 << "\n";
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	map<char,int> mp;
	mp['I']=1;
	mp['V']=5;
	mp['X']=10;
	mp['L']=50;
	mp['C']=100;
	mp['D']=500;
	mp['M']=1000;
	string s;
	while(cin>>s){
		int ans=0;
		rep(i,s.size()){
			if(i+1<s.size()&&mp[s[i]]<mp[s[i+1]])ans-=mp[s[i]];
			else ans+=mp[s[i]];
		}
		cout<<ans<<endl;
	}
}

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

int main() {
    string S;
    cin >> S;
    int count = 0;
    for(int i=0;i<S.size()/2;i++){
        if(S.at(i)!=S.at(S.size()-1-i)) count++;
    }
    cout << count << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <inttypes.h>
#include <stdint.h>

#define __STDC_FORMAT_MACROS

int main(void)
{
	int32_t knownCats, unknown, sumCats;

	scanf("%"PRId32" %"PRId32" %"PRId32, &knownCats, &unknown, &sumCats);

	printf("%s", ((knownCats <= sumCats) && (sumCats <= knownCats + unknown)) ? "YES" : "NO");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define QOEINDIEDIS freesteed
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve(){
	int n;
	cin>>n;
	VI a(n,0);
	ll  tol=0;
	rep(i,0,n){
		cin>>a[i];
		if(i!=n-1){
			if(i&1){
				tol+=a[i];
			}else{
				tol-=a[i];
			}
		}
	}
	ll f1 = (a[n-1]-tol);
	cout<<f1<<" ";
	rep(i,1,n){
		cout<<2LL*a[i-1]-f1<<" ";
		f1 = 2LL*a[i-1]-f1;
	}
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    llong dp[100100];
    int cnt;

    signed call_of_Cthulhu( signed datum ) {

        llong n, k;
        read n >> k;
        for ( int i = 0; i < n; i++ ) {
            llong a, b;
            read a >> b;
            dp[a] += b;
            chmax ( cnt, b );
        }
        for ( int i = 1; i <= cnt; i++ ) {
            if ( k <= dp[i] ) {
                echo i fin;
                return 0;
            }
            k -= dp[i];
        }

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(){
    string S;
    int i, len, max_len;
    len = max_len = 0;
    cin >> S;
    for (i = 0; i < S.length(); i++){
        if(S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T'){
            len++;
        }
        else{
            max_len = max(max_len, len);
            len = 0;
        }     
    }
    max_len = max(max_len, len);
    cout << max_len << "\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N, M;
int diff[MAX_N + 1];
int X[MAX_N + 1];

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

  sort(X, X + M);

  priority_queue<int> q;
  diff[0] = 0;
  REP(i, M - 1)
  {
    if (M - 1 == 0) break;
    diff[i + 1] = X[i + 1] - X[i];
    q.push(diff[i + 1]);
  }
  int sum = X[M - 1] - X[0];

  int n = N - 1;
  while (n > 0 && !q.empty()) {
    int s = q.top();
    q.pop();
    sum -= s;
    n--;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1532
import java.util.Scanner;

public class Main {

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

        final int N = sc.nextInt();

        for (int i = 0; i <= N; i += 4) {
            for (int j = 0; j <= N; j += 7) {
                if (i + j == N) {
                    System.out.println("Yes");
                    return;
                }
            }
        }

        System.out.println("No");
    }
}


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

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] R = new int[n];

        for(int i = 0; i < n; i++){
            R[i] = Integer.parseInt(br.readLine());
        }
        int max = Integer.MIN_VALUE;
        int min = R[0];

        for(int i = 1; i < n; i++){
            max = Math.max(max, R[i] - min);
            min = Math.min(min, R[i]);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 43140
#!/usr/bin/env python3
def main():
  a,b,c = map(int, input().split())
#  print("a:{},b:{},c:{}".format(a,b,c))
  if a+b+c == 17:
    s = list(set([a,b,c]))
#    print(s)
    if (s[0]==5 and s[1]==7) or (s[0]==7 & s[1]==5):
      print ("YES")
    else:
      print ("NO")
  else:
    print ("NO")

if __name__=='__main__':main()

Measured memory_bytes: 3060
A_lists = [map(int, input().split()) for _ in range(3)]
num_dict = {}
for n1, A_list in enumerate(A_lists):
    for n2, a in enumerate(A_list):
        num_dict[a] = (n1, n2)

N = int(input())
B_list = [int(input()) for _ in range(N)]
bing_ar = [[False, False, False] for _ in range(3)]

keys = num_dict.keys()
for b in B_list:
    if b in num_dict:
        n1, n2 = num_dict[b]
        bing_ar[n1][n2] = True

if ((sum(bing_ar[0]) == 3) or (sum(bing_ar[1]) == 3) or (sum(bing_ar[2]) == 3)) or \
    ((bing_ar[0][0] == True) and (bing_ar[1][0] == True) and (bing_ar[2][0] == True)) or \
    ((bing_ar[0][1] == True) and (bing_ar[1][1] == True) and (bing_ar[2][1] == True)) or \
    ((bing_ar[0][2] == True) and (bing_ar[1][2] == True) and (bing_ar[2][2] == True)) or \
    ((bing_ar[0][0] == True) and (bing_ar[1][1] == True) and (bing_ar[2][2] == True)) or \
    ((bing_ar[0][2] == True) and (bing_ar[1][1] == True) and (bing_ar[2][0] == True)):
    print('Yes')
else:
    print('No')
    



Measured memory_bytes: 9224
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

void solve()
{
	int n;
	cin>>n;
	int g=__gcd(n,360);
	g=(n*360)/g;
	ol(g/n);
}

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
int t=1;
while(t--)
{
	solve();
}
return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
/* Written by Nishant Mittal aka nishantwrp */
#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define modnum 1000000007
#define mp make_pair
#define pb push_back
#define PB pop_back
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define lcase(a) (char)tolower(a)
#define ucase(a) (char)toupper(a)
#define precise(a) fixed<<setprecision(a)<<
#define F first
#define S second
#define I insert
#define pii pair<int,int>
#define trav(a, x) for(auto& a : x)
#define rep(n) for(int i = 0;i<n;i++)
#define time cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" "; cout<<endl;
#define ingrid(data,n,commands) for(int i = 0; i<n; i++){cin>>data[i];commands}
#define section(a,b,w) set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w) set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define copy(a,w) copy(a.begin(), a.end(),back_inserter(w));
#define all(data) data.begin(), data.end()
#define PI 3.14159265358979323844
#define endl '\n'

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

// Graph DFS
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};

//Returns index of first element not less than key and more than key respectively
#define lb(data,key) lower_bound(all(data),key) - data.begin();
#define up(data,key) upper_bound(all(data),key) - data.begin();
#define fnd(data,key) find(all(data),key) - data.begin();

/*

███╗   ██╗██╗███████╗██╗  ██╗ █████╗ ███╗   ██╗████████╗██╗    ██╗██████╗ ██████╗ 
████╗  ██║██║██╔════╝██║  ██║██╔══██╗████╗  ██║╚══██╔══╝██║    ██║██╔══██╗██╔══██╗
██╔██╗ ██║██║███████╗███████║███████║██╔██╗ ██║   ██║   ██║ █╗ ██║██████╔╝██████╔╝
██║╚██╗██║██║╚════██║██╔══██║██╔══██║██║╚██╗██║   ██║   ██║███╗██║██╔══██╗██╔═══╝ 
██║ ╚████║██║███████║██║  ██║██║  ██║██║ ╚████║   ██║   ╚███╔███╔╝██║  ██║██║     
╚═╝  ╚═══╝╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝   ╚═╝    ╚══╝╚══╝ ╚═╝  ╚═╝╚═╝     
                                                                                                       
*/
int ans = 0;


signed main()
{
FAST
int n;
cin>>n;
vector <int> data;
invect(data,n,)
vector <int> data2 = data;
sort(data.begin(),data.end());
trav(x,data2) {
  if (x == data[n-1])
  {
    cout<<data[n-2]<<endl;
  } else {
    cout<<data[n-1]<<endl;
  }
}
return 0;
}

Measured memory_bytes: 3316
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100];
	int a,i,c=0;
	scanf("%s",s);
	a=strlen(s);
	for(i=0;i<a/2;i++){
		if(s[i]!=s[a-1-i]) c++;
	}
	printf("%d\n",c);
	return 0;
}


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

int main() {
  vector<char> a(3);
  rep(i, 3) cin >> a[i];

  int cnt = 0;
  rep(i, 3) if (a[i] == 'o') cnt++;
  cout << 700 + cnt * 100 << endl;
}


Measured memory_bytes: 256
// F.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <map>

using namespace std;

typedef long long LL;
const LL MOD = 1000000007;
static const size_t MAX_N = 2000001;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

modll combination(LL n, LL r) {
	static modll fact[MAX_N + 1], inv[MAX_N + 1];
	if (!fact[0]) {
		fact[0] = 1;
		for (int i = 1; i <= MAX_N; ++i) {
			fact[i] = fact[i - 1] * i;
		}
		inv[MAX_N] = modll::modinv(fact[MAX_N]);
		for (int i = MAX_N; i >= 1; --i) {
			inv[i - 1] = inv[i] * i;
		}
	}
	if (r > n) {
		return 0;
	}
	return (fact[n] * inv[r]) * inv[n - r];
}

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1, a[2];
		cin >> n >> a[0] >> a[1];
		if (n < 0) return 0;
		modll ans = 1;
		LL r = n;
		if (n > 100000) {
			modll x = 1;
			for (LL i = 0; i < 100000; ++i) {
				x *= 2;
			}
			while (r > 100000) {
				ans *= x;
				r -= 100000;
			}
		}
		while (r > 0) {
			ans *= 2;
			--r;
		}
		ans -= 1;
		for (LL t = 0; t < 2; ++t) {
			LL d = a[t];
			modll p = 1, q = 1;
			for (LL i = 0; i < d; ++i) {
				p *= (n - i);
				q *= (i + 1);
			}
			LL v = modll::modinv(q);
			p *= v;
			ans -= p;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

void ng() {
  cout << -1 << endk;
  exit(0);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  if(s[n-1] == '1') ng();
  if(s[0] == '0') ng();
  rep(i, n-1) if(s[i] != s[n-2-i]) ng();
  vector<int> P(n);
  int par = -1;
  rep(i, n) {
    P[i] = par;
    if(i == 0 || s[n-1-i] == '1') par = i;
  }
  rep(i, n) if(i) cout << i+1 << ' ' << P[i]+1 << endk;
  return 0;
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }







int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int h, w, n;
    cin >> h >> w >> n;
    
    vector<pii> v(n);
    set<pii> s;
    rep(i, n) {
        cin >> v[i].F >> v[i].S;
        s.insert(pii(v[i].F, v[i].S));
    }
    
    ll ans[10] = {0};
    
    rep(i, n) { // 10^5
        int p = v[i].F;
        int q = v[i].S;
        rep(j, 3) rep(k, 3) { // (p - j, q - k)が左上の正方形
            if (p - j <= 0 || q - k <= 0) continue;
            if (p - j + 2 > h || q - k + 2 > w) continue;
            int ny = p - j;
            int nx = q - k;
            int cnt = 0;
            rep(l, 3) rep(m, 3) {
                if (s.find(pii(ny + l, nx + m)) != s.end()) {
                    cnt++;
                }
            }
            ans[cnt]++;
        }
    }
    ll sum = 0;
    rep3(i, 1, 10) {
        sum += ans[i] / i;
    }
    cout << (ll)(h - 2) * (w - 2) - sum << endl;
    
    rep3(i, 1, 10) {
        ans[i] /= i;
        cout << ans[i] << endl;
    }
    
}


Measured memory_bytes: 5760
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

  using i8 = std::int_fast8_t;
  using i32 = std::int_fast32_t;
  using i64 = std::int_fast64_t;
  using u8 = std::uint_fast8_t;
  using u32 = std::uint_fast32_t;
  using u64 = std::uint_fast64_t;
  using isize = std::ptrdiff_t;
  using usize = std::size_t;

  constexpr usize operator"" _z(unsigned long long x) noexcept {
    return static_cast<usize>(x);
  }

  class rep {
    const usize f, l;

  public:
    class itr {
      friend rep;
      usize i;
      constexpr itr(const usize x) noexcept : i(x) {}

    public:
      void operator++() noexcept { ++i; }
      constexpr usize operator*() const noexcept { return i; }
      constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
    };
    constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
    constexpr itr begin() const noexcept { return itr(f); }
    constexpr itr end() const noexcept { return itr(l); }
  };
  class revrep {
    const usize f, l;

  public:
    class itr {
      friend revrep;
      usize i;
      constexpr itr(usize x) noexcept : i(x) {}

    public:
      void operator++() noexcept { --i; }
      constexpr usize operator*() const noexcept { return i; }
      constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
    };
    constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
    constexpr itr begin() const noexcept { return itr(l); }
    constexpr itr end() const noexcept { return itr(f); }
  };
  template <class T> using vec_alias = std::vector<T>;
  template <class T> auto md_vec(const usize n, const T& value) {
    return std::vector<T>(n, value);
  }
  template <class... Args> auto md_vec(const usize n, Args... args) {
    return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
  }
  template <class T> constexpr T difference(const T& a, const T& b) {
    return a < b ? b - a : a - b;
  }
  template <class T> T scan() {
    T ret;
    std::cin >> ret;
    return ret;
  }

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

  bool solve() {
    const usize k = scan<usize>();
    const usize n = 1_z << k;
    std::vector<u32> s(n);
    for (auto& e : s) {
      std::cin >> e;
    }
    std::sort(s.begin(), s.end(), std::greater<u32>());
    std::vector<bool> used(n, false);
    std::vector<u32> cur;
    cur.push_back(s[0_z]);
    used[0_z] = true;
    for (const auto loop : rep(0_z, k)) {
      usize c = 0_z;
      for (const auto i : rep(0_z, n)) {
        if (c == (1_z << loop)) {
          break;
        }
        if (!used[i] && s[i] < cur[c]) {
          cur.push_back(s[i]);
          used[i] = true;
          ++c;
        }
      }
      if (c != (1_z << loop)) {
        return false;
      }
      std::sort(cur.begin(), cur.end(), std::greater<u32>());
    }
    return true;
  }

  void main_() { std::cout << (solve() ? "Yes" : "No") << std::endl; }

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 4472
n,k=map(int,input().split())
k2=format(k+1,"0%ib"%40)
lists=list(map(int,input().split()))
countlist=[0]*40
for j in lists:
    c=format(j,"0%ib"%40)
    for i in range(40):
        if c[i]=="1":
            countlist[i]+=1

emptylist=[]
for i in range(40):
    if k2[i]=="1":
        emptylist.append(i)
if k>=1:
    ans=0
    for i in emptylist:
        subing=0
        for j in range(40):
            if j<i:
                if k2[j]=="1":
                    subing+=(2**(39-j))*(n-countlist[j])
                elif k2[j]=="0":
                    subing+=(2**(39-j))*countlist[j]
            if j==i:
                subing+=(2**(39-i))*countlist[i]
            
            if j>i:
                subing+=(2**(39-j))*max(countlist[j],n-countlist[j])
        ans=max(ans,subing)
    print(ans)
elif k==0:
    ans=0
    for i in range(40):
        ans+=(2**(39-i))*countlist[i]
    print(ans)
        

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < 1000; i++) {
    string t;
    int x = i;
    for (int j = 0; j < 3; j++) {
      t += x % 10 + '0';
      x /= 10;
    }
    int ti = 0;
    for (int j = 0; j < n; j++) {
      if (s.at(j) == t.at(ti)) {
        ti++;
        if (ti == 3) {
          break;
        }
      }
    }
    if (ti == 3) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    map<int,int> mp;

    int cnt = 0;
    REP(i,n) {
        cin >> v[i];
        cnt = (cnt + v[i]) % m;
        mp[cnt]++;
    }

    ll ans = 0;
    cnt = 0;
    REP(i,n) {
        if (mp[cnt] > 0) {
            ans += mp[cnt];
        }
        cnt = (cnt + v[i]) % m;
        mp[cnt]--;
    }

    cout << ans << '\n';

    return 0;
}

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  rep(i, M) cin >> B.at(i);
  vector<vector<int>> A(N, vector<int>(M));
  rep(i, N) rep(j, M) cin >> A.at(i).at(j);
  int ans = 0;
  rep(i, N) {
    int check = C;
    rep(j, M) check += A.at(i).at(j) * B.at(j);
    if (check > 0) ans++;
  }
  cout << ans;
}


Measured memory_bytes: 3600
import java.io.*;

class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int it = Integer.parseInt(str);
        String[] strarr = new String[it];
        for(int i=0; i < it; i++) {
            strarr[i] = br.readLine();
        }
        
        int max = -1000000001;
        int min = Integer.parseInt(strarr[0]);
        for(int i=1; i < it; i++) {
            max = Math.max(max, Integer.parseInt(strarr[i])-min);
            min = Math.min(min, Integer.parseInt(strarr[i]));
        }
        
        System.out.println(max);
    }
    
}


Measured memory_bytes: 42792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <fstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

main(){
  int T;
  cin>>T;
  while(T--){
    int n;
    cin>>n;
    string up,down;
    cin>>up;
    down=up.substr(2*n);
    up=up.substr(0,2*n);

    int dp[n+1][2];
    rep(i,n+1)rep(j,2)dp[i][j]=INT_MAX/2;
    
    dp[0][0]=0;
    dp[0][1]=1;
    if(up[0]=='Y'){
      dp[0][0]=1;
    }
    if(down[0]=='Y'){
      dp[0][0]=3;
      dp[0][1]=2;
    }

    rep(i,n){
      int sh=0;
      if(down[i*2+1]=='Y' || (i*2+2<2*n && down[i*2+2]=='Y'))sh+=2;
      if(up[i*2+1]=='Y' || (i*2+2<2*n && up[i*2+2]=='Y'))sh+=1;

      switch(sh){
      case 0:
	dp[i+1][0]=min(dp[i][0]+1,dp[i][1]+2);
	dp[i+1][1]=min(dp[i][1]+1,dp[i][0]+2);
	break;
      case 1:
	dp[i+1][0]=min(dp[i][0]+2,dp[i][1]+2);
	dp[i+1][1]=min(dp[i][0]+2,dp[i][1]+2);
	break;
      case 2:
	dp[i+1][0]=min(dp[i][0]+4,dp[i][1]+3);
	dp[i+1][1]=min(dp[i][0]+3,dp[i][1]+2);
	break;
      case 3:
	dp[i+1][0]=min(dp[i][0]+4,dp[i][1]+3);
	dp[i+1][1]=min(dp[i][0]+3,dp[i][1]+3);
	break;
      }
      //cout<<sh<<endl;
      //cout<<dp[i+1][0]<<" "<<dp[i+1][0]<<endl;
    }
    cout<<dp[n][0]<<endl;
  }
}

Measured memory_bytes: 0