akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll solve(string s) {
    vector<ll> val(2019, 0);
    ll tenfactor = 1;
    ll r = 0;
    val[r]++ ;
    ll n = s.size();
    for (int i = 0; i < n; i++) {
        r = (r + (s[n-i-1] - '0') * tenfactor) % 2019;
        tenfactor = tenfactor * 10 % 2019;
        val[r]++;
    } 
    ll ans = 0;
    for (int i = 0; i < 2019; i++) {
        ans += val[i] * (val[i] - 1) / 2;
    }
    return ans;
}

int main() {
    string s; cin >> s;
    cout << solve(s) << endl;
}


Measured memory_bytes: 3816
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-24 17:29:25
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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


  string s; cin >> s;
  if (s == "SUN") {
    cout << 7 << endl;
  } else if (s == "MON") {
    cout << 6 << endl;

  } else if (s == "TUE") {
    cout << 5 << endl;

  } else if (s == "WED") {
    cout << 4 << endl;

  } else if (s == "THU") {
    cout << 3 << endl;

  } else if (s == "FRI") {
    cout << 2 << endl;

  } else {
    cout << 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int n,a,d,t[1000003],maxa=-(1<<30);
int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
void fj(int x){
    for(int i=2;i*i<=x;){
        if(!(x%i)){
            ++t[i];
            while(!(x%i)) x/=i;
        }
        else ++i;
    }
    if(x>1) ++t[x];
}
int main(){
    scanf("%d%d",&n,&a),d=a;
    for(int i=2;i<=n;i++){
        scanf("%d",&a);
        if(maxa<a) maxa=a;
        d=gcd(d,a);
        fj(a);
    }
    if(d==1){
        for(int i=2;i<=maxa;i++) if(t[i]>1) return puts("setwise coprime"),0;
        return puts("pairwise coprime"),0;
    }
    else return puts("not coprime"),0;
    return 0;
}

Measured memory_bytes: 5520
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		int bus = stdIn.nextInt();
		int bus_free = stdIn.nextInt();
		int train = stdIn.nextInt();
		int train_free = stdIn.nextInt();
		
		int bus_fee = bus;
		int train_fee = train;
		
		if(bus > bus_free)
		{
			bus_fee = bus_free;
		}
		if(train > train_free)
		{
			train_fee = train_free;
		}
		
		System.out.println(bus_fee + train_fee);

	}

}


Measured memory_bytes: 35596
/*********************
Esse é um problema LCS clássico
O algoritmo de solução encontra-se em pseudo-código no livro
Algoritmos do Cormen
A ideia é basicamente, encontrar na matriz o momento em que as
linhas mudam de valor e isso gera a maior sequencia
*********************/
#include <bits/stdc++.h>

using namespace std;

    string s, t;
    int resp[3001][3001];

void lcs(int i,int j){
    if(i!=0 && j!=0){
        if(s[i-1] == t[j-1]){
            lcs(i-1, j-1);
            cout<<s[i - 1];
        }else if(resp[i-1][j] > resp[i][j-1]){
            lcs(i-1, j);
        }else{
            lcs(i, j-1);
        }
    }
}

int main(){

    cin >> s >> t;

    int tam_s=s.length(), tam_t=t.length(), q=0;

    for (int i = 0; i <= tam_s; i++) {
        for(int j=0; j<=tam_t; j++){
            if(i==0 || j==0){
                q=0;
            }else if(s[i-1]==t[j-1]){
                q=resp[i-1][j-1]+1;
            }else{
                q = max(resp[i-1][j], resp[i][j-1]);
            }
            resp[i][j]=q;
            //cout << "Entrei: " << q << endl;
        }
    }

//     int i = tam_s, j=tam_t, q2=resp[tam_s][tam_t];

//     char lcs[q2+1];
//     lcs[q2] = '\0';

//     while (i > 0 && j > 0){
//       if (s[i-1] == t[j-1]){
//           lcs[q2-1] = s[i-1]; 
//           i--;
//           j--;
//           q2--;
//       }
//       else if (resp[i-1][j] > resp[i][j-1]){
//          i--;
//       }
//       else{
//          j--;
//       }
//    }
    
//     cout << lcs << endl;

    lcs(tam_s, tam_t);
    cout << endl;
}

Measured memory_bytes: 35840
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    double N;
    cin >> N;
    vector<pair<double,int>> A(N);
    double ave=0;
    rep(i,N){
        int a; cin >> a;
        A[i] = {a,i};
        ave += a;
    }
    ave /= N;
    rep(i,N) A[i].first = abs(A[i].first - ave);

    sort(all(A));

    cout << A[0].second << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	string field[100];
	int h,w;
	cin >> h >> w;
	for(int i = 0;i < h;i++) cin >> field[i];
	for(int i = 0;i < h * 2;i++){
		for(int j = 0;j < w;j++){
			cout << field[i / 2][j];
		}
		cout << endl;
	}
	return 0;
}

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

#define MAX 100

int main() {
	int N, h[MAX];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	int l, r;
	int ans = 0;
	while (true) {
		for (int i = 0;; i++) {
			if (h[i] != 0 || i == N) {
				l = i;
				break;
			}
		}
		for (int i = l;; i++) {
			if (h[i] == 0 || i == N) {
				r = i;
				break;
			}
		}
		if (l == N && r == N) {
			break;
		}
		for (int i = l; i < r; i++) {
			h[i]--;
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define all(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())

int main(void)
{
  // code begin

  string s;

  cin >> s;

  for (auto &c : s)
  {
    cout << "x";
  }

  cout << endl;

  // code end
  return 0;
}


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

int main()
{
  ll N, K;
  cin >> N >> K;
  if (N >= K) {
    N = N % K;
  }
  N = min(N, abs(N-K));
  cout << N << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

const int maxn=(int)(1e5)+5;
char s[maxn];

int main() {
    scanf("%s",s+1);
    int n=strlen(s+1);
    int tot=0,cnt=0;
    REP(i,1,n) if(s[i]==s[1]) ++cnt;tot=max(cnt,tot);
    cnt=0;
    PER(i,n,1) if(s[i]==s[n]) ++cnt,tot=max(cnt,tot);
    if(s[1]==s[n]) tot+=tot-1; else tot+=tot;n-=tot;
    if(n&1) printf("First\n"); else printf("Second\n");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 2e5+2;
unsigned long long nums[MAXN];
 
const long long MAXL = 1e18;
bool overflow(unsigned long long a, unsigned long long b) {
    if (ULLONG_MAX / a < b) {
        return true;
    }

    unsigned long long ans = a*b;
    if (ans>MAXL) {
        return true;
    }
    return false;
}
 
int main() {
    int n;
    scanf("%d",&n);
    for (int i=0;i<n;i++) {
        scanf("%llu", &nums[i]);
        if (0==nums[i]) {
            printf("0\n");
            return 0;
        }
    }
 
    long long ans=1;
    for (int i=0;i<n;i++) {
        if (true==overflow(ans,nums[i])) {
            printf("-1\n");
            return 0;
        }
        ans*=nums[i];
    }
 
    printf("%llu",ans);
 
    return 0;
}

Measured memory_bytes: 4596
import math

def comb(n,r):
	if n >= r:
		return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
	else:
		return 0

N, K = map(int, input().split())

for i in range(1,K+1):
	print(comb(K-1,i-1)*comb(N-K+1,i)%(10**9+7))

Measured memory_bytes: 3444
#include<stdio.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
int main(){
  long long a,b,c,d,x,y,z,i,ans=0,M=1e9+7;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  x=y=1;
  for(i=0;i<b;i++){
    z=inv(i+1,M);//printf("%lld %lld %lld\n",x,y,z);
    x=((x*(a+i  ))%M*z)%M;
    y=((y*(c+i+1))%M*z)%M;//printf("%lld %lld\n",x,y);
  }//printf("%lld %lld\n",x,y);
  for(i=b;i<=d;i++){//printf("!!%lld %lld\n",y,x);
    //ans=((ans+y)%M+M-x)%M;printf("%lld\n",ans);
    z=inv(i+1,M);
    y=(y*(c+i+1)%M*z)%M;
    x=(x*(a+i  )%M*z)%M;
    ans=((ans+y)%M+M-x)%M;//printf("%lld\n",ans);
  }
  printf("%lld\n",ans);
  return 0;
}
   
//   ans=((ans+y)%M+M-x)%M;printf("%lld\n",ans);


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    if(s.size() != t.size()){
        return 0;
    }else{
        int cnt = 0;
        for(int i = 0;i < s.size();i++){
            if(s[i] != t[i]){
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    
}

Measured memory_bytes: 3448
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int M=scan.nextInt();
		int A[][]=new int[N][2];
		for(int i=0;i<N;i++) {
			A[i][0]=scan.nextInt();
			A[i][1]=1;
		}
		for(int i=0;i<M;i++) {
	    int x=scan.nextInt();
	    int y=scan.nextInt();
	    if(A[x-1][0]>A[y-1][0]) {
	    	A[y-1][1]=0;
	    }
	    else if(A[x-1][0]<A[y-1][0]) {
	    	A[x-1][1]=0;
	    }
	    else {A[y-1][1]=0;A[x-1][1]=0;
	    }
		}
		int num=0;
		for(int i=0;i<N;i++) {
			if(A[i][1]==1) {
				num++;
			}
			else {}
		}
		System.out.println(num);
	}

}


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

#define 	pi 				3.1415926536
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define 	vi 				vector<int>
#define     pii              pair<int, int>
#define     pll             pair<long long int, long long int>
#define     vll             vector<long long int>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


/*############################# DSU ##############################*/
vi parent(1e5), Size(1e5), Rank(1e5);

void make_set(int v){
    parent[v]=v;
    Size[v] = 1;
    // Rank[v] = 0;
}
 
int find_set(int v){
	return (parent[v]==v) ?  v : parent[v] = find_set(parent[v]);
}
 
void union_sets(int a, int b){
	a = find_set(a);
	b = find_set(b);
	if(a != b){
        if(Size[a] < Size[b])
            swap(a, b);
        // if(Rank[a] < Rank[b])
        //     swap(a, b);
		parent[b] = a;
        Size[a] += Size[b];
        // if(Rank[a] == Rank[b])
        //     Rank[a]++;
    }
}
/*############################# DSU ##############################*/


bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }

double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }

ll pw2[32];
void cal(){ pw2[0] = 1; rep(i, 1, 32)pw2[i] = 2*pw2[i-1]; }

/* ################################################################ */

vector<vector<ll>> adj(2e5);
// vector<bool> visit;

void solve()
{
    ll x; cin>>x;
    vll a(1001, 0), b(1001, 0);
    vector<pll> c;
    rep(i, 1, 1001){
        a[i] = i*i*i*i*i;
        b[i] = -a[i];
    }
    rep(i, 1, 1001){
        c.PB({b[i], -1*i});
    }
    c.PB({0, 0});
    rep(i, 1, 1001){
        c.PB({a[i], i});
    }
    rep(i, 0, c.sz){
        rep(j, i+1, c.sz){
            if(c[j].F-c[i].F==x){
                cout<<c[j].S<<ws<<c[i].S<<nl;
                // cout<<c[j].F<<ws<<c[i].F<<nl;
                return;
            }
        }
    }

}


int main()
{
    // boost;
    cal();
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 9352
#include <iostream>

using namespace std;
typedef long long int int64;

int main(int argc, char **argv)
{
    int64 N, A, B;
    cin >> N >> A >> B;

    int64 d = N / (A + B);
    int64 r = N - d * (A + B);
    if (r < A) cout << d * A + r;
    else cout << (d + 1) * A;
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
playlist = []
for i in range(N):
    s, t = list(input().split())
    playlist.append([s, int(t)])
X = input()

time = 0
is_sleep = False
for s, t in playlist:
    if is_sleep:
        time += t
    if s == X:
        is_sleep = True

print(time)

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

int N, A, brosky[105], michael=0, i;

int main () {
  cin >> N;
  for (int i=1;i<=N;i++){
    cin >> A;
    brosky[A]++;
  }
  //baca frekuensi sampai 100, karena bilangan dapat berupa puluhan dan seratus
  for(int num=1; num<=100; num++) {
    if(brosky[num]>0){
      michael++;
    }
  }
  cout << michael << endl;
} 


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int n,m;
char a[201][201];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	  scanf("%s",a[i]+1);
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
	      printf("%c",a[i][j]);
	    printf("\n");
	    for (int j=1;j<=m;j++)
	      printf("%c",a[i][j]);
	    printf("\n");
	}
	return 0;
} 

Measured memory_bytes: 256
N = int(input())
S = input()
nums = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            nums.append(str(i) + str(j) + str(k))

cnt = 0
for num in nums:
    j = 0
    for i in range(N):
        if S[i] == num[j]:
            j += 1
        if j > 2:
            cnt += 1
            break

print(cnt)


Measured memory_bytes: 40940
import java.util.Arrays;
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int res = 0;
		int[] n = new int[N];
		Arrays.fill(n, 0);

		for(int i=0;i<N;i++) {

			n[i]=sc.nextInt();
			int max = n[0];
			for(int s =0;s<i;s++) {
				if(max<n[s]) {
					max = n[s];
				}
			}
			if(n[i]>=max) {
			
				res++;
			}

		}
		System.out.println(res);




	}
}

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

int main() {
    
    double a, b;
    cin >> a >> b;
    
    double res = a/b;
    
    
    
    cout << fixed << setprecision(10) << res << endl;
    
    
    
   
    
    
	return 0;
}

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N/1000;
  b = (N-1000*a)/100;
  c = (N-1000*a-100*b)/10;
  d = (N-1000*a-100*b-10*c);
  
  if (a == b && b == c && c == d) {
    cout << "Yes" << endl;
  }
  else if (a == b && b == c) {
    cout << "Yes" << endl;
  }
  else if (b == c && b == d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NUM 1005
int N;
int H, W;
int table[NUM][NUM];

int main() {
	H = NUM - 1;
	W = NUM - 1;
	for (int row = 0; row <= H; row++) {
		for (int col = 0; col <= W; col++) {
			table[row][col] = 0;
		}
	}
	scanf("%d", &N);
	int x1, y1, x2, y2;
	for (int loop = 0; loop < N; loop++) {
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		table[y1][x1]++;
		table[y1][x2]--;
		table[y2][x1]--;
		table[y2][x2]++;
	}
	int ans = 0;
	for (int row = 0; row < H; row++) 
		for (int col = 1; col < W; col++) 
			table[row][col] += table[row][col - 1];
	for (int col = 0; col < W; col++) 
		for (int row = 1; row < H; row++) 
			table[row][col] += table[row - 1][col];
	for (int row = 0; row < H; row++) 
		for (int col = 0; col < W; col++) 
			ans = max(ans, table[row][col]);

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




Measured memory_bytes: 7164
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int a = 0, b = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        int x = s[i] - '0';
        a += (x + i) % 2;
        b += (x + i + 1) % 2;
    }
    cout << min(a, b);
}


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


using namespace std;

bool f(int n) {
    int i;
    for (i = 1; i*i <= n; i++) {
        if (n % i == 0)
            ;
    }
    if ((i-1)*(i-1) == n)
        return true;
    else
        return false;
}

int str2int (const string &str) {
  stringstream ss(str);
  int num;
  if((ss >> num).fail())
  {
  }
  return num;
}


int main()
{
    string a, b;
    cin >> a >> b;
    int c = str2int(a+b);
    if (f(c) == true)
        cout << "Yes" << endl;
    else
        cout << "No";


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main()
{
	int x,n;
	scanf("%i%i",&x,&n);
	int a[n+1];
	if(n==0)
	{
		printf("%i",x);
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%i",&a[i]);
	}
	bool bul=false,buul=false;
	int i=x;
	while(bul==false)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[j]==i)
			{
				i++;
				break;
			}
			if(j==n)
			{
				bul=true;
			}
		}
	}
	int k=x;
	while(buul==false)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[j]==k)
			{
				k--;
				break;
			}
			if(j==n)
			{
				buul=true;
			}
		}
	}
	if(abs(x-k)<abs(x-i))
	{
		printf("%i",k);
	}
	else if(abs(x-k)>abs(x-i))
	{
		printf("%i",i);
	}
	else printf("%i",k);
    return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int w,ans[10],wei[10];
signed main(void){
		ios::sync_with_stdio(false);
		for(int i=0;i<10;i++)
			wei[i]=1<<i;
		while(cin>>w){
			memset(ans,0,sizeof(ans));
			for(int i=9;i>=0;i--)
				if(w>=wei[i]){
					ans[i]=1;
					w-=wei[i];
				}
			for(int i=0,j=0;i<10;i++)
				if(ans[i]){
					if(j!=0)
						cout<<" ";
					else
						j=1;
					cout<<wei[i];	
				}
			cout<<endl;
		}
}

Measured memory_bytes: 1192
#include<stdio.h>
#include<math.h>
int main(){
  
  int n,i,j,cnt,a[10000];
  cnt=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);

  for(i=0;i<n;i++){
    
    if(a[i] == 2 || a[i] == 3) cnt++;
    
    if(a[i] > 3){
      for(j=2;j<=(int)sqrt(a[i]);j++){
	if(a[i] % j == 0) break;
	if(j == (int)sqrt(a[i])){cnt++;break;} 
      }
    }
  }
  printf("%d\n",cnt);
}


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


int main()
{
	int n,x,t;
	cin>>n>>x>>t;
	int sum=0,ans=0;
	while(sum<n)
	{
		ans=ans+t;
		sum+=x;
	}
	cout<<ans;
	return 0;
}


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

void solve() {
  int n; cin >> n;
  int a, b; cin >> a >> b;
  vector<int> cnt(3, 0);
  while(n--) {
    int p; cin >> p;
    if(p <= a) ++cnt[0];
    else if(p <= b) ++cnt[1];
    else ++cnt[2];
  }
  cout << *min_element(begin(cnt), end(cnt)) << endl;
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
 int N,M,K;
  in(N>>M>>K);
  if(K%N==0||K%M==0){
out("Yes");
   return 0; 
  }
  bool f =false;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=M;j++){
   if(K==M*i+j*(N-i*2)) f = true;
  }
  }
  if(f) out("Yes");
  else out("No");
}
  

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

lli gcd(lli a,lli b){
    if(b>a){
        lli t=a;
        a=b;
        b=t;
    }
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    lli n,sum=0;
    lli i,j,k;
    cin>>n;
    rep(i,1,n+1){
        rep(j,1,n+1){
            rep(k,1,n+1){
//                cout<<gcd(gcd(i,j),k)<<endl;;
                sum+=gcd(gcd(i,j),k);
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main (void){
    int n,k;
    scanf("%d %d",&n,&k);
    int a[(int)n];
    int sum=0;
    int all_flag = 1;
    for(int i=0;i<n;i++)scanf("%d",&a[i]);

    for(int i = 0;i<k;i++){
        int  b[200005] = {0};
        all_flag = 1;
        for(int j=0;j<n;j++){//各電球を見る
            b[j-a[j]>0?j-a[j]:0] ++;//照らし始め
            b[j+a[j]+1<n?j+a[j]+1:n]--;//終わり
        }
        for(int j=0;j<n;j++){
            sum += b[j];
            a[j] = sum;
            if(a[j] != n) all_flag = 0;
        }
        if(all_flag) break;
        sum = 0;
    }

    if(!all_flag){
        for(int i=0;i<n-1;i++)printf("%d ",a[i]);
        printf("%d",a[n-1]);
    }else{
        for(int i=0;i<n-1;i++)printf("%d ",n);
        printf("%d",n);        
    }



    return 0;
}

Measured memory_bytes: 3284
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>

int main() {
	int n,k;
	std::cin>>n;
	std::cin>>k;
	std::vector<int> arr(n);
	for (int i = 0; i < n; ++i) {
		std::cin >> arr[i];
	}
	std::vector<int> dp(k+1, 0);
	for (int i = 1; i <= k; ++i) {
		for (int x : arr) {
			if (i < x)
				break;
			if (dp[i-x] == 0) {
				dp[i] = 1;
				break;
			}
		}
	}

	if (dp[k])
		printf("First\n");
	else
		printf("Second\n");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for(int i = 0;i < m;i++) {
    cin >> b.at(i);
  }
  int count = 0;
  for(int i = 0;i < n;i++) {
    int sum = c;
    for(int j = 0;j < m;j++) {
      int a;
      cin >> a;
      sum += a * b.at(j);
    }
    if(sum > 0) {
      count++;
    }
  }
  cout << count << endl;
}

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

int main() {
	int K, X; cin >> K >> X;
	int const MIN = X - K + 1, MAX = X + K - 1;
	for (int i = MIN; i <= MAX; i++) {
		cout << i;
		if (i != MAX) cout << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a;
    int n;
    cin>>n;
    while (cin>>a){
        for(int i=1;i<=n;i++){
            a=a+1;
			if (a>'Z') a='A';
             
        }
        cout<<a;
    }
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "file"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    deque<int> dq;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if((n % 2 && i % 2) || (n % 2 == 0 && i % 2 == 0))
            dq.push_back(a);
        else
            dq.push_front(a);
    }
    for(int i: dq)
        cout << i << " ";
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool ng = false;
    if (n&1) ng = true;
    rep(i,n/2){
        if (s.substr(i*2, 2) != "hi") ng = true;
    }
    cout << (ng ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {

  int i,j,n,c,len,array[100];

  scanf("%d",&len);

  for(i=0 ; i<len ; i++)
    scanf("%d",&array[i]);

  for(i=0 ; i<len ; i++){
    for(j=len-1 ; j>i ; j--){
      if(array[j] < array[j-1]){
        n = array[j-1];
        array[j-1] = array[j];
        array[j] = n;
        c++;
      }
    }
  }

  for(i=0 ; i<len ; i++){
    if(i==len-1)
      printf("%d",array[i]);
    else
      printf("%d ",array[i]);
  }
  printf("\n%d\n",c);
  
return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x, a, b;
		x = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		if(b - a <= 0) {
			System.out.println("delicious");
		} else if(b - a <= x) {
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n;
	cin >> n;
	queue<int>i, j, c;
	vector<vi>map(2, vi(n));
	rep(i, 2) {
		rep(j, n) {
			cin >> map[i][j];
		}
	}
	i.push(0);
	j.push(0);
	c.push(map[0][0]);
	int ans = 0;
	while (i.size() != 0) {
		if (i.front() == 0) {
			if (j.front() != n - 1) {
				i.push(0);
				j.push(j.front() + 1);
				c.push(c.front() + map[0][j.front() + 1]);
			}
			i.push(1);
			j.push(j.front());
			c.push(c.front() + map[1][j.front()]);

		}
		else {
			if (j.front() != n - 1) {
				i.push(1);
				j.push(j.front() + 1);
				c.push(c.front() + map[1][j.front() + 1]);
			}
			else {
				ans = max(ans, c.front());
			}
		}
		i.pop();
		j.pop();
		c.pop();
	}
	cout << ans << endl;
}



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

struct node{
  int key;
  struct node *next, *prev;
};

typedef struct node *NP;

NP listsearch(int);
void init();
void printlist();
void delenode(NP);
void delfirst();
void dellast();
void delkey(int);
void insert(int);

NP nil;



int main(){
  int key, n, i, size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){
      insert(key);
      np++;
      size++;
    } else if(com[0]=='d') {
      if(strlen(com)>6){
        if(com[6]=='F') delfirst();
        else if(com[6]=='L') dellast();
      } else {
        delkey(key);
        nd++;
      }
      size--;
    }
  }

  printlist();

return 0;
}

NP listsearch(int key){
  NP cur = nil->next;
  while(cur!=nil && cur->key!=key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printlist(){
  NP cur = nil->next;
  int isf = 1;
  while(1){
    if(cur==nil) break;
    if (isf==0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void delenode(NP t){
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void delfirst(){
  NP t = nil->next;
  if(t==nil) {
    return;
  }
  delenode(t);
}

void dellast(){
  NP t = nil->prev;
  if(t==nil) {
    return;
  }
  delenode(t);
}

void delkey(int key){
  delenode(listsearch(key));
}

void insert(int key){
  NP x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}


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

int main() {
    int n;
    std::cin >> n;
    std::vector<int> vec{};
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        vec.push_back(a);
    }

    int q;
    std::cin >> q;
    for (int j = 0; j < q; ++j) {
        int b, e, t;
        std::cin >> b >> e >> t;
        std::swap_ranges(vec.begin() + b, vec.begin() + e, vec.begin() + t);
    }

    for (auto iter = vec.begin(); iter != vec.end(); ++iter) {
        std::cout << *iter;
        if (iter != vec.end() - 1) std::cout << ' ';
    }
    std::cout << std::endl;
}


Measured memory_bytes: 3140
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e4;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e6;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2)%MOD;
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a % MOD * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[j]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}



in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc);
    while(tc--)
    {
        string s;
        cin>>s;
        int x=s[0]-'0',y=s[2]-'0';
        x*=10;
        y*=10;
        x+=s[1]-'0';
        y+=s[3]-'0';
        if((x>12||x==0)&&y<=12&&y>0){
            cout<<"YYMM\n";
        }
        else if((y>12||y==0)&&x<=12&&x>0){
            cout<<"MMYY\n";
        }
        else if(y<=12&&y>0&&x<=12&&x>0){
            cout<<"AMBIGUOUS\n";
        }
        else{
            cout<<"NA\n";
        }
    }
    RETURN;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static List<piece> cakes;
	static int ansIdx= 0;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {

			int n = sc.nextInt();
			int w = sc.nextInt();
			int d = sc.nextInt();

			if(n == 0 && w == 0 && d ==0) {
				break;
			}
//			if(ansIdx != 0) {
//				System.out.println();
//			}
//			ansIdx++;
			cakes = new ArrayList<>();

			int[] p = new int[n];
			int[] s = new int[n];
			piece initCake= new piece(w, d);
			cakes.add(initCake);

			for(int i = 0; i < n; i++) {
				p[i] = sc.nextInt();
				s[i] = sc.nextInt();
				divide(p[i], s[i]);
			}
			List<Integer> ansList = new ArrayList<>();
			cakes.stream()
			.forEach(piece -> ansList.add(piece.size()));

			ansList.sort(null);

			StringBuilder sb = new StringBuilder();

			ansList.stream().forEach(ans -> sb.append(ans + " "));
	        sb.setLength(sb.length()-1);
	        System.out.println(sb.toString());

		}
	}

	private void addPieces(piece new1, piece new2) {

	}
	static void divide(int idx, int s) {
		piece dividedPiece = cakes.get(idx-1);
		cakes.remove(idx-1);

		piece new1;
		piece new2;

		s %= (dividedPiece.w + dividedPiece.d)*2;

		if(s < dividedPiece.w){
			//縦に切る
				new1 = new piece(s,dividedPiece.d);
				new2 = new piece(dividedPiece.w-s, dividedPiece.d);

		}else if(dividedPiece.w + dividedPiece.d < s && s < dividedPiece.w *2 + dividedPiece.d) {
			//縦に切る
			new1 = new piece(s - dividedPiece.w - dividedPiece.d,dividedPiece.d);
			new2 = new piece(dividedPiece.w * 2 + dividedPiece.d -s, dividedPiece.d);
				}
		else if (dividedPiece.w < s && s < dividedPiece.w + dividedPiece.d) {
			//横に切る
			new1 = new piece(dividedPiece.w, s-dividedPiece.w);
			new2 = new piece(dividedPiece.w, dividedPiece.d + dividedPiece.w -s);
		}else {
			//横に切る
			new1= new piece(dividedPiece.w , s- dividedPiece.w * 2 - dividedPiece.d);
			new2 = new piece(dividedPiece.w, dividedPiece.w*2 + dividedPiece.d *2 -s);
		}
		if(new1.size() < new2.size()) {
			cakes.add(new1);
			cakes.add(new2);
		}else {
			cakes.add(new2);
			cakes.add(new1);
		}
		return;
	}
}

class piece {
	int w;
	int d;

	public piece(int w, int d){
		this.w = w;
		this.d = d;
	};
	public int size() {
		return this.w*this.d;
	}
}


Measured memory_bytes: 48328
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef long long ll;
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"         here"
#define out(value) cout<<value<<en


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

  int ans=1;
  for(int i=0; i<d; i++){
    ans*=100;
  }
  
  if(n!=100) cout<<n*ans<<en
  else cout<<101*ans<<en
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	ll n, a = 0, b = 0, f = 0, c = 0;
	cin >> n;
	rep(i, 0, n) {
		string s;
		cin >> s;
		rep(i2, 0, s.size() - 1) {
			if (s[i2] == 'A' && s[i2 + 1] == 'B')c++;
		}
		if (s.back() == 'A')a++;
		if (s.front() == 'B')b++;
		if ((s.back() == 'A') && (s.front() == 'B'))f++;
	}
	//printf("a:%lld b:%lld c:%lld f:%lld\n", a, b, c, f);
	printf("%lld\n", min(a, b) - (a == b && a == f && f > 0) + c);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ARC062 D

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  int p = 0;
  REP(i, N){
    if(S[i] == 'p') p++;
  }
  cout << N/2-p << endl;
}

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

const int maxn = 55;

long long f[maxn * maxn][maxn];
int x[maxn];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, a, s = 0; cin >> n >> a;
	for(int i = 0; i < n; ++ i) {
		cin >> x[i]; s += x[i];
	}
	f[0][0] = 1;
	for(int i = 0; i < n; ++ i) for(int j = s; j >= x[i]; -- j) {
		for(int k = 1; k <= n; ++ k)
			f[j][k] += f[j - x[i]][k - 1];
	}
	long long ans = 0;
	for(int i = 0; i <= s; ++ i) for(int j = 0; j <= n; ++ j) if(i == j * a) ans += f[i][j];
	cout << ans - 1 << "\n";
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define fl '\n'
#define vi vector<int>
#define sz size
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------
 
int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
 
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
 
    int n,l;
    vector<string>v;
    cin>>n>>l;
    for(int i=0;i<n;i++){
        string s;cin>>s;v.pb(s);
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(v[i]>v[j])swap(v[i],v[j]);
        }
    }
    for(auto it:v)cout<<it;
 
    return 0;
}

Measured memory_bytes: 256
function main(input) {
    const args = input.split(/\s/);
    const N = parseInt(args[0], 10),
          A = parseInt(args[1], 10),
          B = parseInt(args[2], 10);

    // const nums = [];
    // for (var i = 1; i <= N; i++) {
    //     var n = i.toString().split('').reduce((p, c) => p + parseInt(c), 0);
    //     if (n >= A && n <= B) nums.push(i);
    // }

    const nums = Array.from(new Array(N), (v, i) => ++i).filter((i) => {
        var n = i.toString().split('').reduce((p, c) => p + parseInt(c), 0);
        return (n >= A && n <= B);
    });
    
    console.log(nums.reduce((p, c) => p + c, 0));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 9968
from math import floor
a, b = map(int, input().split())
x1 = a/0.08
x2 = b/0.1
max_ = max(int(x1), int(x2)) + 100
min_ = min(int(x1), int(x2)) - 100

for i in range(min_, max_):
    if floor(i*0.08)==a and floor(i*0.1)==b:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3188
#include<stdio.h>
int main(){

  int h, a, n;
  scanf("%d %d",&h, &a);
  if(h%a==0){
  n=(h-h%a)/a;
  }
  else{
      n=(h-h%a)/a+1;
  }
  printf("%d\n", n);
  return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    REP(i, N) cin >> H[i];
    sort(ALL(H));
    reverse(ALL(H));
    ll ans = 0;
    REP(i, N) if (i >= K) ans += H[i]; 

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int calc(int x) {
	int ret = 0;
	while(x % 100 == 0) {
		x /= 100;
		++ret;
	}
	return ret;
}
int main() {
	int D, N;
	cin >> D >> N;
	int cnt = 0, val = 0;
	while(cnt < N) {
		++val;
		if(calc(val) == D) ++cnt;
	}
	cout << val << '\n';
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define N 2010
#define mod 1000000007
using namespace std;
int f[N];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	f[n+1]=1;
	for(int i=1;i<=m-1;i++)
		for(int j=n-i+1;j>=2;j--)
			f[j]=(f[j]+f[j+1])%mod;
    int ans=0;
	for(int i=2;i<=n-m+2;i++) (ans+=f[i])%=mod;
	if(m==1) ans=1;
	for(int i=1;i<=n-m-1;i++) ans=2ll*ans%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
ll mod = pow(10,9) + 7;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}


int main(void){
    ll a, b, x;
    cin >> a >> b >> x;
    if(a > 0){
        cout << b / x - (a - 1) / x << endl;
    } else {
        cout << (b / x) + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

vector<vector<int>> group(101010);
vector<int> id(101010);

void unite(int a, int b)
{
    int ga = id[a];
    int gb = id[b];
    if (ga == gb)
        return;
    if (group[ga].size() < group[gb].size())
    {
        swap(ga, gb);
    }
    for (auto x : group[gb])
    {
        group[ga].push_back(x);
        id[x] = ga;
    }
    group[gb].clear();
}

bool same_root(int a, int b)
{
    //cerr << a << ":" << id[a] << endl;
    //cerr << b << ":" << id[b] << endl;
    return id[a] == id[b];
}

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, n)
    {
        group[i] = {i};
        id[i] = i;
    }
    VI p(n);
    rep(i, n)
    {
        cin >> p[i];
        p[i]--;
    }
    rep(i, m)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        unite(x, y);
    }
    ll ans = 0;
    rep(i, n)
    {
        if (group[i].empty())
            continue;
        map<int, bool> mp;
        for (auto &&x : group[i])
        {
            mp[x] = true;
        }
        for (auto &&x : group[i])
        {
            if (mp[p[x]])
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14196
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = LI()
    dic = collections.Counter()
    for a in A:
        dic[a] += 1
    even = False
    if N % 2 == 0:
        even = True
    cnt = 1
    n_element = 0
    if not even:
        for key, val in dic.items():
            if key == 0:
                continue
            if key % 2 > 0:
                cnt = 0
                break
            if val != 2:
                cnt = 0
                break
            n_element += 1

        for i in range(n_element):
            cnt = cnt * 2 % mod
        if dic[0] != 1:
            cnt = 0
    else:
        for key, val in dic.items():
            if key % 2 == 0:
                cnt = 0
                break
            if val != 2:
                cnt = 0
                break
            n_element += 1

        for i in range(n_element):
            cnt = cnt * 2 % mod
    print(cnt)

main()



Measured memory_bytes: 16280