akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  int x, y;
  int i, d;

  scanf("%d%d", &x, &y);
 

  if(x > y){
    for(i = (x%y); i >= 0; i--){
      if((y % i) == 0 && ((x%y) % i) == 0){
	printf("%d\n", i);
	break;
      }
    }
  }

  else if(x < y){
    for(i = (y%x); i >= 0; i--){
      if((x % i) == 0 && ((y%x) % i) == 0){
	printf("%d\n", i);
	break;
      }
    }
  }

  else printf("%d\n", x);
  
  return 0;
}



Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        String t = scan.nextLine();
        if (s.equals(t.substring(0, s.length()))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35508
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    s = inputs[0].split(' ')
    num = int(s[0] + s[1])
    if int(math.sqrt(num)*10) % 10 == 0:
        return 'Yes'
    return 'No'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


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

int main() {
	//入力
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	//処理
	int Min = 1000000000, Max = 0;
	for (int i = 0; i < N; i++) {
		Min = min(Min, A.at(i));
		Max = max(Max, A.at(i));
	}

	cout << Max - Min << endl;

}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add_self(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int add(int a,int b){
	int c=a+b;
	if(c>=mod){
		c-=mod;
	}
	return c;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=2000005;
 
void solve(){
	int h,w,k;
	cin>>h>>w>>k;
	vector<string>a(h);
	cin>>a;
	vector<vector<int>>ans(h,vector<int>(w));
	vector<int>last;
	int cnt=0;
	for(int i=0;i<h;i++){
		int prv=0;
		int fl=0;
		for(int j=0;j<w;j++){
			if(a[i][j]=='#'){
				cnt++;
				fl++;
				while(prv<=j){
					ans[i][prv]=cnt;
					prv++;
				}
			}
		}
		if(fl){
			while(prv<w){
				ans[i][prv]=cnt;
				prv++;
			}
		}
	}
	int lst=0;
	int fs=0;
	for(int i=0;i<h;i++){
		if(accumulate(all(ans[i]),0ll)){
			if(fs==0){
				fs=i+1;
			}
			lst=i;
			continue;
		}
		ans[i]=ans[lst];
	}
	fs--;
	for(int i=0;i<h;i++){
		if(accumulate(all(ans[i]),0ll)){
			break;
		}
		ans[i]=ans[fs];
	}
	for(auto i:ans){
		for(auto j:i){
			cout<<j<<' ';
		}
		cout<<"\n";
	}
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int n, cnt4, cnt2;

int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		int x; cin >> x;
		if (x % 4 == 0) cnt4++;
		else if (x % 2 == 0) cnt2++;
	}	
	if (cnt4 >= n / 2){
		cout << "Yes";
		return 0;	
	}
	else if (cnt4 * 2 + cnt2 >= n){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
	
}


Measured memory_bytes: 256
// garnab27
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ll int64_t
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
ll modex(ll a,ll b,ll p){ll res=1;a%=p;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b>>=1;}return res;}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
 
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);	
 
	string s;
	cin>>s;

	for(int i=0;i<3;i++){
		if(s[i]=='7'){
			cout<<"Yes";
			return 0;
		}
	}

	cout<<"No";
	
 
 
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char const* argv[])
{
    int n;
    std::cin >> n;

    auto values = std::vector<int>(n);

    for(auto &v: values)
    {
        std::cin >> v;
    }
    for(auto &v: values)
    {
        int tmp;
        std::cin >> tmp;
        v -= tmp;
    }

    std::sort(values.begin(), values.end(), std::greater<int>());

    int result = 0;
    for(auto v: values)
    {
        if(v > 0)
        {
            result += v;
        }
        else
        {
            break;
        }
    }
    std::cout << result << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  string s,t;
  cin >> s;
  reverse(all(s));
  int u=0;
  rep(i,s.size()){
      if (s[i]=='B') u++;
      else if (u>0) u--;
      else if (s[i]=='1') t+='1';
      else t+='0';
  }
  reverse(all(t));
  cout << t << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
lis = [0]*8
fr = 0
for i in a:
    col = i // 400
    if col > 7:
        fr += 1
    else:
        lis[col] = 1
mi = max(lis.count(1),1)
mx = lis.count(1) + fr

print(mi,mx)

Measured memory_bytes: 3060
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
int main(){
    
    int long long n,p;
    cin>>n>>p;
    int long long a=1;
    int long long ans=0;
    if(n==1){
        cout<<p<<endl;
        return 0;
    }
    
    int long long b=sqrt(p);
    
    while(true){
        int long long a=pow(b,n);
        if(p%a==0){
            ans=b;
            break;
        }
        
        b--;
    }
    cout<<ans<<endl;
    
    
    
    /*while(true){
        int long long b=pow(a,n);
        if(b>p){
            break;
        }
        if(p%b==0){
            ans=a;
        }
        a++;
    }*/

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  if (A[0] != 0) {
    cout << -1 << endl;
    return 0;
  }
  ll num = 0;
  for (int i = 1; i < N; i++) {
    if (A[i] == A[i-1] + 1) {
      num += 1;
    } else if (A[i] <= A[i-1] + 1) {
      num += A[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << num << endl;
  return 0;
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {
	int n;
 	cin >> n;
  
  	if (n%10 == 7 || ((n/10)%10)== 7 || ((n/100)%10) == 7)
      cout << "Yes";
  	else
      cout << "No";
}

Measured memory_bytes: 3632
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

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

  ll mon = 100;
  int year = 0;
  while (1) {
    if (mon >= x) {
      break;
    }
    mon += mon * 0.01;
    year++;
  }
  cout << year;

  return 0;
}


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

int main() {
    string s;
    int Q;
    string front = "";
    string end = "";
    int r=0;
    cin >> s;
    cin >> Q;
    int q,F;
    char C;
    for(int i=0;i<Q;i++) {
        cin >> q;
        if(q == 1) r++;
        else {
            cin >> F >> C;
            if(F == 1) {
                if(r%2) end = end+C;
                else front = C+front;
            }
            else {
                if(r%2) front = C+front;
                else end = end+C;
            }
        }
    }
    string ans = front + s + end;
    if(r%2) reverse(ans.begin(), ans.end());
    cout << ans << endl;

}

Measured memory_bytes: 1512
#include <stdio.h>

int n;
int bit[5001];
int sum(int i){
  int s=0;
  while(i>0){
    s+=bit[i];
    i -=i&-i;
  }
  return s;
}
void add(int i,int x){
  while(i<=n){
    bit[i]+=x;
    i+=i&-i;
  }
}
int max(int a,int b){
  if(a<b)return b;
  else return a;
}
int main(){
  int i,j,x,s,t;
  int mx,tmp;
  while(1){
    mx=-5000000;
   
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<=n;i++)bit[i]=0;
    for(i=1;i<=n;i++){
      scanf("%d",&x);
      add(i,x);
    }
    for(i=1;i<=n;i++){
      tmp=sum(i);
      if(mx<tmp){mx=tmp;s=0;t=i;}
    }
    for(i=1;i<n;i++){
      for(j=i+1;j<=n;j++){
	tmp=sum(j)-sum(i);
	if(mx<tmp){mx=tmp;s=i;t=j;}
      }
    }
    printf("%d\n",mx);
  }
  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int N = 22;
const int MAXS = (1 << 20) + 5;
const int MOD = 1e9 + 7;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

int n, m, K, S, must[N][N];
int nxt[MAXS][N], dp[2][N][MAXS], ans;

inline void Inc(int &x, int y) {
	x += y; if (x >= MOD) x -= MOD;
}

void init() {
	read(n); read(m); read(K); 
	--n; S = (1 << n);
	mset(must, -1);
	for (int i = 1, a, b; i <= K; ++i) {
		read(a); read(b);
		read(must[a][b - 1]);
	}
	for (int s = 0; s < S; ++s) {
		int lst = -1;
		for (int i = n - 1; ~i; --i) {
			if ((s >> i) & 1) lst = i;
			nxt[s][i] = lst;
		}
	}
}

void solve() {
	int pre = 0, cur = 1;
	dp[pre][n][0] = 1;
	for (int i = 1; i <= m; ++i) {
		mset(dp[cur], 0);
		for (int s = 0; s < S; ++s) {
			dp[cur][0][s] = dp[pre][n][s];
		}
		for (int j = 0; j < n; ++j) {
			for (int s = 0; s < S; ++s) {
				if (!dp[cur][j][s]) continue;
				for (int b = 0; b < 2; ++b) {
					if (~must[i][j] && must[i][j] != b) continue;
					int k = (s >> j) & 1;
					if (k > b) continue;
					if (k == b) {
						Inc(dp[cur][j + 1][s], dp[cur][j][s]);
					} else {
						int t = nxt[s][j];
						if (t == -1) {
							Inc(dp[cur][j + 1][s ^ (1 << j)], dp[cur][j][s]);
						} else {
							Inc(dp[cur][j + 1][s ^ (1 << j) ^ (1 << t)], dp[cur][j][s]);
						}
					}
				}
			}
		}
		swap(pre, cur);
	}
	for (int s = 0; s < S; ++s) {
		Inc(ans, dp[pre][n][s]);
	}
	printf("%d\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 227584
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <random>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)
#define DMP(x) cerr << #x << ": " << x << "\n"
#define INF  1000000000

using namespace std;
typedef long long lint;
const int MOD = 1000000007;
random_device rnd;

int dp[45][410][410];

int main() {

	cin.tie(0);
	
	int N, M_a, M_b, ans = INF;
	cin >> N >> M_a >> M_b;

	vector<int> a(N), b(N), c(N);
	FOR(i, 0, N) cin >> a[i] >> b[i] >> c[i];

	FOR(i, 0, 45)FOR(j, 0, 410)FOR(k, 0, 410) {
	
		dp[i][j][k] = INF;
	}

	dp[0][0][0] = 0;

	FOR(i, 0, N) {
		FOR(j, 0, 400) {
			FOR(k, 0, 400) {

				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
				dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
			}
		}
	}

	for (int i = 1; i * max(M_a, M_b) < 410; i++) ans = ans > dp[N][i*M_a][i*M_b] ? dp[N][i*M_a][i*M_b] : ans;
	if (ans == INF) cout << "-1";
	else cout << ans;

	return 0;
}

Measured memory_bytes: 29824
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.Stream;

public class Main {
	static long count = 0;
	
	public static long[] func(long[] ar) {
		Arrays.sort(ar);
		if (ar[0] == 0) {
			long[] result = {count, 0};
			return result;
		}
		//System.out.prlongln(Arrays.toString(ar));
		count = count + ar[0] * 3 * (ar[1] / ar[0]);
		long[] next = {ar[0], (ar[1] % ar[0])};
		return func(next);
	}
	
	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String[] line = br.readLine().trim().split(" ");
		//long[] ar = Stream.of(line).mapToLong(Integer::parseLong).toArray();
		Scanner sc = new Scanner(System.in);
			long[] ar = {sc.nextLong(), sc.nextLong()};
		Arrays.sort(ar);
		ar[1] = ar[1] - ar[0];
		//System.out.prlongln(Arrays.toString(ar));
		System.out.println(func(ar)[0]);
	}
}

Measured memory_bytes: 9552
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))


score=0
#食べた番号
num=0
old_num=0

for i in range(N):
    num=A[i]-1
    score+=B[num]
    if i!=0 and num==old_num+1:
        score+=C[num-1]
    old_num=num

print(score)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(){
  int a = 0;
  char s[10];
  scanf("%s",s);
  if(strcmp(s,"SUN")==0)
    a = 7;
  else if(strcmp(s,"MON")==0)
    a = 6;
  else if(strcmp(s,"TUE")==0)
    a = 5;
  else if(strcmp(s,"WED")==0)
    a = 4;
  else if(strcmp(s,"THU")==0)
    a = 3;
  else if(strcmp(s,"FRI")==0)
    a = 2;
  else if(strcmp(s,"SAT")==0)
    a = 1;
  printf("%d",a);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
  int line_height_a, line_width_a, line_height_b, line_width_b;
  scanf("%d %d %d %d", &line_height_a, &line_width_a, &line_height_b, &line_width_b);
  if(line_height_a * line_width_a > line_height_b * line_width_b) {
    printf("%d\n", line_height_a * line_width_a);
  } else {
    printf("%d\n", line_height_b * line_width_b);
  }
  return 0;
}


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

typedef long long LL;

LL a, b, c, k;

int main(){
	while(~scanf("%lld %lld %lld %lld", &a, &b, &c, &k)){
		if(k % 2 == 1)	swap(a, b);
		printf("%lld\n", a - b);
	}
	return 0;
}


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

    int ans;
int main() {
    int N;
    cin >> N ;
    
    for (int i = 0; i < N; i++){
        int l,r;
        cin >>l>>r;
        ans += r-l+1;
    }
    cout << ans;
      
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int gcd(int x, int y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    ll A, B, C, D; cin >> A >> B >> C >> D;

    if (C < D) swap(C, D);
    ll lcm = C * D / gcd(C, D);
    ll out = B - A + 1
            - B / C + (A - 1) / C 
            - B / D + (A - 1) / D
            + B / lcm - (A - 1) / lcm;

    cout << out << endl;

    return 0;
}


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

int main() {
  int S,W;
  cin >> S >> W;
  if(S>W) cout << "safe" << endl;
  else cout << "unsafe" << endl;
  return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		StringBuilder b = new StringBuilder(sc.next());
		String r = b.deleteCharAt(b.length()-1).toString();

		if (a.equals(r)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 26952
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
char a;
  cin >> a;
  if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}


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

using ll = long long;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 1000;
    for (int i = 0; i < s.size() - t.size() + 1; ++i) {
        int replace = 0;
        for (int j = 0; j < t.size(); ++j) {
            if (s[i+j] != t[j]) ++replace;
        }
        ans = min(ans, replace);
    }
    cout << ans << endl;
}

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

int main(){
	int n;
	cin >> n;
	ll ans = 0;
	rep(i,n){
		ll a;
		cin >> a;
		ans += --a;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(){
	char n[20];
	int a,b,c;
	a=0;
	b=0;
	c=0;
	for(int i=0;i<20;i++){
		n[i]=0;
	}
	cin >> n ;
	for(int i=0;i<20;i++){
		if((n[i]>='0')&&(n[i]<='9')){
			a=1;
		}
		if((n[i]>='a')&&(n[i]<='z')){
			b=1;
		}
		if((n[i]>='A')&&(n[i]<='Z')){
			c=1;
		}
	}
	if(n[5]==0){
		cout <<"INVALID\n";
	}
	else if((a==1)&&(b==1)&&(c==1)){
		cout <<"VALID\n";
	}
	else{
		cout <<"INVALID\n";
	}
return 0;
}

Measured memory_bytes: 1108
#include<stdio.h>

int main(){
    int x,y,s;
    int i,j;
    int before,after;
    int max;
    
    for(;scanf("%d %d %d", &x, &y, &s),x;){
        max=0;

        for(i=1;i<s;i++){
            for(j=1;j<s;j++){
                before = (100+x)*i/100 + (100+x)*j/100;
                if(before==s){
                    after = (100+y)*i/100 + (100+y)*j/100;
                    if(after>max)
                        max=after;
                }
            }
        }
        printf("%d\n",max);
    }
    
    return 0;
}

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

int n, l, r;
bool f;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	l = 0;
	r = n;
	string s;
	cout << 0 << endl;
	cin >> s;
	if(s[0] == 'V') return 0;
	if(s[0] == 'M') f = true;
	while(1){
		int m = (r-l)/2+l;
		cout << m << endl;
		string t;
		cin >> t;
		if(t[0] == 'V') return 0;
		if((t[0] == 'M') ^ (m % 2 == 0) ^ f) l = m;
		else r = m;
	}
}

Measured memory_bytes: 852
/*https://atcoder.jp/contests/abc092/tasks/abc092_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int n, d, x, p = 0, a[100], count = 0;
	cin >> n >> d >> x;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
	{
		if (a[i] == 1)
			p++;
		// cout << a[i] << " ";
		int b = 1, j = 1;
		while (b <= d)
		{
			if (b <= d)
				count++;
			b = a[i] * j + 1, j++;
			// cout << b << " ";

		}
		// cout << endl;

	}
	// for (int i = 0; i < v.size(); i++)
	// 	cout << v[i] << " ";
	// cout << endl;
	cout << count + x;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, h, w;
    cin >> n >> h >> w;
    
    cout << (n - w + 1) * (n - h + 1) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	n = max(n, m);
	if (k % n == 0)
		printf("%d\n", k / n);
	else
		printf("%d\n", k / n + 1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
struct edge{ ll to; ll cap; ll rev;};

const ll MAXN=2000;
vector<edge> G[MAXN];

bool used[MAXN];
ll yaku(ll a, ll b){
    if(a>b) return yaku(b,a);
    else{
        if(b%a==0) return a;
        else return yaku(b%a,a);
    }
}

void addEdge0(ll from, ll to, ll cap){
    edge A={to,cap,(ll)G[to].size()};
    edge B={from,0,(ll)G[from].size()};
    G[from].push_back(A);
    G[to].push_back(B);
    return;
}//有向グラフを作る

void addEdge1(ll a, ll b, ll cap){
    edge A={b,cap,(ll)G[b].size()};
    edge B={a,cap,(ll)G[a].size()};
    G[a].push_back(A);
    G[b].push_back(B);
    return;
}//無向グラフを作る

ll dfs(ll v, ll t, ll f){
    if(v==t) return f;
    used[v]=true;
    rep(i,G[v].size()){
        edge &e=G[v][i];
        if(!used[e.to] && e.cap>0){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

ll MaxFlow(ll Start, ll Goal){
    ll ans=0;
    while(true){
        rep(i,MAXN) used[i]=false;
        ll P=dfs(Start, Goal, INF);
        if(P==0) break;
        ans+=P;
    }
    return ans;
}

int main(){
    vec A;
    while(true){
        ll M,N; cin>>M>>N;
        if(M==0 && N==0) break;
        rep(i,MAXN) G[i].clear();
        vec r(M), b(N);
        rep(i,M) cin>>r.at(i);
        rep(i,N) cin>>b.at(i);
        rep(i,M) addEdge0(1500,i,1);
        rep(i,N) addEdge0(i+700,1501,1);
        rep(i,M) rep(j,N){
            if(yaku(r.at(i),b.at(j))>1) addEdge0(i,j+700,1);
        }

        A.push_back(MaxFlow(1500,1501));
    }
    rep(i,A.size()) cout<<A.at(i)<<endl;


}



Measured memory_bytes: 15884
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  ll X;
  cin >> X;
  vector<ll> vec;
  for (ll i = 0; i <= 1000; i++) { vec.push_back(i * i * i * i * i); }
  for (int i = 0; i < vec.size(); i++) {
    for (int j = 0; j < vec.size(); j++) {
      if (vec[i] + vec[j] == X) {
        cout << i << ' ' << -j << endl;
        return;
      }
      if (vec[i] - vec[j] == X) {
        cout << i << ' ' << j << endl;
        return;
      }
    }
  }
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3632
import sys
from collections import defaultdict
def cur(n):
    if n not in dic:
        if n%2==0:
            m=n//2
            n1=cur(m)+ min(a,d*(n-m))
        else:
            n1=min(cur(n//2)+min(a+d,d*(n-n//2)),cur(n//2+1)+a+d)

        if n%3==0:
            m=n//3
            n2=cur(m)+ min(b,d*(n-m))
        else:
            n2=min(cur(n//3)+min(b+d*(n%3),d*(n-n//3)) ,cur(n//3+1)+b+d*(3-n%3))

        if n%5==0:
            m=n//5
            n3=cur(m)+ min(c,d*(n-m))
        else:
            n3=min(cur(n//5)+ min(c+d*(n%5),d*(n-n//5) ) ,cur(n//5+1)+c+d*(5-n%5))
        dic[n]=min(n1,n2,n3)
    return dic[n]

t=int(input())
for _ in range(t):
    p,a,b,c,d=map(int,input().split())
    tmpdic=defaultdict(lambda: 10**15)
    tmpdic[0]=0;tmpdic[1]=d;tmpdic[2]=min(2*d,a+d)
    s=(1,2)
    for _ in range(7):
        ss=set()
        for x in s:
            tmpdic[2*x]=min(tmpdic[2*x],tmpdic[x]+a);ss.add(2*x)
            tmpdic[3*x]=min(tmpdic[3*x],tmpdic[x]+b);ss.add(3*x)
            tmpdic[5*x]=min(tmpdic[5*x],tmpdic[x]+c);ss.add(5*x)
            tmpdic[x+1]=min(tmpdic[x+1],tmpdic[x]+d);ss.add(x+1)
            tmpdic[x-1]=min(tmpdic[x-1],tmpdic[x]+d)
            if x-1>2: ss.add(x-1)
        s=ss
    dic={0:0,1:d,2:min(2*d,a+d)}
    for i in range(3,11):
        dic[i]=min(tmpdic[i],i*d)
    print(cur(p))

Measured memory_bytes: 96308
#include<iostream>
#include<vector>
#include<algorithm>

#define DIAGONAL 1
#define TOP 0
#define NMAX 100
#define WMAX 10000

using namespace std;

struct Item{
  int value, weight;
};

Item item[NMAX + 1];

int C[NMAX + 1][WMAX + 1];
int G[NMAX + 1][WMAX + 1];

void initialize(int N, int W){
  for(int i = 1; i <= N; i++){
    cin >> item[i].value >> item[i].weight;
  }


  for(int i = 0; i <= N; i++){
    for(int w = 0; w <= W; w++){
      C[i][w] = 0;
      G[i][w] = TOP;
    }
  }
}

int solve(int N, int W){
  int update, no_update;

  for(int i = 1; i <= N; i++){
    for(int w = 1; w <= W; w++){
      no_update = C[i-1][w];

      if(item[i].weight <= w){
        update = C[i-1][w-item[i].weight] + item[i].value;
        if(update > no_update){
          C[i][w] = update;
          G[i][w] = DIAGONAL;
        }else{
          C[i][w] = no_update;
        }
      }else{
        C[i][w] = no_update;
      }
    }
  }
  return C[N][W];
}

void history(vector<int> &selection, int N, int W){
  selection.clear();

  for(int i = N, w = W; i > 0; i--){
    if(G[i][w] == DIAGONAL){
      selection.push_back(i);
      w -= item[i].weight;
    }
  }

  reverse(selection.begin(), selection.end());

  for(vector<int>::iterator itr = selection.begin(); itr != selection.end(); ++itr){
    cout << *itr << ' ';
  }
}


int main(){
  int max;
  int N, W;
  cin >> N >> W;
  initialize(N,W);
  max = solve(N,W);

  cout << max << endl;

  return 0;
}



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

using  ll = long long;
using ull = unsigned long long;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
constexpr ll kINF = 1152921504606846976;
constexpr double kEps = 1e-6;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second

ll dp[100010];
ll N;
ll h[100010];

template<class T>inline bool chmin(T& a, const T b) {if (a > b) {a = b; return true;} return false;}

int main(void) {
  cin >> N;
  rep(i,N) cin >> h[i];

  rep(i,N-1) dp[i+1] = kINF;

  rep(i,N-1) {
    chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
    chmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
  }

  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String sl[] = s.split(" ");
            int A = Integer.parseInt(sl[0]);
            int B = Integer.parseInt(sl[1]);
            int C = Integer.parseInt(sl[2]);
            int D = Integer.parseInt(sl[3]);

            System.out.println(A * B <= C * D ? C * D : A * B);
        }
    }
}


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

int main() {
  string s,t;
  cin >> s >> t;
  int cnt = 0;
  for (int i = 0; i< s.size(); i++) {
    if (s.at(i)!=t.at(i)) cnt++;
    else continue;
  }
  cout << cnt << endl;
}

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

#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector < ll >
#define vvll vector < vll >
#define vld vector < ld >
#define pll pair < ll,ll >
#define ppll pair < ll, pll > 
#define pld pair < ld,ld > 
#define vpll vector < pll >
#define vpld vector < pld >
#define all(X) X.begin(),X.end()
#define rall(X) X.rbegin(),X.rend()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
vll emptyVector;
const ll MAX = 2e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884197169399375105;

ll binaryExpo(ll x, ll n)
{
	if(n == 0)
		return 1;
	if(n % 2 == 0)
		return binaryExpo((x*x) % MOD, n/2);
	return (x*binaryExpo((x*x) % MOD, n/2)) % MOD;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
/*-------------------------------------------		CODE STARTS FROM HERE		------------------------------------------*/

ll fun(ll z)
{
	return (z*(z + 1))/2;
}

void solve(void)
{
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int h = k / 60;
	int m = k % 60;
	h2 -= h;
	m2 -= m;
	cout << (h2 - h1)*60 + (m2 - m1) << endl;
	




}

int main(void)
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);


	// int t;
	// cin >> t;
	// while(t--)
	{
		solve();
	}


	return 0;
}

Measured memory_bytes: 3636
#include <string>
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <vector>
#include <numeric>
using namespace std;

int main(){
    int n, m;
    bool check = true;
    cin >> n >> m;
    vector<unsigned long int> step(n+1, 0);
    step[0] = 1;
    step[1] = 1;
    for(int i = 2, k = -1; i<n+1; i++){
        if(check && m!=0){
            m--;
            cin >> k;
            if (k==1){
                step[1] = 0;
                cin >> k;
                m--;
            }
        }
        if(i==k){
            step[i] = 0;
            check = true;
        }
        else{
            step[i] = (step[i-1] + step[i-2])%1000000007;
            check = false;
        }
    }
    cout << step[n]<< endl;
    
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head) << " ";
  print(tail...);
}

int main() {
  GI(N);
  vector<ll> a(N), acc(N);
  FOR(i, N) {
    cin >> a[i];
    acc[i] = (i > 0 ? acc[i - 1] : 0) + a[i];
  }
  ll mn = 1LL << 48;
  FOR(i, N - 1) {
    ll tmp = abs(acc[i] - (acc[N - 1] - acc[i]));
    mn = min(mn, tmp);
  }
  print(mn);
  return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
 
int selection_sort(int n, int *a)
{
    int i, j, minj, x;
int ans = 0;
 
    for (i = 0; i < n; i++) {
        minj = i;
        for (j = i; j < n; j++) {
            if (a[j] < a[minj]) minj = j;
        }
        if (i != minj) {
            x = a[i], a[i] = a[minj], a[minj] = x;
ans++;
        }
    }
return ans;
}
 
int in()
{
    int n = 0, c = getchar_unlocked();
    do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
    return n;
}
 
int a[102];
 
int main()
{
    int N, i, k;
 
    N = in();
    for (i = 0; i < N; i++) a[i] = in();
    k = selection_sort(N, a);
    printf("%d", a[0]);
    for (i = 1; i < N; i++) printf(" %d", a[i]);
    putchar('\n');
    printf("%d\n", k);
    return 0;
}



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

//TO_STRING
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(char ch){
  string s;
  s += ch;
  return s;
}

string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
    to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
    to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

//DEBUG 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL //compile with -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vvi> vvvi;

#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define fi first
#define se second  
#define sz(x) ((int)x.size())


void solve() {
	int n, m;
	cin >> n >> m;
	int sum = 0;
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		sum += x;
	}
	cout << max(-1, n - sum) << endl;
}	

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0); 
  
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}

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

int main(){
  int n;
  cin >> n;
  string str;
  cin >> str;
  int left = 0;
  int right = 0;
  for(int i=0; i<n; i++){
    if(str[i] == '('){
      left++; 
    }else{
      if(left > 0) left--;
      else right++;
    }
  }
  string leftStr = "";
  string rightStr = "";
  for(int i=0; i<right; i++) leftStr += "(";
  for(int i=0; i<left; i++) rightStr += ")";
  cout << leftStr + str + rightStr << endl;
  return 0;
}

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

void solveA(){
  int n,k;
  cin >> n >> k;

  if (k <= (n+1)/2){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}
void solveB(){
  int a[3],b[3];
  int cnt[4] = {0};
  bool flg = true;

  for(int i=0;i<3;i++){
    cin >> a[i] >> b[i];
    cnt[a[i]-1] ++;
    cnt[b[i]-1] ++;
  }

  for(int i=0;i<4;i++){
    if (cnt[i] >= 3) flg = false;
  }
  if (flg) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}
void solveC(){
  
}
void solveD(){
}

int main(){
  solveB();
}


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

#define REP(i,n) for(int i=0; i<n; ++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 pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a == 1) a = 14;
    if(b == 1) b = 14;
    if(a == b){
        cout << "Draw" << "\n";
    }else if(a > b){
        cout << "Alice" << "\n";
    }else{
        cout << "Bob" << "\n";
    }

    return 0;
}


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

using namespace std;

int main() {

    int n, m;
    string id;
    map<string, bool> account;
    bool door = false;

    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> id;
        account[id] = true;
    }

    cin >> m;
    for(int i = 0; i < m; ++i) {
        cin >> id;
        if(account.count(id)) {
            if(door == false) cout << "Opened by ";
            else cout << "Closed by ";
            door = !door;
        } else {
            cout << "Unknown ";
        }
        cout << id << endl;
    }

}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
 /* if (K % 2 == 1) {
    N /= K;
    //最大がi.
    REPS(i, N) { ans += 3 * (i * i - i) / 2 - 1; }

  } else {
    K /= 2;
    N /= K;
    REPS(i, N) { ans += 3 * (i * i - i) / 2 - 1; }
    REPS(i, N / 2) { ans += 3 * (i * i - i) / 2 - 1; }
  }
  cout << ans << endl; */
  lli nk = N/K;
  if (K%2==1){
    cout <<nk*nk*nk<<"\n";
  }else{
    lli modk  =  N % K;
    lli n2k = modk>=K/2?nk+1:nk;
    cout << nk*nk*nk+n2k*n2k*n2k<<"\n";
  }
}
// 18 4
// N N 1-N  i
// N p p   (i-1)/2
// N p q  i-1
// 6-2 7-3 8-3
// 52.43.61 62 53 44 54
// 62 53 44 63 54 64 55 65
//

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sqr(x) (x*x)
using namespace std;
typedef long long ll;
ll a[101001], b[101010], n;
map<ll,int>id;
int main() {
    while(cin>>n) {
        id.clear();
        for(ll i=1;i<=n;i++) {
            ll t;
            cin>>t;
            for(ll j=2;j*j*j<=t;j++) {
                while(t%(j*j*j)==0) {
                    t/=(j*j*j);
                }
            }
            id[t]++;a[i]=t;
            ll ans=1;
            for(ll j=2;j*j*j<=t;j++) {
                if(t%j==0) {
                    if(t%(j*j)==0) {
                        ans*=j;
                    }
                    else {
                        ans*=(j*j);
                    }
                }
                while(t%j==0) {
                        t/=j;
                }
            }
            if(sqr((ll)sqrt(t))==t) ans*=(ll)sqrt(t);
            else ans*=t*t;
            b[i]=ans;
        }
        ll ans1=0;
        if(id[1]){
            ans1++;
            id[1]=0;}
        for(int i=1;i<=n;i++) {
            ans1+=max(id[a[i]],id[b[i]]);
            id[a[i]]=id[b[i]]=0;
        }
        cout<<ans1<<endl;
    }
    return 0;
}

Measured memory_bytes: 14336
#include <iostream>

using namespace std;

int c[4][4];

int main(void)
{
	for(int i = 1; i <= 3; i++){
		for(int j = 1; j <= 3; j++){
			cin >> c[i][j];
		}
	}
	
	for(int i = 1; i < 3; i++){
		if(c[i][1] - c[i+1][1] != c[i][2] - c[i+1][2]) goto ng;
		if(c[i][1] - c[i+1][1] != c[i][3] - c[i+1][3]) goto ng;
	}
	cout << "Yes" << endl;
	return 0;
	
	ng:;
	cout << "No" << endl;
	return 0;
}

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

typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int>t(n),a(n);
	ll Ta = 1, Ao = 1;
	for (int i = 0; i < n; i++) {
		cin >> t[i] >> a[i];
		ll tmp;
		tmp = max(((Ta + t[i] - 1) / t[i]), ((Ao + a[i] - 1) / a[i]));
		Ta = t[i] * tmp, Ao = a[i] * tmp;
	}
	cout << Ta+Ao << endl;

	return 0;
}

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

char mcxi[4] = {'i', 'x', 'c', 'm'};
int a[4], b[4], c[5];
string s1, s2;

void print() {
  for (int i = 3; i >= 0; i--) {
    if (c[i] == 0) continue;
    if (c[i] == 1) cout << mcxi[i];
    else cout << c[i] << mcxi[i];
  }
  cout << endl;
}

void calcC() {
  for (int i = 0; i < 4; i++) {
    c[i + 1] = (a[i] + b[i] + c[i]) / 10;
    c[i] = (a[i] + b[i] + c[i]) % 10;
  }
}

void calcB() {
  for (int i = s2.length() - 1; i >= 0; i--) {
    for (int j = 0; j < 4; j++) {
      if (s2[i] == mcxi[j]) {
	if (i == 0) {
	  b[j] = 1;
	} else {
	  if ('2' <= s2[i - 1] && s2[i - 1] <= '9') {
	    b[j] = s2[i - 1] - '0';
	  } else {
	    b[j] = 1;
	  }
	}
      }
    }
  }
}

void calcA() {
  for (int i = s1.length() - 1; i >= 0; i--) {
    for (int j = 0; j < 4; j++) {
      if (s1[i] == mcxi[j]) {
	if (i == 0) {
	  a[j] = 1;
	} else {
	  if ('2' <= s1[i - 1] && s1[i - 1] <= '9') {
	    a[j] = s1[i - 1] - '0';
	  } else {
	    a[j] = 1;
	  }
	}
      }
    }
  }
}

void init() {
  for (int i = 0; i < 4; i++) {
    a[i] = 0;
    b[i] = 0;
    c[i] = 0;
  }
  c[4] = 0;
}

int main() {
  int n;
  cin >> n;
  while (n--) {
    cin >> s1 >> s2;
    init();
    
    calcA();
    calcB();
    calcC();
    print();
  }
}

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

int main()
{
    /*A
    string s;
    cin>>s;
    if(s=="AAA" || s=="BBB")
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    */
   /*B
    ll n,a,b;
    cin>>n>>a>>b;
    ll count=0;
    if(a==0)
    {
       cout<<0<<endl;
       return 0;
    }
    else if(n%(a+b)==0)
    {
        count = (n/(a+b))*a;
        cout<<count<<endl;
        return 0;
    }
    else
    {
        if(n%(a+b)<=a)
        {
            count=(n/(a+b))*a+n%(a+b);
            cout<<count<<endl;
            return 0;
        }
        else
        {
            count =  (n/(a+b))*a+a;
            cout<<count<<endl;
            return 0;
        }
    }

    cout<<count<<endl;
    */

    int a,b;
    cin>>a>>b;

    for(int i=1;i<=1009;i++)
    {
        if(int(i*0.08)==a && int(i*0.1)==b)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
   
    return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

var (
	xs []int
	s  [][]int
	p  []int
)

func dfs(cur int, sw int) int {
	if cur != 0 {
		xs[cur-1] = sw
	}
	if cur == len(xs) {
		for i := range s {
			var light int
			for j := range s[i] {
				light += xs[s[i][j]-1]
			}
			if light%2 != p[i] {
				return 0
			}
		}
		return 1
	}
	sum := 0
	sum += dfs(cur+1, 0)
	sum += dfs(cur+1, 1)
	return sum
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	s = make([][]int, m)
	var k int
	for i := range s {
		fmt.Scan(&k)
		s[i] = make([]int, k)
		for j := 0; j < k; j++ {
			fmt.Scan(&s[i][j])
		}
	}
	p = make([]int, m)
	for i := range p {
		fmt.Scan(&p[i])
	}

	xs = make([]int, n)
	fmt.Println(dfs(0, 0))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#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 FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    ll ans=1;
    vector<int> vec={0,0,0};
    rep(i,n) {
        int a;
        cin>>a;
        int cnt=0;
        rep(j,3) {
            cnt+=(vec[j]==a);
        }
        ans=ans*(ll)cnt%MOD;
        rep(j,3) {
            if(vec[j]==a) {
                vec[j]++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
W = [0] * N
for i in range(N):
    W[i] = input()
if len(set(W)) != N:
    print('No')
    exit()
for i in range(N - 1):
    w1 = W[i]
    w2 = W[i+1]
    if w1[-1] != w2[0]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 3316