akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
bool see[410][410]={};
string g[410];
Int b,w;
int d[]={1,0,-1,0,1};

void dfs(int i,int j){
  see[i][j]=true;
  if(g[i][j]=='#')b++; else w++;
  //cout<<i<<' '<<j<<'\n';
  rep(k,4){
    int y=i+d[k],x=j+d[k+1];
    if(y<0||y>=n||x<0||x>=m||see[y][x]||g[y][x]==g[i][j])continue;
    dfs(y,x);
  }
  return;
}

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

  cin>>n>>m; Int ans=0;
  rep(i,n)cin>>g[i];
  rep(i,n)rep(j,m){
    if(!see[i][j]){
      b=w=0;
      dfs(i,j);
      ans+=b*w;
    }
  }
  END
}

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

N  = int(input())

ans = 0
T, A = [0] * 1001, [0] * 1001

for i in range(N):
    T[i], A[i] = map(int, input().split())

    if i != 0 and T[i-1] >= T[i] or A[i-1] >= A[i]:
        t = T[i-1] // T[i] if T[i-1] % T[i] == 0 else T[i-1] // T[i] + 1
        s = A[i-1] // A[i] if A[i-1] % A[i] == 0 else A[i-1] // A[i] + 1

        m = max(t, s)

        T[i] *= m
        A[i] *= m

    ans = sum([T[i], A[i]])

print (ans)


Measured memory_bytes: 3064
#include<stdio.h>

int N,K;
int ans = 1;

int main()
{
    scanf("%d%d",&N,&K);
    for(int i = 0; i < N; i++)
    {
        if(ans <= K)ans *= 2;
        else ans += K;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class UnionFindTree
{
    vector<int> parent;
    vector<int> depth;
    vector<int> cnt;

public:
    UnionFindTree(int n) : parent(n), depth(n), cnt(n)
    {
        for (int i = 0; i < n; i++)
        {
            parent[i] = i;
            depth[i] = 0;
            cnt[i] = 1;
        }
    }

    //木の根を求める
    int find(int x)
    {
        if (parent[x] == x)
        {
            return x;
        }
        else
        {
            return parent[x] = find(parent[x]);
        }
    }

    //xとyの属する集合を併合
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (depth[x] < depth[y])
        {
            parent[x] = y;
            cnt[y] += cnt[x];
        }
        else
        {
            parent[y] = x;
            cnt[x] += cnt[y];
            if (depth[x] == depth[y])
                depth[x]++;
        }
    }
    // 同じ集合に属しているか判定
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    // 集合のサイズを取得
    ll size(int x)
    {
        return cnt[find(x)];
    }
};

int main()
{
    ll n, m;
    cin >> n >> m;
    UnionFindTree utree(n + 10);
    vector<int> a(m);
    vector<int> b(m);
    vector<ll> ans(m);
    int i = 0;
    for (i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
    }
    ans[m - 1] = n * (n - 1) / 2;
    for (i = m - 1; i > 0; i--)
    {
        if (utree.same(a[i], b[i]))
            ans[i - 1] = ans[i];
        else
        {
            ans[i - 1] = ans[i] - utree.size(a[i]) * utree.size(b[i]);
            utree.unite(a[i], b[i]);
        }
    }
    for (int i = 0; i < m; i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}

int n, m;
string s, t;

int32_t main(){_
   
   
   cin >> n;

   vector<int> a(n);
   for (int i = 0; i < n; ++i)
   {
      cin >> a[i];
   }

   sort(a.begin(), a.end());
   int ans = 0;
      
   ans += a[n-1];
   int curr = n-2;
   int prev = 0;

   for (int i = n-3; i >= 0; --i)
   {
      if (prev == 0){
         ans += a[curr];
         prev++;
      }
      else{
         ans += a[curr];
         prev = 0;
         curr--;
      }
   }

   cout<<ans;

   return 0;
}

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

int main() {
    int a = 0, b = 0, c = 0;
    cin >> a >> b >> c;

    if(a < b && b < c) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;

int main()
{
	int h,w;
	cin >> h >> w;
	char c;
	int a[h][w];
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> c;
			if(c=='#'){
				a[i][j]=1;
			}else{
				a[i][j]=0;
			}
		}
	}

	int tate,yoko;
	for(int i=0;i<h;i++){
		for(int j=0; j<w; j++){
			tate=0;
			yoko=0;
			for(int k=0; k<w; k++){
				yoko += a[i][k];
			}
			for(int k=0; k<h; k++){
				tate += a[k][j];
			}
			if(tate!=0 && yoko!=0){
				if(a[i][j]==1){
					cout << "#";
				}else{
					cout << ".";
				}
			}
		}
		if(yoko){
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  while(true){
  int n, mn, mx;
  cin >> n >> mn >> mx;

  if(n == 0 && mn == 0 && mx == 0) break;

  vector<int> v(n);
  REP(i,n){
    cin >> v[i];
  }

  //sort(ALL(v), greater<int>());
  int g = 0;
  int ans;
  for(int i = mn; i <= mx && i < n; ++i){
    int tmp = v[i-1] - v[i];
    //cout << i+1 << " " << tmp << " " << g << endl;
    if(tmp >= g){
      g = tmp;
      ans = i;
    }
  }

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




Measured memory_bytes: 3088
#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;

struct Node {
	vector<Node *> children;
};
using Hash = int;

constexpr int MAX = 20000;
Node pool[MAX];
int number_of_nodes;

inline Node *new_node() {
	assert(number_of_nodes < MAX);
	pool[number_of_nodes].children.clear();
	return pool + number_of_nodes++;
}

Node *make_tree() {
	int h, w;
	if(!(cin >> h >> w && h)) throw "finish";
	h += 2;
	w += 2;
	vector<string> image(h, string(w, '.'));
	for(int i = 1; i < h - 1; ++i) {
		string line;
		cin >> line;
		image[i] = '.' + move(line) + '.';
	}

	const auto out = [&h, &w](const int x, const int y) { return x < 0 || y < 0 || x >= w || y >= h; };
	static constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
	static constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
	int size = 0;
	vector<vector<int>> label(h, vector<int>(w, -1));
	const auto bfs = [&](const int sx, const int sy, const int dn) {
		const char color = image[sy][sx];
		label[sy][sx] = size++;
		queue<pair<int, int>> que{{{sx, sy}}};
		while(!que.empty()) {
			const int x = que.front().first;
			const int y = que.front().second;
			que.pop();
			for(int d = 0; d < dn; ++d) {
				const int nx = x + dx[d];
				const int ny = y + dy[d];
				if(out(nx, ny) || label[ny][nx] != -1 || image[ny][nx] != color) continue;
				que.emplace(nx, ny);
				label[ny][nx] = label[y][x];
			}
		}
	};
	for(int y = 0; y < h; ++y) {
		for(int x = 0; x < w; ++x) {
			if(label[y][x] == -1) bfs(x, y, image[y][x] == '.' ? 4 : 8);
		}
	}
	vector<set<int>> G(size);
	const auto add_edge = [&](const int x1, const int y1, const int x2, const int y2) {
		if(out(x1, y1) || out(x2, y2)) return;
		const int u = label[y1][x1];
		const int v = label[y2][x2];
		if(u != v) {
			G[u].emplace(v);
			G[v].emplace(u);
		}
	};
	for(int y = 0; y < h; ++y) {
		for(int x = 0; x < w; ++x) {
			add_edge(x, y, x + 1, y);
			add_edge(x, y, x, y + 1);
		}
	}

	queue<int> que{{0}};
	vector<bool> used(size, false);
	vector<Node *> nodes(size, nullptr);;
	for(int i = 0; i < size; ++i) {
		nodes[i] = new_node();
	}
	used[0] = true;
	while(!que.empty()) {
		const int v = que.front();
		que.pop();
		for(const auto &u : G[v]) {
			if(!used[u]) {
				que.emplace(u);
				nodes[v]->children.emplace_back(nodes[u]);
				used[u] = true;
			}
		}
	}
	return nodes[0];
}

Hash calc_hash(const Node *tree) {
	static map<vector<Hash>, Hash> table;
	static function<Hash(const Node*)> f = [](const Node *v) -> Hash {
		vector<Hash> children_hashes;
		children_hashes.reserve(v->children.size());
		for(const auto &c : v->children) {
			children_hashes.emplace_back(f(c));
		}
		sort(begin(children_hashes), end(children_hashes));
		const auto p = table.emplace(children_hashes, table.size());
		return p.first->second;
	};
	return f(tree);
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(true) {
		number_of_nodes = 0;
		try {
			cout << (calc_hash(make_tree()) == calc_hash(make_tree()) ? "yes" : "no") << endl;
		} catch(const char *s) {
			return EXIT_SUCCESS;
		}
	}
}

Measured memory_bytes: 3812
#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))
//-------------------------------------------------------

int N;
char S[101010];

int ok(int L) {
	int i;
	deque<int> D;
	FOR(i,N) if(S[i]!=S[i+1]) D.push_back(i+1);
	if(L>N) return 0;
	
	
	while(D.size()) {
		if(D.back()-D.front()>=L) {
			D.pop_back();
			D.pop_front();
		}
		else {
			if(D.front()+L>N && D.front()-L<0) return 0;
			D.pop_front();
		}
	}
	return 1;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	N=strlen(S);
	S[N]='0';
	
	int mi=1;
	for(i=20;i>=0;i--) if(ok(mi+(1<<i))) mi+=1<<i;
	cout<<mi<<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: 624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <numeric>
#include <type_traits>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

ll gcd(ll a, ll b){

    if(a < b){
        ll temp = a;
        a = b;
        b = temp;
    }

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


int main(){

    int a;
    cin >> a;
    ll ans = 0;
    for(ll i1 = 1; i1 <= a; i1 ++){
        for(ll i2 = 1; i2 <= a; i2++){
            for(ll i3 = 1; i3 <= a; i3 ++){
                ll tmp = gcd(i1, i2);
                tmp = gcd(tmp, i3);
                ans += tmp;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
n,m=map(int,input().split())

ab=[]
cd=[]
for _ in range(n):
  ab.append(list(map(int,input().split())))
for _ in range(m):
  cd.append(list(map(int,input().split())))

arr=[0]*len(ab)
for i in range(len(ab)):
  min_d=float('inf')
  for j in range(len(cd)):
    d=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])	
    if d<min_d:
      min_d=d
      arr[i]=j+1
print(*arr,sep='\n')

Measured memory_bytes: 3064
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int A,B,K;
signed main(){
    scanf("%lld %lld %lld",&K,&A,&B);
    for(int i=A;i<=B;i++){
        if(i%K==0){printf("OK\n");return 0;}
    }
    printf("NG\n");
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
int x,y;
int main(){
  cin >> x >> y;
  int ans=0;
  if(x <= 3)ans += 300000-((x-1)*100000);
  if(y <= 3)ans += 300000-((y-1)*100000);
  if(x==1 && y==1)ans += 400000;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main
{
	public static void main (String[] arg)throws IOException
	{
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String line;
		line=input.readLine();
		int a = Integer.parseInt(line);
		StringTokenizer tokenizer;
		double[] r1= new double[3];
		double[] r2= new double[3];
			
		for(int i=0;i < a; i++){
			tokenizer = new StringTokenizer(input.readLine());
			for(int j=0;j < 3; j++ ){
				r1[j]=Double.parseDouble(tokenizer.nextToken());
			}
			for(int j=0;j < 3; j++ ){
				r2[j]=Double.parseDouble(tokenizer.nextToken());
			}
			double dis=0;
			dis=Math.sqrt(Math.pow((r1[0]-r2[0]),2)+ Math.pow((r1[1]-r2[1]),2));
			if(dis>r2[2]+r1[2])
			{
				System.out.println("0");
			}else{
				if(dis+r2[2]<r1[2])	{
					System.out.println("2");
				}else{
					if(dis+r1[2]<r2[2]) {
						System.out.println("-2");
					}else{
						System.out.println("1");
					}
				}
			}
		}	
	}
}	
		

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

using namespace std;

int main()
{
	int arr[26] = { 0 };
	string str;

	while (getline(cin, str))
	{
		for (unsigned int i = 0; i != str.length(); ++i)
		{
			if (str.at(i) >= 'A'&&str.at(i) <= 'Z')
			{
				str.at(i) += 32;
			}
			++arr[str.at(i) - 'a'];
		}
	}
	
	for (int i = 0; i != 26; ++i)
	{
		cout <<char('a'+i)<<" : "<< arr[i]<<endl;
	}
	
	return 0;

}


Measured memory_bytes: 3192
#include <string>
#include <vector>
#include <iostream>
using namespace std;
const vector<vector<int> > r = {
	{5, 1, 3, 4, 6, 2},
	{4, 2, 1, 6, 5, 3},
	{2, 6, 3, 4, 1, 5},
	{3, 2, 6, 1, 5, 4}
};
int n; string s;
int main() {
	while (cin >> n, n) {
		vector<int> a = { 1, 2, 4, 3, 5, 6 };
		for (int i = 0; i < n; i++) {
			cin >> s;
			int d = 0;
			if (s[0] == 'e') d = 1;
			if (s[0] == 's') d = 2;
			if (s[0] == 'w') d = 3;
			vector<int> b = a;
			for (int j = 0; j < 6; j++) b[j] = a[r[d][j] - 1];
			a = b;
		}
		cout << a[0] << endl;
	}
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  string s[3]; for(int i = 0; i < 3; i++) cin >> s[i];
  int idx[3] = {};
  int curr = 0;
  while(1) {
    curr = s[curr][idx[curr]++] - 'a';
    if(idx[curr] >= s[curr].size()) {
      cout << char('A'+curr) << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#Priority Queueを使った解法
import heapq

N,M = map(int,input().split())
A = list(map(lambda x:(-1)*int(x),input().split()))

heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A,(-1)*(-a//2))

print(-sum(A))

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

using namespace std;

typedef long long ll;

ll N, M, Q, A, B, C, c[200005], v[205];
string s, p;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	A = 0;
	cin >> N;
	for (int i = 1; i <= N; ++i){
		cin >> v[i];
	}
	for (int j = 1; j <= N; ++j){
		cin >> c[j];
	}
	for (int i = 1; i <= N; ++i){
		if (v[i] >= c[i]){
			A += v[i] -c[i];
		}
	}
	cout << A << '\n';
	
}

Measured memory_bytes: 256
# 入力
N = int(input())

# Nが偶数ならば完全グラフから辺 (1, N), (2, N-1), ... を除いたグラフが解
# Nが奇数ならば完全グラフから辺 (1, N-1), (2, N-2), ... を除いたグラフが解
M = (
    N * (N - 1) // 2 - N // 2 if N % 2 == 0 else
    N * (N - 1) // 2 - (N - 1) // 2
)
s = N + 1 if N % 2 == 0 else N
ans = str(M) + '\n' + '\n'.join(
    '{} {}'.format(i, j)
    for i in range(1, N)
    for j in range(i + 1, N + 1)
    if i + j != s
)

# 出力
print(ans)


Measured memory_bytes: 3316
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int s1 = A + B, s2 = C + D;
    if (s1 == s2) {
        cout << "Balanced" << endl;
    } else if (s1 > s2) {
        cout << "Left" << endl;
    } else {
        cout << "Right" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	double v,t,nn;
	int a,n;
	for(;;){
		if(scanf("%lf",&v)==EOF){break;}
		t=v/9.8;
		nn=(t*t*4.9+5)/5;
		n=(t*t*4.9+5)/5;
		if(n!=nn){n++;}
		printf("%d\n",n);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    int n, minIndex = -1;
    long long int a[100000], ans[2], min = 1000000000;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    long long int *t = max_element(a, a+n);
    ans[0] = *t;
    for (int i = 0; i < n; i++) {
        if (i != t-&a[0]) {
            if (abs(a[i] - ans[0] / 2) < min) {
                min = abs(a[i] - ans[0] / 2);
                minIndex = i;
            }
        }
    }
    ans[1] = a[minIndex];
    cout << ans[0] << " " << ans[1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;
struct Edge { int from, to; long long cost; };
using Graph = vector<vector<Edge>>;

template<typename T = long long>
T mod_pow(T a, T x, T md) {
    T res = 1;
    while(x) {
        if(x & 1) res = res * a % md;
        a = a * a % md;
        x >>= 1;
    }
    return res;
}

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

    ll n,k;
    cin>>n>>k;
    cout<<mod_pow(k,n,MOD)<<endl;
}


Measured memory_bytes: 3152
# 1-index
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
A = [0] + A

visited = [False]*(N+1)
visited[1] = True
step = [0]*(N+1)
step[0] = 1
step[1] = A[1]
count = [0]*(N+1)
count[1] = 0
count[A[1]] = 1

now = A[1]
cnt = 1
roop = 0

for _  in range(N):
    now = A[now]
    cnt += 1

    if visited[now]:
        roop = cnt - count[now]
        break
    count[now] = cnt
    step[cnt] = now
    visited[now] = True

if K < count[now]:
    print(step[K])
else:
    K -= count[now]
    ind = K % roop
    print(step[ind+count[now]])

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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  string ans = "AGC";
  int R;
  cin >> R;

  if (R < 2800) {
    ans = "ARC";
  }
  if (R < 1200) {
    ans = "ABC";
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
     
int main(){
    int a, b, c, ans;
    scanf("%d %d %d", &a, &b, &c);
 
    int A = a + b;
    int B = b + c;
    int C = c + a;
	
	if( A <= B ){
	    if( A <= C ) ans = A;
	    if( A > C ) ans = C;
	}else if( A >= B ){
	    if( A <= C ) ans = B;
	    if( A > C ){
		if( B <= C ) ans = B;
		if( B > C ) ans = C;
	    }
	}

     printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for (int i = m; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    ll n;
    cin >> n;
    vector<ll> d(n);
    rep(i, n) cin >> d[i];
    ll sum = 0;
    
    rep2(i, 0, n -1) {
        rep2 (j, i + 1, n) {
            sum += d[i] * d[j];
        }
    }
    put(sum)

    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  ll r;
  cin>>r;
  ll ans=3*r*r;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int fld[80][80];
string dp[80][80];
int w, h;

int main()
{
	while (cin >> w >> h, w)
	{
		vector<string> v;
		REP(i, h + 1)REP(j, w + 1)
		{
			dp[i][j] = "";
			fld[i][j] = -1;
		}
		REP(i, h)REP(j, w)
		{
			char c;
			cin >> c;
			if (isalpha(c)) fld[i][j] = -1;
			else fld[i][j] = c - '0';
		}
		string ans = "0";
		for (int i = h; i >= 0; i--)
		{
			for (int j = w; j >= 0; j--)
			{
				if (fld[i][j] >= 0)
				{
					char c = fld[i][j] + '0';
					string t1, t2;
					t1 = c + dp[i][j + 1]; t2 = c + dp[i + 1][j];
					if (t1.size() != t2.size()) dp[i][j] = (t1.size() > t2.size() ? t1 : t2);
					else dp[i][j] = max(t1, t2);
				}
			}
		}
		REP(i, h)REP(j, w)
		{
			string s = dp[i][j];
			while (s[0] == '0') s.erase(0, 1);
			v.push_back(s);
		}
		REP(i, v.size())
		{
			if (v[i].size() > ans.size()) ans = v[i];
			else if (v[i].size() == ans.size()) ans = max(ans, v[i]);
		}
		cout << ans << endl;

	}
	return 0;
}

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


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,num=0,count=0;
  cin>>N;
  for(int i=1;i<=N;i++){
    num=0;
    if(i%2!=0){ //まず奇数
      for(int j=1;j<=i;j++){
        if(i%j==0){//約数発見
          num++;
        }
      }
      if(num==8){
        count++;
      }
    }
  }
  cout<<count;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll dp[n];
  dp[0] = 1000;
  reps1(i, n) dp[i] = 0;
  
  reps1(i, n) {
    rep(j, i) {
      ll tmp = dp[i-j-1] / a[i-j-1];
      chmax(dp[i], dp[i-j-1]);
      chmax(dp[i], dp[i-j-1] - tmp * a[i-j-1] + tmp * a[i]);
    }
  }

  cout << dp[n-1] << endl;

  return 0;
}


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

int main(){
  int a,b,c;
  int k;
  cin >> a >> b >> c;
  cin >> k;
  int maxa,ans;
  int maxn;
  maxa = max(a,b);
  maxa = max(maxa,c);

  ans = 0;
  maxn = maxa;
  for(int i = 0;i < k;i++){
    maxn *= 2;
  }

  if(maxa == a){
    ans = maxn + b + c;
  }else if(maxa == b){
    ans = a + maxn + c;
  }else{
    ans = a + b + maxn;
  }

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val result = solve(Scanner(System.`in`))
    if (result.isNotEmpty()) println(result)
}

fun solve(sc: Scanner): String {
    val X = sc.nextInt()
    val A = sc.nextInt()
    val B = sc.nextInt()

    return ((X - A) % B).toString()
}


Measured memory_bytes: 31136
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# s = sys.stdin.readline().rstrip()
import sys,bisect
sys.setrecursionlimit(15000)
h,w = map(int,sys.stdin.readline().split())
buffer = [None for _ in range(h)]
T = [[0]*(w+1) for _ in range(h)]

for r in range(h):
  buffer[r] = list(map(int,sys.stdin.readline().split()))

for col in range(w):
  for r in range(h):
    if buffer[r][col] == 1:
      T[r][col] = 0
    elif r == 0:
      T[0][col] = 1
    else:
      T[r][col] = T[r-1][col]+1
m = 0

for buffer in T:
  stack = []
  for i in range(w+1):
    rect = {"h":buffer[i],"p":i}
    if not stack:
      stack.append(rect)
    else:
      if stack[-1]["h"] < buffer[i]:
        stack.append(rect)
      elif stack[-1]["h"] > buffer[i]:
        while stack and stack[-1]["h"] >= buffer[i]:
          pre = stack.pop()
          m = max(m,pre["h"]*(i-pre["p"]))
          rect["p"] = pre["p"]
        stack.append(rect)
print(m)


Measured memory_bytes: 63276
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  vector<ll>dp(n);
  set<ll>se;
  ll mod=1e9+7;
  rep(i,m){
    ll a;cin>>a;
    a--;
    se.insert(a);
  }
  if(se.count(0))dp[0]=0;
  else dp[0]=1;
  dp[1]=dp[0];
  if(se.count(1))dp[1]=0;
  else dp[1]+=1;
  repi(i,2,n){
    if(se.count(i)){
      continue;
    }
    dp[i]=dp[i-1]+dp[i-2];
    // /cout<<i<<" "<<dp[i]<<endl;
    dp[i]%=mod;
  }
  cout<<dp[n-1]<<endl;


  return 0;

}


Measured memory_bytes: 5760
#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;

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

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

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

void solve(){
    int n,k;cin >> n >> k;
    string s;cin >> s;
    int ans = 0;int cnt = 0;
    vector<char>v;
    for(int i = 0;i<n-1;i++){
        if(s[i]==s[i+1]) ans++;
    }
    char c = 'a';
    for(int i = 0;i<n;i++){
        if(s[i]!=c) {v.push_back(s[i]);c = s[i];}
        if(v.size()==3) {cnt++;v.clear();v.push_back(c);}
    }
    ans += min(k,cnt)*2;
    if(k>cnt&&v.size()==2) ans++;
    cout << ans;
}

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


Measured memory_bytes: 3748
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
 
using namespace std;
 
 
#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif
 
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
 
typedef long long int lint;
typedef pair<int,int> pi;
 
namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}
 
//const int INF=5e8;
 
 
static const int MAXN=100005;
struct BIT{
  int val[MAXN*2+2];
  int n;
  void init(int n_){
    n=1;
    while(n<n_) n<<=1;
    REP(i,n+1) val[i]=0;
  }
  void add(int k,int a){
    ++k;
    while(k<=n){
      val[k]+=a;
      k+=k&-k;
    }
  }
  int query(int k){ //[0,k)
    int res=0;
    while(k>0){
      res+=val[k];
      k-=k&-k;
    }
    return res;
  }
};
 
 
int n;
int buf[3][100005];
 
int ar[100005],sign[100005];
void ng(){
  puts("No");
  exit(0);
}
 
BIT bit;
 
int main(){
  cin>>n;
  REP(i,3) REP(j,n) scanf("%d",&buf[i][j]),--buf[i][j];
 
  REP(i,n){
    int base=buf[0][i]/3;
    REP(j,3) if(buf[j][i]/3!=base) ng();
    if(buf[1][i]%3!=1) ng();

    ar[i]=base;
    sign[base]=(buf[0][i]%3==2);
    if((ar[i]&1)!=(i&1)) ng();
  }
 
  bit.init(n);
  debug(ar,ar+n);
  debug(sign,sign+n);
  for(int i=0;i<n;i+=2){
    int dif=(i/2-bit.query(ar[i]));
    sign[1]^=(dif&1);
    bit.add(ar[i],1);
  }
  debug(sign,sign+n);
  bit.init(n);
  for(int i=1;i<n;i+=2){
    int dif=(i/2-bit.query(ar[i]));
    sign[0]^=(dif&1);
    bit.add(ar[i],1);
  }
 
  debug(sign,sign+n);
 
  int cnt[2]={0};
  REP(i,n) if(sign[i]) cnt[i&1]++;
  if(cnt[0]%2==0 && cnt[1]%2==0) puts("Yes");
  else puts("No");
  return 0;
}
 


Measured memory_bytes: 2688
#include <iostream>
#include <string>
using namespace std;
int h,w;
int H,W;
string s[109];
string S;
bool flag;
int main() {
  cin >> H>> W;
  h=0;
  w=W;

  for(int i=0;i<H;i++){
    cin >> S;
    flag=false;
    for (int j=0;j<W;j++){
      if(S.substr(j,1)=="#"){
        flag=true;
      }
    }
    if(flag){
      s[h]=S;
      h++;
    }
  }
  for(int i=W-1;i>=0;i--){
    flag=true;
    for(int j=0;j<h;j++){
      if(s[j].substr(i,1)=="#"){
        flag=false;
      }
    }
    if(flag){
      for(int k=0;k<h;k++){
        s[k].erase(i,1);
      }
    }
  }
  for(int i=0;i<h;i++){
    cout << s[i] << "\n";
  }
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
from itertools import permutations, combinations
n,m,R = map(int,input().split())
r=list(map(int,input().split()))
for i in range(R):
    r[i]-=1
d = np.zeros((n,n)) 
# 入力
for i in range(m):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    d[a,b] = c
dist =floyd_warshall(d,directed=0).astype(int)
ans=10**10
for v in permutations(r):
    tmp=0
    for i in range(R-1):
        tmp+=dist[v[i],v[i+1]]
    ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 14964
#include<stdio.h>
int main(void)
{
    int n, i, j, a = 0;
    
    scanf("%d", &n);
    
    for(i = 0 ; i < 26 && 4*i <= n ; i++)
    {
        for(j = 0 ; j < 15 && 4*i + 7*j <= n ; j++)
        {
            if(4*i + 7*j == n) a++;
        }
    }
    if(a != 0) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 128
a,z,x,i,j;main(t){for(scanf("%d",&t);t--;){for(a=z=0,scanf("%d%d",&x,&i);--x;)scanf("%d",&j),i-=j,a=i>a?i:a,z=i<z?i:z,i=j;printf("%d %d\n",-z,a);}exit(0);}

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

using namespace std;

int gcd(int a, int b){
  if(a < b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  
  int r = a % b;
  if(r == 0){
    return b;
  }else{
    return gcd(b, r);
  }
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  vector<int> left(n);
  vector<int> right(n);
  
  left.at(0) = a.at(0);
  right.at(n - 1) = a.at(n - 1);
  
  for(int i = 1; i < n - 1; i++){
    left.at(i) = gcd(a.at(i), left.at(i - 1));
  }
  for(int i = n - 2; i > 0; i--){
    right.at(i) = gcd(a.at(i), right.at(i + 1));
  }
  
  int max_gcd = right.at(1);
  for(int i = 1; i < n - 1; i++){
    max_gcd = max(max_gcd, gcd(left.at(i - 1), right.at(i + 1)));
  }
  max_gcd = max(max_gcd, left.at(n - 2));
  
  cout << max_gcd << endl;
  
  return 0;
}


Measured memory_bytes: 1408
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/

int main()
{
	int a, b;
	
	scanf("%d%d", &a, &b);
	if (a == 1){
		a = 14;
	}
	if (b == 1){
		b = 14;
	}
	if (a > b){
		puts("Alice");
	} else if (a < b){
		puts("Bob");
	} else {
		puts("Draw");
	}
} 

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
print('x'*len(s))

Measured memory_bytes: 63980
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	 const int N =1e5+5;
    
     int mod= 1e9+7,INF=1e17;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
     
     
     vi v[N];
     int n,k,ans=1;
    
    void dfs(int x,int p,int num){
		   ans=(ans*num)%mod;
		   
		   num=k-1;
		   if(p!=-1) 
		     num--;
		   
		   for(auto to:v[x]){
			   if(to!=p){
				 
				   if(num<=0){
					   ans=0;
					   return;					   
				   }				   
				   dfs(to,x,num);
				   num--;
			   }
		   }	   
	} 
     
     
     void solve(){
		 
		 
        cin>>n>>k;
        
        rep(i,1,n){
			int x,y;
			cin>>x>>y;
			v[x].pb(y);
			v[y].pb(x);
		}
		
	  
	
	   dfs(1,-1,k);
	
		cout<<ans<<endl;
       
	 }
	
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    cin >> len;
    vector<vector<int>> arr(len, vector<int> (3));
    for(int i = 0; i < len; i++) {
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }
    for(int i = 0; i < len - 1; i++) {
        int ans = 0;
        ans += arr[i][1] + arr[i][0];
        for(int j = i + 1; j < len - 1; j++) {
            if(ans <= arr[j][1])
                ans = arr[j][1];
            else {
                while(ans % arr[j][2] != 0)
                    ans++;
            }
            ans += arr[j][0];
        }
        cout << ans << endl;
    }
    cout << 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=500005,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,L,cnt,h[N],b[N],sl[N],sr[N];
ll ans;
typedef pair<int,int> pr;
priority_queue<pr,vector<pr>,greater<pr> > f;
struct node{int val,l,r,pre,nex;}a[N];
int getsum(int *s,int l,int r){return s[r]-s[l-1];}
void split(int x){
	int cur=x;m=0;
	while (a[x].val==a[cur].val){
		b[++m]=cur;
		sl[m]=sl[m-1]+a[cur].l;
		sr[m]=sr[m-1]+a[cur].r;
		cur=a[cur].nex;
	}
}
int getpre(int x){while(a[a[x].pre].val==a[x].val) x=a[x].pre;return x;}
void recalc(int x,int y){
	split(getpre(x));
	for (int i=1;i<=m;i++) if (b[i]==x) {x=i;break;}
	for (int i=1;i<=m;i++) if (b[i]==y) {y=i;break;}
	for (int i=1;i<=y;i++){
		int l=max((i<x) ? x : (y+1),i+L-1),r=m;
		if (l<=r) ans+=(ll)a[b[i]].l*getsum(sr,l,r);
	}
}
void printch(int x){
	while (a[x].pre) x=a[x].pre;
	for (;x;x=a[x].nex) printf("%d ",x);
	printf("\n");
}
int main(){
	n=read();L=read();ans=cnt=n;
	for (int i=1;i<=n;i++){
		a[i].val=read();a[i].l=a[i].r=1;
		a[i].pre=i-1;a[i].nex=i+1;h[i]=1;
		f.push(make_pair(a[i].val,i));
	}
	a[n].nex=0;
	for (int i=1,j;i<=n;i=j){
		for (j=i;a[i].val==a[j].val;j++);
		int len=j-i;
		if (len>=L) ans+=(ll)(len-L+1)*(len-L+2)/2;
	}
	while (1){
		while (!h[f.top().second]) f.pop();
		int x=getpre(f.top().second),y;f.pop();
		//printch(x);
		if (a[x].val>=inf) break;
		split(x);
		for (int i=1;i<=m;i++) h[b[i]]=0;
		x=a[b[1]].pre,y=a[b[m]].nex;
		if (m<L){
			a[++cnt].val=inf;a[cnt].pre=x;a[cnt].nex=y;
			if (x) a[x].nex=cnt;
			if (y) a[y].pre=cnt;
			h[cnt]=1;f.push(make_pair(a[cnt].val,cnt));
			continue;
		}
		int r=m/L;
		for (int i=1;i<=r;i++){
			a[cnt+i].val=a[b[1]].val+1;
			int tl=m-(r-i+1)*L+1,tr=max(1,tl-(L-1));
			a[cnt+i].l=getsum(sl,tr,tl);
			tl=i*L,tr=min(m,tl+L-1);
			a[cnt+i].r=getsum(sr,tl,tr);
			a[cnt+i].pre=(i!=1) ? (cnt+i-1) : x;
			a[cnt+i].nex=(i!=r) ? (cnt+i+1) : y;
			h[cnt+i]=1;f.push(make_pair(a[cnt+i].val,cnt+i));
		}
		if (x) a[x].nex=cnt+1;
		if (y) a[y].pre=cnt+r;
		recalc(cnt+1,cnt+r);
		cnt+=r;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 19440
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	string s; cin >> s;
	Int ans = 0;
	vector<vector<Int>> a(3, vector<Int>(n+1, 0));
	for(Int i=0; i<n; ++i)
		a[s[i]=='R'?0:s[i]=='G'?1:2][i+1] = 1;
	for(Int i=1; i<=n; ++i)
		for(Int j=0; j<3; ++j)
			a[j][i] += a[j][i-1];
	for(Int j=1; j+1<n; ++j){
		Int t = s[j] == 'R' ? 0 : s[j] == 'G' ? 1 : 2;
		Int u = (t + 1) % 3;
		Int v = (u + 1) % 3;
		ans += a[u][j] * (a[v][n] - a[v][j]);
		ans += a[v][j] * (a[u][n] - a[u][j]);
		for(Int k=1; j-k>=0&&j+k<n; ++k)
			if(s[j-k] != s[j] && s[j+k] != s[j] && s[j-k] != s[j+k])
				--ans;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3744
def main():
  str = input()
  first = str[:2]
  second = str[2:]
  first = change(first)
  second = change(second)
  f_y = 0; s_y = 0;
  f_y = check_y(first)
  s_y = check_y(second)
  if(f_y == 0 and s_y == 0):
    print("AMBIGUOUS")
  elif(f_y == 0 and s_y == 1):
    print("MMYY")
  elif(f_y == 1 and s_y == 0):
    print("YYMM")
  else:
    print("NA")
    
def change(str):
  if(str[0] == "0"):
    return int(str[1])
  else:
    return int(str)
  
def check_y(num):
  if(num == 0 or num > 12):
    return 1
  else:
    return 0
  
if __name__ == "__main__":
  main()



Measured memory_bytes: 3064