akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

typedef long long ll;

ll MOD = 998244353;

ll N,M,K;

ll factorial[200001];

ll power(ll a, ll b) {
  if(b == 0L) return 1L;
  ll foo = power(a,b/2);
  if(b%2 == 0) return (foo*foo)%MOD;
  return ((foo*foo)%MOD*a)%MOD;
}

ll inv(ll a) {
  return power(a, MOD-2);
}

ll choose(ll N, ll K) {
  if (K > N) return 0L;
//  cout << N << " choose " << K << endl;
//  cout << factorial[N] << endl;
  return (((factorial[N]*inv(factorial[N-K]))%MOD)*inv(factorial[K]))%MOD;
}

ll F(ll N, ll K) {
  if (K >= N) return 0L;
//  cout << N-1 << " choose " << K << " =" << choose(N-1,K) << endl;
  return (((choose(N-1,K)*M)%MOD)*power(M-1,N-K-1))%MOD;
}

int main() {
  cin >> N >> M >> K;
  factorial[0] = 1L;
  for(ll i = 1; i < 200001;i++) factorial[i] = (i*factorial[i-1])%MOD;

  ll ans = 0;
  for(ll k = 0; k <= K; k++) {
//    cout << "K = " << k << endl;
//    cout << "F(N,k)=" << F(N,k) << endl;
    ans += F(N,k); ans %= MOD;
  }
  cout << ans << endl;
}



Measured memory_bytes: 5204
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import Control.Monad

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

medians :: [Int] -> (Int, Int)
medians xs = (xs' !! (half - 1), xs' !! half)
  where xs' = sort xs
        half = length xs `div` 2

main :: IO ()
main = do
  getLine
  xs <- getInts
  let (m1, m2) = medians xs
  forM_ xs $ \x ->
  	print $ if x < m2 then m2 else m1


Measured memory_bytes: 52476
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> p(N);
    int cnt = 0;
    REP(i, N) {
        cin >> p[i];
        if (p[i] != i + 1) {
            cnt++;
        }
    }
    if (cnt <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

int main(){
	while(true){
		int x,y;
		char c;
		cin >> x >> c>>y;
		
		if(c=='?')break;
		int z;
		switch(c){
			case '+':
				z=x+y;
				break;
			case '-':
				z=x-y;
				break;
			case '*':
				z=x*y;
				break;
			case '/':
				z=x/y;
				break;
		
		}
		cout<< z << endl;
	}
	
	return 0;
}



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

int N, K;
int A[200000];

bool f(int m){
	int c = 0;
	rep(i, N) c += (A[i] - 1) / m;
	return c <= K;
}

int main(){
	cin>>N>>K;
	rep(i, N) cin>>A[i];
	int ng = 0, ok = 1e9; // (ng,ok] = (l,r]
	while(ok - ng > 1) if(int m=(ok+ng)/2; f(m)) ok = m; else ng = m;
	cout<< ok <<endl;
}


Measured memory_bytes: 4320
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  int X, Y;
  scanf("%d %d", &X, &Y);

  if (X % Y == 0) {
    puts("-1");
  } else {
    printf("%lld\n", X*1LL*Y + X);
  }
  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)

int K;
string S;

int main(){
	fast;
	
	cin>>K>>S;
	
	if (S.size() <= K) cout<<S;
	else{
		string ans = "";
		FOR(i,0,K-1) ans += S[i];
		ans = ans + "...";
		cout<<ans;
	}
}



Measured memory_bytes: 3660
local S_dash=io.read()
local S=""
local T=io.read()

for i=#S_dash-#T+1,1,-1 do
    local subS=S_dash:sub(i,#T+i-1)
    local flag=true
    for j=1,#T do
        if subS:sub(j,j)~="?" and subS:sub(j,j)~=T:sub(j,j) then
            flag=false
        end
    end
    if flag then
        if S=="" then
            S=S_dash:sub(1,i-1)..T..S_dash:sub(#T+i)
            S=S:gsub("?","a")
        else
            local T=S_dash:sub(1,i-1)..T..S_dash:sub(#T+i)
            T=T:gsub("?","a")
            if S>T then
                S=T
            end
        end
    end
end

print(#S>0 and S or "UNRESTORABLE")

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long int
 
int main() {
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(ll i=1;i<n;i++){
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    ll ans=max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
    cout<<ans<<"\n";
}

Measured memory_bytes: 8220
#include <iostream>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    long long r=n%(a+b);
    long long c=(n-r)/(a+b);
    if(r<=a)cout<<c*a+r<<'\n';
    else cout<<(c+1)*a<<'\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int min = 0;
		int max = 0;
		long amount = 0;

		for(int i = 0; i < n; i++){
			int x = scan.nextInt();
			if(i == 0){
				min = x;
				max = x;
				amount = x;
			}else{
				if(x < min){
					min = x;
				}else if(x > max){
					max = x;
				}
				amount = amount + x;
			}
		}
		System.out.println(min + " " + max + " " + amount);
	}
}

Measured memory_bytes: 41780
#include <iostream>

#include <atcoder/dsu.hpp>

using namespace std;
using namespace atcoder;

typedef unsigned long long ull;

ull N, M;


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

	dsu d(N);

	for (ull i = 0; i < M; i++) {
		ull a, b;
		cin >> a >> b;
		d.merge(a-1, b-1);
	}

	vector<vector<int>> v = d.groups();

	cout << (v.size()-1) << endl;
}

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

int main()
{
    int N;
    scanf("%d", &N);
    char si[100000];
    char s1[] = "AC", s2[] = "WA", s3[] = "TLE", s4[] = "RE";
    int c0=0, c1=0, c2=0, c3=0;
    while(N--)
    {
        scanf("%s", &si);
        if(strcmp(si, s1)==0)
        {
            c0++;
        }
        else if(strcmp(si,s2)==0)
        {
            c1++;
        }
        else if(strcmp(si,s3)==0)
        {
            c2++;
        }
        else if(strcmp(si,s4)==0)
        {
            c3++;
        }
    }
    printf("AC x %d\n", c0);
    printf("WA x %d\n", c1);
    printf("TLE x %d\n", c2);
    printf("RE x %d\n", c3);

    return 0;
}




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

long long gcd(long long a, long long b)
{
    if (a < b)
    {
        swap(a, b);
    }
    if (b == 0)
    {
        return a;
    }

    long long mod = a % b;
    a = b;
    b = mod;

    return gcd(a, b);
}

long long lcm(long long a, long long b)
{
    if (a < b)
    {
        swap(a, b);
    }

    return (a / gcd(a, b)) * b;
}

int main()
{
    int N; cin >> N;
    long long T[105] = {};
    for (int n = 1; n <= N; n++)
    {
        cin >> T[n];
    }

    long long ans = 1;
    for (int n = 1; n <= N; n++)
    {
        ans = lcm(ans, T[n]);
    }

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

Measured memory_bytes: 256
def main(a: int, b: int):
    x, y = 1, 1

    while (a * x) != (b * y):
        if (a * x) > (b * y):
            y += 1
        else:
            x += 1

    print(a * x)


if __name__ == "__main__":
    a, b = map(int, input().split())

    main(a, b)


Measured memory_bytes: 2940
n,m=map(int,input().split())
k=[]
for i in range(m):
  a,b=map(int,input().split())
  c=sum(map(lambda x:2**(int(x)-1),input().split()))
  k.append((a,c))

dp=[2**100 for i in range(2**n)]
dp[0]=0
for i in k:
  for j in range(2**n):
    dp[i[1]|j]=min(dp[i[1]|j],dp[j]+i[0])
if dp[-1]==2**100:
  print(-1)
else:
  print(dp[-1])

Measured memory_bytes: 74984
#include <iostream>

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 revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long A, B, K; cin >> A >> B >> K;

    if (A-K >= 0)
        A = A-K;
    else {
        B = B-(K-A);
        if (B < 0) B = 0;
        A = 0;
    }

    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }


#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;


typedef long long ll;

const int max_n = 40;
const int max_a = max_n * 10;
const int max_b = max_n * 10;

int dp[max_n+1][max_a+1][max_b+1];


int main() {
  ios::sync_with_stdio(false);

  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;

  vector<int> a(N), b(N), c(N);
  for(int i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }

  // dp[i][j][k] := i番目までの薬品を使い、薬品A が j グラム、薬品B が k グラムとなるような物質を作ることにかかる最小のお金
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= max_a; j++) {
      for(int k = 0; k <= max_b; k++) {
        dp[i][j][k] = inf;
      }
    }
  }

  // for(int i = 0; i <= N; i++) {
  //   dp[i][0][0] = 0;
  // }
  dp[0][0][0] = 0;

  for(int i = 1; i <= N; i++) {
    for(int j = 0; j <= max_a; j++) {
      for(int k = 0; k <= max_b; k++) {
        if( (a[i-1] <= j) && (b[i-1] <= k) ) {
          dp[i][j][k] = min( dp[i-1][j][k],  dp[i-1][ j - a[i-1] ][ k - b[i-1] ] + c[i-1]);
        } else {
          dp[i][j][k] = dp[i-1][j][k];
        }
      }
    }
  }

  int ans = inf;
  for(int j = 1; j <= max_a; j++) {
    for(int k = 1; k <= max_b; k++) {
      if( (j * Mb == k * Ma) ) {
        ans = min(ans, dp[N][j][k]);
      }
    }
  }

  cout << (ans == inf ? -1 : ans )  << "\n";

  return 0;
}


Measured memory_bytes: 25984
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
long long y(int k) {
	if (k == 0)return 1;
	else return 2 * y(k - 1);
}
int main() {
	queue<long long>l;
	int n; cin >> n;
	for (long long i = 0; i < y(n); i++){
		long long p;
		cin >> p;
		l.push(p);
	}
	while (l.size() != 1) {
		long long a = l.front();
		l.pop();
		long long b = l.front();
		l.pop();
		if (a > b)l.push(a - b);
		else if (a == b)l.push(a);
		else if (a < b)l.push(b - a);
	}
	cout << l.front() << endl;
	char c; cin >> c;
}

Measured memory_bytes: 2432
from sys import stdin
N = int(stdin.readline().rstrip())
S = (stdin.readline().rstrip())
w = [0] * N
e = [0] * N

W_c = 0
E_c = 0
for ind,i in enumerate(S):
    if i == "E":
        E_c += 1
    
    e[ind] = E_c

for ind,i in enumerate(reversed(S)):
    if i == "W":
        W_c += 1
   
    w[ind] = W_c

w = list(reversed(w))
ans = [0] * N
w_end = w[0]
e_end = e[-1]

for j in range(N):
    ans[j] = (e_end - e[j]) + (w_end - w[j])
print(min(ans))

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

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,Q;
	cin >> N >> Q;
	vector<vector<int>> to(N);
	vector<int> ans(N),cnt(N);
	rep(i,N-1){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	rep(i,Q){
		int p,x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	queue<int> q;
	vector<bool> v(N);
	v[0] = 1;
	q.push(0);
	while(!q.empty()){
		int now = q.front();q.pop();
		for(int j=0;j<to[now].size();j++){
			int next = to[now][j];
			if(v[next])continue;
			v[next] = 1;
			ans[next] += ans[now];
			q.push(next);
		}
	}
	rep(i,N)cout << ans[i] <<" ";
	cout << endl;
}

Measured memory_bytes: 16372
#include <bits/stdc++.h>
using namespace std;
int main(){
  string h;
  cin>>h;
  for(int i=0;i<h.size();i++){
   if(h[i]=='A'&&h[i+1]=='C') {
     cout<<"Yes"<<endl;
     return 0;
   }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1e18+10
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int a[10000],i;
int32_t main() {
	int n;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int x=0,y=0;
	for(i=0;i<n;i++)
		if(i&1)
			x+=a[i];
		else y+=a[i];
	cout<<abs(x-y);
}


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

int main(){
  int n, m;
  cin >> n >> m;
  map<int,int> mp;
  ll tot = 0, ans = 0;
  ++mp[0];
  for(int i=0; i<n; ++i){
    int x;
    cin >> x;
    tot += x;
    tot %= m;
    ans += mp[tot];
    ++mp[tot];
  }
  cout << ans << endl;
}

Measured memory_bytes: 6456
#include<bits/stdc++.h>
#define SYNC ios::sync_with_stdio(false); cin.tie(NULL); cerr.tie(NULL);
using namespace std;
int main(){
  int a,b,sum=0;
  cin >> a >> b;
  int diff=b-a;
  int p[1000],ans=0;
  for(int i=1;i<1000;i++){
    sum+=i;
    p[i]=sum;
  }
  for(int i=2;i<1000;i++){
    if(p[i]-p[i-1]==diff){
      ans=p[i-1]-a;
      break;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    ll l, r;
    cin >> l >> r;
    ll ans = 10000;
    for (ll i = l; i <= min(l + 2019, r); i++) {
        for (ll j = i + 1; j <= min(l + 2019, r); j++) {
            ans = min(ans, (i * j) % 2019);
        }
    }
    OUT(ans);
}


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

int main(){
  ll N,A,B,C;
  cin>>N>>A>>B>>C;
  map<char,ll>mp;
  mp['A']=A;
  mp['B']=B;
  mp['C']=C;
  vector<char>ans(N);
  int flag=0;
  queue<string>qu;
  
  rep(i,N){
  	string s;
    cin>>s;
  	qu.push(s);
  }
  ll sum=A+B+C;
  if(sum!=2){
  	rep(i,N){
      string s=qu.front();qu.pop();
      if(mp[s[0]]==0&&mp[s[1]]==0){flag=1;break;}
      if(mp[s[0]]>mp[s[1]]){
      	mp[s[0]]--;mp[s[1]]++;
        ans[i]=s[1];
      }
      else{
      	mp[s[1]]--;mp[s[0]]++;
        ans[i]=s[0];
      }
  	}
  }
  if(sum==2){
    rep(i,N){
    	string s=qu.front();qu.pop();
    	if(mp[s[0]]==0&&mp[s[1]]==0){flag=1;break;}
      	if(mp[s[0]]==1&&mp[s[1]]==1){
        	string t=qu.front();
        	if(t[0]==s[0]||t[1]==s[0]){
            	mp[s[0]]++;mp[s[1]]--;
              	ans[i]=s[0];
            }	
          	else{
              mp[s[1]]++;mp[s[0]]--;
              ans[i]=s[1];
            }
        }
      	else{
        	if(mp[s[0]]>mp[s[1]]){
      		  mp[s[0]]--;mp[s[1]]++;
        	  ans[i]=s[1];
      		}
      		else{
      		  mp[s[1]]--;mp[s[0]]++;
        	  ans[i]=s[0];
      		}
        }
    }//rep	
  }//if
  
  if(flag==1){cout<<"No";}
  else{
    cout<<"Yes"<<endl;
    rep(i,N){cout<<ans[i]<<endl;}
  }
}

Measured memory_bytes: 6876
# -*- coding: utf-8 -*-


def main():
    from math import sqrt
    from math import ceil

    a, b = map(str, input().split())
    number = int(a + b)

    if ceil(sqrt(int(number))) ** 2 == int(number):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}


//ミョ(-ω- ?)
int main() {
    int n;
    cin >> n;
    vector<ll> p(n+1,0);
    repp(i,2,n+1){
        auto a = prime_factorize(i);
        for(auto b : a)p[b.first] += b.second;
    }
    ll res = 1;
    repp(i,2,n+1){
        res *= p[i]+1;
        res%=MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
	int n;
	int x, y;
	long long A = 1, B = 1;
	long long result;
	
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d %d", &x, &y);
		long long  m = max((A+x-1)/x, (B+y-1)/y);
		A = m*x;
		B = m*y;
	}
	result = A+B;
	printf("%lld\n", result);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++)

int n, k;
vector<int> d(10);
vector<int> flag;
int ans = 10000000;

bool check(int num) {
    if(num >= n) {
        ans = min(ans, num);
        //cout << "ans_w: " << num << endl;
        return true;
    }
    else {
        return false;
    }
}

void dfs(int num) {
    //cout << num << endl;
    
    /*
    rep(i, 0, flag.size()) {
        //num *= 10;
        rep(j, 0, flag.size()) {
            if(num+flag[j] == 0) {
                continue;
            }
            
            if(check(num+flag[j])) {
                continue;
            }
            else {
                dfs(num+flag[j]);
            }
        }
    }
    */

    rep(i, 0, flag.size()) {
        if(num*10+flag[i] == 0) {
            continue;
        }
        if(check(num*10+flag[i])) {
            return;
        }
        dfs(num*10+flag[i]);
    }
}

int main() {
    
    cin >> n >> k;
    rep(i, 0, k) {
        int tmp;
        cin >> tmp;
        d[tmp] = 1;
    }

    int p = 0;
    for(int i = 0; i < d.size(); i++) {
        if(d[i] == 0) {
            flag.push_back(i);
        }
    }

    dfs(0);
    //cout << "ans: " << ans << endl;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>

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

    long int n;

    while (std::cin >> n, n++) {
        std::array<long int, 7> arr{{}};
        int age;

        for (; --n;) {
            std::cin >> age;
            age = (age < 70 ? age : 60);
            ++arr[age / 10];
        }
        
        for (const auto& cnt : arr) {
            std::cout << cnt << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ll long long
#define ull unsigned long long
#define ld long double
#define mx 100005
#define mod 1000000007
#define fr first
#define cti(a) (a-48)
#define itc(a) char(a+48)
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld e, ld b){ return log(e)/log(b); }

void solve()
{
    string s1;
    cin >> s1;
    (s1[2] == s1[3] && s1[4] == s1[5]) ? cout << "Yes\n" : cout << "No\n";
}

int main()
{
   fast;
   int t=1;
   //cin >> t;
   while(t--) solve();

   return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a,bbb=b;i<=bbb;++i)
#define repd(i,a,b) for(register int i=a,bbb=b;i>=bbb;--i)
#define reps(s) for(register int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define gmn(a,b) a=min(a,b)
#define gmx(a,b) a=max(a,b)
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
typedef double db;
const ll inf=4e18;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline db qd(){
    char c=getchar();int flag=1;double ans=0;
    while((!(c>='0'&&c<='9'))&&c!='-') c=getchar();
    if(c=='-') flag=-1,c=getchar();
    while(c>='0'&&c<='9') ans=ans*10+(c^48),c=getchar();
    if(c=='.'){c=getchar();for(register int Bit=10;c>='0'&&c<='9';Bit=(Bit<<3)+(Bit<<1)) ans+=(double)(c^48)*1.0/Bit,c=getchar();}
    return ans*flag;
}
//start!

int main()
{
	ll a=ql(),b=ql(),c=ql(),d=ql();
	ll ans=-inf;
	gmx(ans,a*c),gmx(ans,a*d),gmx(ans,b*c),gmx(ans,b*d);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3760
N = int(input())
p = list(map(int,input().split()))
for i in range(N):
    if p[i] != i+1:
        a = p[i]
        p[i] = i+1
        p[a-1] = a
        break
if p == [i for i in range(1,N+1,1)]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int maxN = 407;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

inline void NIE() {puts("NO"); exit(0);}
inline void TAK() {puts("YES"); exit(0);}

int n, H;
int in[maxN], out[maxN];
bool occ[maxN];

int pt(int kd, int x) {return kd * H + x;}

namespace dsu {
	int fa[maxN], hav[maxN];

	void init(int n) {
		rep (i, 1, n) fa[i] = i, hav[i] = 0;
	}

	inline int find(int x) {return fa[x] == x ? x : fa[x] = find(fa[x]);}

	void merge(int x, int y) {
		x = find(x), y = find(y);
		if (x != y) fa[x] = y;
	}

	inline int& ok(int x) {return hav[find(x)];}
}

int main() {
	n = ri(); H = ri();
	dsu::init(2 * H);
	rep (i, 1, n) {
		int a = ri(), b = ri(), c = ri(), d = ri();
		int lf = (c == 0) ? pt(0, a) : pt(1, c);
		int rt = (d == 0) ? pt(1, b) : pt(0, d);
		occ[lf] = occ[rt] = 1;
		++out[lf], ++in[rt];
		dsu::merge(lf, rt);
	}

	rep (i, 1, H) {
		int x = pt(0, i);
		if (occ[x] && in[x] > out[x]) NIE();
		if (occ[x] && in[x] < out[x]) dsu::ok(x) = 1;
		x = pt(1, i);
		if (occ[x] && in[x] < out[x]) NIE();
	}

	rep (i, 1, H) {
		int x = pt(0, i);
		if (occ[x] && !dsu::ok(x)) NIE();
		x = pt(1, i);
		if (occ[x] && !dsu::ok(x)) NIE();
	}

	TAK();
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<long long> A(n); 
    long long B=0;
    for(int i=0;i<n;i++){
        cin >> A[i];
        B ^=A[i];
    }

    for(int i=0;i<n;i++){
        cout << (B^A[i]) << endl;
    }
}

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

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

  int64_t a, b;
  n -= n / k * k;
  a = n;
  while(1) {
    n -= k;
    if (abs(n) > a) {
      b = a;
      break;
    }else {
      a = abs(n);
    }
  }

  cout << b << endl;
}

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

int main() {
  int N,K,w=0;
  cin >> N >> K;
  vector<int> l(N);
  for(int i=0; i<N; i++){
    cin >> l.at(i);
  }
  sort(l.begin(),l.end(),greater<int>());
  for(int i=0; i<K; i++){
    w+=l.at(i);
  }
  cout << w << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    ll ans = 0;
    return ans;
}

int main(){
    ll N,A,B; cin >> N >> A >> B;
    if((B-A)%2 == 0){print((B-A)/2); return 0;}
    
    print(min({B-1,N-A,A-1+(B-A-1)/2 + 1,N-B+(B-A-1)/2 + 1}));
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  ll x,k,d;
  cin >> x >> k >> d;

  //回数が十分ではないとき
  if(k < abs(x)/d){
    ll ans = (ll)abs(x) - k*d;
    cout << ans << endl;
    return 0;
  }

  ll c = abs(x)/d;
  debug(c);
  ll e_pos = abs(x) - c*d;
  ll o_pos = abs(e_pos - d);

  k -= c;
  if(k%2 == 0) cout << e_pos << endl;
  else  cout << o_pos << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t1,t2,a1,a2,b1,b2;
int main()
{
    scanf("%lld%lld%lld%lld%lld%lld",&t1,&t2,&a1,&a2,&b1,&b2);
    ll a=a1-b1,b=a2-b2;
    if(a<0) a*=-1,b*=-1;
    ll k=t1*a+t2*b;
    if(k==0) {printf("infinity\n");return 0;}
    if(k>0){printf("0\n");return 0;}
    ll ans=a*t1/(-k)+(-b)*t2/(-k);
    if(-b*t2%(-k)==0) ans--;
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long moder = 1000000007;
long long fac[5005]={1};
long long multi(long long a,long long b){
	if(b==0) return 0;
	if(b==1) return a;
	long long ret = multi(a,b/2);
	ret*=ret;
	ret%=moder;
	if(b%2) ret*=a;
	return ret%moder;
}
long long F(long long n){
	long long&ret = fac[n];
	if(~ret) return ret;
	if(n<=1) return ret = 1;
	return ret = (n*F(n-1))%moder;
}
long long C(long long n,long long r){
	long long up = F(n);
	long long down = F(n-r)*F(r);
	down%=moder;
	return (up*multi(down,moder-2))%moder;
}
long long H(long long n,long long r){
	return C(n+r-1,r);
}

int main(){
	memset(fac,-1,sizeof(fac));
	long long n,k;
	cin>>n>>k;
	long long blue = k;
	long long red = n-k;
	for(long long i=1; i<=k; i++){
		long long red_wall = i-1;
		if(red_wall>red) cout<<0<<'\n';
		else{
			long long red_left = red-red_wall;
			long long blue_left = blue-i;
			cout<<(H(red_wall+2,red_left)*H(i,blue_left))%moder<<'\n';
		}
	}
}

Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = 610;
const int mod = 1e9 + 7;
long long dp[maxn][maxn] = {0}, g[maxn], h[maxn][maxn];
int ea[maxn], eb[maxn];
int n, m;
bool in(int l, int r, int x)
{
	return l <= x && x <= r;
}
int get(int l, int r)
{
	int cnt = 0;
	for(int i = 1; i <= m; i ++)
	{
		bool asd1 = in(l, r, ea[i]), asd2 = in(l, r, eb[i]);
		if(asd1 ^ asd2)
			return -1;
		if(asd1)
			cnt ++;
	}
	return cnt * 2;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> m;
	n *= 2;
	for(int i = 1; i <= m; i ++)
		cin >> ea[i] >> eb[i];
	g[0] = 1;
	for(int i = 2; i <= n; i += 2)
		g[i] = g[i - 2] * (i - 1) % mod;
	for(int i = 1; i <= n; i ++)
		for(int j = i; j <= n; j ++)
			h[i][j] = get(i, j);
	long long ans = 0;
	for(int l = 2; l <= n; l += 2)
		for(int i = 1; i + l - 1 <= n; i ++)
		{
			int j = i + l - 1;
			//cout << i << " " << j << " : " << endl;
			int c = h[i][j];
			//cout << c << endl;
			if(c != -1)
			{
				long long a = g[n - l - m * 2 + c];
				dp[i][j] = g[l - c] % mod;
				//cout << g[l - c] << " " << a << endl;
				for(int k = i + 1; k < j; k += 2)
					if(h[k + 1][j] != -1 && h[i][k] != -1)
					{
						(dp[i][j] += (mod - dp[i][k] * g[j - k - h[k + 1][j]] % mod)) %= mod;
						//cout << k << " " << dp[i][k] << " " << j - k - h[k + 1][j] << " " << g[j - k - 1 - h[k + 1][j]] << endl;
						//cout << dp[i][k] * g[j - k - 1 - h[k + 1][j]] % mod * a % mod << endl;
					}
				(ans += dp[i][j] * a) %= mod;
			}
			//cout << dp[i][j] << endl;
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    int N, A, B; cin>>N>>A>>B;

    int wa=0, sum=0;
    for (int i = 1; i <= N; ++i) {
        int tmp = i, wa = 0;
        while(tmp>0){
            wa += tmp % 10;
            tmp /= 10;
        }
        if(wa>=A && wa<=B) sum+=i;
    }

    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

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

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

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    int N; cin >> N;
    int ans=0;
    int onlyA=0;
    int onlyB=0;
    int AandB=0;
    rep(i,N){
        string S; cin >> S;
        for(int j=0; j<S.size()-1; j++){
            if(S[j]=='A' && S[j+1]=='B'){
                ans++;
            }
        }
        if(S[S.size()-1]=='A' && S[0]=='B'){
            AandB++;
        }else if(S[S.size()-1]=='A'){
            onlyA++;
        }else if(S[0]=='B'){
            onlyB++;
        }
    }

    if(AandB>0 && onlyA>0){
        onlyA--;
        ans++;
    }
    if(AandB>0 && onlyB>0){
        onlyB--;
        ans++;
    }
    cout << ans+max(0,AandB-1)+min(onlyA,onlyB) << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = -1000000000
for i in range(n):
    now = i
    j = 0
    score = deque([0])
    while j < k:
        score.append(score[j] +c[p[now]-1])
        now = p[now]-1
        j += 1
        if now == i:
            break
    ans = max(ans, max(list(score)[1:]))
    if j < k and score[-1] > 0:
        loop_num = k//j
        rest = k%j
        ans = max(ans, max(list(score)[:rest+1])+loop_num*score[-1] )
        ans = max(ans, max(list(score))+(loop_num-1)*score[-1] )
print(ans)
        

Measured memory_bytes: 94704
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, k;
	cin >> n >> k;
	if ((n + 1) / 2 >= k)puts("YES");
	else puts("NO");
}

Measured memory_bytes: 256
//Har Har Mahadev
using namespace std;
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
#define pb push_back
#define mp make_pair
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " -> " << a << endl;
	err(++it, args...);
}

void testcase(){
	ll n,d;
	int ans = 0;
	cin >> n >> d;
	while(n--){
		ll x,y;
		cin >> x >> y;
		if(x*x + y*y <= d*d){
			ans++;
		}
	}
	cout << ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, a[N];
bool u[N];
vector<int> g[N];

int rec(int x) {
	u[x] = 1;
	set<pii> st;
	for(auto to : g[x]) {
	  if(u[to]) continue;
		st.insert(mp(rec(to), to));
	}
	int mx = 0, height = sz(st);//sz(g[x]) - 1;
	while(sz(st) > 0) {
		pii now = *st.begin();
		st.erase(st.begin());
		mx = max(mx, height + now.F);		
		height --;
	}
	return mx;
}

int main() {
	megaRandom();
	scanf("%d", &n);
	for(int i = 2; i <= n; i ++) {
		scanf("%d", &a[i]);
		g[i].pb(a[i]);
		g[a[i]].pb(i);
	}
	printf("%d", rec(1));
	return 0;  
}


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  while(A >= 0 || C >= 0){
	C-=B;
    if(C <= 0){
      cout << "Yes";
      break;
    }
    A-=D;
    if(A <= 0){
      cout << "No";
      break;
    }
  }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

  int largest = (b / k) * k;
  if (a <= largest) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3600
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;
vi a;

signed main(){

    in(n);
    resz(n,a);
    in(a);
    bool f=true;
    for(auto e:a){
        if(e&1){
            f=false;
        }
    }
    puts(f?"second":"first");

    return 0;
}


Measured memory_bytes: 1024
program A319D
    implicit none
    integer(8)::N,calc,i,j,bcount
    integer(8),allocatable,dimension(:)::A,ans
    read*,N
    allocate(A(N))
    allocate(ans(N))
    read*,A
    ans=0
    bcount=0
    do i=0,N-1
        calc=0
        do j=1,N/(N-i)
            calc=calc+ans(j*(N-i))
        end do
        if(A(N-i)==0)then
            if(mod(calc,2)==1)then
                ans(N-i)=1
                bcount=bcount+1
            end if
        else
            if(mod(calc,2)==0)then
                ans(N-i)=1
                bcount=bcount+1
            end if
        end if
    end do

    print'(i0)',bcount
    do i=1,N
        if(ans(i)==1)write(*,fmt='(i0,1x)',advance='no')i
    end do
    print'(A)',""
end program A319D

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

namespace detail
{
    struct node {
        int num;
        node* prev;
        node* next;

        explicit node(int n): num(n), prev(nullptr), next(nullptr) {}
    };

    struct list {
        node* root;

        list() : root(new node(0)) {
            root->next = root;
            root->prev = root;
        }

        node* head() { return root->next; }
        node* tail() { return root->prev; }

        void insert(node* e, node* at) {
            auto n = at->next;
            at->next = e;
            e->next = n;
            e->prev = at;
            n->prev = e;
        }

        void insert(int num) {
            insert(new node(num), root);
        }

        node* find(int num) {
            auto it = root->next;
            while (it != root) {
                if (it->num == num)
                    return it;
                it = it->next;
            }
            return nullptr;
        }

        void remove(node* e) {
            e->prev->next = e->next;
            e->next->prev = e->prev;
            delete e;
        }

        void remove(int num) {
            auto at = find(num);
            if (at) remove(at);
        }
    };
}

using list = detail::list;
using node = detail::node;

using namespace std;

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

    int n;
    cin >> n;

    list l;
    for (int i = 0; i < n; ++i) {
        string s;
        int x;
        cin >> s;
        if (s == "insert") {
            cin >> x;
            l.insert(x);
        } else if (s == "delete"){
            cin >> x;
            l.remove(x);
        } else if (s == "deleteFirst") {
            l.remove(l.head());
        } else if (s == "deleteLast") {
            l.remove(l.tail());
        }
    }

    auto it = l.head();
    while (it != l.tail()) {
        cout << it->num << " ";
        it = it->next;
    }
    cout << it->num << endl;

    return 0;
}

Measured memory_bytes: 34404
#!/usr/bin/env python3
n, m = map(int, input().split())
s = [list(map(str, input().split())) for _ in range(m)]
wa = [0]*n
ac = [0]*n
p = 0
for i in range(m):
    s[i][0] = int(s[i][0])
    ac[s[i][0] - 1] += s[i][1] == 'AC' and ac[s[i][0] - 1] == 0
    wa[s[i][0] - 1] += s[i][1] == 'WA' and ac[s[i][0] - 1] == 0
for j in range(n):
    if ac[j] > 0:
        p += wa[j]
print(sum(ac))
print(p)

Measured memory_bytes: 36868
/**
    AUTHOR:JUNSH
    TIME:19/6/1
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
const int maxn=1e4+10;
int vis[maxn];
int cnt[maxn];
int ans[maxn];
int c[maxn];
int tot=1;
int n;
vector<int>v[maxn];
queue<int>q;
void bfs(){
    while(!q.empty()){
    int pos=q.front();
    q.pop();
    int len=v[pos].size();
    for(int i=0;i<len;++i){
        if(!vis[v[pos][i]]){
            vis[v[pos][i]]=1;
            q.push(v[pos][i]);
            ans[v[pos][i]]=c[++tot];
        }
    }
    }
}
bool cmp(int a,int b){
    return a>b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    int mm=0;
    int s;
    for(int i=1;i<n;++i){
        int x,y;
        cin>>x>>y;
        cnt[x]++;
        if(cnt[x]>mm){
            mm=cnt[x];
            s=x;
        }
        cnt[y]++;
        if(cnt[y]>mm){
            mm=cnt[y];
            s=y;
        }
        v[x].emplace_back(y);
        v[y].emplace_back(x);
    }
    int mx=0;
    int sum=0;
    for(int i=1;i<=n;++i){
        cin>>c[i];
        sum+=c[i];
        mx=max(c[i],mx);
    }
    sort(c+1,c+n+1,cmp);
    ans[s]=c[1];
    q.push(s);
    vis[s]=1;
    bfs();
    cout<<sum-mx<<endl;
    for(int i=1;i<=n;++i){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			final int n = sc.nextInt();
			int i = 1;
			do {
				int x = i;
				if (x % 3 == 0) {
					System.out.print(" " + i);
				} else {
					do {
						if (x % 10 == 3) {
							System.out.print(" " + i);
							break;
						}
						x /= 10;

					} while (x != 0);
				}
			} while (++i <= n);
			System.out.println();
		}
	}
}

Measured memory_bytes: 28604
#include <stdio.h>
bool reverse(bool *b) {
    *b = *b ? false : true;
}
int main() {
    int h,w;
    while (scanf("%d %d", &h, &w) && (h || w)) {
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if ((i + j) % 2 == 0) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2588