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

#define A_MAX 2000001
#define C_MAX 10001

int A[A_MAX], B[A_MAX], C[C_MAX];

int main(void){
  int i;
  int n;

  scanf("%d", &n);

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

  for(i=1; i<C_MAX; i++) C[i]+=C[i-1];
  for(i=n-1; i>=0; i--){
    C[A[i]]--;
    B[C[A[i]]]=A[i];
  }

  for(i=0; i<n; i++){
    if(!i)printf("%d", B[i]);
    else printf(" %d", B[i]);
  }

  printf("\n");
  
  return 0;
}



Measured memory_bytes: 18796
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	As := make([]int, N)
	var A int
	for i := 1; i < N; i++ {
		fmt.Scan(&A)
		As[A-1]++
	}

	for i := 0; i < len(As); i++ {
		fmt.Println(As[i])
	}

}


Measured memory_bytes: 6464
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long LL;

char str[1111111];

int main() {
	/*ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);*/
	
	scanf("%s", str + 1);
	int l = strlen(str + 1);
	int sum = 0;
	for (int i = 2; i <= l; ++i) {
		if (str[i] != str[i - 1]) {
			++sum;
		}
	}
	cout << sum << endl;
/*	if (flag) {
		puts("0");
	} else {
		if (str[1] == 'W' || str[l] == 'W') {
			puts("1");
		} else {
			puts("2");
		}
	}*/
}

Measured memory_bytes: 384
#include <cstdio>

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)

int main()
{
    int no_of_houses;
    scanf("%d", &no_of_houses);

    int min_house = 1000, max_house = 0;
    while(no_of_houses--)
    {
        int distance;
        scanf("%d", &distance);

        min_house = min(min_house, distance);
        max_house = max(max_house, distance);
    }

    printf("%d\n", max_house - min_house);
    return 0;
}


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

for i in range(n):
    v = a[i]
    j = i-1
    while j>=0 and a[j]>v:
        a[j+1] = a[j]
        j -= 1
        a[j+1] = v
    print(*a)


Measured memory_bytes: 5984
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n,z,w; cin >> n >> z >> w;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    if(n == 1){
        cout << abs(a[n-1] - w) << endl;
    }else{
        cout << max(abs(a[n-1] - w), abs(a[n-1] - a[n-2])) << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		if (x-y >= -1 && x-y <= 1) {
			System.out.println("Brown");
		} else {
			System.out.println("Alice");
		}

	}

}


Measured memory_bytes: 22740
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


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

	if ((b%a) == 0) cout << a + b << endl;
	else cout << b - a << endl;

	return 0;
}

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

int main(){
    int N, K, min, max, che;
    cin >> K >> N;
    vector<int> dis(N);
    for(int i = 0; i < N; i++){
        cin >> dis.at(i);
    }
    max = 0;

    for(int i = 0; i < N-1; i++){
        che = dis.at(i+1) - dis.at(i);

        if(che > max){
            max = che;
        }
    }
    che = dis.at(0) - dis.at(N-1) + K;

    if(che > max){
        max = che;
    }

    min = K - max;

    cout << min << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if (n == 0)
				break;
			int[][] le = new int[n][n];
			int[][] se = new int[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					le[i][j] = se[i][j] = INF;
				}
				le[i][i] = se[i][i] = 0;
			}
			for (int i = 0; i < m; i++) {
				int a = scanner.nextInt() - 1;
				int b = scanner.nextInt() - 1;
				int c = scanner.nextInt();
				char t = scanner.next().charAt(0);
				if (t == 'L') {
					le[a][b] = le[b][a] = Math.min(le[a][b], c);
				} else
					se[a][b] = se[b][a] = Math.min(se[a][b], c);
			}
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					for (int k = 0; k < n; k++) {
						le[j][k] = Math.min(le[j][k], le[j][i] + le[i][k]);
						se[j][k] = Math.min(se[j][k], se[j][i] + se[i][k]);
					}
			int nq = scanner.nextInt();
			int[] q = new int[nq];
			for (int i = 0; i < nq; i++)
				q[i] = scanner.nextInt() - 1;
			int[][] dp = new int[2][n];
			for (int i = 0; i < n; i++)
				dp[0][i] = INF;
			dp[0][q[0]] = 0;
			for (int i = 1; i < nq; i++) {
				for (int j = 0; j < n; j++)
					dp[i % 2][j] = INF;
				for (int j = 0; j < n; j++) {
					for (int k = 0; k < n; k++) {
						dp[i % 2][k] = Math.min(dp[i % 2][k],
								dp[(i + 1) % 2][j] + le[q[i - 1]][j] + se[j][k]
										+ le[k][q[i]]);
					}
					dp[i % 2][j] = Math.min(dp[i % 2][j], dp[(i + 1) % 2][j]
							+ le[q[i - 1]][q[i]]);
				}
			}
			int ans = INF;
			for (int i = 0; i < n; i++)
				ans = Math.min(ans, dp[(nq + 1) % 2][i]);
			System.out.println(ans);
		}
	}

	int INF = 1 << 25;
}

Measured memory_bytes: 69780
(n,m)=gets.split.map(&:to_i)
a=ARGF.map {|s|s.to_i}
a2=[false]*(n+1)

a.each{|i|
    a2[i]=true
}

tmp=[0]*(n+1)
tmp[0]=1 if !a2[0]
tmp[1]=1 if !a2[1]
(2..n).each{|i|
    tmp[i] = tmp[i-1] + tmp [i-2] if !a2[i]
}

print tmp[n]%1000000007


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

int main() {
    string s;
    cin >> s;
    if(s =="SUN") cout << 7 << endl;
    else if (s == "SAT") cout << 1 << endl;
    else if (s == "FRI") cout << 2 << endl;
    else if (s == "THU") cout << 3 << endl;
    else if (s == "WED") cout << 4 << endl;
    else if (s == "TUE") cout << 5 << endl;
    else if (s == "MON") cout << 6 << endl;
    
    
}

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

int main(void){
  char str1[5],str2[100],str3[100],str4[100];
  int N,a[20],b[20],c[20],i,sum;
  
  fgets(str1,sizeof(str1),stdin);
  fgets(str2,sizeof(str2),stdin);
  fgets(str3,sizeof(str3),stdin);
  fgets(str4,sizeof(str4),stdin);
  
  N=atoi(str1);
  a[0]=atoi(strtok(str2," "));
  for(i=1;i<N;i++){
    a[i]=atoi(strtok(NULL," "));
  }
  b[0]=atoi(strtok(str3," "));
  for(i=1;i<N;i++){
    b[i]=atoi(strtok(NULL," "));
  }
  c[0]=atoi(strtok(str4," "));
  for(i=1;i<N-1;i++){
    c[i]=atoi(strtok(NULL," "));
  }
  
  sum=b[a[0]-1];
  for(i=1;i<N;i++){
    sum+=b[a[i]-1];
    if(a[i]==a[i-1]+1){
      sum+=c[a[i-1]-1];
    }
  }
  
  printf("%d\n",sum);
  return 0;
}
  
    

Measured memory_bytes: 128
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long int
//#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define vali 1000000000000000000
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    if(t>=30)
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
}
    

Measured memory_bytes: 3648
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt(), ans = 0;
        String s = scanner.next(), t = scanner.next();
        for (int i = 0; i <= n; i++)
            if (s.substring(n - i).equals(t.substring(0, i)))
                ans = 2 * n - i;
        System.out.println(ans);
    }
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute(int a,int b) {
  if( a > 8 || b > 8 ) {
    puts(":(");
    return;
  }
  puts("Yay!");
}

int main() {
  int a,b;
  cin >> a >> b;
  compute(a,b);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
          
int main()
{
  int a[3];
  int b, i, j;
  cin >>a[1]>>a[2]>>a[3];
     
  for(j=1; j<=2; j++)
  {
    for(i=1; i<=3-j; i++)
    {
      if(a[i]>a[i+1])
      {
         b=a[i];
         a[i]=a[i+1];
         a[i+1]=b;
      }
    }
  }
     
  cout <<a[1]<<" "<<a[2]<<" "<<a[3]<<"\n";
       
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define vi vector<int>
#define umap unordered_map
#define pii pair<int, int>
#define vpii vector<pii>
#define uset unordered_set
#define frw(i, a, b) for(auto i = (a); i < (b); i++)
#define bck(i, a, b) for(auto i = (a); i > (b); i--)
#define T() int testcases; cin >> testcases; frw(TC, 1, testcases + 1)
#define tez ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define fi first
#define se second
#define pow asdihagsiduh
#define pub push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) (int)(a.size())
#define sq(a) ((a) * (a))

#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> 
void ZZ(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}

//console o/p without variable names
#define trace1(...) ZZ(__VA_ARGS__)
template<typename Arg1>
void ZZ(Arg1&& arg1){
    cerr << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZ(Arg1&& arg1, Args&&... args){
    cerr << arg1 << ' ';
    ZZ(args...);
}

signed main(){
    tez
    int n; cin >> n;
    vi a(n + 1);
    frw(i, 1, n + 1)    cin >> a[i];
    vi pre_gcd(n + 1), suff_gcd(n + 2);
    frw(i, 1, n + 1)    pre_gcd[i] = __gcd(pre_gcd[i - 1], a[i]);
    bck(i, n, 0)        suff_gcd[i] = __gcd(suff_gcd[i + 1], a[i]);
    int ans = 0;
    frw(i, 1, n + 1)    ans = max(ans, __gcd(pre_gcd[i - 1], suff_gcd[i + 1]));
    cout << ans;
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef pair<double,double> P;

int A,B,C,D,E,F;
vector<int> water, suger;

int main(){
    cin>>A>>B>>C>>D>>E>>F;

    rep(i,F+1){
        rep(j,F+1){
            int w=100*(A*i+B*j);
            int s=C*i+D*j;
            if(w<=F) water.push_back(w);
            if(s<=F) suger.push_back(s);
        }
    }

    int anssum=0, ansS=0;
    double x=0;
    rep(i,water.size()){
        rep(j,suger.size()){
            if(water[i]==0) continue;
            if(suger[j]<=water[i]/100*E && water[i]+suger[j]<=F){
                if(x<=100.0*suger[j]/(double)(water[i]+suger[j])){
                    x=100.0*suger[j]/(double)(water[i]+suger[j]);
                    anssum=water[i]+suger[j];
                    ansS=suger[j];
                }
            }
        }
    }

    cout<<anssum<<' '<<ansS<<endl;
}

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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	long a, b, c;
	long min, max;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	ifs >> a >> b >> c;
#else
	std::cin >> a >> b >> c;
#endif

	min = std::min(a, std::min(b, c));
	max = std::max(a, std::max(b, c));

	std::cout << min << " " << max << std::endl;
	return 0;
}



Measured memory_bytes: 3100
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    if(sum <= 21)
        cout << "win" << endl;
    else
        cout << "bust" << endl;

    return 0;
}


Measured memory_bytes: 764
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u16,
        a: [[u16; n]; 2],
    }

    let mut sum_r1: u16 = a[0][0];
    let mut sum_r2: u16 = a[1].iter().sum();
    // println!("{}, {}", sum1, sum2);
    let mut ans = 0;
    for i in 0..n {
        if i != 0 {
            sum_r1 += a[0][i as usize];
            sum_r2 -= a[1][(i - 1) as usize];
        }
        // println!("{}: {} {}", i, sum_r1, sum_r2);
        if sum_r1 + sum_r2 > ans {
            ans = sum_r1 + sum_r2;
        }
    }

    println!("{}", ans);
}


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

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

    int n, m;
    cin >> n >> m;
    long long A[n][3];
    REP(i, n) REP(j, 3) cin >> A[i][j];

    long long maxi = -1e18;
    for(int i = 0; i < 8; i++){
        vector<long long> B(n);
        for(int j = 0; j < n; j++){
            long long cost = 0;
            for(int k = 0; k < 3; k++){
                if((i >> k) & 1){
                    cost += A[j][k] * -1;
                }else{
                    cost += A[j][k];
                }
            }
            B[j] = cost;
        }
        sort(B.begin(), B.end(), greater<long long>());
        long long tmp = 0;
        REP(i, m) tmp += B[i];
        maxi = max(maxi, tmp);
    }
    cout << maxi << endl;  

    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
int cnt[26];
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	string s;cin>>s;
	trav(i,s) cnt[i-'a']++;
	ll ans = 1,mod = 1e9+7;
	rep(i,26) ans = ans*(cnt[i]+1)%mod;
	cout<<(ans+mod-1)%mod;
	
	
	
	
	return 0;
}



Measured memory_bytes: 512
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    for(auto &x : A) cin >> x;

    sort(A.begin(), A.end(), greater<int>());
    int ans = 0;
    REP(i, k){
        ans += A[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i,a,b,c,k,maxx,s=0;
	scanf("%d%d%d",&a,&b,&c);
	scanf("%d",&k);
	maxx=max(a,b);
	s+=min(a,b);
	maxx=max(maxx,c);
	s+=min(max(a,b),c);
	for(i=0;i<k;i++)
	{
		maxx*=2;
	}
	printf("%d",maxx+s);
	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
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);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vvi isUsed(n,vi(n,-1));
	vl cnt(n,n-1);
	int st=0,level=1;
	while(1){
		if(st==n)break;
		if(cnt[st]==0){
			st++; continue;
		}
		// puta("CNT",cnt);
		vi costs(n,-1);
		stack<tlll> q;
		range(i,st,n){
			q.emplace(-1,i,costs[i]==-1?0:costs[i]);
			while(!q.empty()){
				ll prev,cur,cost;
				tie(prev, cur,cost)=q.top(); q.pop();
				if(prev!=-1 and isUsed[prev][cur]!=-1)continue;
				if(costs[cur]!=-1 and costs[cur]%2 != cost%2)continue;
				// puta("use",level,prev,cur);
				if(prev!=-1) isUsed[prev][cur]=isUsed[cur][prev]=level;
				if(prev!=-1) {cnt[prev]--; cnt[cur]--;}
				if(costs[cur]!=-1) continue;
				costs[cur]=cost;
				rep(i,n){
					// puta("OK", cur,i,isUsed[cur][i],costs[i],costs[cur]);
					if(cur!=i and isUsed[cur][i]==-1 and (costs[i]!=-1 or costs[i]%2 != costs[cur]%2)){
						q.emplace(cur,i,cost+1);
					}
				}
			}
		}
		level++;
	}
	rep(i,n){
		range(j,i+1,n)cout<<isUsed[i][j]<<(j+1!=n?" ":"");
		cout<<endl;
	}

	return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> A(H+2,vector<char>(W+2));
  for (int i=0; i<H ; i++){
    for (int j=0; j<W; j++) {
      cin >> A[i+1][j+1];
    }
  }
  for (int i=0; i<H+2 ; i++){
    for(int j=0; j<W+2; j++){
      if(i==0 || i==H+1 || j==0 || j==W+1){
        A[i][j]='#';
      }
      cout << A[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
local counter=0
local BA,B_,_A=0,0,0
local n=io.read("n","l")
for i=1,n do
    local s=io.read()
    local _,sAB=s:gsub("AB","")
    counter=counter+sAB
    sf=s:sub(1,1)
    sl=s:sub(#s,#s)
    BA=((sf=="B" and sl=="A") and BA+1 or BA)
    B_=((sf=="B" and sl~="A") and B_+1 or B_)
    _A=((sf~="B" and sl=="A") and _A+1 or _A)
end

if BA==0 then
    counter=counter+math.min(B_,_A)
elseif BA>0 and B_+_A>0 then
    counter=counter+BA+math.min(B_,_A)
elseif BA>0 and B_+_A==0 then
    counter=counter+BA-1
end
print(counter)

Measured memory_bytes: 880
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N=2e5+5;
int n,p,cur,cnt[N],val[N];
string s;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("SSMOD.inp","r",stdin);
    //freopen("SSMOD.out","w",stdout);
	cin>>s;
	n=s.size();
	p=2019;
	int ans=0;
	int q=p;
	int t=1;
	while(q%2==0) q/=2,t*=2;
	while(q%5==0) q/=5,t*=5;
    for(int i=0;i<n;i++)
    {
        int now=0;
        for(int j=i;j<min(n,i+20);j++)
        {
            now=(now*10+s[j]-'0')%p;
            if(now==0) ans++;
        }
    }
    cur=0;
    int now=1;
    for(int i=n-1;i>=0;i--)
    {
        (cur+=(s[i]-'0')*now)%=q;
        val[i]=cur;
        now=now*10%q;
    }
    cnt[val[0]]++;
    for(int i=20;i<n;i++)
    {
        int l=i-19;
        int now=0;
        for(int j=l;j<=i;j++) now=(now*10+s[j]-'0')%t;
        if(now==0) ans+=cnt[val[i+1]];
        cnt[val[l]]++;
    }
	cout<<ans;
}


Measured memory_bytes: 5296
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String n=sc.next();
    int a=0;
    for(int i=0;i<n.length();i++)a+=Integer.parseInt(n.substring(i,i+1));
    System.out.println(Integer.parseInt(n)%a==0?"Yes":"No");
  }
}

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

int main(void)
{
	vector<int> a(3);
	rep(i, 0, 3)cin >> a[i];
	sort(a.begin(), a.end());

	int x = a[2] - a[1];
	int y, z;
	if ((a[2] - a[0] - x) % 2 == 0) {
		y = (a[2] - a[0] - x) / 2;
		z = 0;
	}
	else {
		y = (a[2] - a[0] - x + 1) / 2;
		z = 1;
	}
	int ans = x + y + z;
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
string S;
int main() {
	cin>>S;
	S[3]='8';
	cout<<S<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int x = int.Parse(input[0]);
    int a = int.Parse(input[1]);
    int b = int.Parse(input[2]);
    Console.WriteLine(Math.Abs(x-a) < Math.Abs(x-b) ? "A" : "B");
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main(){
  int n, a, b; cin >> n >> a >> b;
  int x{}, y{}, z{};
  REP(i, n){
    int p; cin >> p;
    if(p <= a) x++;
    else if(p <= b) y++;
    else z++;
  }

  cout << min(x, min(y, z)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

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

    vector<int64_t> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        A[i] -= i+1;
    }
    sort(A.begin(), A.end());

    int64_t ans = 0;
    for(int i = 0; i < N; ++i){
        ans += abs(A[i] - A[N/2]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    field = []
    for row in inputs:
        line = []
        for c in row:
            line.append(c)
        field.append(line)

    if len(field) == 1:
        if len(field[0]) == 1:
            return "No"

    for i, row in enumerate(field):
        for j, _ in enumerate(row):
            available = False
            if field[i][j] == ".":
                continue
            if i - 1 >= 0:
                available |= field[i - 1][j] == "#"

            if j - 1 >= 0:
                available |= field[i][j - 1] == "#"
            if j + 1 < len(row):
                available |= field[i][j + 1] == "#"

            if i + 1 < len(field):
                available |= field[i + 1][j] == "#"
            if not available:
                return "No"

    return "Yes"


if __name__ == "__main__":
    [N, _] = map(lambda x: int(x), input().split())
    ret = solve(inputs(N))
    print(ret)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    int w=0,b=0,k=0;
    cin>>s;
    for(auto x:s){
        if(x-48)w++;else b++;
    }
    k=b>w?w:b;
    cout<<k*2<<endl;
}

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

int p[201];
int di[201];

int fun(int i)
{  int count=0;
   for(int j=1;j<=sqrt(i);j++)
     {
     	
     	 if(i%j==0 && j*j==i)
     	  ++count;
     	else if(i%j==0)
     	  count+=2;
     }
   return count;  
}

int main() {
	int a,b,i;
	cin>>a;
	memset(di,0,sizeof(di));
	//cout<<fun(105)<<"\n";
	for(i=1;i<201;i++)
	  {  if(fun(i)==8 && i%2==1)
	      di[i]=di[i-1]+1;
	     else
	        di[i]=di[i-1];
	  }
	cout<<di[a]-di[0]<<"\n";
	// your code goes here
	return 0;
}

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

#define max(a, b) (((a) > (b)) ? (a) : (b))

unsigned char calculate_maximum_allowance (unsigned char const *A, unsigned char const *B, unsigned char const *C)
{
	return max(max(*A, *B), *C) * (unsigned char)(9) + *A + *B + *C;
}

int main (void)
{
	// variables for main process
	unsigned char A, B, C;
	int           rtvl_scanf;

	// STEP.01
	// read out the given string
	rtvl_scanf = scanf("%hhu %hhu %hhu", &A, &B, &C);

	// STEP.02
	// calcualte & output the points
	printf("%u\n", calculate_maximum_allowance(&A, &B, &C));

	// STEP.END
	return EXIT_SUCCESS;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if (s == u) a--;
    else b--;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;
signed main(){
	int a,b,ans=1;
	cin>>a>>b;
	for(int i=2;i*i<=b;i++){
		int x=0;
		while(b%i==0){
			b/=i;
			x++;
			if(x==a){
				x=0;
				ans*=i;
			}
		}
	}
	if(b!=1&&a==1) ans*=b;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std
;
int main()
{
	long long n;
	while(scanf("%Ld\n", &n), n){
		vector<pair<long long, long long> > v;
		for(long long i = 0; i < n; i++){
			long long p, q, r, f = 1;
			scanf("%Ld %Ld %Ld\n", &p, &q, &r);
			for(long long j = 0; j < v.size(); j++){
				if(v[j].first == p){
					f = 0;
					v[j].second += q * r;
				}
			}
			if(f){
				pair<long long, long long> pa(p, q * r);
				v.push_back(pa);
			}
			
		}
		long long g = 1;
		for(long long i = 0; i < v.size(); i++){
			if(1000000 <= v[i].second){
				g = 0;
				printf("%Ld\n", v[i].first);
			}
		}
		if(g) puts("NA");
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
 
public class Main {

  public static void main(String[] args) {

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

    Set<Integer> treeSet = new TreeSet<Integer>();

    for (int i = 0; i < N; i++) {
      treeSet.add(sc.nextInt());
    }

    sc.close();

    int s = treeSet.size();

    if (s % 2 == 0) {
      System.out.println(s - 1);
    } else {
      System.out.println(s);
    }

  }

}

Measured memory_bytes: 65196
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  int i,j,k,lim,x,y,z,now;
  string s,ans;
  vector<string> a[2];
  scanf("%d%d%d",&x,&y,&z);
  a[0].clear();
  for (i=0;i<x;i++)
  {
    s="";
    s.push_back('a');
    a[0].push_back(s);
  }
  for (i=0;i<y;i++)
  {
    s="";
    s.push_back('b');
    a[0].push_back(s);
  }
  for (i=0;i<z;i++)
  {
    s="";
    s.push_back('c');
    a[0].push_back(s);
  }
  now=0;
  while (a[now].size()>1)
  {
    sort(a[now].begin(),a[now].end());
    s=a[now][0];

    //for (i=0;i<a[now].size();i++)
    //  cout<<a[now][i]<<" ";
    //cout<<endl;
    for (i=0;i<a[now].size();i++)
      if (a[now][i]!=s) break;
    if (i==a[now].size()) break;
    lim=i;
    j=a[now].size()-1;
    a[1-now].clear();
    for (i=0;i<=j;i++)
    {
      if ((j>=lim)&&(i<lim))
      {
        a[1-now].push_back(a[now][i]+a[now][j]);
        j--;
      }
      else
      {
        a[1-now].push_back(a[now][i]);
      }
    }
    now=1-now;
  }
  ans="";
  for (i=0;i<a[now].size();i++)
    ans=ans+a[now][i];
  printf("%s\n",ans.c_str());
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x[10001],a=0,b=0,n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=2*n;i++)
    {
        scanf("%d",&x[i]);
    }
    sort(x+1,x+1+2*n);   
    for(int i=1;i<=2*n;i+=2)
    {
        b+=x[i];
    } 
    printf("%d\n",b);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
         
        int n = stdIn.nextInt();
        int m = stdIn.nextInt();
        int l = stdIn.nextInt();
         
        long[][] A = new long[n][m];
        long[][] B = new long[m][l];
        long[][] C = new long[n][l];
         
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                A[i][j] = stdIn.nextInt();
            }
        }
         
        for(int i = 0; i < m; i++) {
            for(int j = 0; j < l; j++) {
                B[i][j] = stdIn.nextInt();
            }
        }
         
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < l; j++) {
                for(int k = 0; k < m; k++) {
                    C[i][j] += A[i][k] * B[k][j];
                }
            }
        }
         
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < l-1; j++) {
                System.out.print(C[i][j] + " ");
            }
            System.out.println(C[i][l-1]);
        }
    }
}


Measured memory_bytes: 54384
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    std::string S; std::cin >> S;
    std::cout << S[0] << S[1] << S[2] << std::endl;
    return 0;
}


Measured memory_bytes: 3628
/*
  Topic12 ProblemA 最小全域木(Minimum Spanning Tree)
  与えられた重み付きグラフ G=(V,E) に対する最小全域木の辺の重みの総和を計算するプログラムを作成する。

  最初の行にGの頂点数nが与えらる。続くn行でGを表すn×nの隣接行列Aが与えられる。
  Aの要素 aij は、頂点iと頂点jを結ぶ辺の重みを表します。ただし、辺がなければ-1で示される。

  Gの最小全域木の辺の重みの総和を1行に出力する。
*/

#include<stdio.h>

#define INFTY 2000
#define BLACK 2
#define GRAY 1
#define WHITE 0

int main()
{
  int i, j, u, v, n, mincost;
  int A[100][100], color[100], d[100], p[100];
  int sum = 0;

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

  //初期化
  for(i=0;i<n;i++)
    {
      color[i] = WHITE;    
      p[0] = -1;
      d[i] = INFTY;
    }
  d[0] = 0;

  while(1)
    {
      mincost = INFTY;
      for(i=0;i<n;i++)
	{
	  if(color[i] != BLACK && d[i] < mincost)
	    {
	      mincost = d[i];
	      u = i;
	    }
	}

      if(mincost == INFTY)break;

      color[u] = BLACK;

      for(v=0;v<n;v++)
	{
	  if(color[v] != BLACK && A[u][v] != -1)
	    {
	      if(A[u][v] < d[v])
		{
		  d[v] = A[u][v];
		  p[v] = u; color[v] = GRAY;
		}
	    }
	}
    }

  for(i=0;i<n;i++)
    {
      if(p[i] != -1)sum += A[i][p[i]];
    }

  printf("%d\n", sum);
  return 0;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a;
  b=a;
  reverse(b.begin(),b.end());
  for(int i=0;i<b.size();i++){
    if(b.at(i)=='p')
      b.at(i)='q';
    else if(b.at(i)=='q')
      b.at(i)='p';
    else if(b.at(i)=='b')
      b.at(i)='d';
    else if(b.at(i)=='d')
      b.at(i)='b';
    }
  if(a==b)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  }


Measured memory_bytes: 512
/*
  AtCoder Beginner Contest 102
  C - Linear Approximation
*/

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int N;
int A[200000];

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

  sort(A, A+N);
  int med = A[(N/2)];
  
  unsigned long long result = 0;
  for (int i = 0; i < N; ++i) result += abs(A[i] - med);
  printf("%llu\n", result);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
  ll a[3];
  cin >>a[0]>>a[1]>>a[2];
  ll e=0,o=0;
  for(ll i=0;i<3;i++){
    if(a[i]%2==1) o++;
    else e++;
  }
  if(o==3||e==3){
    cout <<(3*max({a[0],a[1],a[2]})-(a[0]+a[1]+a[2]))/2<<endl;
  }
  else{
    if(e==1) {
      ll sum=0;
      for(ll i=0;i<3;i++){
        if(a[i]%2==0) sum+=a[i];
        else {
          sum+=(a[i]+1);a[i]++;
        }
      }
      cout <<((3*max({a[0],a[1],a[2]})-sum)/2)+1<<endl;
    }
    else{
      ll sum=0;
      for(ll i=0;i<3;i++){
        if(a[i]%2==1) sum+=a[i];
        else {
          sum+=(a[i]+1);a[i]++;
        }
      }
      cout <<((3*max({a[0],a[1],a[2]})-sum)/2)+1<<endl;
    }
  }
}


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

towers = [sum(range(1, n)) for n in range(2, 1001)]
diffs = [0] * 998
for i in range(998):
    diffs[i] = towers[i + 1] - towers[i]
i = diffs.index(b - a)
print(towers[i] - a)


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

using namespace std;

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

int main() {
	int n; cin >> n;
	int a[n]; rep(i, n) cin >> a[i];
	int maxv = a[1] - a[0];   // 最大利益を入れる
	int minv = a[0];          // a[i]の最小値を入れる

	REP(i, 1, n) {
		maxv = max(maxv, a[i] - minv);
		minv = min(minv, a[i]);
	}
	cout << maxv << endl;
}

Measured memory_bytes: 1940
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
const int mx = 1000 * 100 + 5;
int a[mx], w[mx];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	int n, l, t, x = 0;
	cin >> n >> l >> t;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> w[i];
		if(w[i] == 1){
			if(t >= l - a[i])
				x += 1 + (t - (l - a[i])) / l;
			a[i] = (a[i] + t) % l;
		}
		else{
			if(t > a[i])
				x -= 1 + (t - a[i] - 1) / l;
			a[i] = ((a[i] - t) % l + l) % l;
		}
	}
	sort(a , a + n);
	x = (x % n + n) % n;
	for(int i = x; i < n; i++)
		cout << a[i] << endl;
	for(int i = 0; i < x; i++)
		cout << a[i] << endl;
	return 0;
}


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

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int N,M; cin>>N>>M;
  for(int i=M/N;i>=1;i--){
    int tmp=M-N*i;
    if(tmp%i==0){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N, Y = map(int, input().split())

    for i in range(N + 1):
        for j in range(N + 1):
            k = N - i - j
            if 0 <= k:
                if (10000 * i + 5000 * j + 1000 * k) == Y:
                    print(i, j, k)
                    return
    print(-1, -1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>

using namespace std;


int main() {

    int N;
    cin >> N;

    set<string> ss;
    string s;
    for (int i = 0; i < N; ++i) {
        cin >> s;
        ss.insert(s);
    }

    cout << ss.size() << endl;


    return 0;

}

Measured memory_bytes: 19220
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main() {
	cin>>a>>b>>c>>d;
	int tot=0;
	while(++tot&&a>0&&c>0) {
		if(tot&1)
			c-=b;
		else
			a-=d;
		if(a<=0) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll n;
    cin >> n;
    vector<vector<ll> > c(26,vector<ll>(n,0));
    rep0(i, n){
        string s;
        cin >> s;
        rep0(j, s.size())++c[s[j] - 'a'][i];
    }
    string ans;
    rep0(i, 26){
        ll m = INF;
        rep0(j, n)chmin(m,c[i][j]);
        rep0(j, m)ans.push_back(char(i + 'a'));
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 256
nums = [input().split() for i in range(3)]
numss = nums[0] + nums[1] + nums[2]
if numss.count('1') >= 3 or numss.count('2') >= 3 or numss.count('3') >= 3 or numss.count('4') >= 3: 
    print("NO")
else:
    print("YES")

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<pair<int,int>> vpi;

const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    int n;cin>>n;
    ll a[n];
    ll b[n];
    FOR(i,0,n){
        cin>>a[i];
        b[i]=a[i];
    }
    map<int,int> m;
    bool f=0;
    FOR(i,0,n){
        for(int j=2;j*j<=b[i];j++){
            if(b[i]%j==0 && !m.count(j)){
                m[j]=1;
                while(b[i]%j==0){
                    b[i]/=j;
                    
                }
                
            }
            else if(b[i]%j==0){
                f=1;
                break;
            }
        }
        if(f) break;
        if(b[i]!=1){
            if(!m.count(b[i])) m[b[i]]=1;
            else{
                f=1;
                break;
            }
        }
        
        
    }
    
    if(!f) cout<<"pairwise coprime\n";
    else{
        ll g=0;
        FOR(i,0,n){
            g = __gcd(g,a[i]);
        }
        if(g==1){
            cout<<"setwise coprime\n";
        }
        else cout<<"not coprime\n";
        
    }
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 19264
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,count1[200]={},count2=0;
    cin>>n;
    for(int i=1;i<=n;i+=2){
        for(int j=1;j<=n;j++){
            if(i%j==0)count1[i]++;
        }
    }
    for(int i=1;i<=n;i+=2){
        if(count1[i]==8)count2++;
    }
    cout<<count2<<endl;
    return 0;
}
    


Measured memory_bytes: 256
object Main extends App {
  val in = readLine.split(' ').map(_.toInt)
  val a = in(0)
  val b = in(1)
  val C = in(2).toRadians

  val c = math.sqrt(a*a + b*b - 2*a*b*math.cos(C))

  val L = a + b + c;

  val h = b * math.sin(C)

  val S = a * h / 2;

  println(S)
  println(L)
  println(h)
}



Measured memory_bytes: 43844
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <math.h>

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

typedef int long long ill;
typedef int long il;
using namespace std;

int n;
int k;
vector<bool> x;

bool solve(int m)
{
    while (m)
    {
        if (!x[m % 10])
            return false;
        m /= 10;
    }
    return true;
}

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

    REP(i, 10)
    x.push_back(true);
    REP(i, k)
    {
        int tmp;
        cin >> tmp;
        x[tmp] = false;
    }
    while (true)
    {
        if (solve(n))
        {
            break;
        }
        n++;
    }
    cout << n << '\n';
    return 0;
}

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

signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  sort(rbegin(A),rend(A));
  int ans=0;
  int space=N-1;
  rep(i,N){
    int lim=2;
    if(i==0)lim=1;
    rep(j,lim){
      if(space>0){
        ans+=A[i];
        space-=1;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main( void ) {
    int a, b;
    char s;
    while( cin >> a >> s >> b && s != '?' ) {
        int ans = 0;
        switch( s ) {
            case '+': ans = a + b; break;
            case '-': ans = a - b; break;
            case '/': ans = a / b; break;
            case '*': ans = a * b; break;
        }
        cout << ans << '\n';
    }
    return 0;
}


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

signed main() {
    char b;
    cin >> b;
    
    if ( b == 'A' ) {
        cout << "T\n";
    } else if ( b == 'T' ) {
        cout << "A\n";
    } else if ( b == 'C') {
        cout << "G\n";
    } else {
        cout << "C\n";
    }
    return (0);
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main(){
  double N,K;
  cin >> N >> K;
  double ans=0.0;
  for(int i=1;i<N+1;i++){
    if (K>i) ans+=pow(1.0/2.0,double(ceil(log2(K/i))))/N;
    else ans+=1/N;
  }
  cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
//エラトステネスの篩
#include <bits/stdc++.h>
using namespace std;
 
vector<long> sieve(long N){
    vector<long> search_list(N-1);
    vector<long> prime_list;
    long prime_number;

    //2 ~ Nの整数を昇順で格納
    for(long i=0; i<N-1; i++){
        search_list[i] = i + 2;
    }

    //sqrt(N)まで実行
    for(long i=0; i<sqrt(N)+1; i++){
        //素数リストに探索リストの先頭の数を追加
        //なぜ! = 1としたかは後述
        if(search_list[i] != 1){
            prime_number = search_list[i];
            prime_list.push_back(prime_number);
        }        
        //その倍数を探索リストから篩い落とす
        for(long j=0; j<search_list.size(); j++){
            if(search_list[j] % prime_number == 0){
                //.eraseはO(N)なので1を代入することで代用
                search_list[j] = 1;
            }
        }
    }

    //探索リストに残った数を素数リストに追加
    for(long i=0; i<search_list.size(); i++){
        if(search_list[i] != 1){
            prime_list.push_back(search_list[i]);
        }
    }

    return prime_list;
}

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

    vector<long> sieved;

    sieved = sieve(100003);

    for(int i=0; i<sieved.size(); i++){
        if(sieved[i] >= X){
            cout << sieved[i] << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
const ll mod=998244353;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
int n,a[N],b[N];
void solve()
{
	n = read();
	int cnt = 0;
	for(int i=1; i<=n; i++) {
		a[i] = read(); b[i]=read();
		if(a[i] == b[i]) cnt++;
		else cnt = 0;
		if(cnt == 3) {
			puts("Yes");
			return;
		}
	}
	puts("No");
}
int main()
{
	int T=1;
	while(T--) solve();
}

Measured memory_bytes: 3640