akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

#define MAX_N 100000
ll uf[MAX_N];
 
void init(ll n) {
	rep(i, n) {
		uf[i] = i;
	}
}
 
ll root(ll i) {
	if(uf[i] == i) {
		return i;
	} else {
		return uf[i] = root(uf[i]);
	}
}
 
bool same(ll x, ll y) {
	return root(x) == root(y);
}
 
bool unite(ll x, ll y) {
	x = root(x);
	y = root(y);
	if(x == y) return false;
	uf[x] = y;
	return true;
}

int main(int argc, const char* argv[]) {
	ll n, m;
	cin >> n >> m;
	init(n);

	ll ret = n;
	rep(i, m) {
		ll x, y, z;
		cin >> x >> y >> z;
		if(unite(x, y)) --ret;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N,M;
int x[110000];
signed main() {
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        int u=max(a,b),l=min(a,b);
        x[u]=max(x[u],l);
    }
    int ans=-1,r=0;
    for(int i=1;i<=N;i++){
        cerr<<x[i]<<" "<<r<<endl;
        if(x[i]>=r){
            ans++;
            r=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
S = input()
X = int(S[0:2])
Y = int(S[2:4])

if X > 12 and Y > 12:
    print("NA")
elif X == 0 or Y == 0:
    if X == 0:
        if Y > 12 or Y == 0:
            print("NA")
        else:
            print("YYMM")
    else:
        if X > 12:
            print("NA")
        else:
            print("MMYY")
elif X < 13 and Y < 13:
    print("AMBIGUOUS")
elif X > Y:
    print("YYMM")
else:
    print("MMYY")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    int k;cin>>k;
    ll s=0;
    repA(i,1,k)repA(j,1,k)repA(l,1,k)s+=__gcd(i,__gcd(j,l));
    cout<<s;

	return 0;
}
 



Measured memory_bytes: 3644
x,y= map(int, input().split())
a=min(x,y)
b=max(x,y)
mod=pow(10,9)+7
if b-a>a or (a-(b-a))%3!=0:
    print(0)

else:
    r=(a-(b-a))//3
    l=((a-(b-a))//3)+(b-a)
    c=1
    d=1
    for i in range(r):
        c=(c*(l+r-i))%mod
        d=(d*(r-i))%mod
    ans=c*pow(d,mod-2,mod)
    print(ans%mod)


Measured memory_bytes: 40172
#include<bits/stdc++.h>
#define int long long int
using namespace std;
#define pb push_back
#define MAX 200005
int par[MAX];
int sz[MAX];
void init()
{
	for(int i=0;i<MAX;i++){
		par[i]=i;
		sz[i]=1;
	}
}
int parent(int x)
{
	if(par[x]==x)	return x;
	par[x]=parent(par[x]);
	return par[x];
}
void unionxy(int x,int y)
{
	int px=parent(x);
	int py=parent(y);
	if(px==py)	return;
	par[py]=px;
	sz[px]+=sz[py];
}


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

	int n,m;
	cin >> n >> m;
	int t=m;
	init();
	while(t--){
		int x,y;
		cin >> x >> y;
		unionxy(x,y);
	}
	int ans=1;
	for(int i=1;i<=n;i++){
		if(i==parent(i)){
			ans=max(ans,sz[i]);
		}
	}
	cout << ans << endl;



	return 0;
}


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

int main() {
    long long N, K;
    cin >> N >> K;
    
    double res = 0.0;
    for (long long n = 1; n <= N; ++n) {
        double tmp = 1.0;
        long long nn = n;
        while (nn < K){nn *= 2; tmp /= 2.0;}
        res += tmp;
    }
    res /= N;
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 3756
import numpy as np
D, G=list(map(int, input().split()))
p_c = []
for _ in range(D):
    p_c.append( list(map(int, input().split())) )

min_num = -1
for i in range( 2**D ):
    incomp = -1
    temp_score = 0
    temp_num   = 0
    for j in range(D):
        if i>>j & 1:
            temp_score += 100*(j+1)*p_c[j][0] + p_c[j][1]
            temp_num   += p_c[j][0]

    num=0
    if temp_score < G:
        diff = G-temp_score
        for j in reversed( range(D) ):
            if not i>>j & 1:
                while 100*(j+1)*num<diff:
                    num += 1
                if num < p_c[j][0]:
                    temp_num += num
                else:
                    temp_num = np.inf
                break

    if min_num < 0 or min_num > temp_num:
        min_num = temp_num
print(min_num)


Measured memory_bytes: 21540
#include<iostream>
#include<algorithm>
#include<vector>


using namespace std;

vector<int> a(3);

int m;

int main(){
	for(int i=0;i<3;i++){
		cin>>a[i];
	}

	sort(a.begin(),a.end());

	int m=a[2];

	//cout<<a[2]<<endl;

	for(int i=0;i<3;i++){
		a[i]=abs(a[i]-m);
		
	}

	int ans=0,count=0;

	for(int i=0;i<3;i++){
	if(a[i]!=0)ans+=a[i]/2;
	if(a[i]!=0)a[i]=a[i]%2;
	count+=a[i];
	}
	
	if(count==0)cout<<ans<<endl;

	else if(count==1)cout<<ans+2<<endl;

	else if(count==2)cout<<ans+1<<endl;

	else cout<<ans<<endl;
	
	/*
	for(int i=0;i<=3;i++){
		if(count==i){
			cout<<ans+i<<endl;
			break;
		}
	}
	*/
	
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

int BOX[100001][2];//個数，入っている可能性

int main(){
    INT(N);INT(M);
    REP2(i,1,N){
        BOX[i][0] = 1;
        BOX[i][1] = 0;
    }
    BOX[1][1] = 1;
    
    REP1(i,M){
        INT(x);INT(y);
        //移動元に可能性があったら移動先に可能性フラグを立てる.
        if (BOX[x][1] == 1) {
            BOX[y][1] = 1;
        }
        BOX[x][0]--;
        BOX[y][0]++;
        
        //移動後0こになったら，可能性はなくなる．
        if (BOX[x][0] == 0) {
            BOX[x][1] = 0;
        }
    }
    
    int sum = 0;
    REP2(i,1,N) sum += BOX[i][1];
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
using namespace std;
typedef unsigned int uii;
const int maxn=100005;
int n,m,Q,u,v,o[maxn],d[maxn],q[maxn],col[maxn],vis[maxn];
vector<int> G[maxn];
void dfs(int u,int l,int c) {
    if (vis[u]>=l)
        return;
    vis[u]=l;
    if (!col[u])
        col[u]=c;
    for (uii i=0;i<G[u].size();++i)
        dfs(G[u][i],l-1,c);
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=0;i<m;++i) {
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    scanf("%d",&Q);
    for (int i=0;i<Q;++i)
        scanf("%d%d%d",&o[i],&d[i],&q[i]);
    for (int i=Q-1;i>=0;--i)
        dfs(o[i],d[i]+1,q[i]);
    for (int i=1;i<=n;++i)
        printf("%d\n",col[i]);
    return 0;
}


Measured memory_bytes: 8440
class BinaryIndexedTree:
    def __init__(self, size):
        self.data = [0] * (size+1)
        self.msb = 1 << (size.bit_length()-1)
    
    def _add(self, i, w):
        i += 1
        while i < len(self.data):
            self.data[i] += w
            i += i & -i
    
    def _get_sum(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res

    def __getitem__(self, i):
        """
        [0,i)
        """
        if isinstance(i, slice):
            if i.start is None:
                return self._get_sum(i.stop)
            else:
                return self._get_sum(i.stop) - self._get_sum(i.start)
        else:
            return 0 # fake value
    
    __setitem__ = _add
    
    def bisect_left(self, v):
        """
        return smallest i s.t v <= sum[:i]
        """
        i = 0
        k = self.msb
        while k > 0:
            i += k
            if i < len(self.data) and self.data[i] < v:
                v -= self.data[i]
            else:
                i -= k
            k >>= 1
        return i
    
    def bisect_right(self, v):
        """
        return smallest i s.t v < sum[:i]
        """
        i = 0
        k = self.msb
        while k > 0:
            i += k
            if i < len(self.data) and self.data[i] <= v:
                v -= self.data[i]
            else:
                i -= k
            k >>= 1
        return i
    
    bisect = bisect_right



def solve(C, queries):
    N = len(C)
    bit = BinaryIndexedTree(N)

    last_ind = [None]*(5*10**5 + 1)

    queries = sorted(((r,l-1,i) for i,(l,r) in enumerate(queries)), key=lambda x:x[0])
    qi = 0

    res = [None]*len(queries)

    for i,c in enumerate(C):
        li = last_ind[c]
        if li is not None:
            bit[li] -= 1
        last_ind[c] = i
        bit[i] += 1

        while qi < len(queries) and queries[qi][0] == i+1:
            res[queries[qi][2]] = bit[queries[qi][1]:i+1]
            qi += 1
        if qi == len(queries):
            break

    return res

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

if __name__ == '__main__':
    N,Q = map(int,readline().split())
    C = list(map(int,readline().split()))

    m = map(int,read().split())
    queries = list(zip(m,m))

    print(*solve(C,queries), sep='\n')


Measured memory_bytes: 266316
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
    int N,T;
    cin >> N >> T;
    vector<int> c(N);
    vector<int> t(N);
    int cost = 1001;
    rep(i,0,N){
        cin >> c[i] >> t[i];
        if(t[i]<=T){
            cost = min(c[i], cost);
        }
    }
    if(cost == 1001) cout << "TLE" << endl;
    else cout << cost << endl;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int len = 0;
  int x;
  for(int i=0; i<N; i++){
    cin >> x;
    if(x < abs(K-x)) len += x*2;
    else len += abs(K-x)*2;
  }
  cout << len << endl;
}

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

int main() {
    int n; cin >> n;
    vector<vector<int>> a(4, vector<int>(13));
    //vector<char> s{'S', 'H', 'C', 'D'};

    rep(i, n) {
        char c;
        int num;
        cin >> c >> num;
        num--;
        if (c == 'S')
            a.at(0).at(num)++;
        else if (c == 'H')
            a.at(1).at(num)++;
        else if (c == 'C')
            a.at(2).at(num)++;
        else
            a.at(3).at(num)++;
    }
    rep(i, 4) {
        char c;
        if (i == 0)
            c = 'S';
        else if (i == 1)
            c = 'H';
        else if (i == 2)
            c = 'C';
        else
            c = 'D';

        rep(j, 13) {
            if (a.at(i).at(j) == 0) {
                printf("%c %d\n", c, j + 1);
            }
        }
    }
}


Measured memory_bytes: 3256
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main()
{
    int n,k;cin>>n>>k;
    VL a(n);
    REP(i,n){
        cin>>a[i];
    }

    LL result = INF_LL;
    REP(bit,(1<<n)){
        if(bitset<16>(bit).count() != k){
            continue;
        }
        LL now = 0;
        LL cost = 0;

        REP(i,n){
            if(bit&(1<<i)){
                cost += max(0LL,now-a[i]+1);
                now = max(now+1, a[i]);
            }
            else{
                now = max(now,a[i]);
            }
        }
        result = min(result,cost);
    }
    cout<<result<<endl;
	return;
}

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

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
int fun(int n)
{
    int m=0;
    while(n)
    {
        int yu=n%10;
        m=m*10+yu;
        n=n/10;
    }
    return m;
}
int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    int cnt=0;
    for(int i=A;i<=B;i++)
    {
        if(i%10==0)
            continue;
        else
        {
            int j=fun(i);
            if(j==i)
                cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int ans=0;
        for(int i=1;i<=n;i++){
            if((i+"").length()%2==1)ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 34492
x,y = [int(x) for x in input().split()]
 
if y == 0:
    print(abs(x) + (x>0))
elif x < y < 0:
    print(y-x)
elif 0 < y < x:
    print(x-y+2)
else:
    print(abs(abs(y) - abs(x)) + (x < 0) + (y < 0))

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

ans=[0 for i in range(n+1)]

list_tonari=[[] for i in range(n+1)]

for i in range(m):
  a,b=map(int,input().split())
  list_tonari[a].append(b)
  list_tonari[b].append(a)
  
const=list()
const.append(1)

const_vary=list()


while True:
  const_vary=const
  const=[]
  
  while len(const_vary):
    get=const_vary.pop()
    
    for n in list_tonari[get]:
      if ans[n] ==0:
        ans[n]=get
        list_tonari[n].remove(get)
        const.append(n)
        
  if len(const)==0:
    break
    
print("Yes")
for n in ans[2:]:
  print(n)


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

int main() {
  int N;
  cin >> N;
  //ctor<string> S[N];
  map<string,int> dict;
  map<string,int> dict2;
  
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    dict[S] ++;
  }
  int max =0;
  map<string,int> ::iterator itr;
  for (itr = dict.begin(); itr != dict.end(); ++itr){
        if((itr->second) > max) max= (itr->second);   
    }
  for (itr = dict.begin(); itr != dict.end(); ++itr){
        if((itr->second) == max){
          dict2[(itr->first)]=itr->second;
        }
    }
  
  for (itr = dict2.begin(); itr != dict2.end(); itr++)
{
    cout << itr->first << "\n";
}
   
}

Measured memory_bytes: 37760
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <math.h>
using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> w(n), sum(n, 0);
  for (int i = 0; i < n; i++)
  {
    cin >> w.at(i);
  }
  //sort(w.begin(), w.end());
  for (int i = 0; i < n; i++)
  {

    if (i == 0)
    {
      sum.at(i) = w.at(i);
    }
    else
    {
      sum.at(i) = sum.at(i - 1) + w.at(i);
    }
  }
  int tmp;
  int ans = INT_MAX;
  for (int i = 0; i < n; i++)
  {
    tmp = abs(sum.at(n - 1) - sum.at(i) - sum.at(i));
    ans = min(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;

int n;

int d[200006];
int t[200006];
int m;
int now;
int f;
int k[200006];
int main()
{
	//now=-1:
	cin>>n;
	rep(i,n)cin>>d[i];
	sort(d,d+n);
	cin>>m;
	rep(i,m)
	{
		cin>>k[i];
	}
	sort(k,k+m);
	for(int i=0;i<m;i++)
	{
		while(1)
		{
			if(now>=n)
			{
				f=1;
				break;
			}
			if(k[i]==d[now])
			{
				//break;
				now++;
				break;
			}
			now++;
		}
		if(f==1)
		{
			break;
		}
	}
	if(f==1)
	{
		cout<<"NO"<<endl;
	}
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int>aso(N);
  for(int i=0;i<N;i++){
    cin >> aso.at(i);
  }
  
  int high=0;
  int answer=0;
  for(int i=0;i<N;i++){
    if(aso.at(i) >= high){
      answer++;
      high = aso.at(i);
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(float, input().split()))
dp = [[0] * (n+1) for i in range(n+1)]
dp[0][0] = 1.0
for i in range(n):
    for j in range(0, i+1):
        dp[i + 1][j + 1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j]*(1-p[i])

ans = 0
for i in range((n + 1) // 2):
    ans += dp[n][i]

print(1-ans)


Measured memory_bytes: 254728
var
  c2,c1,c3:char;
  a,b:longint;
begin
  readln(a,c1,c2,c3,b);
  if (c2='-') then begin
    writeln(a-b);
    exit;
  end
  else begin
    writeln(a+b);
    exit;
  end;
end.
  

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

public class A {
    public static void Main(){
        string[] numbers = Console.ReadLine().Split(' ');
        List<int> A = new List<int>();
        for (int i=0;i<3;i++)
        {
            A.Add(int.Parse(numbers[i]));
        }
        int c = A.Distinct().Count();
        if (c == 2)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13152
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for (int i = 0; i < 1000; i++) {
        string num = to_string(i);
        if (0 <= i && i <= 9) num = "00" + to_string(i);
        if (10 <= i && i <= 99) num = "0" + to_string(i);
        int find = 0;
        for (int j = 0; j < n; j++) {
            if (s[j] == num[find]) find++;
            if (find == 3) break;
        }
        if (find == 3) cnt++;
    }
    cout << cnt << endl;
}


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

class Main{
		public static void main(String args[]) throws IOException{
			Scanner scan = new Scanner(System.in);
			char[] buf = new char[20];

			int n1,n2;
			while(scan.hasNext()){
				String str1 = scan.next();
				buf = str1.toCharArray();
			}
			for(int i = buf.length-1;i>=0;i--){
				System.out.print(buf[i]);
			}
			System.out.print("\n");
	}
}

Measured memory_bytes: 12000
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

pair<int64_t, int64_t> Split(const vector<int64_t> &vec, int left, int right, int64_t offset)
{
    int64_t sum = vec[right] - offset;
    int64_t half = sum / 2;

    int index = left;
    int power = (1 << 25);

    while (power > 0) {
        int next_index = index + power;
        power >>= 1;

        if (next_index < right && vec[next_index] - offset <= half) {
            index = next_index;
        }
    }

    if (index + 1 < right) {
        int64_t curr_diff = abs(vec[index] - offset - (vec[right] - vec[index]));
        int64_t next_diff = abs(vec[index + 1] - offset - (vec[right] - vec[index + 1]));

        if (next_diff < curr_diff) {
            index += 1;
        }
    }

    int64_t sum_left = vec[index] - offset;
    int64_t sum_right = vec[right] - vec[index];

    return {sum_left, sum_right};
}

int64_t Diff(const vector<int64_t> &vec, size_t mid)
{
    auto left = Split(vec, 0, mid, 0);
    auto right = Split(vec, mid + 1, vec.size() - 1, vec[mid]);

    auto big = max(max(left.first, left.second), max(right.first, right.second));
    auto small = min(min(left.first, left.second), min(right.first, right.second));

    return big - small;
}

int64_t Solve(vector<int64_t> &vec)
{
    for (size_t i = 1; i < vec.size(); i += 1) {
        vec[i] += vec[i - 1];
    }

    int64_t res = (1LL << 50);
    for (size_t i = 1; i + 2 < vec.size(); i += 1) {
        res = min(res, Diff(vec, i));
    }
    return res;
}

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

    vector<int64_t> vec(n);
    for (auto &num : vec) {
        cin >> num;
    }

    auto res = Solve(vec);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
typedef long long ll;


int main(){
    ll K; cin >> K;
    vector<ll> A(K);
    rep(i, 0, K) cin >> A[i];

    ll ub = 1e18, lb = 1;
    
    // 最小の値
    while(ub - lb > 1){
        ll m = (ub + lb) / 2;
        ll tmp = m;
        rep(i, 0, K){
            tmp = tmp - tmp % A[i];
        }
        if(tmp < 2) lb = m;
        else ub = m;
    }
    ll ans_s = ub;
    ub = 1e18, lb = 2;
    while(ub - lb > 1){
        ll m = (ub + lb) / 2;
        ll tmp = m;
        rep(i, 0, K){
            tmp = tmp - tmp % A[i];
        }
        if(tmp > 2) ub = m;
        else lb = m;
    }
    ll ans_b = lb;

    if(ans_b < ans_s){
        cout << -1 << endl;
        return 0;
    }
    /* ll tmp = ans_s;
    rep(i, 0, K){
        tmp = tmp - tmp % A[i];
    }
    if(tmp != 2){
        cout << -1 << endl;
        return 0;
    } */
    cout << ans_s << " " << ans_b << endl;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int K;
  cin >> K;
  int x = 7%K;
  set<int> s;
  int i = 1;
  while (s.count(x) == 0) {
    s.insert(x);
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    x = (x*10+7)%K;
    i++;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 50340
A,B,K = map(int,input().split())
if B - A + 1 <= 2 * K:
    l = list(range(A,B + 1))
else:
    l1 = list(range(A,A + K))
    l2 = list(range(B - K + 1,B + 1))
    l = l1 + l2
for e in l:
    print(e)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int a,b,c,i,sum=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
       if(c%i==0)
            sum++;
    }
    printf("%d\n",sum);
    return 0;
 }

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, lim; cin >> n >> lim;
    VI v(n), w(n);
    FOR(i, 0, n)cin >> v[i] >> w[i];

    VI dp(lim + 1);
    FOR(i, 0, n)eFOR(j, w[i], lim) {
        if (0 < j)chmax(dp[j], dp[j - 1]);
        chmax(dp[j], dp[j - w[i]] + v[i]);
    }
    cout << dp[lim] << "\n";
}


Measured memory_bytes: 3224
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cstring>

#define LL long long 

LL n,x;

LL solve(LL a,LL b) {
	if(!b) return -a;
	return solve(b,a%b)+(a/b)*b*2;
}

int main() {
	scanf("%lld%lld",&n,&x);
	printf("%lld",n+solve(n-x,x));
	return 0;
} 

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

int main(){
    int N,P;cin >> N >> P;
    vector<int> A(N);
    int m = 0;
    for(auto &i:A){
        cin >> i;
        if(i&1) m++;
    }
    if(P==0){
        if(m==0) cout << (1LL<<N) << endl;
        else cout << (1LL<<(N-1)) << endl;
    }else{
        if(m==0) cout << 0 << endl;
        else cout << (1LL<<(N-1)) << endl;
    }
}

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

using namespace std;

const int MAX = 1e+6;

int n;
long long a[MAX];
long long sum = 0;

long long f(long long a, long long b) {
    long long x = a - b;
    if (x < 0) return -x;
    return x;
}

int main() {    
    cin >> n;
    a[0] = 0;
    a[n + 1] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += f(a[i], a[i - 1]);
    }
    sum += f(a[n + 1], a[n]);
    for (int i = 1; i <= n; i++) {
        cout << sum - f(a[i - 1], a[i]) - f(a[i + 1], a[i]) + f(a[i - 1], a[i + 1]) << "\n";
    }
    return 0;
}


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

using namespace std;

int main(){
	while(true){
		int many = 32;
		vector<int> get;
		int a;
		scanf("%d", &a);
		if(!a){
			return 0;
		}
		get.resize(a);
		int i = 0;
		for(int i = 0; i < a; i++){
			scanf("%d", &get[i]);
		}
		bool now_ichiro = true;
		while(many != 0){
			if(now_ichiro){
				many -= (many - 1) % 5;
				now_ichiro = false;
			}
			else{
				many = max(0, many - get[i % a]);
				i++;
				now_ichiro = true;
			}
			printf("%d\n", many);
		}
	}
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007

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

    int a[n];
    ll d=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        d^=a[i];
    }
    for(int i=0;i<n;i++)
        cout<<(d^a[i])<<" ";
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 4400
H,W=(int(i) for i in input().split(' '))
grid=[]
delete_count= 0
pop_count=0
for h in range(H):
  tmp = [char for char in input()]
  if tmp.count('#')!=0:
    grid.append(tmp)
  else:
    delete_count += 1
for w in range(W):
  check = 0
  for h in range(H-delete_count):
    if grid[h][w-pop_count]=='#':
      check = 1
  if check == 0:
    for h in range(H-delete_count):
      del grid[h][w-pop_count]
    pop_count+=1
for h in range(H-delete_count):
  grid[h]=''.join(grid[h])
  print(grid[h])

Measured memory_bytes: 3064
import math

N = int(input())
x = []
y = []
for _ in range(N):
  u,v = map(int,input().split())
  x.append(u)
  y.append(v)

ans = 0.0
for deg in range(360):
  rad = deg*math.pi/180.0
  u,v = math.cos(rad),math.sin(rad)
  
  x0,y0 = 0.0,0.0
  for n in range(N):
    if 0.0<=u*x[n]+v*y[n]:
      x0 += x[n]
      y0 += y[n]
  ans = max(ans,math.sqrt(x0**2+y0**2))
print(ans)


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

int main()
{
	int a,b,c,d;
	while(cin>>a>>b>>c>>d)
	{
		int A,B,C;
		A=abs(a-b);
		B=abs(b-c);
		C=abs(c-a);
		if(C<=d)
			cout<<"Yes"<<endl;
		else if(A<=d&&B<=d)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
			
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())

ans = 0
List = []
for i in range(N):
    A = int(input())
    List.append(A)
    
def func(a, b):
    ret = 0
    for i in range(a, b + 1):
        ret += List[i] // 2
        if List[i] % 2 and i != b:
            List[i + 1] -= 1
            ret += 1
    return ret

left = 0
for right in range(N):
    if List[right] == 0:
        ans += func(left, right - 1)
        left = right + 1
    
ans += func(left, N - 1)

print(ans)

Measured memory_bytes: 7076
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;
int n, k;
int v[55];

int main(){
    cin >> n >> k;
    REP(i,n)cin >> v[i];
    int ans=0;
    REP(i, n + 1)
    {
        REP(j, n+1)
        {
            vector<int> vec;
            if (i + j <= n && i + j <= k){
                REP(l, i) vec.push_back(v[l]);
                REP(l, j) vec.push_back(v[n-1-l]);

                sort(vec.begin(), vec.end());
                REP(l,k-i-j) if(l < (int)vec.size() && vec[l]<0)vec[l]=0;
                //cout << "SIZE" << (int)vec.size() << endl;
                int tmp=0;
                REP(l, (int)vec.size())tmp+=vec[l];
                ans = max(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}

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

const int N = 2000;

int n, k, q, a[N];

int main()
{
    scanf("%d%d%d", &n, &k, &q);
    for (int i = 0; i < n; ++ i) {
        scanf("%d", a + i);
    }
    int result = INT_MAX;
    for (int mi_idx = 0; mi_idx < n; ++ mi_idx) {
        int mi = a[mi_idx];
        int last = -1;
        std::vector<int> candidates;
        for (int i = 0; i <= n; ++ i) {
            if (i == n || a[i] < mi) {
                std::vector<int> elems;
                for (int j = last + 1; j < i; ++ j) {
                    elems.push_back(a[j]);
                }
                std::sort(elems.begin(), elems.end());
                for (int j = 0; j < (i - last - 1) - (k - 1); ++ j) {
                    candidates.push_back(elems[j]);
                }
                last = i;
            }
        }
        if ((int)candidates.size() >= q) {
            std::sort(candidates.begin(), candidates.end());
            result = std::min(result, candidates[q - 1] - candidates[0]);
        }
    }
    printf("%d\n", result);
}

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

template <typename T> inline void read(T& x)
{
    int f = 0, c = getchar(); x = 0;
    while (!isdigit(c)) f |= (c == '-'), c = getchar();
    while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
    if (f) x = -x;
}
template <typename T, typename... Args>
inline void read(T& x, Args&... args)
{
    read(x); read(args...);
}
template <typename T> void write(T x)
{
    if (x < 0) x = -x, putchar('-');
    if (x > 9) write(x / 10);
    putchar(x % 10 + 48);
}
template <typename T> void writeln(T x) { write(x); puts(""); }
template <typename T> inline bool cmin(T& x, const T& y)
{ return y < x ? (x = y, true) : false; }
template <typename T> inline bool cmax(T& x, const T& y)
{ return x < y ? (x = y, true) : false; }

#define LL long long
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
#define dwn(i, a, b) for (int i = a; i >= b; -- i)
#define ptc putchar
#define pii pair<int, int>
#define fi first
#define se second

using namespace std;

const int N = 1e6 + 5;
const double eps = 1e-20;
const int INF = 0x7fffffff;
const LL mod = 1e9 + 7;

int n;

void main_solve()
{
    read(n);
    for (int i = 1; i <= 9; ++ i)
    {
        for (int j = 1; j <= 9; ++ j)
        {
            if (i * j == n)
            {
                puts("Yes");
                return ;
            }
        }
    }
    puts("No");
    return ;
}

signed main()
{
    int T = 1;
    while (T --)
    {
        main_solve();
    }
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict


def main():
    n, k, q = map(int, input().split())
    alist = [int(input()) for _ in range(q)]
    scores = [0] * n

    for winner in alist:
        scores[winner - 1] += 1

    for score in scores:
        if score - q + k > 0:
            print('Yes')
        else:
            print('No')


main()


Measured memory_bytes: 8912
#include <iostream>

using namespace std;

int main()
{
    string s;
    int x=0,c=0;
    cin>>s;
    if(s[0]=='A'){
    for(int i=1;i<s.size();i++){
        if(s[i]=='C'){
            c++;
        }
    }
    if(c==0 || c>1){
        cout<<"WA";
    }
    else{
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C'){
            c=0;
            x=i;
            break;
        }
    }
    for(int i=0;i<s.size();i++){
        if (i==0 || i==x){
            continue;
        }
        else if(i!=0||i!=x){
             if(isupper(s[i])){
                x=1;
                break;
             }

        }
    }
    if(x!=1 && c==0){
                cout<<"AC";
             }
    else if(x==1){
        cout<<"WA";
    }
}}
    else{
        cout<<"WA";
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int a[3];
int num[6];
//void judge(int *a)
//{
//	int t;
//	if (a[0] < a[1]) { t = a[0]; a[0] = a[1]; a[1] = t; }
//	if (a[1] < a[2]) { t = a[1]; a[1] = a[2]; a[2] = t; }
//	if (a[0] < a[1]) { t = a[0]; a[0] = a[1]; a[1] = t; }
//}
int main(void)
{
	int sum = 0, min;
	for (int i = 0; i < 3; i++)
	{
		scanf("%d",&a[i]);
	}
	//judge(a);
	min = 1000;
	num[0] = abs(a[1] - a[0]) + abs(a[2] - a[1]);
	num[1] = abs(a[2] - a[0]) + abs(a[1] - a[2]);
	num[2] = abs(a[0] - a[1]) + abs(a[2] - a[0]);
	num[3] = abs(a[2] - a[1]) + abs(a[0] - a[2]);
	num[4] = abs(a[0] - a[2]) + abs(a[1] - a[0]);
	num[5] = abs(a[1] - a[2]) + abs(a[0] - a[1]);
	for (int i = 0; i < 6; i++)
	{
		if (min > num[i]) min = num[i];
	}
	printf("%d", min);
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner stdIn = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int a = stdIn.nextInt();
		long b = stdIn.nextLong();
		long n = stdIn.nextLong();
		long max = 0;
		
		
		/*long cnt = 0;
		while(true) {
			cnt++;
			if(a*cnt/7>=1) {
				break;
			}
		}*/
		long cnt = Math.min(n, b-1);
		max =Math.max(max,(long)Math.floor(a*cnt/b) - a*(long)Math.floor(cnt/b));
		
		
		/*for(long i = 1; i <=cnt; i++) {
			long  d = (long)Math.floor(a*i/b) - a*(long)Math.floor(i/b);
			if(max < d) {
				max = d;
			}
		
			
		}*/
		
		out.println(max);

		out.flush();
	}

}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 32444
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
    long long n, x, res = 0;
    vector<long long> burgerBuns(51);
    vector<long long> burgerPatty(51);

    cin >> n >> x;

    burgerBuns[0] = 1;
    burgerPatty[0] = 1;

    for (long long i = 1; i <= 50; ++i)
    {
        burgerBuns[i] = burgerBuns[i - 1] * 2 + 3;
        burgerPatty[i] = burgerPatty[i - 1] * 2 + 1;
    }

    while (n > 0 && x > 0)
    {
        x--;
        n--;
        if (x >= burgerBuns[n])
        {
            x -= burgerBuns[n];
            res += burgerPatty[n];
            if (x == 0)
            {
                break;
            }
            x--;
            res++;
            if (x >= burgerBuns[n])
            {
                res += burgerPatty[n];
                break;
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            C();
        }

        static void C()
        {
            var NK = ReadSplitInt();
            var N = NK[0];
            var K = NK[1];
            var h = ReadSplitInt();
            var dp = new int[N];
            for (var i = 0; i < N; i++) dp[i] = int.MaxValue;

            Func<int, int> func = null;

            func = i =>
            {
                if (dp[i] < int.MaxValue) return dp[i];
                if (i == 0) return 0;
                if (i == 1)
                {
                    dp[1] = func(i - 1) + Abs(h[i] - h[i - 1]);
                    return dp[1];
                }
                for (int k = 1; k <= K; k++)
                {
                    if (i - k >= 0)
                    {
                        var a = Min(dp[i], func(i - k) + Abs(h[i] - h[i - k]));
                        dp[i] = a;
                    }
                }
                return dp[i];
            };

            Println(func(N - 1));
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

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

#define int long long

signed main()
{
    int n, m, p;
    while(cin>>n>>m>>p, n) {
        int t = 0;
        int sum = 0;
        for(int i=1; i<=n; ++i) {
            int a;
            cin >> a;
            sum += a*100;
            if(i==m) t = a;
        }

        sum = sum - sum*p/100;
        if(t==0) cout << 0 << endl;
        else cout << sum/t << endl;
    }
    return 0;
}

Measured memory_bytes: 2984
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long N, M; cin >> N >> M;

    if (N == 1 and M == 1) cout << 1;
    else if (N == 1 or M == 1) cout << N*M-2;
    else cout << (N-2)*(M-2);
    cout << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

const int N = 1e5 + 5;
int W[N], V[N];
ll memo[2][N];
int n, w;

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

	cin >> n >> w;

	rep(i, 0, n)
		cin >> W[i] >> V[i];

	ll res = 0;
	erep(i, 1, 1e5)
		memo[n & 1][i] = 1e10;

	for (int i = n - 1; i >= 0; i--)
	{
		int curr = i & 1, nxt = (curr & 1) ^ 1;

		for (int j = 1e5; j > 0; j--)
		{
			ll &ret = memo[curr][j];
			ret = 1e10;
			ret = min(ret, memo[nxt][j]);
			if (j - V[i] >= 0)
				ret = min(ret, W[i] + memo[nxt][j - V[i]]);
		}
	}

	erep(i, 0, 1e5)
		if (memo[0][i] <= w)
			res = i;
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1792
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
AB = [lr() for _ in range(N)]
AB.sort(key=lambda x: x[1])
answer = 'Yes'
time = 0
for i in range(N):
    if time + AB[i][0] > AB[i][1]:
        answer = 'No'
    time += AB[i][0]

print(answer)


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

const ll INF = 1e18 + 10;
 
int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll res = -INF;
    chmax(res, a * c);
    chmax(res, a * d);
    chmax(res, b * c);
    chmax(res, b * d);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	ll a,b;
	cin>>a>>b;
	cout<<(a*a)-b<<endl;
	
}

Measured memory_bytes: 256
s = input()
k = int(input())

from itertools import groupby

n=len(s)
cnt =0

gp = groupby(s)

Keys=[]
values=[]
for key,value in gp:
    Keys.append(key)
    values.append(len(list(value)))

if len(Keys)==1:
    print(values[0]*k//2)
    exit(0)

if k==1:
    for i in values:
        cnt+=i//2
    print(cnt)
    exit(0)
    
if k>=2:
    if Keys[0]==Keys[-1]:
        values2=list(reversed(values))

        m=len(values)

        for i in range(m-1):
            if values[i]>=2:
                cnt+=values[i]//2
            if values2[i]>=2:
                cnt+=values2[i]//2
        
        cnt+= (k-1) * ((values[0]+values[-1])//2)

        for j in range(m):
            if j==0 or j==m-1:
                continue
            else:
                cnt+= (k-2)*(values[j]//2)

        print(cnt)
        exit(0)

for i in values:
    if i>1:
        cnt += k*(i//2)


print(cnt)


Measured memory_bytes: 3064