akhauriyash/Code-Regression huggingface dataset:
n=int(input(''))
l=[]
k=[]
for a in range(n):
    i,j=map(int,input('').split(' '))
    l.append(i)
    k.append(j)

ok=0
for a in range(n-2):
    if l[a]==k[a] and l[a+1]==k[a+1] and l[a+2]==k[a+2]:
        ok=1
        break

if ok==1:
    print('Yes')
else:
    print('No')

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

bool is_yeap(int y){
    return y%400==0||(y%4==0&&y%100);
}
int main(){
    int a,b;
    bool flag=false;

    while(scanf("%d%d",&a,&b),a||b){
        if(flag)puts("");
        else flag=true;
        bool latte=false;
        for(int i=a;i<=b;i++){
            if(is_yeap(i)){
                printf("%d\n",i);
                latte=true;
            }
        }

        if(!latte)puts("NA");
    }

    return 0;
}

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

int gcd(int a,int b){
	while(a != b){
		if(a > b) a -= b;
		else b -= a;
	}
	return a;
}
int lcm (int a,int b){
	return ((a / gcd(a,b)) * b);
}
int main(){
	int x,y;
	while(cin >> x >> y){
		cout << gcd(x,y) << " " << lcm(x,y) << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
using namespace std;

int main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i != n; ++i) {
        cin >> a[i];
        --a[i];
        a[i] %= k;
    }
    vector<int> p(n);
    int sum = 0;
    long long ans = 0;
    for (int i = 0; i != n; ++i) {
        sum = (sum + a[i]) % k;
        p[i] = sum;
        if (sum == 0 && i + 1 < k)
            ++ans;
    }
    map<int, int> cur;
    for (int i = 0; i != n; ++i) {
        if (i - k >= 0) {
            auto it = cur.find(p[i - k]);
            --it->second;
            if (it->second == 0)
                cur.erase(it);
        }
        auto it2 = cur.find(p[i]);
        if (it2 != cur.end())
            ans += it2->second;
        ++cur[p[i]];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int values[n];
  int coins[n];
  for(int i = 0; i < n; i++) cin >> values[i];
  for(int i = 0; i < n; i++) cin >> coins[i];
  int res =0;
  for(int i = 0; i < n; i++)
    if(values[i] > coins[i]) res += values[i] - coins[i];
  cout << res;
}

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

ans = 0

for i in range(N):
  if A[i] <= B[i]:
    ans += min(A[i]+A[i+1],B[i])
    A[i+1] = max(0,A[i+1] - (B[i] -A[i]))
    A[i] = 0
  else:
    ans += B[i]
    A[i] -= B[i]
  
print(ans)

Measured memory_bytes: 82148
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			map = new char[h][w];
			v = new boolean[h][w];
			for (int i = 0; i < h; i++) {
				map[i] = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (map[i][j] != '.') {
						v[i][j] = true;
					}
				}
			}
			ans = new int[4];
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++) {
					
					if (v[i][j])
						continue;
					u = 0;
					int ret  = dfs(i, j);
					ans[u] += ret;
				}
			System.out.println(ans[1] + " " + ans[2]);
		}
	}

	private int dfs(int y, int x) {
		int ret = 0;
		if (v[y][x])
			return ret;
		v[y][x] = true;
		ret++;
		for (int[] m : move) {
			int ny = y + m[0];
			int nx = x + m[1];
			if (!isOK(ny, nx))
				continue;
			if (map[ny][nx] == 'B') {
				u |= 1;
				continue;
			} else if (map[ny][nx] == 'W') {
				u |= 2;
				continue;
			}
			ret += dfs(ny, nx);
		}
		return ret;
	}

	private boolean isOK(int y, int x) {
		return 0 <= y && y < h && 0 <= x && x < w;
	}

	int w, h, u, ans[];
	boolean[][] v;
	char[][] map;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
}

Measured memory_bytes: 25648
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int mod=1e9+7;
#define N 505
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m,cnt[N],ans,fac[N],inv[N];
int dp[2][N][N]; // 区间长度到i，区间个数j，区间长度和 k。 
inline int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=1LL*fac[i-1]*i%mod;
	}
	inv[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i){
		inv[i]=1LL*inv[i+1]*(i+1)%mod;
	}
}
inline int C(int n,int m){
	return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;++i){
		++cnt[read()];
	}
	init(m);
	dp[(m+1)&1][0][0]=1;
	for(int i=m;i>=1;--i){
		memset(dp[i&1],0,sizeof(dp[i&1]));
		for(int j=0;j<=m/i;++j){
			for(int k=0;k<=m;++k){
				if(!dp[(i+1)&1][j][k])continue;
				int lim=min((m-k)/i,m-j);
				for(int p=0;p<=lim;++p){
					dp[i&1][j+p][k+p*i]=(dp[i&1][j+p][k+p*i]+1LL*dp[(i+1)&1][j][k]*inv[p])%mod;
				}
			}
		}
		for(int j=0;j<=m;++j){
			for(int k=j*(i-1);k<=m;++k){
				dp[i&1][j][k]=1LL*dp[i&1][j][k]*qpow(k-j*(i-1),cnt[i])%mod;
			}
		}
	}
	for(int j=0;j<=m;++j){
		for(int k=0;k<=m;++k){
			ans=(ans+1LL*fac[j]*dp[1][j][k]%mod*C(m-k+1,j)*((m-k)&1?-1:1))%mod;
		}
	}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}



Measured memory_bytes: 5756
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = 0
k = int(input())
for i in range(k):
    for j in range(i,k):
        for l in range(j,k):
            if i!=j and j!=l and l!=i:
                ans += gcd(i+1,j+1,l+1)*6
            elif i == j and j ==l and l ==i:
                ans += gcd(i+1,j+1,l+1)
            else:
                ans += gcd(i+1,j+1,l+1)*3
print(ans)


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

int main() {
    int n;

    cin >> n;

    long fizzbuzz = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        fizzbuzz += i;
    }
    cout << fizzbuzz << endl;

    return 0;
}

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

int main(int argc, char *argv[]){
  string S,T;
  cin>>S>>T;
  int count=0;
  int flag=-1;
  for(int i=S.size()-T.size(); i>=0; i--){
    for(int j=i,k=0; k<T.size(); j++,k++){
      if(S[j]==T[k] || S[j]=='?') count++;
      else{
	count=0;
	break;
      }
    }
   
    if(count==T.size()){
      flag=1;
      for(int l=0; l<T.size(); l++){
    
	S[i]=T[l];
	i++;
      }
      break;
    }
  }
  if(flag==-1){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
  char ch='a';
  for(int i=0; i<S.size(); i++){
    if(S[i]=='?'){
      S[i]=ch;
      
    }
    cout<<S[i];
  }
}
  
      
     


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

int main(){
  int n=1;
  while (true){
    int x;
    cin >> x;
    if (x == 0){
      break;
    }
    else {
      cout << "Case "<< n <<": " << x << endl;
    }
    n++;
  }
}



Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
int n,viz[10],x[10],y[10],v[10];
double ans;
void back(int k)
{
    if(k==n+1)
    {
        for(int i=1;i<n;++i)
            ans+=sqrt((x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]])+(y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]));
        return ;
    }
    for(int i=1;i<=n;++i)
    if(!viz[i])
    {
        viz[i]=1;
        v[k]=i;
        back(k+1);
        viz[i]=0;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;++i) cin>>x[i]>>y[i];
    back(1);
    for(int i=2;i<=n;++i) ans/=i;
    cout<<fixed<<setprecision(7)<<ans;
    return 0;
}


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

#include <boost/algorithm/string/classification.hpp>  // is_any_of
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/math/tools/minima.hpp>
#include <boost/multi_array.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>

const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); ++i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::algorithm::split;
using boost::math::tools::brent_find_minima;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;
// TOP
void Main()
{
	bitset<10000000> bs;
	int a, b, c;
	cin >> a >> b >> c;
	int n;
	n = a;
	while (1)
	{
		int x;
		x = n % b;
		if (x == c)
		{
			cout << "YES" << endl;
			return;
		}
		if (bs.test(x))
			break;
		else
			bs.set(x);
		n += a;
	}
	cout << "NO" << endl;
}
// END

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 1536
//Not 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int a;cin>>a;
    cout<<(a^1)<<nnn;
    return 0;
}

Measured memory_bytes: 3668
fun main(args: Array<String>) {
    abc104a()
}

fun abc104a() {
    val answer = when (readLine()!!.toInt()) {
        in 0 until 1200 -> "ABC"
        in 1200 until 2800 -> "ARC"
        else -> "AGC"
    }

    println(answer)
}


Measured memory_bytes: 33636
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
#define pb push_back
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
 
 
void solve()
{
	int n, d, x, y, ans=0;
	// vector<int> a;
	cin>>n>>d;
	F0R(i, n) {
		cin>>x>>y;
		double dist = (pow(pow(x,2)+pow(y,2),0.5));
		if(dist<=(double)(d))	ans++;
	}
	cout<<ans<<endl;
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int main() 
{
	string W;
	cin >> W;
	map<char, int> cnt;
	rep(i, 0, W.size())
	{
		++cnt[W[i]];
	}
	for (auto it = cnt.begin(); it != cnt.end(); it++)
	{
		if (it->second % 2)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
	
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, a, output int
	fmt.Scanf("%d", &n)
	var tmp []int    // 入力
	var num [110]int // 各成分に対応する値の個数
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		tmp = append(tmp, a)
	}

	for i := 0; i < n; i++ {
		num[tmp[i]]++
	}
	for i := 0; i <= 100; i++ {
		if num[i] > 0 {
			output++
		}
	}
	fmt.Println(output)
}


Measured memory_bytes: 512
N= int(input())
res = {}
res['AC'] = 0
res['WA'] = 0
res['TLE'] = 0
res['RE'] = 0
for i in range(N):
    S = input()
    res[S] += 1
print('AC x ' + str(res['AC']))
print('WA x ' + str(res['WA']))
print('TLE x ' + str(res['TLE']))
print('RE x ' + str(res['RE']))

Measured memory_bytes: 9208
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();

        //1万円
        for (int i = 0; i <= n; i++) {
            //5000円
            for (int j = 0; j + i <= n; j++) {
                int k = n - i - j;
                int sum = (1000 * k) + (5000 * j) + (10000 * i);
                if (sum == y) {
                    System.out.println(i + " " + j + " " + k);
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");

    }
}


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

int main() {
   string s;
   cin >> s;
   char a,b;
   ll c,d = 0;
   a = s.at(0);
   c = s.length() - 2;
   d = s.length() - 1;
   b = s.at(d);
   cout << a << c << b <<endl;
}

Measured memory_bytes: 3552
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
const ll infty = 1000000007;

int main () {
  int N;
  cin >> N;
  ll a[110];
  for (auto i = 0; i < N; ++i) {
    cin >> a[i];
  }
  ll ans = infty;
  for (auto i = -100; i < 101; ++i) {
    ll t = 0;
    for (auto j = 0; j < N; ++j) {
      ll sa = (a[j] - i);
      t += sa * sa;
    }
    ans = min(t, ans);
  }
  cout << ans << endl;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}



int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll ans = max(max(A * C, A * D), max(B *C, B * D));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  int n,m,memo;
  cin >> n >> m;
  priority_queue<int> pq;
  
  rep(i,0,n) {
    cin >> memo;
    pq.push(memo);
  }
  rep(i,0,m){
    memo = pq.top();
    pq.pop();
    memo /= 2;
    pq.push(memo);
  }
  int ans = 0;
  while (!pq.empty()) {
      //cout << pq.top() << ' ';
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String s = sc.nextLine();

		int n = Integer.parseInt(s.substring(0, 1));
		for (int i=0; i<s.length()-2; i++) {
			if (Math.abs(Integer.parseInt(s.substring(i, i+3))-753)<Math.abs(n-753)) {
				n = Integer.parseInt(s.substring(i, i+3));
			}
		}

		System.out.println(Math.abs(n-753));
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define oo 0x7ffffff
using namespace std;
char buf[110][100];
int judge(int k)
{
	for(int i=1;i<k;++i)
		{
			int f=strcmp(buf[i],buf[k]);
			if(f==0)
				return 0;
		}
	return 1;
}
int main()
{
	int n;
	cin>>n;
	int cnt=0;
	char ls;
	int flag=0; 
	while(n--)
		{
			cnt++;
			scanf("%s",buf[cnt]);
			if(flag)
				continue; 
			if(!judge(cnt))
				{
					flag=1; 	
				}
			if(cnt!=1&&buf[cnt][0]!=ls)
				{
					flag=1; 
				}
			int len=strlen(buf[cnt]);
			ls=buf[cnt][len-1];
		}
	if(flag==0)
		cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, p = LI()
    print((a*3+p)//2)
    return

#B
def B():
    n = II()
    sp = []
    for i in range(n):
        sp.append(input().split())
    another = [(s[0], -1 * int(s[1]),num) for num,s in enumerate(sp)]
    another.sort()
    for s,p,q in another:
        print(q+1)

    return

#C
def C():
    n, m = LI()
    ks = LIR_(m)
    p = LI()
    patern = itertools.product(range(2), repeat=n)
    ans = 0
    for on in patern:
        ki = [0 for i in range(m)]
        for num, oni in enumerate(on):
            if oni:
                for i,ksi in enumerate(ks):
                    ksi = ksi[1::]
                    if num in ksi:
                        ki[i] ^= 1
        #print(ki)
        for num, pi in enumerate(p):
            if pi != ki[num]:
                break
        else:
            ans += 1
    print(ans)

            
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 44016
<?php
$input_lines = trim(fgets(STDIN));
$input_data  = trim(fgets(STDIN));
$array = explode(" ", $input_data);
sort($array);
$min_diff_all = 100000000;
$min_diff_ab  = 100000000;
$min_diff_key = null;
foreach($array as $key => $value){
    if($key > 0 ){
        $diff = $array[$key] - $array[$key - 1];
        if($diff < $min_diff_all){
            $min_diff_all = $diff;
            $min_diff_key = $key;
        }
        if($key < $input_lines - 1){
            if($diff < $min_diff_ab){
              $min_diff_ab = $diff;
            }
        }
    }
    
    
}

$sum_ab = $array[$input_lines - 1] + $array[$input_lines - 2];
array_splice($array,$min_diff_key,1);
array_splice($array,$min_diff_key - 1,1);

$sum_ab_2 = $array[count($array) - 1] + $array[count($array) - 2];

$result_1 = $sum_ab / $min_diff_ab;
$result_2 = $sum_ab_2 / $min_diff_all;
if($result_1 > $result_2){
    echo $result_1;
}else{
    echo $result_2;
}
?>

Measured memory_bytes: 15444
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/

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

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

int main() {
  ll N,M;
  cin>>N>>M;
  string S,T;
  cin>>S>>T;
  ll g=GCD(N,M);
  rep(i,g){
    if(S[(N/g)*i]!=T[(M/g)*i]){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<LCM(N,M)<<endl;


return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){	
	string s;
  	cin>>s;
  	if(s.at(0) == 'A'){
    	cout<<"T"<<"\n";
    }
       else if(s.at(0) == 'T')
    	{
    	cout<<"A"<<"\n";
    }
    else if(s.at(0) == 'G'){
    	cout<<"C"<<"\n";
    }
       else if(s.at(0) == 'C')
    	{
    	cout<<"G"<<"\n";
    }


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2 + 2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1], R[n2];

  for ( int i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( int i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for ( int k = left; k < right; k++ ) {
    cnt++;
    if ( L[i] <= R[j] ) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if ( left+1 < right ) {
    int mid = (left + right) / 2.0;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for ( int i = 0; i < n; i++) cin >> A[i];

  mergeSort(A, n, 0, n);
  
  for ( int i = 0; i < n; i++) {
    if ( i ) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MAX 1000010
#define MOD 1000000007
  
using ll = long long;
using Graph = vector<vector<pair<ll,ll>>>;

int main(){
  int N; cin>>N;
  vector<ll> A(N);
  rep(i,N)cin>>A.at(i);
  sort(begin(A),end(A));
  ll n = A.at(N-1),k;
  auto iter = lower_bound(begin(A),end(A),n/2);
  int index = distance(begin(A),iter);
  if(index>0){
    if((A.at(index)!=n/2&&A.at(index)!=n/2+(N%2))&&n/2-A.at(index-1)<=A.at(index)-n/2)index--;
  }  
  if(index==N-1)index--;
  k = A.at(index);
  cout<<n<<" "<<k<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 2147483647;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
const ll LLMAX = 9223372036854775805;

int main(){
    vector<int> x(5);
    for(int i=0;i<5;i++){
        cin >> x[i];
    }
    for(int i=0;i<5;i++){
        if(x[i]==0){
            cout << i+1 << endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;

const int NIL = -1;
const int MAX = 2000001;
int c[1001][1001];

int main(void)
{
	int q, m, n;
	string a, b;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> a >> b;
		m = a.length();
		n = b.length();
		for (int i = 1; i <= m; i++)
			c[i][0] = 0;
		for (int j = 1; j <= n; j++)
			c[0][j] = 0;
		for (int i = 1; i <= m; i++) {
			for (int j = 1; j <= n; j++) {
				if (a[i - 1] == b[j - 1])
					c[i][j] = c[i - 1][j - 1] + 1;
				else if (c[i - 1][j] >= c[i][j - 1])
					c[i][j] = c[i - 1][j];
				else
					c[i][j] = c[i][j - 1];
			}
		}
		cout << c[m][n] << endl;
	}
	return 0;
}


Measured memory_bytes: 7128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,k;cin>>a>>b>>k;
    if(k<=a)cout<<a-k<<" "<<b;
    else if(k<=a+b)cout<<0<<" "<<a+b-k;
    else cout<<"0 0";
    
    return 0;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2020/02/22
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}
int sc[6][2] = {0};

int main()
{
	int N = 0, M = 0, i = 0;
	char ans[4] = {0};
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d", &sc[i][0], &sc[i][1]);
	}
	for (i = 0; i < 4; i++) {
		ans[i] = -1;
	}
	for (i = 0; i < M; i++) {
		if (ans[sc[i][0]] == -1) {
			ans[sc[i][0]] = (char)sc[i][1];
		} else if (ans[sc[i][0]] != (char)sc[i][1]) {
			printf("-1\n");
			return 0;
		} else {
		}
	}

	if (N == 1) {
		if (ans[1] == -1) {
			ans[1] = 0;
		}
		printf("%1d\n", ans[1]);
		return 0;
	}
	if (N == 2) {
		if (ans[1] == 0) {
			printf("-1\n");
			return 0;
		} else {
			if (ans[2] == -1) {
				ans[2] = 0;
			}
			if (ans[1] == -1) {
				ans[1] = 1;
			}
			printf("%1d%1d\n", ans[1], ans[2]);
			return 0;
		}
	}

	// N == 3
	if (ans[1] == 0) {
		printf("-1\n");
		return 0;
	}
	if (ans[3] == -1) {
		ans[3] = 0;
	}
	if (ans[2] == -1) {
		ans[2] = 0;
	}
	if (ans[1] == -1) {
		ans[1] = 1;
	}
	printf("%1d%1d%1d\n", ans[1], ans[2], ans[3]);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int aHealth = sc.nextInt();
        int aAttack = sc.nextInt();
        int bHealth = sc.nextInt();
        int bAttack = sc.nextInt();
        int aWin = (int) Math.ceil((double) bHealth/aAttack);
        int bWin = (int) Math.ceil((double) aHealth/bAttack);
        System.out.println(aWin <= bWin ? "Yes" : "No");
    }
}


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

#define ll long long
#define ull unsigned long long

const ull MOD = 1000000007;

using namespace std;

int main() {
	ll N, K;
	cin >> N >> K;

	ll sum = 0;
	for (ll ii = K; ii <= N+1; ++ii){
		ll low = (ii * (ii - 1) / 2) % MOD;
		ll up = (ii * (2 * N - ii + 1) / 2) % MOD;
		sum = (sum + up - (low - 1) + MOD) % MOD;
	}

	cout << sum << endl;


	return 0;
}


Measured memory_bytes: 3636
import re
L = input()
k1 = L.count("k")
e3 = L.count("e")
y1 = L.count("y")
n1 = L.count("n")
c1 = L.count("c")
if k1 >= 1 and e3 >= 3 and y1 >= 1 and n1 >= 1 and c1 >= 1:
    if re.match("^k.*eyence$", L) or re.match("^ke.*yence$", L) or re.match("^key.*ence$", L) or re.match("^keye.*nce$", L) or re.match("^keyen.*ce$", L) or re.match("^keyenc.*e$", L) or re.match("^.*keyence$", L) or re.match("^keyence.*$", L):
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 3188
def sum(i):
  t=0
  while True:
    if i==0:
      return t
    else:
      t+=i%10
      i//=10

N,A,B=[int(i) for i in input().split()]
s=0
for i in range(1,N+1):
  if sum(i)<=B and sum(i)>=A:
    s+=i
print(s)

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

string s, t;

int main()
{
	cin >> s >> t;
	bool ok = s == t;
	for (int i = 1; i < s.length() && !ok; i++)
		ok = s.substr(i) + s.substr(0, i) == t;
	printf("%s\n", ok? "Yes": "No");
	return 0;
}

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

public class Main {

  void solve(InputReader in, PrintWriter out) {
    char[] o = "hi".toCharArray();
    char[] arr = in.next().toCharArray();

    int i = 0;
    int j = 0;

    for (char c : arr) {
      if (c != o[i++]) {
        out.println("No");
        return ;
      }
      i %= o.length;
    }

    if (i != 0) {
      out.println("No");
    } else {
      out.println("Yes");
    }
    
  }

  public static void main(String[] args) throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Main solver = new Main();
    solver.solve(in, out);
    out.close();
  }

  static class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream is) {
      in = new BufferedReader(new InputStreamReader(is));
    }

    public String next() {
      try {
        while (st == null || !st.hasMoreTokens()) {
          st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
  }
}


Measured memory_bytes: 21204
h, w = gets.split.map(&:to_i)
map = Array.new(h)
h.times do |i|
  map[i] = gets.chomp.chars
end

nmap = []

map.each do |line|
  nmap << line if line.include?('#')
end

map = []
nmap = nmap.transpose.map(&:reverse)
nmap.each do |line|
  map << line if line.include?('#')
end

map = map.transpose.reverse

map.each do |line|
  puts line.join
end

Measured memory_bytes: 2428
import collections
N=int(input())
s=[input() for i in range(N)]
#S=sorted(s)
a=1
num=[]
st=[]
c = collections.Counter(s)#要素数が大きい順に辞書型ですべての要素を返す
#print(c)
max_c = max(c.values())#最も多い要素の数
#print(max_c)
st=[]
for k,v in c.items():
    if v==max_c:
        st.append(k)
st2=sorted(st)
[print(i) for i in st2]

Measured memory_bytes: 35952
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=1e5+5;
ll a[M],b[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,m,k;
	cin>>n>>m>>k;
	for(ll i=1;i<=n;i++)
		cin>>a[i];
	for(ll j=1;j<=m;j++)
		cin>>b[j];
	ll m1=a[1],m2=b[1];
	for(ll i=1;i<=n;i++)
		m1=min(m1,a[i]);
	for(ll i=1;i<=m;i++)
		m2=min(m2,b[i]);
	ll ans=m1+m2;
	for(ll i=1;i<=k;i++)
	{
		ll x,y,c;
		cin>>x>>y>>c;
		ans=min(ans,a[x]+b[y]-c);
	}
	cout<<ans<<"\n";
	return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    char a, b;
    scanf("%c %c",&a, &b);
    if(a=='H'){
        if(b=='H'){
            printf("H\n");
            return 0;
        }
        else{
            printf("D\n");
            return 0;
        }
    }
    else{
        if(b=='H'){
            printf("D\n");
            return 0;
        }
        else{
            printf("H\n");
            return 0;
        }
    }
    return 0;
}


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

int main(void) {
	int H1, W1;
	int H2 = 0, W2 = 0;
	int H3 = 0, W3 = 0;
	string a1[100];
	string a2[100];
	char a3[100][100];

	scanf("%d %d", &H1, &W1);
	W2 = W1;
	for (int i = 0; i < H1; i++) {
		cin >> a1[i];
	}

	// 横を消す
	for (int i = 0; i < H1; i++) {
		bool sFlag = false;
		for (int j = 0; j < W1; j++) {
			if (a1[i][j] == '#') {
				sFlag = true;
				break;
			}
		}
		if (sFlag == true) {
			a2[H2] = a1[i];
			H2++;
		}
	}

	// 縦を消す
	H3 = H2;
	for (int j = 0; j < W2; j++) {
		bool sFlag = false;
		for (int i = 0; i < H2; i++) {
			if (a2[i][j] == '#') {
				sFlag = true;
				break;
			}
		}
		if (sFlag == true) {
			for (int i = 0; i < H2; i++) {
				a3[i][W3] = a2[i][j];
			}
			W3++;
		}
	}

	for (int i = 0; i < H3; i++) {
		for (int j = 0; j < W3; j++) {
			cout << a3[i][j];
		}
		cout << endl;
	}

	return 0;
}


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

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

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

    ll x;
    cin >> x;

    for(int i = 1; i < n; i++){
        ll a;
        cin >> a;
        x = gcd(x, a);
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int A[100], N, sw, i;

  scanf("%d",&N);
  
  for( i = 1 ; i < N + 1 ; i++ )
    {
      scanf("%d",&A[i]);
    }

  sw = bubbleSort(A, N);
  
  printf("%d\n",sw);
 
  return 0;
}

int bubbleSort(int A[],int N)
{
  int sw = 0, i, j, temp;

  for( i = 1 ; i < N + 1 ; i++ )
    {
      for( j = N ; j > i ; j-- )
	{
	  if(A[j] < A[j - 1])
	    {
	      sw++;
	      temp = A[j];
	      A[j] = A[j - 1];
	      A[j - 1] = temp;
	    }
	}
      if(i > 1)
	{
	  printf(" ");
	}
      printf("%d",A[i]);
    }
  printf("\n");
  
  return sw;
}


Measured memory_bytes: 2100
package main

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

func solution(T string) string {
        out := make([]byte, len(T))
        for i := 0; i < len(T); i++ {
                if T[i] == '?' {
                        out[i] = 'D'
                } else {
                        out[i] = T[i]
                }
        }
        return string(out)
}

func main() {
        var fp *os.File = os.Stdin
        reader := bufio.NewReaderSize(fp, 1024)
        T := readLine(reader)
        fmt.Println(solution(T))
}

func readLine(reader *bufio.Reader) string {
        buf := make([]byte, 0, 1024)

        for {
                l, p, _ := reader.ReadLine()
                buf = append(buf, l...)

                if !p {
                        break
                }
        }
        return string(buf)
}

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

int main() {


  vector<int> rhythm(3);
  for(int i = 0; i < 3; i++){
  cin >> rhythm.at(i);
  }
  int fivec = 0;
  int sevenc = 0;
  for(int i = 0; i < 3; i++){
    if(rhythm.at(i) == 5){
      fivec++;
    }
    if(rhythm.at(i) == 7){
      sevenc++;
    }
  }
  if(fivec == 2 && sevenc == 1){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    ((ll)1ll<60)
#define INF     ((int)1<<30)
#define EPS     (1e-9)
#define MOD     (1000000007)
template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool b=1;for(auto s:t)os<<(exchange(b,0)||strlen(abi::__cxa_demangle(typeid(S).name(),0,0,0))>20?"":" ")<<s;return os<<endl;}

#define msk(a) ((int)1<<(a))

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	while(cin>>n,n){
	    vi above(n,0);
	    vi dp(1<<n,0); //dp[取った円盤の集合]=何枚取り除いたか
	    vvi circ(n,vi(4));
	    rep(i,n){
	        cin>>circ[i][0]>>circ[i][1]>>circ[i][2]>>circ[i][3];
	        rep(j,i){
	            if(hypot(circ[i][0]-circ[j][0],circ[i][1]-circ[j][1])+EPS<circ[i][2]+circ[j][2]){
	                above[i]|=(1<<j);
	            }
	        }
	    }
	    int ans=0;
	    rep(s,1<<n){
	        if(s!=0 and dp[s]==0) continue;
	        rep(i,n) if((~s)&msk(i)) range(j,i+1,n) if((~s)&msk(j)){
	            if(circ[i][3]==circ[j][3]){
    	            if(!(above[i] & ~s) and !(above[j] & ~s)){
            	        //cout<<pii(i,j)<<endl;
    	                int ns=s|msk(i)|msk(j);
	                    dp[ns]=dp[s]+2;
    	                ans=max(ans,dp[ns]);
    	            }
	            }
	        }
	    }
	    cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 68636
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n, w;

int main(void){
	cin >> n >> w;
	vector<vector<lli>> dp(n+5, vector<lli>(w+5));
	rep(i, n){
		lli u, v;
		cin >> u >> v;
		rep(j, w+1){
			chmax(dp[i+1][j], dp[i][j]);
			if(j+u <= w) chmax(dp[i+1][j+u], dp[i][j]+v);
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}


Measured memory_bytes: 86260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll grundy(ll a, ll k)
{
    if(a < k) 
    {
        return 0;
    }
    else if(a % k == 0)
    {
        return a / k;
    }
    else
    {
        ll tmp = a / k + 1;
        ll cand = a % k;
        ll co = max(1LL, (cand+1)/tmp);
        return grundy(a - co*tmp, k);
    }
}
int main()
{
    int n;
    cin >> n;
    ll nim = 0;
    for(int i = 0; i < n; i++)
    {
        ll a, k;
        cin >> a >> k;
        nim ^= grundy(a, k);
    }
    if(nim) cout << "Takahashi" << endl;
    else cout << "Aoki" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <numeric>
#include <bitset>
#include <stack>
using namespace std;

bool isliner(char lhs, char rhs)
{
  if (lhs == '(' && rhs == ')' ||
      lhs == ')' && rhs == '(' ||
      lhs == '{' && rhs == '}' ||
      lhs == '}' && rhs == '{' ||
      lhs == '[' && rhs == ']' ||
      lhs == ']' && rhs == '[')
    return true;
  return false;
}

int main()
{
  string in;
  while (cin >> in) {
    string s = in.substr(0, in.find("iwi", 0));
    string t = in.substr(in.find("iwi", 0)+3);
    reverse(t.begin(), t.end());

    vector<vector<int> > dp(s.size()+1, vector<int>(t.size()+1, 0));
    for (int i = 0; i < s.size(); ++i) {
      for (int j = 0; j < t.size(); ++j) {
	if (isliner(s[i], t[j]))
	  dp[i+1][j+1] = dp[i][j]+1;
	else
	  dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
      }
    }
    cout << 3+dp[s.size()][t.size()]*2 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main() {
    unsigned long long K;
    cin >> K;

    const unsigned long long N = 50;
    cout << N << endl;

    unsigned long long a[N];
    for (unsigned long long i = 0; i < N; i++) {
        a[i] = i + K / N;
    }

    for (unsigned long long i = 0; i < K % N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) {
                a[j] += N;
            } else {
                a[j]--;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        cout << a[i];
        if (i < N - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }

    return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  long long ans = 0;
  long long temp_max = 0;
  for(int i = 0; i < N; i++){
    long long a;
    cin >> a;
    
    if(a > temp_max) temp_max = a;
    
    if(temp_max > a){
      ans += temp_max - a;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int n;
string s, t;

int main() {
  cin >> n;
  cin >> s >> t;
  
  rep(i,n) {
    cout << s[i] << t[i];
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int S, h, m, s;
  
  scanf("%d", &S);
  
  h = S / 3600;
  m = (S % 3600) / 60;
  s = S % 60;
  
  printf("%d:%d:%d\n", h, m, s);
  
  return 0;
}

Measured memory_bytes: 592
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  if([scanElem,scanElem,scanElem].sort().array==[5,5,7])end("YES");end("NO");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

int n;

typedef tuple<int,int,int> T;


bool getBit(int b, int y, int x){
	return b >> (y * n + x) & 1;
}
void setBit(int& b, int y, int x){
	b |= 1 << (y * n + x);
}

int bfs(int bit, int sy, int sx){
	map<T, int> memo;

	queue<T> q;
	q.emplace(bit, sy, sx);

	while(not q.empty()){
		int s, y, x;
		tie(s, y, x) = q.front(); q.pop();

		if(s == 0) return memo[T(s, y, x)];

		rep(vd, 8){
			int vy = y + dy[vd];
			int vx = x + dx[vd];
			if(getBit(s, vy, vx)) continue;
			if(vy < 0 || vy >= n || vx < 0 || vx >= n) continue;

			int nxt = 0;
			rep(i,n){
				rep(j,n){
					if(vy == i and vx == j) continue;

					int cnt = 0;
					rep(d,8){
						int ny = i + dy[d];
						int nx = j + dx[d];
						if(ny < 0 || ny >= n || nx < 0 || nx >= n) continue;
						if(getBit(s, ny, nx)) cnt++;
						if(vy == ny and vx == nx) cnt++;
					}

					if((cnt == 2 or cnt == 3) and getBit(s, i, j) == 1){
						setBit(nxt, i, j);
					}else if(cnt == 3 and getBit(s, i, j) == 0){
						setBit(nxt, i, j);
					}
				}
			}

			auto t = T(nxt, vy, vx);
			if(memo.count(t) and memo[t] > memo[T(s, y, x)] + 1){
				memo[t] = memo[T(s, y, x)] + 1;
				q.emplace(t);
			}else if(not memo.count(t)){
				memo[t] = memo[T(s, y, x)] + 1;
				q.emplace(t);
			}
		}
	}

	return -1;
}

int main(){
	while(cin >> n,n){
		int bit = 0, y, x;
		rep(i,n){
			rep(j,n){
				char a;
				cin >> a;
				if(a == '#'){
					setBit(bit, i, j);
				}
				if(a == '@'){
					y = i;
					x = j;
				}
			}
		}

		cout << bfs(bit, y, x) << endl;
	}
}



Measured memory_bytes: 4796
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
-- end of templete



main = do
    d <- getInts
    when (any (/=0) d) $ do
        let [x,y,_] = sort $ map fromIntegral d :: [Double]
        let r = (/2) $ sqrt $ x^2 + y^2
        n <- getInt
        map (cond "OK" "NA" . (>r) . readDouble) <$> replicateM n getLine >>= mapM_ putStrLn
        main

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

struct Node{
  int key;
  struct Node *next,*prev;
};
struct Node *nil;

struct Node* listSearch(int key){
  struct Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (struct Node *)malloc(sizeof(struct Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  struct Node *cur = nil->next;
  int isf = 0;
  while(1){
    if(cur == nil)break;
    if(isf++ > 0)printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(struct Node *t){
  if(t == nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  struct Node *x = (struct Node *)malloc(sizeof(struct Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key,n,i,size = 0,np = 0,nd = 0;
  char com[20];

  scanf("%d",&n);
  init();
  for(i = 0 ; i < n ; i++){
    scanf("%s %d",com,&key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F')deleteFirst();
	else if(com[6] == 'L')deleteLast();
      }
      else{
	deleteKey(key);
	nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 33060