akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL d;
    LL t;
    LL s;
    cin >> d >> t >> s;
    LL tmp=d-t*s;
    if(tmp>0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int main()
{
	int k;
    cin>>k;
    int sum=0;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int r=1;r<=k;r++)
            {
                sum+=gcd(i,gcd(j,r));
            }
        }
    }
    cout<<sum<<endl;
    
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
typedef long long ll;
int main( void )
{
  ios::sync_with_stdio(false);
  ll N, A;
  cin >> N;
  ll ret = 0;
  ll prev = 0;
  for( int i=0; i<N; i++ ){
    cin >> A;
    if( prev > 0 && A > 0 ){
      ret++;
      A--;
    }
    ret += A / 2;
    prev = A % 2;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    bool ok = true;
    for (int i = 1; i < n; ++i) {
        if (h[i] < h[i - 1]) {
            h[i]++;
        }
        if (h[i] < h[i - 1]) {
            ok = false;
            break;
        }
    }
    if (ok)
        cout << "Yes"
             << "\n";
    else
        cout << "No"
             << "\n";
    return 0;
}

Measured memory_bytes: 1024
# -*- coding:utf-8 -*-
# /usr/bin/python3

def main():
  N = int(input())
  liA = list(map(int, input().strip().split(' ')))
  boxes = [0 for _ in range(len(liA))]
  index = []
  for i in range(len(liA))[::-1]:
    sumBoxes = sum([boxes[j] for j in range(i, len(boxes), i+1)])
    if sumBoxes % 2 != liA[i]:
      boxes[i] += 1
      index += [i+1]
  print(len(index))
  print(' '.join(map(str, index)))
  pass

if __name__=='__main__':
  main()



Measured memory_bytes: 19980
#include<cstdio>
#include<cstring>

const int mod=1000000007;
int jc[100001],s,ans,n,a[100001];

int quickmi(int a,int b)
{
	int t=1;
	while (b)
	{
		if (b&1) t=1ll*t*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return t;
}

int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++) scanf("%d",&a[i]);
	jc[0]=1;
	for (int i=1; i<=n; i++) jc[i]=1ll*jc[i-1]*i%mod;
	ans=s=0;
	for (int i=1; i<=n; i++)
		s=(s+1ll*jc[n]*quickmi(i,mod-2))%mod,ans=(ans+1ll*s*a[i])%mod;
	s=0;
	for (int i=2; i<=n; i++)
		s=(s+1ll*jc[n]*quickmi(i,mod-2))%mod,ans=(ans+1ll*s*a[n-i+1])%mod;
	printf("%d\n",ans);
	return 0;
}

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

l = []
h = []

for i in range(N):
    if A[i] < B[i]:
        l.append(B[i]-A[i])
    else:
        h.append(A[i]-B[i])

h.sort()

res = 0
y = 0
for x in l:
    while x > y:
        if h:
            res += 1
            y += h.pop()
        else:
            print(-1)
            exit()
    
    res += 1
    y -= x

print(res)

Measured memory_bytes: 24036
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include <iomanip>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef long double ld;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll n;
    cin >> n;
    cout << 180 * (n-2);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
const int N = 10005;
int a[N], b[N], c[N * 4], low[N * 4], dfn[N * 4], stack[N * 4], ls[N * 4], rs[N * 4],
id[N * 2], fst[N * 4], n, m, nodes, tot, cnt, col, top;
bool u[N * 4];
struct P { int x, id; }q[N * 2];
bool cmp(P a, P b) {
	return a.x < b.x;
}
struct Edge { int to, nxt; }e[N * 120];
void addedge(int x, int y) {
	e[++tot].to = y; e[tot].nxt = fst[x]; fst[x] = tot;
}
void build(int now, int l, int r) {
	if (l == r) {
		id[l] = now;
		return;
	}
	int mid = (l + r) >> 1;
	build(ls[now] = ++nodes, l, mid);
	build(rs[now] = ++nodes, mid + 1, r);
}
void add(int now, int l, int r, int x, int y, int z) {
	if (x <= l && r <= y) {
		addedge(z, now);
		return;
	}
	int mid = (l + r) >> 1;
	if (x <= mid) add(ls[now], l, mid, x, y, z);
	if (y > mid) add(rs[now], mid + 1, r, x, y, z);
}
void tarjan(int x) {
	dfn[x] = low[x] = ++cnt;
	u[stack[++top] = x] = 1;
	for (int i = fst[x]; i; i = e[i].nxt) {
		int y = e[i].to;
		if (!dfn[y]) {
			tarjan(y);
			low[x] = std::min(low[x], low[y]);
		}
		else if (u[y]) low[x] = std::min(low[x], dfn[y]);
	}
	if (low[x] == dfn[x]) {
		++col;
		for (; stack[top] != x; u[stack[top--]] = 0) c[stack[top]] = col;
		c[x] = col; u[x] = 0; top--;
	}
}
bool check(int mid) {
	memset(fst, 0, sizeof fst);
	tot = 0;
	for (int i = 1; i <= nodes; i++)
		if (ls[i]) addedge(i, ls[i]), addedge(i, rs[i]);
	for (int i = 1, l = 1, r = 1; i <= m; i++) {
		for (; q[l].x <= q[i].x - mid; l++);
		for (; r < m && q[r + 1].x < q[i].x + mid; r++);
		if (l < i) add(1, 1, m, l, i - 1, id[q[i].id]);
		if (i < r) add(1, 1, m, i + 1, r, id[q[i].id]);
	}
	memset(dfn, 0, sizeof dfn);
	memset(u, 0, sizeof u);
	cnt = col = top = 0;
	for (int i = 1; i <= nodes; i++)
		if (!dfn[i]) tarjan(i);
	for (int i = 1; i <= n; i++)
		if (c[id[a[i]]] == c[id[b[i]]]) return 0;
	return 1;
}
int main() {
	scanf("%d\n", &n); m = n * 2;
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &q[i * 2 - 1].x, &q[i * 2].x);
		q[i * 2 - 1].id = q[i * 2].id = i;
	}
	std::sort(q + 1, q + m + 1, cmp);
	for (int i = 1; i <= m; i++)
		if (!a[q[i].id]) a[q[i].id] = i;
		else b[q[i].id] = i;
	for (int i = 1; i <= n; i++) q[q[a[i]].id = b[i]].id = a[i];
	nodes = 1; build(1, 1, m);
	int l = 1, r = 1000000000, ans = 0;
	for (; l <= r;) {
		int mid = (l + r) >> 1;
		if (check(mid)) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 12416
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

// (x, y) を始点とした BFS をして、(x, y) から最も遠いマスへの距離を答える
int bfs(const vector<string> &v, ll x, ll y) {
    ll H = v.size(), W = v[0].size();
    vvl dist(H, vl(W, -1));//-1で埋める
    queue<pair<ll,ll>> que;

    ll res = 0;
    que.push(make_pair(x,y));
    dist[x][y] = 0;
    while (!que.empty()) {
        ll x = que.front().first, y = que.front().second;
        res = max(res, dist[x][y]);
        que.pop();
        rep(dir,4){
            ll nx = x+ dx[dir], ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (v[nx][ny] == '.'&&dist[nx][ny]==-1){ //未探索の道なら
                dist[nx][ny] = dist[x][y] + 1; //前のマス+1
                que.push({nx, ny}); //4方位をqueueに追加
            }
        }
    }
    return res;
}
ll ans=0;
int main() {
     SS(ll,a,b,k)
     if(a<k){b-=(k-a);a=0;}
     else a-=k;
     chmax(b,0LL);
     cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
using namespace std;
void arraycout(int *arrayy,int n){
    for(int u=0;u<n;u++){//出力
        if(u==n-1){
            cout<<arrayy[u]<<endl;
        }else{
            cout<<arrayy[u]<<' ';
        }
    }
    
}
void insertionSort(int* suu,int n){

    for(int i=1;i<n;i++){
        arraycout(suu,n);
        int v=suu[i];
        int j=i-1;
        while(j>=0&&v<suu[j]){
            suu[j+1]=suu[j];
            j--;
        }
        suu[j+1]=v;
        
    }
    
    
}





int main(){
    int n;
    cin>>n;
    int suu[n];
    for(int i=0;i<n;i++){
        cin>>suu[i];
    }
    
    insertionSort(suu,n);
    arraycout(suu,n);
    return 0;
}



Measured memory_bytes: 3136
N = int(input())
t = [0]*100001
x = [0]*100001
y = [0]*100001
for n in range(N):
    t[n+1], x[n+1], y[n+1] = map(int, input().split())
ans = True
for n in range(N):
    dt   = t[n+1] - t[n]
    dist = abs(x[n+1] - x[n]) + abs(y[n+1] - y[n])
    if dt < dist:
        ans = False
    if dt % 2 != dist % 2:
        ans = False
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 11636
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		int N=sc.nextInt();	//問題数

		int T[]=new int[100];	//それぞれの問題を解くのにかかる時間
		for(int i=0;i<N;i++) T[i]=sc.nextInt();

		int M=sc.nextInt();	//ドリンクの種類

		int sum=0;
		for(int i=0;i<N;i++) sum+=T[i];	//ドリンクを飲まないときの必要な時間

		int sum_drink[]=new int[100];	//ドリンクありの時と無しの時の差

		for(int i=0;i<M;i++){
			int p=sc.nextInt();
			int x=sc.nextInt();
			sum_drink[i]=T[p-1]-x;
		}

		for(int i=0;i<M;i++) System.out.println(sum-sum_drink[i]);
		
	}
} 

Measured memory_bytes: 22868
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
ans = 0
for param in params:
    if n > m / param:
        break
    ans = param
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main()
{
      char s[300001];
      scanf("%s",s);
      int x=strlen(s);
      int i,sum=0;
      for(i=0;i<x;i++){
            sum+=s[i]-48;
      }
      if(sum%9==0) printf("Yes");
      else printf("No");
}


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

int main() {
	// your code goes here
	int n,i,a,b,c;
	cin>>n;
	vector<int> A[n];
	for(i=0;i<n;i++)
	{
		cin>>a>>b>>c;
		A[i].push_back(a);
		A[i].push_back(b);
		A[i].push_back(c);
		
	}
	int dp[n][3];
	dp[0][0]=A[0][0];
	dp[0][1]=A[0][1];
	dp[0][2]=A[0][2];
	for(i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+A[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+A[i][1];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+A[i][2];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (((a<c)&&(c<b))||((b<c) &&(c<a))){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }  
}


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

using namespace std;

int main(){
while(1){
int H, W;
cin>>H>>W;
if(H == 0 && W == 0) break;

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


Measured memory_bytes: 3088
n=int(input())
li=[]
red=0
white=0
count=0
li=list(input())
for i in li:
  if i == 'R':
    red+=1
  else:
    white+=1

checkw=0
for i in range(red):
  if li[i]=='W':
    checkw+=1

checkr=0
for i in range(white):
  if li[i+red]=='R':
    checkr+=1
sa=checkw-checkr
if sa==0:
  print(checkr)
elif sa>0:
  print(checkr+sa)
else:
  print(checkw+sa)

Measured memory_bytes: 10644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin>>n>>k;
  string str;
  cin>>str;
  if(str.at(k-1)=='A'){
    str.at(k-1)='a';
  }
  if(str.at(k-1)=='B'){
    str.at(k-1)='b';
  }
  if(str.at(k-1)=='C'){
    str.at(k-1)='c';
  }
  cout<<str;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    //変数：乗車券を「　b1　」と特急券を「　b2　」と乗車・特急券を「　b3　」と置く
    int b1, b2, b3;
    
    //入力：乗車券を「　b1　」と特急券を「　b2　」と乗車・特急券を「　b3　」を入力する
    cin >> b1 >> b2 >> b3;
    
    //条件⓵：乗車券を「あり」と特急券を「なし」と乗車・特急券を「なし」
    //条件⓶：乗車券を「なし」と特急券を「あり」と乗車・特急券を「なし」
    //条件⓷：乗車券を「あり」と特急券を「あり」と乗車・特急券を「なし」
    //条件⓸：乗車券を「なし」と特急券を「なし」と乗車・特急券を「あり」
    //条件⓹：乗車券を「なし」と特急券を「なし」と乗車・特急券を「なし」
    //注意：今回ありは「　1　」、なしを「　0　」と置いている
    if( b1 == 1 && b2 == 0 && b3 == 0) cout << "Close" << endl;
    else if( b1 == 0 && b2 == 1 && b3 == 0) cout << "Close" << endl;
    else if( b1 == 1 && b2 == 1 && b3 == 0) cout << "Open" << endl;
    else if( b1 == 0 && b2 == 0 && b3 == 1) cout << "Open" << endl;
    else cout << "Close" << endl;

}



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

public class Main {
	

	public static void main(String[] args) 
	{
		// TODO Auto-generated method stub
		int a,b;
		String str;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		str = sc.next();
		int len = str.length();
		boolean tf = true;
		for (int i = 0;i < len;++i)
		{
			if (i < a && !Character.isDigit(str.charAt(i))) tf = false;
			else if (i == a && str.charAt(i) != '-') tf = false;
			else if (i > a && !Character.isDigit(str.charAt(i))) tf = false;
		}
		if (a+b+1 != len) tf = false;
		if (tf) System.out.println("Yes");
		else System.out.println("No");
	}

}


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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;

int main() {
    int a, b;

    cin >> a >> b;
    cout << ((a<b) ? ("a < b") : ((a>b) ? ("a > b") : ("a == b"))) << endl;

    return 0;
}

Measured memory_bytes: 1156
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		
		int n = sc.nextInt();
		int m = sc.nextInt();

		int u[] = new int[m];
		int v[] = new int[m];
		int w[] = new int[m];
		
		Map<Integer,List<Integer>> g = new HashMap<Integer,List<Integer>>();
		
		for(int i = 0; i < m;i++) {
			u[i] = sc.nextInt()-1;
			v[i] = sc.nextInt()-1;
			w[i] = sc.nextInt();
			
			g.computeIfAbsent(u[i], x -> new ArrayList<Integer>()).add(i);
			g.computeIfAbsent(v[i], x -> new ArrayList<Integer>()).add(i);
		}
		
		int color = 0;
		int[] res = new int[n];
		Arrays.fill(res, -1);
		
		for(int i =0 ; i< n;i++) {
			if(res[i] == -1) {				
				res[i] = color;
				coloring(g,res,i,color,u,v,w);
				color++;
			}
		}
		System.out.println(color);
	}
	
	
	void coloring(Map<Integer,List<Integer>> g,int[] res, int current,int color, int[]u,int v[],int[] w) {
		for(int nextv : g.getOrDefault(current,new ArrayList<Integer>())) {
			int next = u[nextv]+v[nextv]-current;	
			if(res[next] != -1) {
				continue;
			}
			res[next] = color;
			coloring(g,res,next,color,u,v,w);
		}
	}


}

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

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> A(200000, 0);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[a - 1]++;
  }
  sort(A.begin(), A.end(), greater<int>());
  int ans = N;
  for (int i = 0; i < K; i++) {
    ans -= A[i];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;
  cin >> k;
  k--;
  cout << a[k] << endl;
  
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	sc := NewScanner(os.Stdin)
	n, maxWeight := sc.Int(), sc.Int()
	weights, values := make([]int, n+1), make([]int, n+1)
	for i := 1; i <= n; i++ {
		weights[i] = sc.Int()
		values[i] = sc.Int()
	}

	m := make([][]int, n+1)
	for i := range m {
		m[i] = make([]int, maxWeight+1)
	}

	for i := 1; i <= n; i++ {
		w, v := weights[i], values[i]

		for j := 1; j <= maxWeight; j++ {
			m[i][j] = m[i-1][j]
			if j < w {
				continue
			}

			sum := m[i-1][j-w] + v
			m[i][j] = Max(m[i][j], sum)
		}
	}

	fmt.Println(m[n][maxWeight])
}

// generated by https://github.com/murosan/gollect

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

type Scanner struct{ *bufio.Scanner }

func NewScanner(r io.Reader) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &Scanner{Scanner: s}
}

func (s *Scanner) Bytes() []byte { s.Scan(); return s.Scanner.Bytes() }

func (s *Scanner) Int() int { return BytesToInt(s.Bytes()) }

func BytesToInt(b []byte) (n int) {
	var i int
	negative := b[0] == 45
	if negative {
		i++
	}
	for ; i < len(b); i++ {
		n = n*10 + int(b[i]-'0')
	}
	if negative {
		return -n
	}
	return
}


Measured memory_bytes: 81792
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){

  while(1){
  
    int n,m,sum1=0,sum2=0,i;
    cin >> n >> m;
    if(n+m==0) break;
    int arr1[n],arr2[m];

    for(i=0;i<n;i++){
      cin >> arr1[i];
      sum1+=arr1[i];
    }
    for(i=0;i<m;i++){
      cin >> arr2[i];
      sum2+=arr2[i];
    }

    for(i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(sum1-sum2 == arr1[i]*2 - arr2[j]*2){
	  printf("%d %d\n",arr1[i],arr2[j]);
	  goto out;
	}
      }
    }
  out:
    if(i == n) printf("-1\n");
  }
  return 0;
}

Measured memory_bytes: 1148
open System

[<EntryPoint>]
let main argv =
    let a = Console.ReadLine() |> int
    let b = Console.ReadLine() |> int
    let c = Console.ReadLine() |> int
    let d = Console.ReadLine() |> int
    let e = Console.ReadLine() |> int
    let k = Console.ReadLine() |> int
    if (e - a) <= k then "Yay!" else ":("
    |> Console.WriteLine
    0

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	if(H%h==0 && W%w ==0) cout << "No" << endl;
	else
	{
		cout << "Yes" << endl;
		reps(i, H) reps(j, W)
		{
			int t=max(H/h, W/w)+1;
			if(i%h!=0 || j%w!=0) cout << t;
			else cout << (-(h*w-1)*t-1);
			if(j!=W) cout << ' ';
			else cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef long long int ll;
typedef string S;
#define M 1e18
#define AS 1000005
#define in(x)  cin>>x
#define o(x)  cout<<x
#define sp cout<<' '
#define nw cout<<endl
#define rt return
#define fr(i,a,n) for(ll i=a;i<=n;i++)
#define frm(i,a,n) for(ll i=n;i>=a;i--)
#define P pair<ll,ll>
#define vc vector<ll>
#define pb push_back
#define MP map<ll,ll>
bool sortin(const pair<ll,ll> &e,const pair<ll,ll> &f){return (e.first<f.first);}
bool POT(ll x){return x && (!(x&(x-1)));}
ll i,j,k,l,m,n,p,q,r,a,b,c,x,y,z,ts,mn=1e18,mod=1e9+7;
ll ar[AS],br[AS],xr[AS],tem[AS];
ll board[500][500];
int main()
{
    fast;
  S s;
  in(s);n=s.size();
  fr(i,0,n-1)c+=s[i]-'0';
  if(c%9)o("No");
  else o("Yes");
}


Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define inf 10e8
using namespace std;



int main(){
    int n;
    cin >> n;
    int b[n+10];
    int ans=0;
    for (int i=0;i<n-1;i++) {
        cin >> b[i];
        if(i==0) ans+=b[i];
        else ans+=min(b[i],b[i-1]);
         if(i==n-2) ans+=b[i];
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dr[4][2]={{0, 1},{1, 0},{0, -1},{-1, 0}};

int R;
int W, H, X, Y;
int memo[501][501];

void get(vector<vi> &d, int x, int y, vi &res){
	priority_queue<pair<int, pii>, vector<pair<int, pii> >, greater<pair<int, pii> > > pq;
	memset(memo, 63, sizeof(memo));
	pq.emplace(d[y][x], pii(x, y));
	memo[y][x] = d[y][x];
	int p = 0;
	res[p++] = 0;
	while(!pq.empty()){
		int c = pq.top().first;
		int x = pq.top().second.first;
		int y = pq.top().second.second;
		pq.pop();
		if(memo[y][x] < c) continue;
		if(res.size() <= p)break;
		res[p++] = c;
		REP(i, 4){
			int dx = x+dr[i][0];
			int dy = y+dr[i][1];
			if(dx<0||dy<0||W<=dx||H<=dy) continue;
			int dc = max(c, d[dy][dx]);
			if(chmin(memo[dy][dx], dc)) pq.emplace(dc, pii(dx, dy));
		}
	}
}

main(){
	while(cin >> R, R){
		vector<vi> l(2, vi(R+1, INF));
		REP(k, 2){
			cin >> W >> H >> X >> Y;
			vector<vi> d(H, vi(W));
			REP(i, H)REP(j, W) cin >> d[i][j];
			get(d, X-1, Y-1, l[k]);
		}
		
		int ans=INF;
		REP(i, R+1) ans = min(ans, l[0][i] + l[1][R-i]);
		cout << ans << endl;
	}
	return 0;
}

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

/// read the question correctly (is y a vowel?)
/// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
#define fi first
#define se second
#define SZ 1000005
const int mx = 1234567;
const double eps = 1e-6;
const int md = 1e9+7;
const double pi = acos(-1.0);

typedef long long ll;

int dr[8] = {-1,-1,+0,+1,+1,+1,+0,-1};// counter clockwise
int dc[8] = {+0,-1,-1,-1,+0,+1,+1,+1};

int ar[mx],xar[mx],uses[mx];
ll arr[mx];
int tab[1000][1000];
string st[1000];
map<int ,int>mpii;
map<int ,char>mpic;
map<char ,int>mpci;
pair<int, int>pr[mx];

int ar1[mx],ar2[mx],ar3[mx],ar4[mx];

int main(){

    int tk=1,n,m;
//    freopen("in.txt","r", stdin);
//    freopen("out.txt","w", stdout);

//    while(scanf("%d",&n)==1){
//
//    }
    map<string,int>mp;
    string s1,s2,s3;
    cin>>s1>>s2;
    scanf("%d%d",&n, &m);
    mp[s1] = n;
    mp[s2] = m;
    cin>>s3;
    mp[s3]--;
    cout<<mp[s1]<<" "<<mp[s2]<<endl;
    mp.clear();
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
VI findAll(string S,string pattern){VI P;ll pos=(ll)S.find(pattern);
while(pos!=string::npos){P.push_back(pos);pos=(ll)S.find(pattern,pos+1);}return P;}
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
bool is_prime(ll n){if(n<2)return 0;for(int i=2;i*i<n;i++)if(n%i==0)return 0;return 1;}
inline void eratosthenes(VB& p){rep(i,SZ(p))p[i]=1;p[0]=p[1]=0;
rep(i,SZ(p)/2+1){if(p[i])for(ll j=i+i;j<SZ(p);j+=i)p[j]=0;}}
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}// x^n%mod
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
using Graph=vector<vector<int> >;//int と P

int main(){
    int n;cin>>n;
    int h[MAX];rep(i,n)cin>>h[i];
    for(int i=n-1;i>0;i--){
        if(h[i-1]-h[i]==1)h[i-1]--;
        else if(h[i-1]-h[i]>1){cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
}

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

using namespace std;

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

    bool odd = false;
    for(int i=0; i<26; i++){
        int cnt = 0;
        for(int j=0; j<s.length(); j++){
            if(s[j] == 'a'+i) cnt++;
        }
        if(cnt%2) odd = true;
    }

    cout << (odd ? "No" : "Yes") << endl;

    return 0;
}


Measured memory_bytes: 256
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
n, d = map(int, input().split())
ans = 0
for _ in range(n):
    x, y = map(int, input().split())
    if x**2+y**2 <= d**2: ans+=1
print(ans)

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL)
const int N=102,M=11;

int main()
{
	string s;
	cin>>s;
	if(s[1]=='B') cout<<"ARC";
	else cout<<"ABC";
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define N 1000010
using namespace std;
ll c[N], cc[N];
ll s[N];
char st[N];
int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", st+1);
    for (int i=1; i<=n; i++)
        c[i] = c[i-1] + (st[i] == 'M');
    for (int i=1; i<=n; i++)
        cc[i] = cc[i-1] + (st[i] == 'C');
    for (int i=1; i<=n; i++)
        s[i] = s[i-1] + (st[i] == 'C' ? c[i] : 0);
    int Q;
    scanf("%d", &Q);
    while (Q--) {
        int k;
        scanf("%d", &k);
        ll ans = 0;
        for (int i=1; i<=n; i++) {
            if (st[i] != 'D') continue;
            int tar = min(i+k-1, n);
            ans += s[tar]-s[i] - c[i] * (cc[tar]-cc[i]);
            //printf("ans %d : %lld %lld %lld %lld\n", i, ans, s[tar]-s[i], c[i], cc[tar]-cc[i]);
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 24704
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int A,B,T;
    cin >> A >> B >> T;
    int b = 0;
    for(int i=1;i<T+1;i++){
        if(i%A==0){
            b += B;
        }
    }
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N;
	string S;

	cin >> N >> S;

	vector<vector<int>> where(10);
	
	REP(i, N) {
		int n = S[i] - '0';
		where[n].push_back(i);
	}
	
	int res = 0;

	REP(i, 1000) {
		int l, m, r;
		r = i % 10;
		m = i / 10 % 10;
		l = i / 100 % 10;
		if (where[l].empty() || where[m].empty() || where[r].empty()) continue;

		auto itr = upper_bound(where[m].begin(), where[m].end(), where[l][0]);
		if (itr == where[m].end()) continue;
		itr = upper_bound(where[r].begin(), where[r].end(), *itr);
		if (itr != where[r].end()) ++res;
	}

	cout << res << "\n";

	return 0;
}


Measured memory_bytes: 512
using System.Linq;
using static System.Console;

public static class Program
{
    public static void Main()
    {
        var line = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var D = line[0];
        var T = line[1];
        var S = line[2];
        WriteLine(D <= T * S ? "Yes" : "No");
    }
}

Measured memory_bytes: 28264
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++) //n回繰り返すときだけ使う普通はforで楽しないのがいいかな

using namespace std;
typedef long long int ll;
int main()
{
    string s;
    cin >> s;

    int count=0;
    int total=0;
    rep(i,s.size())
    {
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
        {
            count++;
            if(i==(s.size()-1))
                total=max(count,total);
        }
        else
        {
            total = max(total, count);
            count = 0;
        }
    }
        cout <<total <<endl;
        return 0;
        

}


Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

          int n = Integer.parseInt(in.readLine());
          int sum = 0;

          int a[] = new int[n];
          String line = in.readLine();
          char regex = ' ';
          boolean isContinue = true;
          for(int i=0,m=0, offset=0,next=0; isContinue; i++, offset = ++next) {
            if((next = line.indexOf(regex,offset)) == -1) {
              next = line.length();
              isContinue = false;
            }
            sum += a[m++] = Integer.parseInt(line.substring(offset,next));
          }

          int ans=0;
          int d=0, min = 10000000;
          for(int i=0; i<n; i++) {
            d = Math.abs(sum - a[i]*n);
            if(min > d) {
              min = d;
              ans = i;
            }
          }
          System.out.println(ans);
      }
      catch(IOException e) {
        System.err.println(e);
      }
  }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
int main()
{
	char c;
	cin>>c;
	int s=(int)(c-'a');
	if(s<0)
	{
		cout<<"A"<<endl;
	}
	else
	{
		cout<<"a"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
using namespace std; 
typedef long long  ll;
int main()
{
	unsigned long long H,W;
	cin >>H >>W;
	if(H==1||W==1){
		cout <<1<<endl;
	}else{
		cout << (H*W+1)/2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 60000
int main(){
	int m,ans=0;
	int c,c2,c3;
	int bf,af;
	char list[MAX+1];
	for(c=0;c<MAX;c++){
		list[c]=1;
	}
	list[0]=0;list[1]=0;
	while(~scanf("%d",&m)){
		for(c=2;c<MAX;c++){
			if(list[c]){
				for(c2=c*2;c2<MAX;c2+=c)list[c2]=0;
				for(c3=MAX;list[c3]==0;c3--);
				if(c3<c*c)break;
			}
		}
		for(c=2;c<MAX;c++){
			if(m==c){
				printf("%d",af);
				for(c2=c+1;c2<MAX;c2++){
					if(list[c2]){
						bf=c2;
						printf(" %d\n",bf);
						break;
					}
				}
				
			}
			else af=(list[c])?c:af;
		}
	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func swap(a int64, b int64) (int64, int64) {
	return b, a
}

func gcd(a int64, b int64) int64 {
	if b > a {
		a, b = swap(a, b)
	}
	if b == 0 {
		return a
	} else {
		return gcd(a%b, b)
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(nums ...int64) int64 {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int64(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int64) int64 {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int64(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func nextLong() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func nextByte() byte {
	sc.Scan()
	s := sc.Bytes()
	return s[0]
}

func main() {
	sc.Split(bufio.ScanWords)
	//ans := 1
	W := nextLong()
	H := nextLong()
	x := nextLong()
	y := nextLong()
	ans := 0.0
	ans = (float64(H) * float64(W)) / 2.0
	if 2*x == W && y*2 == H {
		fmt.Printf("%f %d", ans, 1)
	} else {
		fmt.Printf("%f %d", ans, 0)
	}
	//fmt.Printf("%d\n", Alllength)
	//fmt.Printf("%d\n", Looplength)
}


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

int main() {
    int N;
    cin >> N;
    vector<long long> a(N), ans(N, 0);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    vector<int> B(31, 0);
    for(long long x : a) {
        int i = 0;
        while(x > 0) {
            if(x % 2) {
                B[i]++;
            }
            x /= 2;
            i++;
        }
    }
    for(int i = 0; i < N; i++) {
        long long k = 1, x = a[i];
        for(int j = 0; j < 31; j++) {
            if((B[j] % 2 == 0 && x % 2 == 1) || (B[j] % 2 == 1 && x % 2 == 0))
                ans[i] += k;
            k *= 2;
            x /= 2;
        }
    }
    for(int i = 0; i < N; i++) {
        if(i == 0)
            cout << ans[i];
        else
            cout << " " << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 6312
import bisect

N, W = map(int, input().split())
w = [0] * (N + 1)
v = [0] * (N + 1)

for i in range(1, N + 1):
    w[i], v[i] = map(int, input().split())
INF = 1000000010
MAX_V = 100010
dp = [[INF] * MAX_V for _ in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    for value in range(MAX_V):
        if value <= v[i]:
            dp[i][value] = min(dp[i-1][value], w[i])
        else:
            dp[i][value] = min(dp[i - 1][value], dp[i-1][value-v[i]] + w[i])

print(bisect.bisect_right(dp[N], W)-1)

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

using namespace std;

const int max_len = 1005;
int dp[max_len][max_len];
char s1[max_len];
char s2[max_len];

void solve() {
  int l1 = strlen(s1);
  int l2 = strlen(s2);
  for (int i = 0; i < max_len; i++) {
    dp[i][0] = dp[0][i] = i;
  }
  for (int i = 0; i < l1; i++) {
    for (int j = 0; j < l2; j++) {
      int d1s = dp[i][j];
      int d1d = dp[i][j] + 1;
      int d2 = dp[i + 1][j] + 1;
      int d3 = dp[i][j + 1] + 1;
      if (s1[i] == s2[j]) {
        dp[i + 1][j + 1] = min(min(d1s, d2), d3);
      } else {
        dp[i + 1][j + 1] = min(min(d1d, d2), d3);
      }
    }
  }
  printf("%d\n", dp[l1][l2]);
}

int main() {
  fgets(s1, max_len, stdin);
  fgets(s2, max_len, stdin);
  for (int i = 0; i < max_len; i++) {
    if (s1[i] == '\n') { s1[i] = '\0'; }
    if (s2[i] == '\n') { s2[i] = '\0'; }
  }
  solve();
  return 0;
}

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


int main(void)
{
	int A = 0, B = 0;
	cin >> A >> B;

	int resAdd = 0, resSub = 0, resMul = 0;
	resAdd = A + B;
	resSub = A - B;
	resMul = A * B;

	cout << max(max(resAdd, resSub), resMul) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,M;
  cin >> N >> M;
  v(bool) acs(N,false);
  vi was(N,0);
  int ac=0;
  rep(i,M) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if(!acs[p]) {
      if(s=="AC") {
        acs[p] = true;
        ac++;
      } else {
        was[p]++;
      }
    }
  }
  int wa = 0;
  rep(i,N) {
    if(acs[i]) {
      wa += was[i];
    }
  }
  cout << ac << " " << wa << endl;
  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

int n, m, q;
int a[16];

void test();

struct shit {
    int a, b, c, d;

    shit () {}

    void read () {
        scanf("%d %d %d %d", &a, &b, &c, &d);
    }
};

void put (int cur) {

    if (cur == n + 1) {
        return test();
    }

    for (int j = a[cur - 1] ; j <= m ; ++ j) {
        a[cur] = j;
        put(cur + 1);
    }
}

int ans = 0;
shit s[152];

void test () {
    int res = 0;
    for (int i = 1 ; i <= q ; ++ i) {
        if (a[s[i].b] - a[s[i].a] == s[i].c) res += s[i].d;
    }

    ans = max(ans, res);
}


int main () {
    a[0] = 1;
    scanf("%d %d %d", &n, &m, &q);


    for (int i = 1 ; i <= q ; ++ i) {
        s[i].read();
    }
    put(1);

    printf("%d\n", ans);
}
/*
    Good Luck
        -Lucina
*/
/*
    I hate Progmeth
*/


Measured memory_bytes: 3816
#include <iostream>

using namespace std;

int main()
{
int D;
cin >>D;
if (D==22)
    cout <<"Christmas Eve Eve Eve";
else if (D==23)
    cout <<"Christmas Eve Eve";
    else if (D==24)
    cout <<"Christmas Eve";
else if (D==25)
    cout <<"Christmas";


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

double INF = 1e20;

int p[1100][3]; // x, y, r
double dist[1100][1100];
double dij[1100]; bool vs[1100];

double getdist(int i1, int i2){
  int dx = p[i1][0] - p[i2][0], dy = p[i1][1] - p[i2][1];
  double cd = sqrt(1LL * dx * dx + 1LL * dy * dy);

  if(cd > p[i1][2] + p[i2][2]) return cd - p[i1][2] - p[i2][2];
  else return 0;
}

int main(){
  scanf("%d%d%d%d", &p[0][0], &p[0][1], &p[1][0], &p[1][1]);
  int N; scanf("%d", &N); N += 2;
  for(int i = 2; i < N; i++) scanf("%d%d%d", &p[i][0], &p[i][1], &p[i][2]);

  for(int i = 0; i < N; i++){
    dist[i][i] = 0.0;
    for(int j = i + 1; j < N; j++) dist[i][j] = dist[j][i] = getdist(i, j);
  }

  for(int i = 0; i < N; i++) dij[i] = INF;
  dij[0] = 0.0;

  for(int n = 0; n < N; n++){
    double md = INF; int now = -1;
    for(int i = 0; i < N; i++) if(dij[i] < md && !vs[i]){ md = dij[i]; now = i; }

    vs[now] = true;
    for(int i = 0; i < N; i++){
      if(!vs[i]){
        double nd = md + dist[now][i];
        if(nd < dij[i]) dij[i] = nd;
      }
    }
  }

  printf("%.15lf\n", dij[1]);
  return 0;
}

Measured memory_bytes: 8832
#include <stdio.h>

int main(void){

  int h,w;
  scanf("%d %d", &h, &w);
  char s[h][w+1];
  for (int i = 0; i < h; i++) {
    scanf("%s", s[i]);
  }
  int count[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      count[i][j] = 0;
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        if (i > 0) {
          count[i-1][j]++;
          if (j > 0) {
            count[i-1][j-1]++;
          }
          if (j < w-1) {
            count[i-1][j+1]++;
          }
        }
        if (i < h-1) {
          count[i+1][j]++;
          if (j > 0) {
            count[i+1][j-1]++;
          }
          if (j < w-1) {
            count[i+1][j+1]++;
          }
        }
        if (j > 0) {
          count[i][j-1]++;
        }
        if (j < w-1) {
          count[i][j+1]++;
        }
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        printf("#");
      } else {
        printf("%d", count[i][j]);
      }
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int mod=2019;
int fpow(int a,int b){
	int res=1;
	while(b>=1){
		if(b&1) res=(res*1LL*a)%mod;
		a=(a*1LL*a)%mod;
		b=b/2;
	}
	return res;
}
int main(int argc, char **argv)
{
	int n,count=0,ans=0,p=1;
	string str;
	cin>>str;
	n=str.size();
	unordered_map<int,int> freq;
	freq[0]++;
	for(int i=0;i<n;i++){
		ans=(ans+((str[i]-'0')*1LL*fpow(10,n-i-1))%mod)%mod;
		if(freq.find(ans)!=freq.end())
		   count+=freq[ans];
		freq[ans]++;
	}
	cout<<count;
	return 0;
}



Measured memory_bytes: 3716
s=list(input())
o = len(s)
j = 0
k = 0

for i in range(o):
    if i%2 == 1:
        if s[i] == str(1):
           j = j + 1
        else: k = k + 1
    if i%2 == 0:
        if s[i] == str(0):
           j = j + 1
        else: k = k + 1

if k >= j:
    print(j)
else: print(k)

Measured memory_bytes: 4004
import fractions

N = int(input())
A = list(map(int, input().split()))

# correct
L = [0] * N
R = [0] * N

for i in range(1, N):
    L[i] = fractions.gcd(L[i - 1], A[i - 1])
for j in range(0, N-1)[::-1]:
    R[j] = fractions.gcd(R[j + 1], A[j + 1])
ans = 0
for k in range(N):
    ans = max(ans, fractions.gcd(L[k], R[k]))
print(ans)


Measured memory_bytes: 16160
#include <iostream>
#include <set>

using namespace std;

int main()
{
    int N;
    cin>>N;
    set<set<int>> S;
    for (int i=0; i<N; i++)
    {
        int p[3];
        cin>>p[0]>>p[1]>>p[2];
        S.insert(set<int>(p, p+3));
    }
    cout<<N-S.size()<<endl;
}

Measured memory_bytes: 3312
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
vector<int>G[10005];
int V,E,F[10005]={0};
queue<P>Q;
int main()
{
	scanf("%d%d",&V,&E);
	for(int i=0;i<E;i++)
	{
		int s,e;
		scanf("%d%d",&s,&e);
		G[s].push_back(e);
		F[e]=1;
	}
	for(int i=0;i<V;i++)if(!F[i])Q.push(make_pair(i,0));
	memset(F,0,sizeof(F));
	while(!Q.empty())
	{
		P T=Q.front();Q.pop();
		int s=T.first,t;
		for(int i=0;i<G[s].size();i++)
		{
			t=G[s][i];
			if(F[t]<F[s]+1)
			{
				F[t]=F[s]+1;
				Q.push(make_pair(t,F[t]));
			}
		}
	}
	for(int i=0;i<V;i++)
	{
		int t=-1;
		for(int i=0;i<V;i++)
		{
			if(t==-1||F[t]>F[i])
				t=i;
		}
		printf("%d\n",t);
		F[t]=100000;
	}
}

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

int main(){
  string taro,hanako;
  int p_taro = 0, p_hanako = 0;
  int n;
  cin >> n;

  for (int i = 0; i < n; i++){
    cin >> taro >> hanako;

    if ( taro > hanako ){
      p_taro += 3;
    }
    else if ( taro == hanako ){
      p_taro += 1;
      p_hanako += 1;
    }
    else {
      p_hanako += 3;
    }
  }
  cout << p_taro << " " << p_hanako << endl;

  return 0;
}

Measured memory_bytes: 3196