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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define fe first
#define se second
#define nl "\n"
#define pp pair < ll , ll > 
#define sz(x) (ll)x.size()
#define st(x) sort(x.begin(),x.end())
#define rst(x) sort(x.rbegin(), x.rend())
#define all(x) x.begin(),x.end()
long double pi = 3.14159265358979323;
 
const double EPS = 1e-12;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
 
ll dp[N] , h[N];
ll n;
ll fun(ll i){

  if(i == n - 1){
    return abs(h[i] - h[n]);
  }
  if(i >= n){
    return 0;
  }
  if(dp[i] != -1){
    return dp[i];
  }

  return dp[i] = min(fun(i+1) + abs(h[i] - h[i+1]), fun(i+2) + abs(h[i] - h[i+2]));
  //return dp[n];
}
 
 
int main()
{
    fast;
    //ll n;
    ll k;
    cin >> n >> k ;
    for(int i = 1 ; i <= n; i++ ){
      cin >> h[i];
    }

   dp[1] = 0;
   for(int i = 2 ;  i <= n ; i++ ){
    ll val = mod ;
    for(int j = max(i - k  , 1LL) ; j < i ; j++ ){
      //cout << j << " ";
      val = min(val , dp[j] + abs(h[j] - h[i]));
    }

    //cout << "\n";
    dp[i] = val;
   }
   cout << dp[n];





















    
    return 0;
    
    
}

Measured memory_bytes: 1792
x,n=map(int,input().split())
import sys

if n>=1:
    p=list(map(int,input().split()))
else:
    print(x)
    sys.exit()
s=[]
d={}
l={}
for i in range(-105,200):
    if i not in p:
        s.append(i)


for k in s:

    d[k]=abs(x-k)


l=[m[0] for m in d.items() if m[1]==min(d.values())]
print(min(l))


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    ll t=1;
    rep(i,n){
        ll b;
        cin >> b;
        t = t/__gcd(t,b)*b;
    }
    cout << t << endl;
}

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

int main()
{
    ll A, B, N;
    cin >> A >> B >> N;

    ll x;
    if (N < B - 1)
    {
        x = N;
    }
    else
    {
        x = B - 1;
    }
    cout << A * (x % B) / B << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;


void input(){

}

void solve(){

}

void output(){
  
}

int main(){
  int N,D;
  cin>>N>>D;
  cout<<(N-1)/(2*D+1)+1<<endl;
  input();
  solve();
  output();
}


Measured memory_bytes: 256
import sys
import sys
sys.setrecursionlimit(1000000)


def input():
    return sys.stdin.readline()[:-1]

def fun(X, n):
    if (int(X/n)):
        return fun(int(X/n), n)+str(X%n)
    return str(X%n)

def main():
    N,K = map(int, input().split())
    print(len(fun(N, K)))
    
if __name__ == "__main__":
    main()

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

#define testcases int t; cin>>t; while(t--)
#define int long long
const int MOD =  1e9 + 7;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int32_t main()
{



	FASTIO;

	map<string, int> mp;

	int n ;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		string s; cin >> s;
		mp[s]++;
	}

	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;


}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define in(x) scanf("%d",&x)
#define inn(x,y) scanf("%d%d",&x,&y)
#define innn(x,y,z) scanf("%d%d%d",&x,&y,&z)

using namespace std;
const int N=2e6+5;
const int mod=1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    cout<<((n/m) + (n%m!=0));    
    return 0;
}

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

using namespace std;

const int N = (int) 1e5;
int h[N];
int cost[N];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", h + i);
    }
    cost[0] = 0;
    cost[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        cost[i] = min(cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2]));
    }
    printf("%d\n", cost[n - 1]);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#define DEBUG

using namespace std;
int n, a[135010];
struct node {
    int id, point;
} node[1<<20];

void add(int id, int x)
{
    id=n-1+id;
    node[id].point+=x;

    while (id>0) {
        id=(id-1)/2;
        int c1=2*id+1, c2=2*id+2;
        if (node[c1].point>=node[c2].point)
            node[id]=node[c1];
        else
            node[id]=node[c2];
    }
}

void print()
{
#ifdef DEBUG
    int k=1;
    int x=0;
    while (true) {
        for(int i=0;i<k;++i) printf("(%d %d)", node[x+i].id, node[x+i].point);
        puts("");
        x+=k;
        k<<=1;
        if (x>=n) break;
    }
    puts("");
#endif
}

int main()
{
    int m, r, l;
    scanf("%d%d%d", &m, &r, &l);
    n=1;
    while (n<m) n<<=1;
    for(int i=0;i<m;++i) node[n-1+i].id=i;

    int pt=0;
    for(int i=0;i<r;++i) {
        int d, t, x;
        scanf("%d%d%d", &d, &t, &x);

        if (pt<t) {
            int id=node[0].id;
            a[id]+=t-pt;
        }
        add(d-1, x);
        print();
        pt=t;
    }
    print();
    a[node[0].id]+=l-pt;
#ifdef DEBUG
    for(int i=0;i<n;++i) printf("%d ", a[i]); puts("");
#endif
    printf("%d\n", 1+(max_element(a, a+n)-a));
}

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

public class Main {
	private static void solve(){
	//Implement solution here.
		int a = ni();
		int b = ni();
		if(a > b) {
			System.out.println(a * 2 - 1);
		}else if(b > a) {
			System.out.println(b * 2 - 1);
		}else {
			System.out.println(a * 2);
		}
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 24916
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    // Your code here!
    int n,x[100],y[100];
    double p_1=0,p_2=0,p_3=0,p_0=0;
    
    scanf("%d",&n);
    
    for(int i=0; i<n; i++)
        scanf("%d",&x[i]);
    for(int i=0; i<n; i++)
        scanf("%d",&y[i]);
        
    for(int i = 0; i < n; i++){
        p_1 += abs(x[i] - y[i]);
        
        p_2 += pow(fabs((double)x[i]-y[i]),2.0);
        
        p_3 += pow(fabs((double)x[i]-y[i]),3.0);
        
        if(p_0 < abs(x[i] - y[i])) p_0 = abs(x[i] - y[i]);
        
        
    }
    
    printf("%lf\n%lf\n%lf\n%lf\n",p_1,pow(p_2,1.0/2),pow(p_3,1.0/3),p_0);
}



Measured memory_bytes: 2100
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;



int main(){
    ll n,k;
    cin>>n>>k;
    ll p=1;
    if(n>k){cout<<0<<endl; return 0;}
    for(int i=0;i<n;i++){
        p*=k;
        k--;
        p%=MOD;
    }
    cout<<p<<endl;
    
    
    return 0;
}



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

int main()
{
 int d,n;
  cin>>d>>n;
  if(d==0)
  {
    if(n!=100)
    cout<<n<<"\n";
    else
      cout<<"101\n";
    return 0;
  }
  if(d==1)
  {
    if(n!=100)
      cout<<n<<"00\n";
    else
      cout<<"10100\n";
    return 0;
  }
  if(d==2)
  {
    if(n!=100)
      cout<<n<<"0000\n";
    else
      cout<<"1010000\n";
    return 0;
  }
  
  
  return 0;
}

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

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

  int K, S;
  cin >> K >> S;
  
  int res = 0;
  for(int x = 0; x <= K; x++){
    for(int y = 0; y <= K; y++){
      int z = S - x - y;
      if(z >= 0 && z <= K) res++;
    }
  }
    
  cout << res << endl;
}


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

int main(){
    int n;
    double sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        double a;
        cin>>a;
        sum+=1/a;
    }
    cout<<setprecision(9)<<1/sum;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
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 MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    string S;
    cin>>S;
    int count=0;
    rep(i,S.size()){
        if(S.at(i)=='x')count++;
    }
    if(count>7){cout<<"NO"<<endl;}
    else{cout<<"YES"<<endl;}
}

Measured memory_bytes: 256
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

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

int32_t main(){
   boost;
   int N; cin>>N;
   str s; cin>>s;
   int cnt=0,x=0,x2=0;

   for(int i=0; i<N; i++){
      if(s[i]=='1') cnt++;
   }
   for(int i=0; i<N; i++){
      if(s[i]=='1') x=(x+modpow(2,N-i-1,cnt+1))%(cnt+1);
   }
   for(int i=0; i<N && cnt>1; i++){
      if(s[i]=='1') x2=(x2+modpow(2,N-i-1,cnt-1))%(cnt-1);
   }

   //cout << x << endl;

   for(int i=0; i<N; i++){
      int xx,cntt=cnt;
      if(s[i]=='0'){
         s[i]='1';  cntt++;
         xx=(x+modpow(2,N-i-1,cntt))%cntt;
      }
      else{
         s[i]='0'; cntt--;
         if(cntt==0) xx=0;
         else xx=(((x2-modpow(2,N-i-1,cntt))%cntt)+cntt)%cntt;
      }

      //cout << xx << endl;
      int res=1;
      if(cntt==0) res=0;
      while(xx>0){
         int nb=0;
         for(int idx=0; idx<28; idx++){
            if(((xx)&(1<<(idx)))>0) nb++;
         }
         xx=xx%nb;
         res++;
      }

      cout << res << endl;
      if(s[i]=='0') s[i]='1'; else s[i]='0';
   }


   return 0;
}



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

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

using namespace std;

vector<int> Z_algorithm(const vector<int>& a){
	int n=a.size();
	vector<int> z(n);
	for(int i=1,pre=0;i<n;i++){
		if(z[pre]>(i-pre)+z[i-pre]){
			z[i]=z[i-pre];
		}
		else{
			int j=max(pre+z[pre]-i,0);
			while(i+j<n && a[j]==a[i+j]) j++;
			z[i]=j;
			pre=i;
		}
	}
	z[0]=n;
	return z;
}

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n);
	rep(i,n) scanf("%d",&a[i]);
	rep(i,n) scanf("%d",&b[i]);

	vector<int> seq(3*n-2);
	rep(i,n-1) seq[i]=b[i]^b[i+1];
	seq[n-1]=-1;
	rep(i,2*(n-1)) seq[n+i]=a[i%n]^a[(i+1)%n];

	auto z=Z_algorithm(seq);

	rep(k,n){
		int x=a[k]^b[0];
		if(z[n+k]==n-1) printf("%d %d\n",k,x);
	}

	return 0;
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {

  int ab,bc,ca; cin >> ab >> bc >> ca;

  int ans = (ab * bc)/2;
  cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#define _ ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int MAXN=100000+10;
ll h[MAXN];
ll a,b;
ll n;
ll INF=1e9+7;
bool C(ll x){
    ll sum=0;
    for(int i=0;i<n;i++){
        ll res=h[i]-x*b;
        if(res<=0)
            continue;
        if(res%(a-b)==0)
            res/=a-b;
        else
            res=res/(a-b)+1;
        sum+=res;
    }
    return sum<=x;
}
int main(){
    _;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    ll l=0,r=INF;
    ll res=-1;
    while(l<=r){
        ll mid=l+r>>1;
        if(C(mid)){
            res=mid;
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    //while(r-l>1){
        //ll m=(l+r)>>1;
        //if(C(m)){
            //r=m;
        //}else{
            //l=m;
        //}
    //}
    //cout<<r<<endl;
    cout<<res<<endl;
}



Measured memory_bytes: 1024
n, x, t = map(int, input().split())
y = 0
if n % x == 0:
    while n // x != 0:
        n -= x
        y += 1
    print(t * y)
else:
    y = 1
    while n // x != 0:
        n -= x
        y += 1
    print(t * y)

Measured memory_bytes: 9040
import java.util.*;
public class Main {
		
	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		sc.close();
		
		int ones[] = new int[N];
		int zeros[] = new int[N];
		Arrays.fill(ones,-1); Arrays.fill(zeros,-1);
		
		char before = '1';
		boolean zeroStart = false;
		if(S.charAt(0)=='0') {
			before = '0';
			zeroStart = true;
		}
		
		char Slast = S.charAt(N-1);
		
		int oneP = 0 , zeroP = 0;
		
		int cnt = 0;
		for(int i=0;i<N;i++) {
			char s = S.charAt(i);
			if(s == before) {				
				cnt ++;
			}else {
				if(s=='0') {
					ones[oneP] = cnt;
					oneP++;
					cnt = 1;
					before = '0';
				}else {
					zeros[zeroP]=cnt;
					zeroP++;
					cnt = 1;
					before = '1';
				}
			}
		}
		if(S.charAt(N-1)=='0') {
			zeros[zeroP] = cnt;
		}else {
			ones[oneP] = cnt;
		}
	
		
		if(ones[0]==-1) {
			System.out.println(zeros[0]);
			return;
		}
		
		int ans = 0;
		boolean fin = false;
		if(!zeroStart) {
			for(int i=0;i<N;i++) {
				int tmp = ones[i];
				int last = Math.min(K,N-1);
				for(int j = 0;j<last;j++) {
						if(ones[i+j+1]<0||zeros[i+j]<0) {
							if(Slast=='0') {
								tmp += zeros[i+j];
							}
							fin = true;
							break;
						}
						tmp += ones[i+j+1]+zeros[i+j];
				}
				ans = Math.max(ans,tmp);
				if(fin)break;
			}
		}
		else {
			for(int i=0;i<N;i++) {
				int tmp = ones[i];
				int last = Math.min(K,N-1);
				for(int j = 0;j<last;j++) {
					if(ones[i+j+1]<0||zeros[i+j+1]<0) {
						if(Slast=='0') {
							tmp += zeros[i+j+1];
						}
						fin = true;
						break;
					}
					tmp += ones[i+j+1]+zeros[i+j+1]; 
				}
				ans = Math.max(ans,tmp);
				if(fin)break;
			}
			int t = 0;
			for(int i=0;i<K;i++) {
				if(ones[i]<0||zeros[i]<0) break;
				t += zeros[i]+ones[i];
			}
			ans = Math.max(ans,t);
		}
		
		System.out.println(ans);
	}

	
}

Measured memory_bytes: 26288
import java.util.Scanner;

class Main {

  private static long INF = Long.MAX_VALUE / 4;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    long[] A = new long[N];
    long[] comSum = new long[N + 1];
    boolean flag = false;
    for (int i = 0; i < N; i++) {
      A[i] = scanner.nextLong();
      comSum[i + 1] = comSum[i] + Math.abs(A[i]);
      if (A[i] == 0) {
        flag = true;
      }
    }
    long min = INF;
    for (int i = 0; i < N; i++) {
      if (Math.abs(min) > Math.abs(A[i])) {
        min = A[i];
      }
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
      if (A[i] < 0) {
        cnt++;
      }
    }
    if (flag || cnt % 2 == 0) {
      System.out.println(comSum[N]);
    } else {
      System.out.println(comSum[N] - 2 * Math.abs(min));
    }
  }

}


Measured memory_bytes: 61564
from collections import defaultdict

N = int(input())
Ds = defaultdict(int)
for k in list(map(int, input().split())):
    Ds[k] += 1
M = int(input())
Ts = defaultdict(int)
for k in list(map(int, input().split())):
    Ts[k] += 1
ans = 'YES'
for k in Ts:
    if Ts[k] > Ds[k]:
        ans = 'NO'
        break
print(ans)


Measured memory_bytes: 125648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int N,A;
	scanf("%d %d", &N, &A);
	
	printf("%d\n",N*N-A);

		return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int rest = a % b;
    bool ok = false;
    IFOR(i, 1, b) {
        int test = i * a;
        if (test % b == c) {
            ok = true;
            break;
        }
    }
    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef pair<long, int> node;
typedef struct edge{
  int to;
  long cost;
  edge(int t, long c){
    to = t;
    cost = c;
  }
}edge;

int main(){
  int n; cin >> n;
  vector<edge> e[n];
  rep(i, n-1){
    int a, b; long c; cin >> a >> b >> c;
    e[a-1].push_back(edge(b-1, c));
    e[b-1].push_back(edge(a-1, c));
  }
  int q, k; cin >> q >> k; k--;
  long d[n]; rep(i, n) d[i] = LONG_MAX;
  priority_queue<node, vector<node>, greater<node>> que;
  que.push(node(0, k));
  d[k] = 0;
  while(!que.empty()){
    node now = que.top(); que.pop();
    long dnow = now.first; int nowid = now.second;
    if(dnow > d[nowid]) continue;
    rep(i, e[nowid].size())if(d[e[nowid][i].to] > dnow+e[nowid][i].cost){
      int nextid = e[nowid][i].to;
      d[nextid] = dnow + e[nowid][i].cost;
      que.push(node(d[nextid], nextid));
    }
  }
  rep(i, q){
    int x, y; cin >> x >> y;
    cout << d[x-1] + d[y-1] << endl;
  }
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int v[n], c[n];
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    int ans = 0;

    rep(i, n) {
        if (v[i] - c[i] > 0) ans += v[i] - c[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL() {};
template <class T, class... Args> void _INPUT_IMPL(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL(args...); }
#define int_cin(...) ll __VA_ARGS__; _INPUT_IMPL(__VA_ARGS__);

int main() {
	std::string s;
	cin >> s;
	cout << "2018" << s.data() + 4 << endl;
}

Measured memory_bytes: 256
from collections import deque

n, m = map(int, input().split())
graph = [[] for i in range(n)]
for i in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    graph[u].append([i,v])
    graph[v].append([i,u])
    
cnt = 0
for i in range(m):
    d = deque()
    d.append(0)
    visited = [False]*n
    visited[0] = True
    while d:
        cf = d.pop()
        for ci, ct in graph[cf]:
            if ci == i:
                continue
            if not visited[ct]:
                d.append(ct)
                visited[ct] = True
    if False in visited:
        cnt += 1
print(cnt)


Measured memory_bytes: 9472
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;

void solve(void){

  long double L;
  cin >> L;
  
  long double l;
  l=(L/3)*(L/3)*(L/3);

  cout << fixed << setprecision(12) << l <<endl;
  
return;
}

int main(void){
  
	solve();
	return 0; 
}

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


int main(){
  string s;
  cin >> s;
  if(s=="SSS"){cout << 0 <<endl;}else 
  if(s=="RSS"){cout << 1 <<endl;}else
  if(s=="RRS"){cout << 2 <<endl;}else 
  if(s=="RRR"){cout << 3 <<endl;}else
  if(s=="SRS"){cout << 1 <<endl;}else 
  if(s=="SSR"){cout << 1 <<endl;}else
  if(s=="SRR"){cout << 2 <<endl;}else 
  if(s=="RSR"){cout << 1 <<endl;}
}

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i <= (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	ll n,y; cin >> n >> y;
	rep(a, min(n,y/10000)){
		rep(b, min(n,(y-a*10000)/5000)){
			ll c = (y - a*10000 - b*5000)/1000;
			//cout << a<<b<<c<<endl;
			if(a+b+c == n){
				cout << a << ' ' << b << ' ' << c << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1\n";
}

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

int main() {
    int N, K;
    std::cin >> N >> K;

    std::vector<int> l(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> l[i];
    }
    
    std::sort(l.begin(), l.end(), std::greater<int>());

    int ret = 0;
    for (int i = 0; i < K; ++i) {
        ret += l[i];
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
n,m,l=map(int,input().split())
A = [tuple(map(int,input().split())) for _ in range(n)]
B = [tuple(map(int,input().split())) for _ in range(m)]
BT = tuple(map(tuple,zip(*B)))
for a in A:
    temp=[]
    for b in BT:
        temp.append(sum([x*y for (x,y) in zip(a,b)]))
    print(*temp)

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

using namespace std;

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

    for (int k = 0; k < n; k++) {
        int b;
        cin >> b;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (a[i][j] == b) {
                    a[i][j] = 0;
                }
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        if (a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for (int i = 0; i < 3; i++) {
        if (a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) {
        cout << "Yes" << endl;
        return 0;
    }

    if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())))
q = sorted(list(map(int, input().split())))
r = sorted(list(map(int, input().split())))[::-1]

pq = sorted(p[-X:] + q[-Y:])
ans = sum(pq)

if pq[0] < max(r):
    left = 0
    right = len(r)
    while left < right - 1:
        mid = (left + right) // 2
        if pq[mid] >= r[mid]:
            right = mid
        else:
            left = mid
    ans = ans + sum(r[:right]) - sum(pq[:right])

print(ans)


Measured memory_bytes: 107748
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,l;
	string s[110];
	scanf("%d%d",&n,&l);
	for(int i=0;i<n;i++)
		cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++)
		for(int j=0;j<l;j++)
			printf("%c",s[i][j]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] == '1')
        {
            count++;
        }
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int j, n, N, c;
	char s;
	int a[4][13] = { 0 };
	scanf ("%d", &N);

	for (c = 0; c<N; c++){
		scanf(" %c %d", &s, &n);
		
		switch (s){
		case 'S':a[0][n - 1] = 1;
			break;
		case 'H':a[1][n - 1] = 1;
			break;
		case 'C':a[2][n - 1] = 1;
			break;
		case 'D':a[3][n - 1] = 1;
			break;
		}
	}
	for (j = 0; j<13; j++){
		if (a[0][j] == 0){printf("S %d\n", j + 1);}
	}
	for (j = 0; j<13; j++){
		if (a[1][j] == 0){printf("H %d\n", j + 1);}
	}
	for (j = 0; j<13; j++){
		if (a[2][j] == 0){printf("C %d\n", j + 1);}
	}
	for (j = 0; j<13; j++){
		if (a[3][j] == 0){printf("D %d\n", j + 1);}
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    reverse(c.begin(),c.end());
    auto tmp=a.back();
    a.pop_back();
    string ans;
    while(1){
        if(tmp=='a'){
            if(a.empty()){
                ans="A";
                break;
            }
            tmp=a.back();
            a.pop_back();
            //cout << "A" << endl;
        }
        if(tmp=='b'){
            if(b.empty()){
                ans="B";
                break;
            }
            tmp=b.back();
            b.pop_back();
            //cout << "B" << endl;
        }
        if(tmp=='c'){
            if(c.empty()){
                ans="C";
                break;
            }
            tmp=c.back();
            c.pop_back();
            //cout << "C" << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a= list(map(int, input().split()))

count=1
flag=True
for i in range(n-1):
    if i==0:
        ans=a[i+1]-a[i]

    if not flag:
        ans=a[i+1]-a[i]
        flag=True

    if (ans<=0 and a[i+1]-a[i]<=0) or (ans>=0 and a[i+1]-a[i]>=0):
        if ans!=0:
            continue
        elif a[i+1]-a[i]!=0:
            ans=a[i+1]-a[i]
        else:
            continue
            


    else:
        count+=1
        flag=False

print(count)

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

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

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

namespace adaptor = boost::adaptors;
using namespace std;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::algorithm::split;
using boost::math::tools::brent_find_minima;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void Main()
{
	string s;
	cin >> s;
	ll n;
	n = s.size();
	vector<ll> V(n + 1);
	rep(i, n)
	{
		if (s.at(i) == '<')
			V.at(i + 1) = V.at(i) + 1;
	}
	rrep(i, n - 1)
	{
		if (s.at(i) == '>')
			V.at(i) = max(V.at(i + 1) + 1, V.at(i));
	}
	cout << accumulate(V.begin(), V.end(), 0LL) << endl;
}
// END

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


Measured memory_bytes: 4764
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

ll INF = 1000000007;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	rep(i, m) cin >> a[i];
	int sum = 0;
	rep(i, m) sum += a[i];
	if (n >= sum) {
		cout << n - sum << endl;
	}
	else {
		cout << -1 << endl;
	}
}


Measured memory_bytes: 3632
table = [[200, 380, 5, 0.8], [300, 550, 4, 0.85], [500, 850, 3, 0.88]]
A, B, C = table.map(&:first)

calc = ->(shop, num) {
  t = table[shop]
  discount = (num / t[2]) * t[2]
  discount * t[1] * t[3] + (num - discount) * t[1]
}

until (soba = $<.gets.to_i).zero?
  min = Float::INFINITY
  (0..soba / C).each do |c|
    pay = calc.(2, c)
    soba1 = soba - c * C
    (0..soba1 / B).each do |b|
      pay1 = pay + calc.(1, b)
      soba2 = soba1 - b * B
      next if (soba2 % A).nonzero?
      pay2 = pay1 + calc.(0, soba2 / A)
      min = pay2 if pay2 < min
    end
  end
  puts min.to_i
end


Measured memory_bytes: 6872
import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li():
    return list(map(int, sys.stdin.readline().split()))


def num():
    return map(int, sys.stdin.readline().split())


def nu():
    return int(input())


def find_gcd(x, y):
    while (y):
        x, y = y, x % y
    return x


def lcm(x, y):
    gg = find_gcd(x, y)
    return (x * y // gg)


mm = 1000000007

def solve():
    t = 1
    for tt in range(t):
        a=input()
        b=input()
        if(a+b[len(b)-1]==b):
            print("Yes")
        else:
            print("No")

                 


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9936
from collections import deque
N, K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
def g(n, k, h):
    gk = deque([abs(h[1] - h[0]), 0])
    g = gk[0]
    for i in range(2, n):
        g = min(abs(h[i] - h[i-j]) + gk[j-1] for j in range(1, min(i, k)+1))
        if i >= k:
            gk.pop()
        gk.appendleft(g)
    return g

print(g(N, K, h))

Measured memory_bytes: 53344
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int a,b,n;
    cin>>n;
    if(n==1) cout<<"Hello World"<<endl;
    else{
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int isPrime(int x){
  int i;

  if(x < 2) return 0;
  else if(x == 2) return 1;
  if(x % 2 == 0) return 0;

  for(i = 3; i * i <= x; i += 2){
    if(x % i == 0) return 0;
  }
  return 1;
}

int main(){
  int n, x, i;
  int cnt = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &x);
    if(isPrime(x)) cnt++;
  }

  printf("%d\n", cnt);

  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  int x = 0;
  x = A / 500;
  if (x * 500 + B >= A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3648
//codeforces 1337C
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ps(x,y) fixed<<setprecision(y)<<x
#define all(x) x.begin(),x.end()
#define endl "\n"
#define io ios_base::sync_with_stdio(false); cin.tie(0)
int const mod = 1000000000+7;
int32_t main() {
    io;
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
  int r;
  cin >> r;
  double ans = 2*3.14159265358*r;
  cout << ps(ans,2) << endl;
  return 0;
}

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

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

    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main()
{
    int i = 0;
    int alfa[27] = {0};
    char ch;

    while(scanf("%c", &ch) != EOF)
    {
        if(isupper(ch))
        {
            ch = tolower(ch);
        }
        i = ch - 'a';
        alfa[i]++;
    }

    for(i = 0; i < 26; i++)
    {
        printf("%c : %d\n", i+'a', alfa[i]);
    }

    return 0;
}

Measured memory_bytes: 548
n = int(input())
ls_a = list(map(int, input().split()))
ls_b = list(map(int, input().split()))

ans = 0
res = 0

for i in range(n):
	ans += min(ls_a[i], res + ls_b[i])
	if res >= ls_a[i]:
		res = ls_b[i]
	else:
		res = max(res + ls_b[i] - ls_a[i], 0)

if res >= ls_a[n]:
	print(ans + ls_a[n])
elif 0 <= res < ls_a[n]:
	print(ans + res)
else:
	print(ans)

Measured memory_bytes: 19156
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import           Unsafe.Coerce

#define MOD 1000000007

main :: IO ()
main = do
    n <- readLn :: IO Int
    ws <- U.unfoldrN n B.uncons <$> B.getLine
    print $ solve ws

solve :: U.Vector Word8 -> Int
solve ws = (-% 1)
    . U.foldl' (*%) 1
    . U.unsafeAccumulate (+) (U.replicate 256 1)
    $ U.map (flip (,) 1 . fromIntegral) ws

infixr 8 ^%
infixl 7 *%, /%
infixl 6 +%, -%

type IntMod = Int

intMod :: Int -> IntMod
intMod x = mod x MOD

(+%) :: IntMod -> IntMod -> IntMod
(I# x#) +% (I# y#) = I# ((x# +# y#) `remInt#` MOD#)
{-# INLINE (+%) #-}

(-%) :: IntMod -> IntMod -> IntMod
(I# x#) -% (I# y#) = I# ((x# -# y# +# MOD#) `remInt#` MOD#)
{-# INLINE (-%) #-}

(*%) :: IntMod -> IntMod -> IntMod
(I# x#) *% (I# y#) = I# ((x# *# y#) `remInt#` MOD#)
{-# INLINE (*%) #-}

(/%) :: IntMod -> IntMod -> IntMod
(I# x#) /% (I# y#) = go# y# MOD# 1# 0#
  where
    go# a# b# u# v#
        | isTrue# (b# ># 0#) = case a# `quotInt#` b# of
            q# -> go# b# (a# -# (q# *# b#)) v# (u# -# (q# *# v#))
        | otherwise = I# ((x# *# (u# +# MOD#)) `remInt#` MOD#)
{-# INLINE (/%) #-}

(^%) :: IntMod -> Int -> IntMod
x ^% n
    | n > 0 = go 1 x n
    | n == 0 = 1
    | otherwise = go 1 (1 /% x) (-n)
  where
    go !acc !y !m
        | m .&. 1 == 0 = go acc (y *% y) (unsafeShiftR m 1)
        | m == 1 = acc *% y
        | otherwise = go (acc *% y) (y *% y) (unsafeShiftR (m - 1) 1)


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

int main()
{
	string s; cin >> s;
	for (char i = 'a'; i <= 'z'; ++i)
		if (s.find(i) == -1)
		{
			cout << i << endl;
			return 0;
		}
	cout << "None" << endl;
}



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

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

  std::vector<int> h(n);
  for (auto&& hi : h) std::cin >> hi;

  const auto m =
      std::count_if(h.begin(), h.end(), [k](const auto hi) { return hi >= k; });
  std::cout << m << std::endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(void)
{
  long long i, sum;
  string N, tmp;
  // get input
  cin >> N;
  // summation of each digit
  sum = 0;
  for(i = 0; i < N.size(); i++) {
    tmp = N[i];
    sum += stoll(tmp);
  }
  // disp answer
  if(sum%9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int h, w;
int dp[20][20];

vector<string> s;

void dfs(int ih, int iw, int dist) {
  if (dp[ih][iw] == -1 || dp[ih][iw] > dist) {
    dp[ih][iw] = dist;
  } else {
    return;
  }

  if (ih + 1 < h && s[ih + 1][iw] != '#') {
    dfs(ih + 1, iw, dist + 1);
  }
  if (ih - 1 >= 0 && s[ih - 1][iw] != '#') {
    dfs(ih - 1, iw, dist + 1);
  }
  if (iw + 1 < w && s[ih][iw + 1] != '#') {
    dfs(ih, iw + 1, dist + 1);
  }
  if (iw - 1 >= 0 && s[ih][iw - 1] != '#') {
    dfs(ih, iw - 1, dist + 1);
  }

  return;
}

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

  cin >> h >> w;
  memset(dp, -1, sizeof dp);
  s.resize(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      // cをスタートしたときの各点への最短経路を求める
      char c = s[i][j];
      if (c == '.') {
        memset(dp, -1, sizeof dp);

        dfs(i, j, 0);
        int dist = 0;
        for (int ih = 0; ih < h; ih++) {
          for (int iw = 0; iw < w; iw++) {
            dist = max(dp[ih][iw], dist);
          }
        }

        ans = max(ans, dist);
      } else {
        continue;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	double A, B;
	cin >> A >> B;
	int ans = (int)(A * B);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3736
object Main extends App {
  val list = readLine.split(" ").map(_.toInt)
  println(
    if ( 
      (list(0) + list(1)) % 3 == 0 ||
      list(0) % 3 == 0             ||
      list(1) % 3 == 0
    ) {
      "Possible"
    } else {
      "Impossible"
    }
  )
}

Measured memory_bytes: 25412
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

bool isPrime(int x) {

	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	for (int i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

int main() {

	int n;
	scanf("%d", &n);
	int x[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &x[i]);
	}

	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (isPrime(x[i]))
			++cnt;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int n;
    cin >> n;
    VI d(n);
    for (Int i = 0; i < n; ++i) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[n / 2] - d[n / 2 - 1] << endl;
    return 0;
}


Measured memory_bytes: 4024
#include <stdio.h>
main()
{
  int i,n[100],N,mini,j,s=0,l=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&n[i]);
  }
   
  for(i=0;i<N;i++){
    mini = i;
    for(j=i;j<N;j++){
      if(n[j]<n[mini]) mini=j;
    }
 
    l=n[i];
    n[i]=n[mini];
    n[mini]=l;
    if(i!=mini)s++;
 
  }
  for(i=0;i<N-1;i++){
    printf("%d ",n[i]);
  }
  printf("%d\n",n[i]);
  printf("%d\n",s);
  return 0;
   
}


Measured memory_bytes: 2136
import sys

N = int(input())

if(N == 0):
    print(0)
    sys.exit()

ans = ""
while(N != 0):
    if(N % 2 == 0):
        ans = "0" + ans
    else:
        ans = "1" + ans
    k = N // 2
    N = -1 * k

print(ans)

Measured memory_bytes: 3060