akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>/*{{{*/
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i, b, e) for (typeof(b) i = (b); assert((i) <= (e)), i != (e); ++i)
#define SZ(a) ((int)a.size())
#define PB(e) push_back(e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
#define F first
#define S second
#define MP(a, b) make_pair(a, b)
#define BIT(n) (1ULL << (n))

static const double PI (3.14159265358979323846);
static const double EPS (1e-10);

using namespace std;
typedef long long int LL;
typedef pair<int,int> P;/*}}}*/

int main(int argc, char const* argv[])
{
	string str;
	while (getline(cin, str)) {
		if (str == ".") {
			break;
		}
		stack<char> st;
		FOR(i, 0, str.length()) {
			switch (str.at(i)) {
				case '(':
					st.push('(');
					break;
				case '[':
					st.push('[');
					break;
				case ')':
					if (st.empty() || st.top() != '(') {
						goto NO;
					}
					st.pop();
					break;
				case ']':
					if (st.empty() || st.top() != '[') {
						goto NO;
					}
					st.pop();
					break;
			}
		}
		if (!st.empty()) {
			goto NO;
		}
		cout << "yes" << endl;
		continue;
NO:
		cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 904
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



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

    cout << max({a+b,a-b,a*b}) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pb push_back
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define N 100010
#define Pa 99991
#define Maxi 1e18
vector<ll>v[100001];
ll dp[100001];
ll dfs(ll src)
{
    if(dp[src]!=-1)
    return dp[src];
    for(int i=0;i<v[src].size();i++)
    {
        dfs(v[src][i]);
        dp[src]=max(dp[src],1+dp[v[src][i]]);
    }
    if(v[src].size()==0)
    {
        dp[src]=1;
        return dp[src];
    }
}
int main()
{
    ll n,m;
    cin>>n>>m;
    ll i;
    for(i=0;i<m;i++)
    {
        ll a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    memset(dp,-1,sizeof(dp));
    ll maxi=1;
    for(i=1;i<=n;i++)
    {
        dfs(i);
    }
    for(i=1;i<=n;i++)
    {
        maxi=max(maxi,dp[i]);
    }
    cout<<maxi-1;
    return 0;
}

Measured memory_bytes: 8576
n, m, x = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(n)]

ans = -1

def calc_score(data, score):
    for i in range(m):
        score[i] += data[i + 1]

def judge_score(score):
    for i in range(m):
        if score[i] < x:
            return False
    
    return True

for i in range(2 ** n):
    score = [0] * m
    price = 0
    for j in range(n):
        if i >> j & 1:
            calc_score(data[j], score)
            price += data[j][0]
    if judge_score(score):
        if ans == -1:
            ans = price
        else:
            ans = min(ans, price)

print(ans)

Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	ios_base :: sync_with_stdio(0);
  	cin.tie(NULL);
  	long long n;
  	cin>>n;
  	long long b=1;
  	while(2*b<=n) b*=2;
  	cout<<2*b-1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
double count(long long x)
{
    double res=0;
    for(;x>0;x/=10)res+=x%10;
    return res;
}
int main()
{
    int k;
    scanf("%d",&k);
   	long long ans=1,pw=1;
    for(int i=0;i<k;i++)
	{
		cout<<ans<<endl;
		ans+=pw;
		if(ans/count(ans)>(ans+pw)/count(ans+pw))
		{
			ans=ans+pw*9;
			pw*=10;
		}
	}
	return 0;
}

Measured memory_bytes: 256
pow = [1]
for p in range(2,32):
  i=2
  while p**i<=1000:
    pow.append(p**i)
    i += 1
#print(pow)
X = int(input())
x = X
while x>0:
  if x in pow:
    ans = x
    break
  x -= 1
print(ans)

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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++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 PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    REP(i,n)cin >> a[i];

    a.emplace_back(k + a[0]);
    vector<int> b(n);

    int max = -1;
    REP(i,n){
        b[i] = a[i + 1] - a[i]; 
        if(b[i] > max){
            max = b[i];
        }
    }
    int sum = accumulate(ALL(b), 0);

    sum -= max;
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4760
n = int(input().strip())
ts = []
for _ in range(n):
    ts.append(int(input().strip()))

def gcd(m, n):
    while 1:
        mod = m % n
        if mod == 0:
            return n
        m, n = n, mod

def lcm(m, n):
    return m * n // gcd(m, n)

from functools import reduce

print(reduce(lcm, ts))



Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 0x3f3f3f3f;
const double pi = 3.14;
int main() {
	// your code goes here
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n ;
	cin >> n ;
	
	int arr[n+1];

	for(int i = 1; i < n ; i++)
	{
		cin >> arr[i];
	}
	
	unordered_map<int,int> mp;

	for(int i = 1 ; i < n ; i++)
	{
		mp[arr[i]]++;
	}

	for(int i = 1 ; i <= n ; i++)
	{
		cout << mp[i] << '\n';
	}
	

	return 0;
	} 

Measured memory_bytes: 12248
N, M, X = map(int, input().split())
C = [(list(map(int, input().split()))) for _ in range(N)]
 
# bit全探索を行い、参考書に関する全ての組みについて、値段と理解度を求める
ans = 10**10
for i in range(2**N):
  U = [0]*(M+1)
  for j in range(N):
    if ((i >> j) & 1):
      for k in range(M+1):
        U[k] += C[j][k]
  
  # ある組みが条件を満たし、その値段が現時点で最小なら、更新する
  if sum([u >= X for u in U[1:]]) == M:
    ans = min(ans, U[0])

if ans == 10**10: print(-1)
else: print(ans)

Measured memory_bytes: 9204
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){

  int H[1000], W[1000];
  int i, j, k;

  for(k = 0; k < 1000; k++){
    scanf("%d %d", &H[k], &W[k]);
    if(H[k] == 0 && W[k] == 0){
      break;
    }else{
      for(i = 0; i < H[k]; i++){
	for(j = 0; j < W[k]; j++){
	  printf("#");
	}
	printf("\n");
      }
    }
    printf("\n");
  }
  
  return 0;
}


Measured memory_bytes: 2120
import java.util.Scanner;

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

    int N = scanner.nextInt();
    while (N > 0) {
      if (N % 10 == 7) {
        System.out.println("Yes");
        return;
      }
      N /= 10;
    }
    System.out.println("No");
  }
}


Measured memory_bytes: 27036
#include <iostream>

int main()
{
    int S = 0;
    
    // input
    std::cin >> S;
    
    if( S >= 0 && S < 86400 )
    {
        std::cout << S / 3600;
        std::cout << ":";
        std::cout << ( S - 3600 * ( S / 3600 ) ) / 60;
        std::cout << ":";
        std::cout << S - 3600 * ( S / 3600 ) - 60 * ( ( S - 3600 * ( S / 3600 ) ) / 60 );
        std::cout << std::endl;
    }
    else
    {
        std::cout << "Error : out of range!" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3068
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>

#define pi 3.141592654589793238462

using namespace std;
int n;

void KochCurve( pair<double,double> left , pair<double,double> right , int now , double length ,double angle){
	pair<double,double> m_left,m_right,top;
	if(now==n){
		printf("%8lf %8lf\n", left.first , left.second );
	}else{
		m_left.first=(2*left.first+right.first)/3;
		m_left.second=(2*left.second+right.second)/3;
		m_right.first=(2*right.first+left.first)/3;
		m_right.second=(2*right.second+left.second)/3;
		KochCurve( left , m_left , now+1 , length/3 , angle );
		top.first=m_left.first + (length/3)*cos( angle+pi/3 ); 
		top.second=m_left.second + (length/3)*sin( angle+pi/3 ); 
		KochCurve( m_left , top , now+1 , length/3 , angle+pi/3 );
		KochCurve( top , m_right , now+1 , length/3 , angle-pi/3 );
		KochCurve( m_right , right , now+1 , length/3 , angle );
	}
}

int main(){
	scanf("%d",&n);
	KochCurve( make_pair(0.00,0.00) , make_pair(100.00,0.00) , 0 , 100 , 0 );
	printf("100.00000000 0.00000000\n");
	return 0;
}


Measured memory_bytes: 3460
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;

int main() {

	int N,D,X;
	cin >> N >> D >> X;

	for (int i = 0; i < N; i++) {
		int A; cin >> A;
		for (int j = 1; j <= D; j += A) {
			X++;
		}
	}

	cout << X << endl;

	return 0;
}

Measured memory_bytes: 256
import heapq
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input().strip())
    l = [int(i) for i in input().strip().split()]
    ans = 0
    m = max(l)
    dp = [0] * (m+1)

    for n in l:
        for j in range(n, m + 1, n):
            dp[j] += 1

    for n in l:
        if dp[n] == 1:
            ans += 1

    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 32228
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n;
    int a;
    int b;
    int c;
    int d;
    cin >> n >> a >> b >> c >> d;
    int x = (n + (a - 1)) / a * b;
    int y = (n + (c - 1)) / c * d;
    cout << min(x, y)<< endl;
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	std::string S;
	std::cin >> S;
	std::string T;
	std::cin >> T;
	long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);
	std::string U;
	std::cin >> U;

	if (S == U) {
		cout << A - 1 << " " << B << endl;
	} else {
		cout << A << " " << B - 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
w = []
N = int(input())


def addchar(s):
    if(len(s) < N):
        x = len(set(s))+1
        for i in range(x):
            t = s + chr(ord("a")+i)
            addchar(t)
    else:
        w.append(s)

addchar("a")
for i in w:
  print(i)

Measured memory_bytes: 12656
#include <stdio.h>

using namespace std;

typedef long long  ll;

int h, w;
int cost[10][10];
int a[201][201];
int ans = 987654321;
void f(int value, int c) {
    //printf("%lld %lld\n", value, c);
    
    if (value == 1) {
        //printf("%lld %lld\n", value, c);
        
        if (c < ans) {
            ans = c;
        }
        return;
    }
    for (int i = 0; i < 10; i++) {
        if (i != value && c + cost[value][i] < ans) {
            f(i, c + cost[value][i]);
        }
        
    }
    
}
int main() {
    
    scanf("%d %d", &h, &w);
    
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++)
            scanf("%d", &cost[i][j]);
    
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            scanf("%d", &a[i][j]);
    
    int realAns = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if (a[i][j] == -1 || a[i][j] == 1)
                continue;
            else {
                f(a[i][j], 0);
                realAns += ans;
                ans = 987654321;
            }
    
    printf("%d", realAns);
    
    return 0;
}




Measured memory_bytes: 256
x_aka,y_mid,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p_aka = sorted(p,reverse=True)
q_mid = sorted(q,reverse=True)
r_mu = sorted(r,reverse=True)
#print(p_aka[:x_aka],q_mid[:y_mid],r_mu)
tmp = p_aka[:x_aka] + q_mid[:y_mid] + r_mu
sort_tmp = sorted(tmp,reverse=True)
#print(sort_tmp[:(x_aka+y_mid)])
print(sum(sort_tmp[:(x_aka+y_mid)]))


Measured memory_bytes: 30460
#155
def main():
    N = int(input())
    S = [input() for i in range(N)]
    S.sort()
    ans = []
    max_len = 0
    streak = 1
    for i in range(N-1):
        if(S[i]==S[i+1]):
            streak+=1
            if(i==N-2):
                if(streak>max_len):
                    max_len = streak
                    ans = [S[i]]
                elif(streak==max_len):
                    ans.append(S[i])
        else:
            if(streak>max_len):
                max_len = streak
                ans = [S[i]]
            elif(streak==max_len):
                ans.append(S[i])
            streak=1
    if(N==1 or S[-2]!=S[-1]):
        ans.append(S[-1])
    for a in ans:
        print(a)
main()

Measured memory_bytes: 20680
#include <stdio.h>

int main()
{
	int N, Y;

	scanf("%d %d", &N, &Y);

	for (int x = 0; x <= N; x++)
	{
		for (int y = 0; y <= N - x; y++)
		{
			if (x * 10000 + y * 5000 + (N - y - x) * 1000 == Y)
			{
				printf("%d %d %d\n", x, y, N-y-x);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

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

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int main(){
    int N, K;
    while(std::cin >> N >> K, N){
        int cards[100];
        REP(i, N){
            std::cin >> cards[i];
        }
    
        int C = 0, c = 1;
        REP(i, K){
            c *= cards[i];
        }
        C = c;
            
        FOR(i, K, N){
            c = c / cards[i-K] * cards[i];
            C = std::max(C, c);
        }

        int C_ = 0;
        REP(i, N){
            FOR(j, i+1, N){
                std::swap(cards[i], cards[j]);

                int c = 1;

                REP(k, K){
                    c *= cards[k];
                }
                C_ = std::max(C_, c);

                FOR(k, K, N){
                    c = c / cards[k-K] * cards[k];
                    C_ = std::max(C_, c);
                }

                std::swap(cards[i], cards[j]);
            }
        }

        // printf("%d, %d\n", C, C_);
        if(C_ - C < 0){
            puts("NOGAME");
        }else{
            printf("%d\n", C_-C);
        }
    }
}

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

using namespace std;
typedef long long int ll;


int main()
{
    ll N; cin >> N;
    vector<ll>A(N); for(ll i = 0; i < N; i++) cin >> A[i];
    vector<ll>dp;
    for(auto x:A)
    {
        auto itr = lower_bound(dp.begin(),dp.end(),x);
        if(itr == dp.begin()) dp.insert(itr,x);
        else itr--,*itr = x;
    }
    cout << dp.size() << endl;
}

Measured memory_bytes: 4968
#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>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<vector<int>> is(26);
    rep(i,n) is[s[i]-'a'].push_back(i);
    rep(i,n) is[s[i]-'a'].push_back(i+n);
    ll ans = 0;
    int p = 0;
    rep(i,m) {
        int c = t[i]-'a';
        if (is[c].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
        if (p >= n) {
            p -= n;
            ans += n;
        }
    }
    ans += p;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4596
(function(stdin){
	var line = stdin.toString().split(' ').map(Number);
	var resolt = (function(width,height,x,y,r){
		return (y + r > height || x + r > width || x - r < 0 || y - r < 0)? "No":"Yes";
	}(line[0],line[1],line[2],line[3],line[4]));
	console.log(resolt);
}(require('fs').readFileSync('/dev/stdin','utf8')));

Measured memory_bytes: 7384
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int INF = INT_MAX / 2;

int solve(int x)
{
    if(x < 0)
        return INF;
    else return x;
}

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    vector<int> dp(2, 0);
    dp[1] = 1;
    for(int i=0; i<n; ++i){
        vector<int> nextDp(2, INF);
        for(int a=0; a<2; ++a){
            for(int b=0; b<10; ++b){
                int x = a * 10 + b - (s[i] - '0');
                nextDp[0] = min(nextDp[0], dp[a] + solve(b) + solve(x));
                nextDp[1] = min(nextDp[1], dp[a] + solve(b) + solve(x - 1));
            }
        }
        dp.swap(nextDp);
    }
    cout << dp[0] << endl;

    return 0;
}


Measured memory_bytes: 1412
n = gets.to_i
dp = Array.new(n) { Array.new(3) }
dp[0][0], dp[0][1], dp[0][2] = gets.split.map(&:to_i)

(n - 1).times do |i|
  a, b, c = gets.split.map(&:to_i)
  dp[i + 1][0] = [dp[i][1], dp[i][2]].max + a
  dp[i + 1][1] = [dp[i][0], dp[i][2]].max + b
  dp[i + 1][2] = [dp[i][0], dp[i][1]].max + c
end

puts dp[n - 1].max


Measured memory_bytes: 22552
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30 and r >= 50:
        print("C")
    elif m + f >= 30 and r < 50:
        print("D")
    else:
        print("F")


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

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

int main(){
    string s;
    cin>>s;
    int n=s.size();
    rep(i,n-1){
        if(s[i]=='B'&&s[i+1]=='C') s[i]='K',s[i+1]='D';
    }
    reverse(s.begin(),s.end());
    ll k=0,cnt=0;
    rep(i,n){
        if(s[i]=='K') k++;
        else if(s[i]=='A') cnt+=k;
        else if(s[i]!='D') k=0;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const int MAX = 4;

ll dp[100001][13];
int main() {
	string s; cin >> s;
	reverse(s.begin(), s.end());

	ll digit = 1;
	ll S = 13;

	rep(i, 0, s.size()) {
		if (i == 0) {
			if (s[i] == '?') {
				rep(j, 0, 10)dp[i][j]++;
			}
			else {
				dp[0][(s[i] - '0')]++;
			}
		}
		else {
			if (s[i] == '?') {
				rep(k, 0, 10) {
					rep(j, 0, S) {
						dp[i][(digit * k + j) % S] += dp[i - 1][j];
						dp[i][(digit * k + j) % S] %= MOD;
					}
				}
			}
			else {
				ll k = s[i] - '0';
				rep(j, 0, S) {
					dp[i][(digit * k + j) % S] += dp[i - 1][j];
					dp[i][(digit * k + j) % S] %= MOD;
				}
			}
		}
		digit *= 10;
		digit %= S;
	}
	cout << dp[s.size() - 1][5] << endl;

	return 0;
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define P pair<int,int>
#define prique priority_queue
int n,m;
signed main(){
    cin>>n>>m;
    if(n==1||m==1){
        if(n==1&&m==1)cout<<1<<endl;
        else{
            if(n>m)swap(n,m);
            cout<<m-2<<endl;
        }
    }
    else{
        int x=max((int)(0),n-2);
        int y=max((int)(0),m-2);
        cout<<x*y<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int S[n];
    for(int i = 0; i < n; i++){
        cin >> S[i];
    }
    
    int q;
    cin >> q;
    int T[q];
    for(int i = 0; i < q; i++){
        cin >> T[i];
    }
    
    int count = 0;
    for(int i = 0; i < q; i++){
        for(int j = 0; j < n; j++){
            if(T[i] == S[j]){
                count++;
                break;
            }
        }
    }
    
    cout << count << endl;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, s.size()) {
		if (s[i] != t[i]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3848
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

int n;


void solve(){
  cin >> n;
  int x[n],y[n],h[n];
  int s=-1;
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i]>0)s=i;
  }
  int rx=-1,ry=-1,rh=-1;
  for(int Cx=0;Cx<=100;Cx++){
    for(int Cy=0;Cy<=100;Cy++){
      bool f=true;
      int H=h[s]+abs(Cx-x[s])+abs(Cy-y[s]);
      for(int i=0;i<n;i++){
        if(h[i]>0 && H-h[i]!=abs(Cx-x[i])+abs(Cy-y[i]))f=false;
        if(h[i]==0 && H>abs(Cx-x[i])+abs(Cy-y[i]))f=false;
      }
      if(f){
        rx=Cx;
        ry=Cy;
        rh=H;
      }
    }
  }
  cout << rx << " " << ry << " " << rh << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n;
	ll x[101][101] = {};
	ll y[101][101] = {};
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int k = 0; k < 10; k++)
		{
			cin >> x[i][k];
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int k = 0; k < 11; k++)
		{
			cin >> y[i][k];
		}
	}
	b = -9999999999999;
	for (int i1 = 0; i1 < 2; i1++)
	{
		for (int i2 = 0; i2 < 2; i2++)
		{
			for (int i3 = 0; i3 < 2; i3++)
			{
				for (int i4 = 0; i4 < 2; i4++)
				{
					for (int i5 = 0; i5 < 2; i5++)
					{
						for (int i6 = 0; i6 < 2; i6++)
						{
							for (int i7 = 0; i7 < 2; i7++)
							{
								for (int i8 = 0; i8 < 2; i8++)
								{
									for (int i9 = 0; i9 < 2; i9++)
									{
										for (int i10 = 0; i10 < 2; i10++)
										{
											a = 0;
											if (i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10 > 0)
											{

												for (int i = 0; i < n; i++)
												{
													a += y[i][i1*x[i][0] + i2*x[i][1] + i3*x[i][2] + i4*x[i][3] + i5*x[i][4] + i6*x[i][5] + i7*x[i][6] + i8*x[i][7] + i9*x[i][8] + i10*x[i][9]];
												}
											b = max(a, b);
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}


	cout << b << endl;
	//cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

ll dig(string s){
	ll ret=0;
	for(auto&& e:s) ret+=e-'0';
	return ret;
}

int main()
{
	string s;
	map<char,ll> m;
	while(getline(cin,s)){
		for(auto&& e:s){
			if(isupper(e)) e+=32;
			m[e]++;
		}
	}
	for(char c='a';c<='z';c++) cout << c << " : " << m[c] << endl;
	return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int n;
    cin >> n;
    vi p(n);
    int cnt = 0;
    rep(i, 0, n)
    {
        int p;
        cin >> p;
        if (p != i + 1)
            cnt++;
    }
    //cout << cnt << endl;
    Print(cnt <= 2);
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (300006)
int main()
{
	ll n; cin>>n;
	FOR(i,0,50000) {
		if(i * 108 / 100 == n) {
			cout<<i; return 0;
		}
	}cout<<":(";
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 0;
  if (a + b > 2 * c) {
    int xy = min(x, y);
    ans += xy * 2 * c;
    ans += (x - xy) * min(a, 2 * c);
    ans += (y - xy) * min(b, 2 * c);
  } else {
    ans += a * x;
    ans += b * y;
  }
  cout << ans << '\n';
  return 0;
}

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


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

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

    ll res = (a * b) / gcd(a, b); 
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3532
// Problem : C - Next Prime
// Contest : AtCoder - AtCoder Beginner Contest 149
// URL : https://atcoder.jp/contests/abc149/tasks/abc149_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
using namespace std;
#define MAX 1000007
int main()
{
	lli t,a,i;
	vector<bool>is_p(MAX,true);
	is_p[0]=false;
	is_p[1]=false;
	for(i=2;i<MAX;i++)
	{
		if(is_p[i]==true){
			for(lli j=i*i;j<MAX;j+=i){
				is_p[j]=false;
			}
		}
	}
	cin>>t;
	while(!is_p[t]){
		t++;
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 3764
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
	int n, K, l = 0, r = 0, P;
	scanf("%d %d", &n, &K);
	vector<int> w(n);
	for (int &x: w) {
		scanf("%d", &x);
		l = l > x ? l : x;
		r += x;
	}
	
	while (l != r) {
		P = (l + r) / 2;
		auto i = w.begin(), e = w.end(), ee = e - 1;
		int k = 0, p = 0;
		for (; i != e && k < K; i++) {
			int t = p + *i;
			if (t < P)
				p = t;
			else if (t > P)
				p = *i, k++;
			else {
				p = 0;
				if (i != ee)
					k++;
			}
		}
		if (i == e && k < K)
			r = P;
		else
			l = P + 1;
	}
	printf("%d\n", r);
}



Measured memory_bytes: 2784
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#include<numeric>
#include<sstream>
#include<math.h>
#include <iomanip>
#define ll long long
#define PLL pair<ll,ll>
#define VS vector<string>
#define VL vector<ll>
#define rep(i,a) for (ll i=0;i<a;i++)
#define nrep(i,n,a) for (ll i=n;i<a;i++)
#define mrep(i,a) for(ll i=a;i>=0;i--)
#define INF 1145141919810
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VSUM(vec) std::accumulate(vec.begin(),vec.end(),0LL)
#define LTS(n) to_string(n)
#define STL(str) stoll(str);

using namespace std;

ll n;
string s;


//s_or_w:0->s  s_or_w:1->w
void fun(string str){
	ll next, prev,i;
	nrep(x, 1, n+1){
		i = x%n;
		next = (i + 1) % n;
		prev = (i == 0 ? n - 1 : i - 1);
		if (s[i]=='o' && str[i] == 'S' || s[i]=='x' && str[i]=='W') str += str[prev];
		else str += (str[prev] == 'S' ? 'W' : 'S');
	}//cout << str << endl;
	if (str[n] == str[0] && str[n+1]==str[1]){
		cout << str.substr(0, n) << endl;
		exit(0);
	}
}


int main() {
	cin >> n;
	cin >> s;
	fun("SS");
	fun("SW");
	fun("WS");
	fun("WW");
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <random>

using namespace std;


int main(){
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;

    int total = A * X + B * Y;
    int price = 0;

    if(X > Y){
        price = C*2*Y + A*(X-Y);
        if(total > price)
            total = price;
        price = C*2*X;
        if(total > price)
            total = price;
    }else{
        price = C*2*X + B*(Y-X);
        if(total > price)
            total = price;
        price = C*2*Y;
        if(total > price)
            total = price;
    }


    cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define INF 100000000
#define mod 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

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


int main() {
    ll n, a, i;
    cin >> n >> a;
    ll x[n], X=a;
    for(i=1; i<=n; i++) {
        cin >> x[i];
        X = max(X, x[i]);
    }
    
    ll d[n+1][n+1][n*X+1];
    ll j, k, s;
    
    for(j=0; j<=n; j++) {
        for(k=0; k<=n; k++) {
            for(s=0; s<=n*X; s++) {
                if(j==0 && k==0 && s==0)
                    d[j][k][s]=1;
                else if(s<x[j] && j>=1)
                    d[j][k][s]=d[j-1][k][s];
                else if(s>=x[j] && j>=1 && k>=1)
                    d[j][k][s]=d[j-1][k][s]+d[j-1][k-1][s-x[j]];
                else
                    d[j][k][s]=0;
            }
        }
    }
    
    ll ans=0;
    for(i=1; i<=n; i++)
        ans += d[n][i][i*a];
    cout << ans << endl;
}


Measured memory_bytes: 51072
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int a,b,x;
    cin>>a>>b>>x;
    if(a>x){
        cout<<"NO"<<endl;
        return 0;
    }
    if(b>=x-a)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#include<string.h>

int main(){
    int N;
    scanf("%d",&N);
    if(N==1) printf("Hello World");
    else{
        int A,B;
        scanf("%d",&A);
        scanf("%d",&B);
        printf("%d",A+B);
    }
    return 0;
}

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

using namespace std;

int main()
{
    int x;
    cin>>x;
    int n=1;
    while(x!=0)
    {
        cout<<"Case"<<" "<<n<<":"<<" "<<x<<endl;
        n++;
        cin>>x;
    }
            
        return 0;
}


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

int main() {
	int n;
	cin>>n;
	if(n%1000==0)
	{
		cout<<0<<"\n";
	}
	else
	{
		cout<<(1000*(n/1000 + 1) - n)<<"\n";
	}
	return 0;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  map<P, int> mp;
  for(int i = 0; i < 6; i++) {
    int a, b;
    cin >> a >> b;
    if(a > b) mp[P(b, a)]++;
    else mp[P(a, b)]++;
  }
  if(mp.size() > 3) {
    cout << "no" << endl;
    return 0;
  }
  if(mp.size() == 1) {
    map<P, int>::iterator it = mp.begin();
    if(it->first.first == it->first.second) cout << "yes" << endl;
    else cout << "no" << endl;
    return 0;
  }
  vector<P> v;
  for(map<P, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    if(it->second == 2 || it->second == 4) {
      v.pb(P(it->first.first, it->first.second));
    }else {
      cout << "no" << endl;
      return 0;
    }
  }

  if(v.size() == 2) {
    if(v[0].first == v[0].second) {
      if(v[0].first == v[1].first || v[0].first == v[1].second) cout << "yes" << endl;
      else cout << "no" << endl;
      return 0;
    }else if(v[1].first == v[1].second) {
      if(v[1].first == v[0].first || v[1].first == v[0].second) cout << "yes" << endl;
      else cout << "no" << endl;
      return 0;
    }else {
      cout << "no" << endl;
    }
  }else if(v.size() == 3) {
    if(v[0].first == v[1].first) {
      if(v[0].second == v[2].first) {
        if(v[1].second == v[2].second) cout << "yes" << endl;
        else cout << "no" << endl;
      }else if(v[0].second == v[2].second) {
        if(v[1].second == v[2].first) cout << "yes" << endl;
        else cout << "no" << endl;
      }else {
        cout << "no" << endl;
      }
    }else if(v[0].first == v[1].second) {
      if(v[0].second == v[2].first) {
        if(v[1].first == v[2].second) cout << "yes" << endl;
        else cout << "no" << endl;

      }else if(v[0].second == v[2].second) {
        if(v[1].first == v[2].first) cout << "yes" << endl;
        else cout << "no" << endl;

      }else {
        cout << "no" << endl;
      }
    }else if(v[0].first == v[2].first) {
      if(v[0].second == v[1].first) {
        if(v[2].second == v[1].second) cout << "yes" << endl;
        else cout << "no" << endl;

      }else if(v[0].second == v[1].second) {
        if(v[2].second == v[1].first) cout << "yes" << endl;
        else cout << "no" << endl;

      }else {
        cout << "no" << endl;
      }
    }else if(v[0].first == v[2].second) {
      if(v[0].second == v[1].first) {
        if(v[2].first == v[1].second) cout << "yes" << endl;
        else cout << "no" << endl;

      }else if(v[0].second == v[1].second) {
        if(v[2].first == v[1].first) cout << "yes" << endl;
        else cout << "no" << endl;

      }else {
        cout << "no" << endl;
      }
    }else {
      cout << "no" << endl;
    }
  }
}

Measured memory_bytes: 3204
// AOJ 1246: Concert Hall Scheduling
// 2017.11.8 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) ((a)>=(b)?(a):(b))
typedef struct { int i, j, w; } T;
T tbl[1002];
int dp[366][366];

int cmp(T *a, T *b) { return a->i - b->i; }

int main()
{
	int n, i, j, k, ans;
	int min, max;

	while (scanf("%d", &n) && n > 0) {
		min = 365, max = 0;
		for (i = 0; i < n; i++) {
			scanf("%d%d%d", &j, &k, &tbl[i].w);
			if (j < min) min = j;
			if (k > max) max = k;
			tbl[i].i = j, tbl[i].j = k;
		}
		qsort(tbl, n, sizeof(T), cmp);
		memset(dp, -1, sizeof(dp));
		dp[0][min] = 0;
		for (i = 0; i < n; i++) for (k = max; k >= 0; k--) {
	        for (j = tbl[i].i - 1; j >= 0; j--) {
				if (dp[k][j] >= 0) dp[k][tbl[i].j] = MAX(dp[k][tbl[i].j], dp[k][j]+tbl[i].w);
			    if (dp[j][k] >= 0) dp[tbl[i].j][k] = MAX(dp[tbl[i].j][k], dp[j][k]+tbl[i].w);
			}
		}
    
		ans = 0;
		for (i = min; i <= max; i++) for(j = min; j <= max; j++)
			if (dp[i][j] > ans) ans = dp[i][j];
		printf("%d\n", ans);
	}
	return 0;
}

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

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

    int ans = n % k != 0;

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


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

int main() {
  int A[200];
  int N, M, X;
  cin >> N >> M >> X;
  int left=0, right=0;
  int test;
	for (int i = 0; i < M; ++i) scanf("%d", A + i);

  for (int i = 0; i < M; i++) {
    if (A[i] < X) left++;
    else right++;
  }
  cout << min(left, right) << endl;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>

using namespace std;
int c = 0;

// void bubblesort(vector<int>& a, int n) {
// 	int flag = 1;
// 	while(flag) {
// 		flag = 0;
// 		for (int i = n - 1; i >= 1; i--)
// 		{
// 			if(a[i-1] > a[i]) {
// 				swap(a[i-1], a[i]);
// 				c++;
// 				flag = 1;
// 			}
// 		}
// 	}
// }

void bubblesort(vector<int>& a, int n) {
	for (int j = 0; j < n; j++)
	{
		for (int i = n-1; i > j; i--)
		{
			if(a[i-1] > a[i]) {
				swap(a[i-1], a[i]);
				c++;
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	bubblesort(a, n);
	for (size_t i = 0; i < n; i++)
	{
		if(i == 0) {
			cout << a[i];
			continue;
		}
		cout << " " << a[i];
	}
	cout << endl;
	cout << c << endl;
}



Measured memory_bytes: 3096
#include <iostream>

 

using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r >= 0 && y-r >= 0  && x+r <= w && y+r <= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vii;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 

 

int MP=999983;

vi is_prime(MP+1,1);
vi sum_prime(MP+1,0);


void set_prime(){
	is_prime[0]=is_prime[1]=0;
	for(int i=2; i<=MP; i++){
		if(is_prime[i]){
			for(int j=i*2; j<MP; j+=i){
				is_prime[j]=0;
			}
		}
		sum_prime[i]=sum_prime[i-1]+is_prime[i];
	}
}

int main(){
	set_prime();
	int n,p,m;
	int x;
	while(cin>>n && n>0){
		int ans=0;

		rep(i,n){
			cin>>p>>m;
			x=(p+m>MP?sum_prime[MP]:sum_prime[p+m])-(p-m-1>0?sum_prime[p-m-1]:0);
			if(x==0) ans--;
			else{
				ans+=x-1;
			}
		}
		cout<<ans<<endl;
	}
}

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

int main()
{
    string s;
    cin >> s;
    bool app[26] = {0};
    for (char c : s)
        app[c - 'a'] = true;
    bool answered = false;
    for (int i = 0; i < 26; i++)
    {
        if (app[i] == false)
        {
            cout << (char)(i + 'a');
            answered = true;
            break;
        }
    }

    if (!answered)
        cout << "None";

    return 0;
}


Measured memory_bytes: 512
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:usize,
    }
    println!("{}",if b%a==0 {a+b}else{b-a})
}

Measured memory_bytes: 2148