akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> A(N);
    set<int> st;
    for(int i=0; i<N; i++){
        cin >> A[i];
        st.insert(A[i]);
    }

    if(st.size()%2==1){
        cout << st.size() << endl;
    }else{
        cout << st.size() - 1 << endl;
    }
}

Measured memory_bytes: 5376
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    AS = list(map(int, input().split()))

    res = [0]*(N+1)
    for i in range(1,N+1)[::-1]:
        a = AS[i-1]
        if sum(res[i*2::i]) % 2 != a:
            res[i] = 1

    print(res.count(1))
    if res.count(1) != 0:
        print(*[i for i,r in enumerate(res) if r == 1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 22112
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 第6回 ドワンゴからの挑戦状 予選 A - Falling Asleep

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        String[] s = new String[n];
        int[] t = new int[n];

        int ttl = 0;
        
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            t[i] = sc.nextInt();
            ttl += t[i];
        }

        String x = sc.next();

        for (int i = 0; i < n; i++) {
            ttl -= t[i];
            if (s[i].equals(x)) {
                break;
            }
        }

        System.out.println(ttl);
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define COUTDOUBLE(v) cout << std::setprecision(20)<<(v)<<endl;
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define f first
#define s second

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    double n,m,d ;cin >> n >> m >> d;
    if(d != 0)COUTDOUBLE(2*(n-d)/(n*n)*(m-1));
    if(d == 0)COUTDOUBLE(1.0/n * (m-1));
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        set<int> s;
        rep(i,3)
        {
                int a; cin>>a;
                s.insert(a);
        }
        cout<<s.size()<<endl;
}

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

int N;
int A[200010],B[200010];
pair<int,int> C[200010];

int main(){
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> A[i] >> B[i];
        C[i] = {B[i],i};
    }
    sort(C+1,C+N+1);
    int ti = 0;
    for(int i=1;i<=N;i++){
        int id = C[i].second;
        if(ti+A[id]<=B[id]) ti += A[id];
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
ll mod = 1e9+7;

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

ll lcm(ll a, ll b){
  return (a/gcd(a,b))*b;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  vector<string> t(4);
  t = {"maerd", "remaerd", "esare", "resare"};
  rep(i, s.size()){
    if(s.size()-i <= 4){cout << "NO" << "\n"; return 0;}
    bool can = false;
    rep(j, 4){
      if(s.substr(i, t[j].size()) == t[j]){
        can = true; 
        i += t[j].size()-1;
        break;
      }
    }
    if(!can){cout << "NO" << "\n"; return 0;}
  }
  cout << "YES" << "\n";
  return 0;
}   

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  if(a>12){
    printf("%d",b);
  }else if(a>5){
    printf("%d",b/2);
  }else{
    puts("0");
  }
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0)
    {
        c-=b;
        if(c<1)
            break;
        a-=d;
    }    
    if(a>0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
	return 0;
}

Measured memory_bytes: 3600
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl

const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;






int main(){
    fastio();
    int n; cin>>n;
    ll ans=0;
    int dp[10][10];
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            dp[i][j]=0;
        }
    }
    for(int i=1;i<n+1;i++){
        int last=i%10;
        int j=i;
        while (j >= 10) {
            j /= 10; 
        }
        int first=j;
        dp[first][last]++;
    }

    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            ans+=(dp[i][j]*dp[j][i]);
        }
    }
    cout<<ans<<endl;

    return 0;
}

 

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

using namespace std;

const int md = 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

const int N = 200010;

int main() {
  int n, m;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a.erase(unique(a.begin(), a.end()), a.end());
  n = a.size();

  vector<int> dp(n + 1), prev(N, -1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    dp[i + 1] = dp[i];
    if (prev[a[i]] > 0) {
      add(dp[i + 1], dp[prev[a[i]]]);
    }
    prev[a[i]] = i + 1;
  }
  cout << dp[n] << '\n';
  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n,m;
	cin >> n >> m;

	vector<int> v[n+1];

	rep(i,m){
		int a,b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	bool used[n+1] = {};

	for(int x : v[1]){
		if(not(used[x])){
			used[x] = true;
			for(int y : v[x]){
				if(y == n) {
					cout << "POSSIBLE" << endl; 
					return 0;
				}
			}
		}	
	}
	
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 12144
N, Q = map(int, input().split())
S = input()

dict_cnt_ac = {}
flag_a = False

cnt_ac = 0
cnt_loop = 0
for s in S:
    cnt_loop += 1
    if flag_a == True and s == "C":
        cnt_ac += 1
        flag_a = False
    elif s == "A":
        flag_a = True
    else:
        flag_a = False
    dict_cnt_ac[cnt_loop] = cnt_ac
    
for q in range(Q):
    l, r = list(map(int, input().split()))
    print(dict_cnt_ac[r] - dict_cnt_ac[l])


Measured memory_bytes: 16624
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  bool flag = true;
  string yaki = "YAKI";
  if (S.size() < 4) {
      flag = false;
  } else {
    for (int i; i < 4; i++) {
      if (S.at(i) != yaki.at(i)) {
        flag = false;
      }
    }
  }
  
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

// 展開図から得られるサイコロシミュレーションを行うプログラム

int main() {
    int iDice[7];   // ダイスの整数
    int iCount;     // counter
    int iSwapTmp;   // 転がした際に目を変更するためのテンポラリ
    char szDiceRole[110];   // 転がす命令

    // In: ダイスに書かれた整数
    for (iCount = 1; iCount <= 6; iCount++) {
        scanf("%d", &iDice[iCount]);
    }
    // In: 転がし方の命令
    scanf("%s", szDiceRole);
    // 命令数分繰り返す
    iCount = 0;
    while (szDiceRole[iCount] != '\0') {
        switch (szDiceRole[iCount]) {
        case 'E':
            iSwapTmp = iDice[1];    // 上面を退避
            iDice[1] = iDice[4];    // 左面->上面
            iDice[4] = iDice[6];    // 下面->左面
            iDice[6] = iDice[3];    // 右面->下面
            iDice[3] = iSwapTmp;    // 上面->右面
            break;
        case 'W':
            iSwapTmp = iDice[1];    // 上面を退避
            iDice[1] = iDice[3];    // 右面->上面
            iDice[3] = iDice[6];    // 下面->右面
            iDice[6] = iDice[4];    // 左面->下面
            iDice[4] = iSwapTmp;    // 上面->左面
            break;
        case 'S':
            iSwapTmp = iDice[1];    // 上面を退避
            iDice[1] = iDice[5];    // 奥->上
            iDice[5] = iDice[6];    // 下->奥
            iDice[6] = iDice[2];    // 手前->下
            iDice[2] = iSwapTmp;    // 上->手前
            break;
        case 'N':
            iSwapTmp = iDice[1];    // 上面を退避
            iDice[1] = iDice[2];    // 手前->上
            iDice[2] = iDice[6];    // 下->手前
            iDice[6] = iDice[5];    // 奥->下
            iDice[5] = iSwapTmp;    // 上->奥
            break;
        default:
            break;
        }
        iCount++;
    }
    printf("%d\n", iDice[1]);

    return 0;
}


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

int main()
{
    int x[2];
    cin >> x[0] >> x[1];
    int g[2];
    for (int i = 0; i < 2; i++)
    {
        int y = x[i];
        if ((y < 8 && y % 2 == 1) || y >= 8 && y % 2 == 0)
        {
            g[i] = 1;
        }
        else if (y == 2)
        {
            g[i] = 3;
        }
        else
        {
            g[i] = 2;
        }
    }
    if (g[0] == g[1])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;
#define N 100010
ll n;
ll a[N],b[N],l[N],r[N];
ll sp,tp;
priority_queue<ll> S;
priority_queue<ll,vector<ll>,greater<ll> >T;
ll Sf(){ return S.top()+sp; }
ll Tf(){ return T.top()+tp; }
void Sp(ll x){ S.push(x-sp); }
void Tp(ll x){ T.push(x-tp); }
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>l[i]>>r[i];
    for(int i=1;i<n;i++){
      a[i]=l[i]-r[i-1];
      b[i]=r[i]-l[i-1];
    }
    ll ans=0;
    sp=0; Sp(0); Sp(-1e17);
    tp=0; Tp(0); Tp(+1e17);
    for(int i=1;i<n;i++){
      sp-=b[i],tp-=a[i];
      ll s0=Sf(),t0=Tf();
      if(s0<=0&&0<=t0){
	Sp(0); Tp(0);
      }
      if(0<s0){
	Sp(0); Sp(0);
	ans+=abs(Sf());
	Tp(Sf()); S.pop();
      }
      if(t0<0){
	Tp(0); Tp(0);
	ans+=abs(Tf());
	Sp(Tf()); T.pop();
      }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

struct UnionFind {
  vector<ll> data;

  UnionFind(ll n){
    data.resize(n+1);
    fill(data.begin(), data.end(), -1);
  }

  ll root(ll x){
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  void unite(ll x, ll y){
    ll rx=root(x);
    ll ry=root(y);

    if(rx!=ry){
      if(data[ry] < data[rx])swap(rx, ry);

      data[rx]+=data[ry];
      data[ry]=rx;
    }
  }

  bool same(ll x, ll y){
    return root(x)==root(y);
  }

  ll size(ll x){
    return -data[root(x)];
  }
};

int main(){
  ll n,m,k;cin>>n>>m>>k;
  vector<pll>ab(m);
  rep(i, m)cin>>ab[i].first>>ab[i].second;
  vector<pll>cd(k);
  rep(i, k)cin>>cd[i].first>>cd[i].second;

  UnionFind f_uf(n), b_uf(n);
  map<ll, ll> friends_count, block_count;

  for(auto p:ab){
    f_uf.unite(p.first, p.second);
    friends_count[p.first]++;
    friends_count[p.second]++;
  }

  for(auto p: cd)if(f_uf.same(p.first, p.second)){
    b_uf.unite(p.first, p.second);
    block_count[p.first]++;
    block_count[p.second]++;
  }

  rep1(i, n){
    cout<<max<ll>(0LL, f_uf.size(i) - friends_count[i] - block_count[i] - 1)<<' ';
//    cout<<f_uf.size(i) - friends_count[i] - b_uf.size(i)<<' ';
//    cout<<f_uf.size(i) <<' '<< friends_count[i] <<' '<< b_uf.size(i)<<endl;
  }

  return 0;
}



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

int main(){
    char c;
    cin >> c;
    
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

int A,B,H;

int main()
{
	cin >> A >> B >> H;

	cout << (A + B) * H / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
import sys

counts = list(map(int,input().split()))
colors = list(map(int,input().split()))
hots = list(map(int,input().split()))

ticketCount = counts[2]

minPrice = sys.maxsize
# first. get disscount consider price
for i in range(ticketCount):
  values = input().split()
  x = int(values[0])
  y = int(values[1])
  dissPrice = int(values[2])
  colorPrice = colors[x-1]
  hotsPrice = hots[y-1]
  validPrice =  colorPrice + hotsPrice - dissPrice
  if minPrice > validPrice:
    minPrice = validPrice

max_color = min(colors)
max_color_idx = colors.index(max_color)
max_hots = min(hots)
max_hots_idx = hots.index(max_hots)
validPrice = max_color + max_hots
if minPrice > validPrice:
  minPrice = validPrice
print(str(minPrice))

Measured memory_bytes: 18684
from operator import mul
from functools import reduce


def cmb(n, r):
	r = min(n - r, r)
	if r == 0:
		return 1
	numer = reduce(mul, range(n, n - r, -1))
	denom = reduce(mul, range(1, r + 1))
	return numer // denom % INF


N, K = map(int, input().split())
INF = 10 ** 9 + 7

for i in range(1, K + 1):
	if i <= N - K + 1:
		print(cmb(K - 1, i - 1) * cmb(N - K + 1, i) % INF)
	else:
		print(0)


Measured memory_bytes: 3944
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n,x,ans;
		while(true){
			n=sc.nextInt();
			x=sc.nextInt();
			if(n==0&&x==0)break;
			ans=0;
			for(int i=1;i<=n-2;i++){
				for(int j=i+1;j<=n-1;j++){
					for(int k=j+1;k<=n;k++){
						if(i+j+k==x)
							ans++;
					}
				}
			}
			System.out.println(ans);
		}
}
}


Measured memory_bytes: 26536
n, m = [int(x) for x in input().split()]
bad = [False for i in range(n + 1)]
for i in range(m):
  bad[int(input())] = True
mod = 10 ** 9 + 7
dp = [0 for i in range(n + 1)]
dp[0] = 1
for i in range(1, n + 1):
  if bad[i]: 
    continue
  x1 = dp[i - 1] if (i > 0) and not bad[i - 1] else 0
  x2 = dp[i - 2] if (i > 1) and not bad[i - 2] else 0
  dp[i] = x1 + x2
  if dp[i] >= mod:
    dp[i] -= mod
print(dp[n])

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

int main()
{
	ll N;
	cin >> N;
	for (ll i = 1; i <= 3500; i++) {
		for (ll j = 1; j <= 3500; j++) {
			if (4 * i * j > (i + j) * N) {
				if ((N * i * j) % (4 * i * j - (i + j) * N) == 0) {
					cout << i << ' ' << j << ' ' << (N * i * j) / (4 * i * j - (i + j) * N) << endl;
					goto end;
				}
			}
		}
	}
	end:
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int max(int a, int b)
{
  int max;
  
    if(a+b >= a-b)
      max = a+b;
  else
    max = a-b;
  
  if(a*b >= max)
    max = a*b;
  
  return max;
}

int main(void)
{
  int a, b;
  
  scanf("%d",&a);
  scanf("%d",&b);
  
  printf("%d", max(a, b));
  
  return 0;
}
  

Measured memory_bytes: 128
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

X = I()

a = [0,1]
for i in range(2,300):
  a.append(i**5)
#print(a)

for i,j in itertools.combinations(a, 2):
  #print(i,j)
  for k in [-1,1]:
    if j - i*k == X:
      print(int(j**0.2), int(i**0.2)*k)
      exit()
print(error)

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

int main(){
  string S;
  cin >> S;
  
  int l = S.length();
  for (int i=0;i<l;i++){
    if(S[i] != S[l-i-1]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  int l2 = (l-1)/2;
  for (int i=0;i<l2;i++){
    if(S[i] != S[l2-i-1]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  int l3 = (l+3)/2;
  for (int i=l3-1;i<l;i++){
    if(S[i] != S[l-i-1]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}
    
    

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

// Use g++ compiler for this include to work.
#include <bits/stdc++.h>

using namespace std;

// Constants 
#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007
 
// // for using in pairs
#define F first
#define S second
 
// Macros
#define all(x) begin(x), end(x)
 
// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Temporary macro.
#define int long long

// Operator overloads.
/**
 * The type of element in the vector should have overload for << operator with ostream. 
 */
template<typename T>
ostream& operator<<(ostream &stream, vector<T>& v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

/**
 * Both types in the pair should have overload for << operator with ostream. 
 */
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, pair<T1, T2>& p)
{
	ostream << p.first << " " << p.second;
	return ostream;
}

template<typename T1, typename T2>
istream& operator>>(istream &istream, pair<T1, T2>& p)
{
	istream >> p.first >> p.second;
	return istream;
}

template<typename T>
istream& operator>>(istream &istream, vector<T>& a)
{
	for (auto &it : a)
		istream >> it;
	return istream;
}

// Utility functions.

int GCD(int a, int b)
{
	if (!b)
		return a;
	return GCD(b, a % b);
}

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

int modpow(int x, int n, int m = MOD)
{
	if (n == 0) return 1 % m;
	long long u = modpow(x, n / 2, m);
	u = (u * u) % m;
	if (n % 2 == 1)
		u = (u * x) % m;
	return u;	
}

//////////////////// START CODE HERE ///////////////////////////

void solve(int tc)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		int u, v;
		cin >> u >> v;
		if (u == v)
			a[i] = 1;
		else
			a[i] = 0;
	}
	string ans = "No";
	for (int i = 0; i < n; i++)
	{
		int x = 0;
		while (a[i] == 1)
		{
			i++;
			x++;
			if (i == n)
				break;
		}
		if (x >= 3)
			ans = "Yes";
	}

	cout << ans;
}	

int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;		
	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define maxn 5010000
using namespace std;

int L, R, n;
char s[maxn];
int val[maxn], A[maxn];

bool judge(int m) {
	for (int i = 1; i <= n; i++) A[i] = val[i];
	for (int i = n; i >= 1; i--) {
		int res = m - A[i];
		if (res < 0) return false;
		A[i] += (res / 10) * 10;
		A[i - 1] -= (res / 10);
		if (A[i - 1] > A[i]) return false;
		m = A[i];
	}
	return true;
}

int main() {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; i++) val[i] = s[i] - '0';
	L = 0; R = (1 << 30);
	while (L < R) {
		int mid = (L + R) / 2;
		if (judge(mid)) R = mid;
		else L = mid + 1;
	}
	printf("%d\n",(L + 8) / 9);
	return 0;
}

Measured memory_bytes: 8320
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
    	int k, a, b;
    	cin >> k >> a >> b;

    	if((a - 1) / k < b / k)
    		cout << "OK\n";
    	else
    		cout << "NG\n";
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



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

class Program
{
    static void Main(string[] args)
    {

            var s = Console.ReadLine();

            if (s.Length == 2)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine(new String(s.Reverse().ToArray()));
            }
    }
}




Measured memory_bytes: 11220
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    vecl A(N+1);
    vecl B(N);
    REP(i,N+1) cin >> A[i];
    REP(i,N) cin >> B[i];
    ll ans = 0;
    ll res = 0;
    REP(i,N+1) {
        //cout << A[i] << endl;
        res += A[i];
    }
    REP(i,N) {
        int tmp = min(A[i],B[i]);
        A[i] -= tmp;
        B[i] -= tmp;
        A[i+1] -= min(B[i],A[i+1]);  
    }
    REP(i,N+1) {
        //cout << A[i] << endl;
        res -= A[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int K, S; std::cin >> K >> S;
  int ans = 0;
  for(int x = 0; x <= K; ++x) for(int y = 0; y <= K; ++y) {
    int z = S-x-y;
    if(0 <= z && z <= K) ++ans;
  }
  fin(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    string S;
    cin >> S;
    int sa = 753;
    for(int i=0; i<S.size()-2; i++){
        string T = S.substr(i,3);
        int sanketa = stoi(T);
        int subsa = max(sanketa-753, 753-sanketa);
        sa = min(sa, subsa);
    }
    cout << sa << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, K;
  cin >> N >> K;
  vector<vector<int64_t>> a(N,vector<int64_t>(2));
  for(int i = 0; i< N; i++){
    for(int j = 0; j< 2;j++){
      cin >> a.at(i).at(j);
    }
  }
  
  int64_t q[100010] ={0};
  for(int i = 0; i < N; i++){
    q[a.at(i).at(0)]+= a.at(i).at(1);
    }
int64_t count = 0;
for(int i = 1; i< 100100; i++){
  if(count< K && K <= count+q[i]){
    cout << i << endl;
    return 0;
  }
  else{
    count+= q[i];
  }
}
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main(){
  ll n;
  cin>>n;
  cout<<ceil(n/2.0);
}

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

public class Main {
    static boolean solve(int heads, int legs){
        for(int crane=0; crane<=heads; crane++){
            int turtle = heads-crane;
            if(crane*2+turtle*4==legs) return true;
        }
        return false;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int heads = sc.nextInt();
        int legs = sc.nextInt();
        System.out.println(solve(heads, legs) ? "Yes" : "No");
        
    }
}

Measured memory_bytes: 35724
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll a[n]={0};
    ll pro=1;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=k;i<n;i++)
    if(a[i]>a[i-k])
    cout<<"Yes\n";
    else
    cout<<"No\n";
}


Measured memory_bytes: 5176
lines = STDIN.read.split("\n")
lines = lines.map(&:to_i)
lines.pop

while lines.count > 0 do
    loopCount = lines[0].to_i
    lines.delete_at(0)


    dataSet = lines.slice(0..loopCount-1)


    dataCount = Hash.new(0)
    dataSet.each_with_index do |v,i|
        dataCount[v] += 1
        lines.delete_at(0)
    end

    for i in 0..9 do
        if(dataCount[i] > 0)
            puts "*" * dataCount[i]
        else
            puts "-"
        end
    end
end








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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{	int A, B, M;
	cin >> A >> B >> M;

	vec(AA);
	vec(BB);
	int a = INT_MAX, b = INT_MAX;
	fx(A) {
		vecp(AA);
		a = min(AA[x], a);
	}
	fx(B) {
		vecp(BB);
		b = min(BB[x], b);
	}
	int ans = a+b;
	fw(M) {
		int x, y, z;
		cin >> x >> y >> z;
		ans = min(ans, AA[x - 1] + BB[y - 1] - z);
	}
	ce(ans)

    return 0;
}



Measured memory_bytes: 1400
from itertools import accumulate
S=input()
l=len(S)
mod=998244353
R_cnt,B_cnt=[],[]
for i in S:
    R_cnt.append(2-int(i))
    B_cnt.append(int(i))
R_acc=[0]+list(accumulate(R_cnt))
R_acc+=[R_acc[-1]]*l
B_acc=[0]+list(accumulate(B_cnt))
B_acc+=[B_acc[-1]]*l
DP=[[0]*(2*l+1) for _ in range(2*l+1)]
DP[0][0]=1
for i in range(2*l):
    for r in range(i+1):
        if R_acc[i+1]>=r+1:
            DP[i+1][r+1]+=DP[i][r]
            DP[i+1][r+1]%=mod
        if B_acc[i+1]>=i+1-r:
            DP[i+1][r]+=DP[i][r]
            DP[i+1][r]%=mod
print(DP[-1][R_acc[-1]])

Measured memory_bytes: 166492
def extended_gcd(a, b):
    """ax + by = gcd(a, b)の整数解(x, y)を求める"""
    if b == 0:
        return a, 1, 0
    else:
        g, y, x = extended_gcd(b, a % b)
        y -= (a // b) * x
        return g, x, y

a, b = map(int, input().split())
_, x, y = extended_gcd(a, b)
print(x, y)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
  
int parent[100000];

int root(int x){
  if(parent[x]==x) return x;
  else return parent[x]=root(parent[x]);
}

int main(){
  //A1-ANそれぞれ偶奇が決まってる
  //ペアの偶奇はわかる
  //ペアでつながる部分は1つわかればすべて決まるしわからないと決まらない
  
  int N,M; cin >> N >> M;
  for(int i=0; i<N; i++) parent[i]=i;
  
  
  for(int i=0; i<M; i++){
    int x,y,z;
    cin >> x >> y >> z;
    x=root(x); y=root(y);
    parent[x]=y;
  }
  
  int count[100000]={};
  for(int i=0; i<N; i++){
    count[root(i)]++;
  }
  int result =0;
  for(int i=0; i<N; i++){
    if(count[i]>0) result++;
  }
  cout << result << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B, K;
		A = sc.nextInt();
		B = sc.nextInt();
		K = sc.nextInt();

		for (int i = A; i <= B; i++) {
			if (i - A < K || B - i < K) {
				System.out.println(i);
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 23380
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 7;

struct SegTree { // 区間sum
	int n;
	vector<int> Sum;
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		Sum.resize(2 * n);
		for (int i = 0; i < 2 * n - 1; ++i) {
			Sum[i] = 0;
		}
	}
	void add(int idx, int val) {
		idx += n - 1;
		Sum[idx] += val;
		while (idx > 0) {
			idx = (idx - 1) / 2;
			Sum[idx] = Sum[idx * 2 + 1] + Sum[idx * 2 + 2];
		}
	}
	int get_sum(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)のsum
		if (r == -1) r = n;
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return Sum[k];
		int vl = get_sum(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get_sum(a, b, k * 2 + 2, (l + r) / 2, r);
		return vl + vr;
	}
};

int N;
int a[100010], b[100010];
int rui[100010];
SegTree st;

int ceil_div(int a, int b)
{
	return (a + b - 1) / b;
}

// median of medians をX 以上にできるか
bool ok(int X)
{
	const int ofs = 100000;
	st.init(200010);

	rep1(i, N) {
		b[i] = a[i] >= X ? 1 : -1;
	}

	rep1(i, N) {
		rui[i] = rui[i - 1];
		rui[i] += b[i];
	}

	int counter = 0;

	rep1(i, N) {
		counter += st.get_sum(0, rui[i] + ofs + 1);
		if (rui[i] >= 0) counter++;
		st.add(rui[i] + ofs, 1);
	}

	return counter >= ceil_div((1 + N) * N / 2, 2);
}

signed main()
{
	cin >> N;
	rep1(i, N) cin >> a[i];

	int lo = 0, hi = inf;

	while (hi - lo > 1) {
		int mid = (lo + hi) / 2;

		if (ok(mid)) {
			lo = mid;
		} else {
			hi = mid;
		}
	}

	cout << lo << endl;
}




Measured memory_bytes: 6656
#include <stdio.h>

int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);

    int i = 1;

    while(1)
    {
        if(i%2 == 1)
        {
            c -= b;

            if(c <= 0)
            {
                 printf("Yes\n");
                 break;
            }
        }

        else
        {
            a -= d;

            if(a <= 0)
            {
                 printf("No\n");
                 break;
            }
        }

        i++;
    }

    return 0;
}


Measured memory_bytes: 1620
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int cnt[3]={};
  for(auto p:s) {
    cnt[p-'a']++;
  }
  sort(cnt,cnt+3);
  cout << (cnt[2]-cnt[0]<=1?"YES":"NO") << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		char[] strArray = str.toCharArray();

		for (int i = 0; i < strArray.length; i++) {

			if (Character.isUpperCase(strArray[i])) {

				strArray[i] = Character.toLowerCase(strArray[i]);

			} else if (Character.isLowerCase(strArray[i])) {

				strArray[i] = Character.toUpperCase(strArray[i]);

			} else {

				strArray[i] = strArray[i];

			}

		}

		for (int i = 0; i < strArray.length - 1; i++) {

			System.out.print(strArray[i]);

		}

		System.out.println(strArray[strArray.length - 1]);

	}
}

Measured memory_bytes: 25056
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using P = pair<int,int>;
using node = pair<string,ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

ll a[200200];
ll acc[200200];
ll to_left[200200];
ll to_right[200200];
ll dp[200200];

int main(void) {
  int l;
  cin >> l;
  acc[0] = 0LL;
  for(int i = 1;i <= l;++i){
    cin >> a[i];
    acc[i] = acc[i-1] + a[i];
  }

  to_left[0] = 0LL;
  for(int i = 1;i <= l;++i){
    if(a[i] == 0) {
      to_left[i] = min(2 + to_left[i-1], acc[i]);
    } else {
      to_left[i] = min(a[i]%2 + to_left[i-1], acc[i]);
    }
  }

  to_right[l] = 0LL;
  for(int i = l-1;i >= 0;--i) {
    if(a[i+1] == 0) {
      to_right[i] = min(2 + to_right[i+1], acc[l] - acc[i]);
    } else {
      to_right[i] = min(a[i+1]%2 + to_right[i+1], acc[l] - acc[i]);
    }
  }

  dp[0] = 0LL;
  for(int i = 1;i <= l;++i){
    dp[i] = min((a[i]+1) % 2 + dp[i-1], to_left[i]);
  }
  ll res = inf;
  for(int i = 0;i <= l;++i){
    res = min(res, dp[i]+to_right[i]);
  }
  cout << res << endl;
  return 0;
}


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

public class Main {
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int a = fs.nextInt();
        int b = fs.nextInt();
        int c = fs.nextInt();
        int now = 0;
        int ans = 0;
        for (int i = 0; i < c; i++){
            now += a;
            if(now > b){
                break;
            }
            ans++;
        }
        pw.println(ans);
        pw.flush();
    }
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n, k;
  cin >> n >> k;
  cout << (n % k > 0 ? 1 : 0);
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstring>

#define MIN (-(1<<30))
using namespace std;

int n;
int W;
int w[105];
int v[105];
long long dp[105][100005];

long long knap(int pos,int sum){
  if(sum>W)return MIN;
  if(pos==n)return 0;
  if(dp[pos][sum]!=-1)return dp[pos][sum];
  
  return dp[pos][sum]=max(knap(pos+1,sum+w[pos])+v[pos],knap(pos+1,sum));
}
int main(){
  cin>>n>>W;
  
  for(int i=0;i<n;i++){
    cin>>w[i]>>v[i];
  }

  memset(dp,-1,sizeof(dp));

  cout<<knap(0,0)<<"\n";
  
  return 0;
}


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

int main(){
	int x,y;
	int tmp;
	int count = 0;
	while(cin >> x >> y){
		tmp = x + y;
		count = 0;
		while(tmp != 0){
			tmp /= 10;
			count++;
		}
		cout << count << endl;
	}
	return 0;
}		

Measured memory_bytes: 3016
import Foundation

func readStr() -> [String] {
    readLine()!.map { String($0) }
}

func main(){
    let s = readStr()
    let t = readStr()
    var ans = 0
    
    for i in 0..<t.count {
        if s[i] != t[i] {
            ans += 1
        }
    }
    print(ans)
}
main()



Measured memory_bytes: 18568
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

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

int fi[11][11];

int n, m;
int res, tot, sx, sy;

void rec(int x, int y, int con) {
    ++con;
    if (con == tot) {
        if (x == sx || y == sy) ++res;
        return;
    }
        
    fi[x][y] = 3;
    for (int i = 0; i < 4; ++i) {
        int nx = x, ny = y;
        while (true) {
            nx += dx[i], ny += dy[i];
            if (nx < 0 || nx >= n || ny < 0 || ny >= m) break;
            if (fi[nx][ny] == 1) {
                rec(nx, ny, con);
                break;
            }
        }
    }
    fi[x][y] = 1;
}

int main() {
    while (scanf("%d%d", &m, &n), n) {
        if (m == 0) break;
        tot = 0;
        for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
            scanf("%d", &fi[i][j]);
            if (fi[i][j] == 1) ++tot;
            if (fi[i][j] == 2) sx = i, sy = j;
        }
        res = 0;
        rec(sx, sy, -1);
        
        printf("%d\n", res);
    }
    return 0;
}


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

int main() {
  int A, B; cin >> A >> B;
  if (A < B)
    swap(A, B);
  int d = abs(A) + abs(B);
  int K = d / 2;
  if (K*2 != d) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << K << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static bool Solve(int N, int[] a, int[] b)
        {
            long c1 = 0;
            long c2 = 0;
            for (int i = 0; i < N; ++i)
            {
                if (a[i] < b[i])
                {
                    c1 += (b[i] - a[i] + 1) / 2;
                    c2 += (b[i] - a[i]) % 2;
                }
                else
                {
                    c2 += (a[i] - b[i]);
                }
            }
            return c1 >= c2;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] a = ReadInts();
            int[] b = ReadInts();
            Console.WriteLine(Solve(N, a, b) ? "Yes" : "No");
        }
    }
}


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

typedef struct{
  double x;
  double y;
} POINT;

void koch(int,POINT,POINT);

int main()
{
  POINT p1, p2;
  int n;

  p1.x = 0;
  p1.y = 0;

  p2.x = 100;
  p2.y = 0;

  scanf("%d",&n);

  printf("%.8f %.8f\n",p1.x,p1.y);
  koch(n, p1, p2);
  printf("%.8f %.8f\n",p2.x,p2.y);
}

void koch(int n, POINT p1, POINT p2)
{
  POINT s, t, u;

  s.x = (2*p1.x + p2.x)/3;
  s.y = (2*p1.y + p2.y)/3;

  t.x = (p1.x + 2*p2.x)/3;
  t.y = (p1.y + 2*p2.y)/3;

  u.x = (t.x - s.x)*cos(M_PI/3) - (t.y - s.y)*sin(M_PI/3) + s.x;
  u.y = (t.x - s.x)*sin(M_PI/3) + (t.y - s.y)*cos(M_PI/3) + s.y;
    
  if(n != 0) {
    koch(n-1, p1, s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1, s, u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1, u, t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1, t, p2);
  }
}



Measured memory_bytes: 2052
#include<stdio.h>
#define N 44

main(){

  int fib[N],i,n;

  scanf("%d",&n);

  for( i = 0 ; i <= n ; i++ ){
    
    if( i == 0 )
      fib[i] = 1;
    if( i == 1)
      fib[i] = 1;
    if( 1 < i )
      fib[i] = fib[ i - 2 ] + fib[ i - 1 ];
    
    if( i == n )
      printf("%d\n",fib[i]);

  }

    return 0;
      

}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,t,a,res=0;
    double tmp = 1000000000;
    cin >> n >> t >> a;
    vi h(n);
    rep(i,n) cin >> h.at(i);
    rep(i,n) {
        double temp = t-h.at(i)*0.006;
        double sub = a - temp;
        sub = sub >= 0 ? sub : -sub;
        if(tmp > sub){
            res = i+1;
            tmp=sub;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
strnum = [str(i) for i in range(10)]

a, b = input().split()
a, b = int(a), int(b)

S = input()

S = S.split("-")

if len(S) == 2:
	if len(S[0]) == a and len(S[1]) == b:
		print('Yes')
	else:
		print('No')
else:
	print('No')




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

#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

using namespace std;

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

    int N, K, C;
    string S;
    cin >> N >> K >> C >> S;

    vector<int> dp(N + 1);
    dp[N] = 0;

    RREP(i, N) {
        if (S[i] == 'x') {
            dp[i] = dp[i + 1];
        } else {
            int j = i + C + 1;
            dp[i] = max(dp[i + 1], 1 + (j < N ? dp[j] : 0));
        }
    }

    int i = 0;
    while (K > 0) {
        int first_o = -1;
        int next_i = -1;
        while (dp[i] >= K) {
            if (S[i] == 'o') {
                if (first_o == -1) {
                    first_o = i;
                    next_i = first_o + C + 1;
                } else {
                    first_o = -1;
                    break;
                }
            }
            ++i;
        }
        if (first_o != -1) {
            cout << (first_o + 1) << '\n'; // 1-based indexing
        }
        i = next_i;
        --K;
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 2580