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

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const ll INF = 1e9+1;
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;}

// a + b == 0 mod K
// b + c == 0 mod K
// c + a == 0 mod K
/*
を満たすa,b,c,の組

列挙はしんどいのでa,b,cの満たす条件を絞り込む

a + b = dK
b + c = eK
c + a = fK　を満たす

a - c = (d - e)K
2a = (d - e + f)K

全部Kが奇数ならKの倍数 Kが偶数ならK/2の倍数

試しにこの方針で
*/

ll N, K;

int main() {
    cin >> N >> K;
    
    ll D = K;
    ll Q = 0;

    ll res = 0;
    if (D % 2 == 0) {
        ll t1 = 0, t2 = 0;
        for (ll i = 1; i <= N; i++) {
            if (i % K == K / 2) t1++;
        }
        for (ll i = 1; i <= N; i++) {
            if (i % K == 0) t2++;
        }
        res = t1*t1*t1 + t2*t2*t2;
    } else {
        for (ll i = 1; i <= N; i++) {
            if (i % K == 0) Q++;
        }
        res = Q * Q * Q;
    }
    


    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	if (n == 1)
	{
		cout << "Hello World";
	}
	else if (n == 2)
	{
		int x, y;
		cin >> x >> y;
		cout << (x + y);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

bool graph[10][10];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int sum = 0;
	int ans = 0;
	rep(i, n) {
		sum += a[i];
		if (i % 2 == 0) {
			if (sum <= 0) {
				ans += abs(sum - 1);
				sum = 1;
			}
		}
		else {
			if (sum >= 0) {
				ans += abs(sum + 1);
				sum = -1;
			}
		}
	}
	sum = 0;
	int ans2 = 0;
	rep(i, n) {
		sum += a[i];
		if (i % 2 == 1) {
			if (sum <= 0) {
				ans2 += abs(sum - 1);
				sum = 1;
			}
		}
		else {
			if (sum >= 0) {
				ans2 += abs(sum + 1);
				sum = -1;
			}
		}
	}
	cout << min(ans,ans2) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<string>
#include<vector>

#define For(counter,initial_value,conditions) for( int counter = initial_value; counter < conditions; counter++ )

using namespace std;
int
main()
{
	string x, y;
	cin >> x >> y;
	if (x > y) cout << ">"<<endl;
	else if (x == y) cout << "=" << endl;
	else cout << "<" << endl;
}

Measured memory_bytes: 384
A,B,C,X,Y=map(int,input().split())
ans=0
tmp=0
for i in range(10**5+1):
    tmp = 2*C*i + A*max(0,X-i) + B*max(0,Y-i)
    if i==0:
        ans = tmp
    if tmp < ans:
        ans = tmp
print(ans)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    string s, t;
    cin>>s>>t;
    t.pop_back();
    if(s==t) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC091_A();
        }

        static void ABC091_A()
        {
            var ABC = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            Console.WriteLine(ABC[0] + ABC[1] >= ABC[2] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 11220
#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__) << "] "
 
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<long double> vld;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846
#define sqr(a) ((a) * (a))
#define len(V) (int)V.size()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define fix(a) fixed << setprecision(a)
#define readv(x) for(auto &_ : (x)) {cin >> _;}
#define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
#define EPS 1e-6
#define MAXN 100047


void solve(){
	int n, k, q; cin >> n >> k >> q;
	vi a(n);
	FOR(i, 0, q) {
		int x; cin >> x;
		a[x-1]++;
	}
	
	FOR(i, 0, n){
		if (k - q + a[i] > 0) cout << "Yes\n";
		else cout << "No\n";
	}
}

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


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while(1){
        C-=B;
        if(C<=0){
            pr("Yes");
            break;
        }
        A-=D;
        if(A<=0){
            pr("No");
            break;
        }
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=a;i<=b;i++){
		if(a+k>i||b-k<i)cout<<i<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
/**
  @file d.cpp
  @title D - Powerful Discount Tickets
  @url https://atcoder.jp/contests/abc141/tasks/abc141_d
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<LL> q;

  LL tmpA;
  REP(i, N) {
    cin >> tmpA;
    q.push(tmpA);
  }

  for (int i = 0; i < M; i++) {
    LL topQ = q.top();
    q.pop();
    q.push(topQ / 2);
  }

  LL ans   = 0;
  auto tmp = q;
  while (!tmp.empty()) {
    ans += tmp.top();
    tmp.pop();
  }

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


Measured memory_bytes: 1908
#include<stdio.h>
#include<string.h>

#define N 128

void push(int *stack,int data,int *sp);
int pop(int *stack,int *sp);

int main(void){
  char str[N];
  int i,j,stack[N],sp,l,out,d;
  while(fgets(str,sizeof(str),stdin)&&str[0]!='.'){
    for(i=0;i<N;i++) stack[i]=0;
    sp=d=0;
    l=strlen(str);
    for(i=0;i<l;i++){
      if(str[i]=='('){
	push(stack,1,&sp);
      }else if(str[i]==')'){
	//puts("out:1");
	out=pop(stack,&sp);
	//printf("%d\n",out);
	if(out!=1){
	  d++;
	  goto shut;
	}
      }else if(str[i]=='['){
	push(stack,2,&sp);
      }else if(str[i]==']'){
	//puts("out:2");
	out=pop(stack,&sp);
	//printf("%d\n",out);
	if(out!=2){
	  d++;
	  goto shut;
	}
      }
    } 
  shut:
    if(d!=0||sp!=0) puts("no");
    else puts("yes");
  }
  return 0;
}
      
void push(int *stack,int data,int *sp){
  stack[(*sp)++]=data;
}

int pop(int *stack,int *sp){
  if(*sp>0) return stack[--(*sp)];
  else return 0;
}

Measured memory_bytes: 524
#include <stdio.h>


int main(void) {

	// 1_5-A Print a Rectangle

	int h,w;
	int i,j;
	
	scanf("%d %d",&h,&w);

	while(h!=0 && w!=0){
		for(i=0; i<h; i++){
			for(j=0; j<w; j++){
				if((i+j)%2==0){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d %d",&h,&w);
	}
        return 0;
}

Measured memory_bytes: 572
#include <cstdio>
int a,b;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
    while(~scanf("%d%d",&a,&b)){printf("%d %lld\n",gcd(a,b),1LL*a*b/gcd(a,b));}
    return 0;
}

Measured memory_bytes: 2572
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;
void init();
#ifdef DEBUG_BUILD
#define DBG(expr) cout << #expr << " = " << expr << endl;
#endif
#define ECHO(expr) cout << expr << endl;
#define REP(var, num) for(ll var = 0; var < num; var++)
#define REP_FROM(var, from, num) for(ll var = from; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define T_FIRST(tuple) (std::get<0>(tuple))
#define T_SECOND(tuple) (std::get<1>(tuple))
#define T_THIRD(tuple) (std::get<2>(tuple))
typedef signed long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) {
    while (b != 0) {
        ll x = a % b;
        a = b;
        b = x;
    }

    return a;
}

void solve() {
    ll n, start;
    cin >> n >> start;
    vector<ll> xs(n);
    REP(i, n) {
        ll x;
        cin >> x;
        xs[i] = x;
    }

    ll ans = abs(start - xs[0]);
    REP_FROM(i, 1, n) {
        ans = gcd(ans, abs(start - xs[i]));
    }

    ECHO(ans)
}

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

#ifdef INPUT_FILE
    if (!freopen(INPUT_FILE, "r", stdin)) {
        perror("freopen");
        exit(1);
    }
#endif

    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(void) {

	int n;
	double unit;
	int debt = 100000;
	int i;

	do {
		scanf("%d",&n);
	}while((n < 0) && (n > 100));

	for (i = 0; i < n; i++) {
		debt += (int)(debt * 0.05);
		unit = pow(10, -3);
		debt = (int)(debt * unit + 0.999);
		debt *= (int)pow(10, 3);
	}
	printf("%d\n",debt);

	return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int n;
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		
		for(int i = 3; i <= n; i ++){
			String str_i = String.valueOf(i);
			if(i % 3 == 0 || str_i.indexOf("3") != -1){
				System.out.print(" "+i);	
			}
		}
		System.out.println();
    	scanner.close();
    }
}

Measured memory_bytes: 29664
n = gets.chomp.to_i
array = gets.chomp.split(' ').map(&:to_i)
array.sort!

max = array[-1]

a = 0
for i in 0..array.length - 2 do
  a += array[i]
end

if max < a
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
N=int(input())
ans=0
li=[]
for i in range(N):
    s=list(input())
    s.sort()
    li.append(s)
li.sort()
temp=1
for j in range(N-1):
    if li[j]==li[j+1]:
        temp+=1
    else:
        ans+=temp*(temp-1)//2
        temp=1
        
ans+=temp*(temp-1)//2
print(ans)


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

int main(){
	int H, W;
	cin >> H >> W;
	char S[H][W];
	int Y[H][W], T[H][W];
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> S[i][j];
			Y[i][j] = -1;;
			T[i][j] = -1;
		}
	}
	for(int i=0;i<H;i++){
		if(S[i][0] == '#')Y[i][0] = 0;
		else{
			int cnt = 1;
			while(cnt < W && S[i][cnt] == '.' )cnt++;
			Y[i][0] = cnt;
		}
		for(int j=1;j<W;j++){
			if(S[i][j] == '#')Y[i][j] = 0;
			else{
				if(Y[i][j-1] > 0)Y[i][j] = Y[i][j-1];
				else{
					int cnt = 1;
					while(j+cnt < W && S[i][j+cnt] == '.')cnt++;
					Y[i][j] = cnt;
				}
			}
		}
		// cout << i << ":";
		// for(int j=0;j<W;j++){
		// 	cout << Y[i][j] << " ";
		// }
		// cout << endl;
	}
	for(int i=0;i<W;i++){
		if(S[0][i] == '#')T[0][i] = 0;
		else{
			int cnt = 1;
			while(cnt < H && S[cnt][i] == '.')cnt++;
			T[0][i] = cnt;
		}
		for(int j=1;j<H;j++){
			if(S[j][i] == '#')T[j][i] = 0;
			else{
				if(T[j-1][i] > 0)T[j][i] = T[j-1][i];
				else{
					int cnt = 1;
					while(j + cnt < H && S[j + cnt][i] == '.')cnt++;
					T[j][i] = cnt;
				}
			}
		}
	}
	// for(int i=0;i<W;i++){
	// 	cout << i << ":";
	// 	for(int j=0;j<W;j++){
	// 		cout << T[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	int ans = 0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			ans = max(T[i][j] + Y[i][j] - 1, ans);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 38760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int n, k;
  cin >> n >> k;
  map<int, int> mp;
  rep(i, n){
    int num;
    cin >> num;
    mp[num]++;
  }
  int size = mp.size();
  vector<pair<int, int>> vec;
  for(auto p : mp){
    vec.push_back(make_pair(p.second, p.first));
  }
  sort(all(vec));
  int sum = 0;
  rep(i, size-k) sum += vec[i].first;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 11768
#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;
	int ans = N*(N+1)/2;
	cout << ans << endl;
    return 0;
}



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

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  
  for (ll i = 1; i <= N; i++) {
    ll n = (N / i);
    ans += i * n * (n + 1) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3560
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



int main(int argc, char *argv[])
{
	string s;

	//input
	cin >> s;


	//calc
	string ans;
	if (s == "AAA" || s == "BBB"){
		ans = "No";
	}
	else{
		ans = "Yes";
	}

	//ans
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int top = 0, c[20000], area[20000][2] = {};

void push(int x){
  top++;
  c[top] = x;
}

int pop(){
  top--;
  return c[top + 1];
}

int main(){

  int sum = 0, cnt = 0;
  string s;

  cin >> s;

  for(int i = 0;i < s.size();i++){
    if(s[i] == '\\'){
      push(i);
    }else if(s[i] == '/' && top > 0){
      int j = pop(), tmp;
      sum += i - j;
      tmp = i - j;
      while(cnt > 0 && area[cnt][1] > j){
        tmp += area[cnt][0];
        cnt--;
      }
      cnt++;
      area[cnt][0] = tmp;
      area[cnt][1] = j;
    }
  }

  cout << sum << endl;
  cout << cnt;
  for(int i = 1;i <= cnt;i++) cout << " " << area[i][0];
  cout << endl;

  return 0;
}



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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int n;
    ll resp=0, x, a;
    cin >> n;
    cin >> x;
    resp+=2*x;
    for(int i=2; i<n; i++){
        cin >> a;
        if(a>=x){
            resp+=a;
        }else{
            resp-=x;
            resp+=2*a;
        }
        x=a;
    }
    cout << resp << endl;
    return 0;
}

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

bool cmp(pair<int,int> a,pair<int,int> b) {
  return a.second < b.second;
}

int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> x(m);
  
  for(int i=0;i<m;i++){
     cin>>x[i].first>>x[i].second;
  }
  
  sort(x.begin(),x.end(),cmp);
  
  int c=0;
  int l=0;
  for(int i=0;i<m;i++){
    if(x[i].first>l){
      l=x[i].second-1;
      c++;
    }
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int solve(int,int);

int n,a[2000],m[200],s[20];

int main(){

  int i,q;

  scanf("%d",&n);  
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }


  for(i=0;i<q;i++){
    if(solve(0,m[i]))printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}


int solve(int i,int m){
  int res;
  if(m==0)return 1;
  if(i>=n)return 0;
  //  printf("i+1:%d m:%d m-a[i]:%d  ",i+1,m,m-a[i]); 
  res = solve(i + 1, m) || solve(i + 1, m - a[i]);
  //printf("i:%d m:%d res:%d\n",i,m,res);
  // printf("res:%d\n",res);
  return res;



}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long A, long long B){
  op(6-A-B)
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

template <class T>
class SegTree {
  int n;                       // 葉の数
  vector<T> data;              // データを格納するvector
  T def;                       // 初期値かつ単位元
  function<T(T, T)> operation; // 区間クエリで使う処理
  function<T(T, T)> update;    // 点更新で使う処理

  // 区間[a,b)の総和。ノードk=[l,r)に着目している。
  T _query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l)
      return def; // 交差しない
    if (a <= l && r <= b)
      return data[k]; // a,l,r,bの順で完全に含まれる
    else {
      T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
      T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
      return operation(c1, c2);
    }
  }

 public:
  // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
  // _update:更新関数
  SegTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
    : def(_def), operation(_operation), update(_update) {
    n = 1;
    while (n < _n) {
      n *= 2;
    }
    data = vector<T>(2 * n - 1, def);
  }

  // 場所i(0-indexed)の値をxで更新
  void change(int i, T x) {
    i += n - 1;
    data[i] = update(data[i], x);
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // [a, b)の区間クエリを実行
  T query(int a, int b) {
    return _query(a, b, 0, 0, n);
  }

  // 添字でアクセス
  T operator[](int i) {
    return data[i + n - 1];
  }
};

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b) {
  // Eucledean algorithm
  while (a) {
    if (a < b) {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  SegTree<ll> st(
    n, 0,
    [](long long a, long long b) {
      if (a > 0 && b > 0) {
        return gcd(a, b);
      }
      return max(a, b);
    },
    [](long long a, long long b) { return b; });

  rep(i, n) {
    st.change(i, a[i]);
  }

  ll ans = st.query(1, n);
  rep(i, n) {
    ll a = st.query(0, i);
    ll b = a;
    if (i != n - 1) {
      b = st.query(i + 1, n);
    }
    chmax(ans, gcd(a, b));
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  ll N,H;
  cin >> N >> H;
  priority_queue<ll> a, b;

  for(int i = 0; i < N; i++){
    ll tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    a.push(tmp1);
    b.push(tmp2);
  }

  ll cnt = 0;
  int b_cnt = N;
  while(H > 0){
    if(b_cnt > 0){
      if(a.top() <= b.top()){
	H -= b.top();
	b.pop();
	cnt++;
	b_cnt--;
      }else{
	H -= a.top();
	cnt++;
      }
    }else{
      H -= a.top();
      cnt++;
    }
  }

  cout << cnt << endl;
  
}


Measured memory_bytes: 2036
A,B,K=[int(x) for x in input().split(' ')]

lis=[]
blis=[]
count=0

sm=min([A,B])
bm=max([A,B])
for i in range(1,sm+1):
	if sm/i == sm//i:
		lis.append(i)

for i in lis:
	if bm/i == bm//i:
		blis.append(i)

blis=list(set(blis))
blis.sort()
blis.reverse()

print(blis[K-1])


#8 12 2



Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt(), b = scanner.nextInt();
		System.out
				.println((int) (a / b) + " " + (int) (a % b) + " " + String.format("%.5f", ((double) a / (double) b)));
	}
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second
const int maxn = 1e5 + 10;
int n, sz[maxn], dpar[maxn], mn = 1e9;
vector<pii> adj[maxn];
vector<int> cent;
ll tot;

void dfs(int i, int p){
    sz[i] = 1;
    int m = 0;

    for(pii j : adj[i]){
        if(j.x != p){
            dpar[j.x] = j.y;
            dfs(j.x, i);
            sz[i] += sz[j.x];
            m = max(m, sz[j.x]);
        }
    }

    m = max(m, n - sz[i]);

    if(m <= n / 2){
        cent.push_back(i);
    }

    if(p != 0){
        tot += ll(dpar[i]) * 2 * min(sz[i], n - sz[i]);
    }
}

int main(){
    ios_base::sync_with_stdio(false);

    cin >> n;

    for(int i = 1; i < n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        adj[a].push_back({b, c});
        adj[b].push_back({a, c});
    }

    dfs(1, 0);

    if(cent.size() == 1){
        for(pii j : adj[cent[0]]){
            mn = min(mn, j.y);
        }
    }else{
        for(pii j : adj[cent[0]]){
            if(j.x == cent[1]){
                mn = min(mn, j.y);
            }
        }
    }

    cout << tot - mn << endl;

    return 0;
}


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

int main() {
  int n, t, a[10000];
  long long int s;
  while (cin >> n && n) {
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a, a+n);
    s = t = 0;
    for (int i=0; i<n-1; i++) {
      t += a[i];
      s += t;
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  int N; cin >> N;
  int count=0,answer=0;
  for(int i=0;i<=N;i++){
    int a=0;
    if(i!=N) cin >> a;
    if(a==0){
      answer += count/2;
      count=0;
    }else{
      count+=a;
    }
  }
  cout << answer;
}

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

int main(){
    int N;cin >> N;
    int sum =0;
    vector<int> d(N);

    rep(i,N){
        cin >> d[i];
        sum -= d[i]*d[i];
    }

    rep(i,N){
        rep(j,N){
            sum += d[i]*d[j];
        }
    }

    cout << sum/2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn = 3e5+10;
ll a[maxn];
int n;
ll ans;
int main()
{
	scanf("%d",&n);
	n*=3;
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	for(int i=2;i<=n/3*2;i+=2) ans+=a[i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	string S = res();
	int N = S.size();
	long K = rei();
	int zeroc = 1;
	int zeronc = 0;
	bool lastchanged1 = true;
	bool lastchanged2 = false;
	for(int i=1;i<N;i++){
		if(!lastchanged1 && S[i] == S[i-1]){
			zeroc++;
			lastchanged1 = true;
		}
		else{
			lastchanged1 = false;
		}
		if(!lastchanged2 && S[i] == S[i-1]){
			zeronc++;
			lastchanged2 = true;
		}
		else{
			lastchanged2 = false;
		}
	}
	long ans;
	if(S[0] != S[N-1]){
		ans = K * zeronc; 
	}
	else{
		if(lastchanged2){
			ans = K * zeronc;
		}
		else{
			if(lastchanged1){
				ans = (K/2) * (zeroc + zeronc) + (K % 2) * zeronc; 
			}
			else{
				ans = (K-1) * zeroc + zeronc; 
			}
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

w = W // 2
h = H // 2
ans = 10 ** 10
for i in range(1,H//2 + 1):
    l = (H - i) // 2
    r = H - i - l
    ans = min(ans, max(W*i, W*l, W*r) - min(W*i, W*l, W*r), max(W*i, w*(H-i), (W-w)*(H-i)) - min(W*i, w*(H-i), (W-w)*(H-i)))

for i in range(1,W//2 + 1):
    l = (W - i) // 2
    r = W - i - l
    ans = min(ans, max(H*i, H*l, H*r) - min(H*i, H*l, H*r), max(H*i, h*(W-i), (H-h)*(W-i)) - min(H*i, h*(W-i), (H-h)*(W-i)))

print(ans)

Measured memory_bytes: 3064
abc = [int(i) for i in input().split()]
abc.sort()
ab, bc = abc[2] - abc[1], abc[2] - abc[0]
cnt = 0
if ab % 2 == 0 and bc % 2 == 0:
    cnt += ab//2
    cnt += bc//2
elif ab % 2 != 0 and bc % 2 != 0:
    cnt += ab//2
    cnt += bc//2 + 1
else:
    cnt += ab//2
    cnt += bc//2 + 2
print(cnt)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const int MAX= 4e5+6;
const ll inf =1e18;
 
 




int main(){
	fastio;
	ll k,n,m,x,a,b,u,v,ans=0;
	cin>>x;
	k=5000;
	f(i,-k,k+1){
		f(j,i,k+1){
			if((j*j*j*j*j-i*i*i*i*i)==x){
				cout<<j<<" "<<i<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int n,m,a[25];
ll f[17][100005],fact[100005],inv[100005];
ll quick_pow(ll x,ll a)
{
	ll ans=1;
	while(a)
	{
		if(a&1)ans=ans*x%MOD;
		x=x*x%MOD;
		a>>=1;
	}
	return ans;
}
int calc(int s)
{
	int ans=0;
	while(s)
	{
		if(s&1)ans++;
		s>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d%d",&n,&m);
	fact[0]=1;
	for(int i=1;i<=100000;i++)fact[i]=fact[i-1]*i%MOD;
	inv[100000]=quick_pow(fact[100000],MOD-2);
	for(int i=100000;i>=1;i--)inv[i-1]=inv[i]*i%MOD;
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	for(int i=1;i*2<=m;i++)
	  swap(a[i],a[m-i+1]);
	f[0][0]=1;
	for(int i=1;i<=m;i++)
	{
		for(int last=0;last<(1<<n);last++)
		{
			if(!f[i-1][last])continue;
			f[i][last]=(f[i][last]+f[i-1][last])%MOD;
			for(int now=0;now<n;now++)
			{
				if(!((1<<now)&last)&&(1<<n)-a[i]-last>=(1<<now)-1)
					f[i][last|(1<<now)]=(f[i][last|(1<<now)]+f[i-1][last]*fact[(1<<n)-a[i]-last]%MOD
					*(1<<now)%MOD*inv[(1<<n)-a[i]-last-(1<<now)+1])%MOD;
			}
		}
	}
	ll ans=0;
	for(int i=0;i<(1<<n);i++)
	{
		if(calc(i)&1)ans-=f[m][i]*fact[(1<<n)-i-1]%MOD;
		else ans+=f[m][i]*fact[(1<<n)-i-1]%MOD;
	}
	ans%=MOD;
	if(ans<0)ans+=MOD;
	printf("%lld\n",ans*(1<<n)%MOD);
	return 0;
}

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


int main(){
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i*j+(n-i)*(m-j)==k){
                return cout<<"Yes",0;
            }
        }
    }
    cout<<"No";
}


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

const long long MOD = 2019;

int main() {
    long long L, R;
    cin >> L >> R;

    if (R - L >= 2019) {
        cout << 0 << endl;
        return 0;
    }

    long long mn = 1LL << 60;
    for (int i = L; i <= R - 1; i++) {
        for (int j = i + 1; j <= R; j++) {
            mn = min(mn, (long long)((i % MOD) * (j % MOD) % MOD));
        }
    }

    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

  public static void main(String [] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();

    int[] vs = new int[n];
    int[] cs = new int[n];

    for (int i = 0; i < n; i ++) {
      vs[i] = s.nextInt();
    }

    int out = 0;

    for (int i = 0; i < n; i ++) {
      cs[i] = s.nextInt();
      if (vs[i] > cs[i])
        out += vs[i] - cs[i];
    }

    System.out.println(out);

  }

}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
//#define int long long
#define INF 1000000
using namespace std;
bool isPrime(int x){
    if(x < 2) return false;
    else if(x == 2) return true;
    else if(x%2 == 0) return false;
    for(int i=3; i*i<=x; i+=2){
        if(x % i == 0) return false;
    }
    return true;
}
int main(){
    int a,d,n;
    while(1){
        int num[100000];
        cin >> a >> d >> n;
        if(a == 0 && d == 0 && n == 0) break;
        int cnt = 0;
        while(a < INF){
            if(isPrime(a)){
                num[cnt] = a;
                cnt++;
            }
            a += d;
        }
        cout << num[n-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3376
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
#include <random>
#include <cassert>
#include <sstream>
using namespace std;
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define ALL(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ln(i, n) " \n"[i == n]
typedef long long LL;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
//////////////////////
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9;
const LL  INFF = (LL)1e15;
const int mod = 998244353;
const int MXN = (int)1e6 + 7;
vector<int> edge[MXN], re_edge[MXN];
int in[MXN], out[MXN];
int ck[MXN], cntp = 0;
int main(){
	int n, m; scanf("%d %d", &n, &m);
	for (int i = 1; i <= m + n - 1; i++) {
		int u, v; scanf("%d %d", &u, &v);
		edge[u].pb(v);
		re_edge[v].pb(u);
		in[v]++;
		out[u]++;
	}
	queue<int> Q; 
	for (int i = 1; i <= n; i++) {
		if (!out[i]) Q.push(i);
	}
	while (!Q.empty()) {
		int v = Q.front(); Q.pop();
		ck[v] = ++cntp;
		for (int x : re_edge[v]) {
			if (!(--out[x])) Q.push(x);
		}
	}
	ck[0] = INF;
	for (int i = 1; i <= n; i++) {
		int id = 0;
		for (int x : re_edge[i]) {
			if (ck[x] < ck[id]) id = x;
		}
		printf("%d\n", id);
	}
	return 0;
}


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

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

    int A[N];
    int B[N];
    int C[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }

    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);

    long long ans = 0;
    long long idxA = 0;
    long long idxC = 0;

    for (int i = 0; i < N; i++)
    {
        while (idxA < N && A[idxA] < B[i])
        {
            idxA++;
        }
        while (idxC < N && B[i] >= C[idxC])
        {
            idxC++;
        }
        ans += idxA * (N - idxC);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	var ans = "Yes"
	types := []string{"L", "R"}
	for i, a := range s {
		b := string(a)
		c := types[(i+1)%2]
		if !(b == c || b == "U" || b == "D") {
			ans = "No"
			break
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846

int main(void)
{
	double a;
	double b;
	double h;
	double m;
	
	double L;
	double l;
	double rad;
	
	scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
	
	rad=(((h+(m/60))/12)-(m/60))*2*PI;
	L=a*a+b*b-2*a*b*cos(rad);
	l = sqrt(L);
	printf("%.20f\n",l);
	
	return 0;
}

Measured memory_bytes: 2592
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
N = len(S)
if len(S) != 1:
    C1 = Counter(S[::2])
    C2 = Counter(S[1::2])

    odd = C1['0']+C2['1']
    even = C1['1']+C2['0']
    print(N-max(odd, even))
else:
    print(0)


Measured memory_bytes: 3444
#include<bits/stdc++.h> 
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long 
#define LL long long 
#define pt(x) printf("%d ", x);
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
using namespace std;

const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7;
const double eps = 1e-9;
void chmax(int &a, int b) {a = (a > b ? a : b);}
void chmin(int &a, int b) {a = (a < b ? a : b);}
int sqr(int x) {return x * x;}
int add(int x, int y) {if(x + y < 0) return x + y + mod; return x + y >= mod ? x + y - mod : x + y;}
void add2(int &x, int y) {if(x + y < 0) x = x + y + mod; else x = (x + y >= mod ? x + y - mod : x + y);}
int mul(int x, int y) {return 1ll * x * y % mod;}
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}

int A, B, C; 
signed main() {
	A = read(); B = read(); C = read();
	if(C <= A) cout << (C + B);
	else {
		C -= A;
		if(C <= B) cout << (A +  B + C);
		else {
			C -= B;
			cout << (A +  2 * B + (bool) (C > 0)); 
		}
	}

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include <ios>
#include <iomanip>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef tuple<ll,ll,ll> Tl;

ll XOR(ll n){
    if(n%4 == 0) return n;
    if(n%4 == 1) return 1;
    if(n%4 == 2) return n+1;
    else return 0;
}

int atcoder(){
    //入力
    ll n,m;
    cin >> n >> m;
    ll ans = XOR(n-1)^XOR(m);
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10**9)


def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()

def main():
    N = ii()

    u = 0
    graph = [[] for _ in range(10**5+10)]
    for i in range(N-1):
        u,v,w=mi()
        graph[u].append((v,w))
        graph[v].append((u,w))

    seen = set()
    stack = deque([u])

    ans=[[] for _ in range(N+1)]
    ans[u] = 0
    while stack:
        current = stack.popleft()

        for next, w in graph[current]:
            if next in seen: continue
            if w%2==0:
                ans[next] = ans[current]
            else:
                ans[next] = 0 if ans[current] == 1 else 1

            seen.add(next)
            stack.append(next)



    print(*ans[1:],sep='\n')




if __name__ == "__main__":
  main()


Measured memory_bytes: 108820
<?php

fscanf(STDIN, "%d %d", $D, $G);
$P = []; $C = [];
for ($i = 0; $i < $D; $i++) {
    fscanf(STDIN, "%d %d", $x, $y);
    $P[] = $x; $C[] = $y;
}

$min = PHP_INT_MAX;
for ($i = 0; $i < 1<<$D; $i++) {
    $score = 0;
    $cnt = 0;
    for ($j = 0; $j < $D; $j++) {
        if ($i & 1<<$j) {
            $score += $C[$j];
            $score += $P[$j] * ($j + 1) * 100;
            $cnt += $P[$j];
        }
    }

    if ($score >= $G) {
        $min = min($min, $cnt);
        continue;
    }

    for ($j = $D - 1; $j >= 0; $j--) {
        if ($i & 1<<$j) {
            continue;
        }

        for ($k = 0; $k < $P[$j]; $k++) {
            $score += ($j + 1) * 100;
            $cnt++;

            if ($score >= $G) break 2;
        }
    }
    $min = min($min, $cnt);
}
echo $min;


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


unsigned long long pascal(int n, int r, int dup)
{
    int nn;
    unsigned long long* a = (unsigned long long*)calloc(n,sizeof(unsigned long long));
    unsigned long long retv;
    
    nn = (dup) ? (n+r-1) : n;
    if ( nn-r < r ) r = nn-r;
    if ( r == 0 ) return 1;
    if ( r == 1 ) return nn;
    for ( int i=1; i<r; i++ ) a[i] = i+2;
    for ( int i=3; i<=nn-r+1; i++ ) {
        a[0] = i;
        for ( int j=1; j<r; j++ ) a[j] += a[j-1];
    }
    retv = a[r-1];
    free(a);

    return retv;
}
 
int main(void){
  int n, m;
  std::cin >> n >> m;
  
  long long cnt=0;
  cnt += pascal(n, 2, 0);
  cnt += pascal(m, 2, 0);
  
  std::cout << cnt << std::endl;
  return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt
  val rate = 380000.0
  var result = 0.0
  for (_ <- 0 until N) {
    val x = sc.nextDouble
    val u = sc.next
    if (u == "JPY") {
      result += x
    } else if (u == "BTC") {
      result += rate * x
    }
  }
  println(result)
}

Measured memory_bytes: 25544
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define N 500043
#define mp(a,b) make_pair(a,b)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<long double>vec(n);
    for(int i=0;i<n;i++) cin >> vec[i];
    vector<vector<long double>>dp(n+1,vector<long double>(n+1,0));
    dp[0][0]=1.000000000;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j==0)
                dp[i][j]=dp[i-1][j]*(1-vec[i-1]);
            else
                dp[i][j]=(dp[i-1][j]*(1-vec[i-1]))+(dp[i-1][j-1]*vec[i-1]);
        }
    }
    int k=(n/2+1);
    long double ans=0.0;
    for(int i=k;i<=n;i++)
        ans+=dp[n][i];
    cout << fixed << setprecision(9) <<ans << endl;
}


Measured memory_bytes: 144248
import sys
N = int(input())
a_list = list(map(int, input().split())) #[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 1]

try:
    idx = a_list.index(1)
except:
    print(-1)
    sys.exit(0)

#idx = 0
value = 1

for k, v in enumerate(a_list):
    if idx <= k and value+1 == v:
        value += 1

print(len(a_list) - value)


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

allset = set()
for i in range(n):
    l_raw = input().split()
    l_new = l_raw[1:]
    if i != 0:
        allset = allset & set(l_new)
    else:
        allset = set(l_new)


print(len(allset))

Measured memory_bytes: 3060
#include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"

using namespace std;

map<string, long long> idx;
long long weight[7];
long long market[7];
long long price[7][7];
long long x[7];
long long y[7];
long long tsp[1 << 7];
long long dp1[8][100001];
long long dp2[(1 << 7) + 1][100001];
long long money[1 << 7];
signed main() {
	long long N, M, W, T;
	cin >> N >> M >> W >> T;
	for (long long i = 0; i < M; i++) {
		string S;
		cin >> S >> weight[i] >> market[i];
		idx[S] = i;
	}
	fill((long long*)price, (long long*)(price + 7), 1 << 30);
	for (long long i = 0; i < N; i++) {
		long long L;
		cin >> L;
		cin >> x[i] >> y[i];
		for (long long j = 0; j < L; j++) {
			string R;
			long long Q;
			cin >> R >> Q;
			price[i][idx[R]] = min(price[i][idx[R]], Q);
		}
	}
	for (long long bit = 1; bit < (1 << N); bit++) {
		long long perm[7] = { 0 };
		long long n = 0;
		for (long long i = 0; i < N; i++) {
			if (bit&(1 << i)) perm[n++] = i;
		}
		tsp[bit] = 1 << 30;
		do {
			long long sum = 0;
			long long prev_x = 0;
			long long prev_y = 0;
			for (long long i = 0; i < n; i++) {
				sum += abs(x[perm[i]] - prev_x);
				sum += abs(y[perm[i]] - prev_y);
				prev_x = x[perm[i]];
				prev_y = y[perm[i]];
			}
			sum += abs(prev_x);
			sum += abs(prev_y);
			tsp[bit] = min(tsp[bit], sum);
		} while (next_permutation(perm, perm + n));
	}
	for (long long bit = 1; bit < (1 << N); bit++) {
		long long min_price[7];
		fill(min_price, min_price + 7, 1 << 30);
		for (long long i = 0; i < N; i++) {
			if (!(bit&(1 << i))) continue;
			for (long long j = 0; j < M; j++) {
				min_price[j] = min(min_price[j], price[i][j]);
			}
		}
		long long w[7], v[7];
		long long cnt = 0;
		for (long long i = 0; i < M; i++) {
			if (min_price[i] <= market[i]) {
				w[cnt] = weight[i];
				v[cnt] = market[i] - min_price[i];
				cnt++;
			}
		}
		fill((long long*)dp1, (long long*)(dp1 + 8), 0);
		for (long long i = 0; i < cnt; i++) {
			for (long long j = 0; j <= W; j++) {
				if (j >= w[i]) dp1[i + 1][j] = max(dp1[i][j], dp1[i + 1][j - w[i]] + v[i]);
				dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j]);
			}
		}
		money[bit] = dp1[cnt][W];
	}
	for (long long i = 0; i < (1 << N); i++) {
		for (long long j = 0; j <= T; j++) {
			if (j >= tsp[i]) dp2[i + 1][j] = max(dp2[i][j], dp2[i + 1][j - tsp[i]] + money[i]);
			dp2[i + 1][j] = max(dp2[i + 1][j], dp2[i][j]);
		}
	}
	cout << dp2[1 << N][T] << endl;
	return 0;
}


Measured memory_bytes: 19924