akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n;
    int a[105];
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int ans = 0;
    a[0] = 10002;
    a[n + 1] = 100005;
    int connected = 1;
    for(int i = 1; i <= n; i++){
        if(a[i] == a[i + 1]){
            connected++;
            continue;
        }
        ans += connected / 2;
        connected = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 1000000007;
int n, a[200020], ans;

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n;
	a[0]=-1;
	for(int i=1; i<=n; i++){
		cin>>a[i];
		if(a[i]>a[i-1]+1) return cout<<-1, 0;
		else if(a[i]<a[i-1]+1) ans+=a[i]-1;
	}
	cout<<n-1+ans;
}

Measured memory_bytes: 1792
def split(a, b):
	temp = a
	a = b
	b = temp
	return a, b

a, b, c = map(int, input().split())
temp = 0

if a > b:
	a, b = split(a, b)
if a > c:
	a, c = split(a, c)
if b > c:
	b, c = split(b, c)

print(a, b, c)

Measured memory_bytes: 7716
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,P;
    cin >> N >> P;
    int cnt[2] = {};
    for(int i = 0;i < N;i++){
        int a;
        cin >> a;
        cnt[a&1]++;
    }
    if(P)cout << (cnt[1]==0?0:(1LL << (N-1))) << endl;
    if(!P)cout << (1LL << (N-(cnt[1]!=0))) << endl;
}

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

#define  ll long long int
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define si(a) a.size()
#define p pair< ll,ll >
#define v vector< ll >
#define vi vector<p>
#define mem(tabl,i) memset(tabl, i, sizeof(tabl))
#define sp(x,y) fixed<<setprecision(y)<<lf(x)
#define debug(c) cout << #c << " = " << c << endl;
#define  f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define Mod 1000000007

const int N = 1e5 + 5;

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
      
           string s;
           ll n,k,b,c,x,y,z;
           ll counter=0,counter1=0,counter2=0;
           ll sum=0,result=0,ans=0, flag=0;
           cin>>n;
           double res=(double)2*3.141592653589793238*n;
           cout<<res<<endl;
       
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n, b[100000] = {};
    cin >> n;
    for (int i = 0;i < n - 1;i++) {
        cin >> b[i];
    }
    int m = b[0] + b[n - 2];
    for (int i = 1; i < n - 1;++i) {
        m += min(b[i - 1], b[i]);
    }
    cout << m << endl;
}

    
    




Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,ans,i,j,x,y,z;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>x>>y>>z;
    x-=z;
    cout<<x/(y+z)<<endl;
    return 0;
}



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

int main() {

	ll n; cin >> n;
	vector<ll> a(n + 1);
	ll sum = 0;
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	vector<ll> accum(n + 1, 0);
	for (ll i = 1; i <= n; i++) {
		accum[i] += a[i] + accum[i - 1];
	}
	ll ans = 9223372036854775807LL;
	for (ll i = 1; i <= n - 1; i++) {
		ll x = accum[i];
		ll y = sum - accum[i];
		ll tmp = abs(x - y);
		ans = min(ans, tmp);
	}
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
n = gets.to_i
a = gets.split.map(&:to_i).sort
sum = 0
(n-2).times do |i|
  ((i+1)...(n-1)).each do |j|
    next if a[i] == a[j]
    ((j+1)...n).each do |k|
      next if a[i] + a[j] <= a[k] || a[j] == a[k] 
      sum += 1
    end
  end
end
puts sum

Measured memory_bytes: 14424
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n,k;
  cin>>n>>k;
  if(n==2){
    if(k>0){
	 cout<<-1<<endl;
    }else{
	 cout<<1<<endl;
	 cout<<"1 2"<<endl;
    }
    return 0;
  }
  if(k>(n-1)*(n-2)/2){
    cout<<-1<<endl;
    return 0;
  }
  int sum=(n-1)*(n-2)/2;
  vector<P> ans;
  for(int i=2;i<=n;i++)ans.pb(P(1,i));
  for(int i=2;i<n;i++){
    for(int j=i+1;j<=n;j++){
	 if(sum==k)break;
	 ans.pb(P(i,j));
	 if(--sum==k)break;
    }
    if(sum==k)break;
  }
  cout<<ans.size()<<endl;
  for(int i=0;i<sz(ans);i++){
    cout<<ans[i].fi<<" "<<ans[i].se<<endl;
  }
  return 0;
}


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

int main()
{
    int a, b, c, ans;
    cin >> a >> b >> c;
    ans = a + b + c;
    if (ans <= 21)
    {
        cout << "win" << endl;
    }
    else
    {
        cout << "bust" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
	int a, b,c,d, q, w;
	scanf("%d%d%d%d", &a, &b, &c,&d);
	q = a * b, w = c * d;
	if (q > w)
	{
		printf("%d", q);
	}
	else printf("%d", w);
	system("pause");
	return 0;
}

Measured memory_bytes: 376
#include <iostream>

using namespace std;

int main() {
	int w = 0;
	int h = 0;
	int x = 0;
	int y = 0;
	int r = 0;
	cin >> w >> h >> x >> y >> r;
	if (((y + r) > h) || ((y - r) < 0)) {
		cout << "No" << endl;
	} else if (((x + r) > w) || ((x - r) < 0)) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 3088
import java.util.Scanner;

class QuickSort {
    static void sort(int[] a, int[] b){
        partialySort(a, b, 0, a.length - 1);
    }

    static void partialySort(int[] a, int[] b, int left, int right){
        if(right <= left)
            return;
        
        int pivot = a[(left+right)/2];
        int i = left;
        int j = right;
        int temp;
        while(i <= j){
            while(a[i] < pivot)
                i++;
            while(a[j] > pivot)
                j--;
            if(i <= j){
                temp = a[i];
                a[i] = a[j];
				a[j] = temp;
				temp = b[i];
				b[i] = b[j];
				b[j] = temp;
                i++;
                j--;
            }
        }

        partialySort(a, b, left, j);
        partialySort(a, b, i, right);
    }
}

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
		int n = stdIn.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i=0; i<n; i++){
			a[i] = stdIn.nextInt();
			b[i] = stdIn.nextInt();
		}

		QuickSort.sort(b, a);

		int time = 0;
		for(int i=0; i<n; i++){
			time += a[i];
			if(time > b[i]){
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");
	}
}


Measured memory_bytes: 61888
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
int n,k,a[N];
ll ans;
int main()
{
    scanf("%d%d",&k,&n);
    ans=k/n;
    if(k%n) ans++;
    cout<<ans;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll ma(ll x, ll y){
    if(x>y)return x;
    return y;
}

int a[10000];
int main(void){
    int n; cin >> n; for(int i = 0;i < n;i++)cin >> a[i]; ll ans = 0;
    for(int i = 0;i < n;i++)while(a[i]%2==0){a[i]/=2; ans++;}
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int n; cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vector<int> v(n);
    rep(i, n) v[i] = i+1;
    int a, b;
    int cnt = 0;
    do{
        bool flg = true;
        rep(i, n) if (v[i]!=p[i]) { flg = false; break; }
        if (flg) a = cnt;
        flg = true;
        rep(i, n) if (v[i]!=q[i]) { flg = false; break; }
        if (flg) b = cnt;
        ++cnt;
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(a - b) << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int maxnum = 0;
    int n;
    cin >> n;
    vector<string> a;
    vector<string> answer;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        a.push_back(s);
    }

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

    string now = "";
    int cnt = 0;
    for (int i = 0; i < n + 1; i++) {
        if (a[i] != now) {
            if (cnt > maxnum) {
                maxnum = cnt;
                answer.clear();
                answer.push_back(now);
            }
            else if (cnt == maxnum) {
                answer.push_back(now);
            }
            cnt = 1;
            now = a[i];
        }
        else {
            cnt++;
        }
    }


    for (int i = 0; i < answer.size(); i++) cout << answer[i] << endl;

    /*for (int i = 0; i < n; i++) {
        string s;
        cin >> s;

        if (a.find(s) != a.end()) {
            if (a.count(s) + 1 > maxnum) {
                maxnum = a.count(s) + 1;
                answer.clear();
                answer.push_back(s);
            }
            else if (a.count(s) + 1 == maxnum) {
                answer.push_back(s);
            }
        }
        else {
            if (maxnum <= 1) {
                maxnum = 1;
                answer.push_back(s);
            }
        }
        a.insert(s);

    }*/

    /*sort(answer.begin(), answer.end());
    for (int i = 0; i < answer.size(); i++) cout << answer[i] << endl;*/

    return 0;

}

Measured memory_bytes: 15984
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int DP [][] = new int[N][3];
        DP[0][0] = sc.nextInt();
        DP[0][1] = sc.nextInt();
        DP[0][2] = sc.nextInt();
        for(int i=1;i<N;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            DP[i][0] = Math.max(DP[i-1][1],DP[i-1][2])+a;
            DP[i][1] = Math.max(DP[i-1][0],DP[i-1][2])+b;
            DP[i][2] = Math.max(DP[i-1][0],DP[i-1][1])+c;
        }
        int max = 0;
        for(int i:DP[N-1]) if(max<i) max = i;
        System.out.println(max);
    }
}

Measured memory_bytes: 99100
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
using namespace std;

int main(){
	while(1){
		string a;
		int n=0,s=0,e=0,w=0;
		getline(cin,a);
		if(feof(stdin))
			break;
		for(int i=0;i<a.size();i++){
			if(a[i]=='S'){
				s++;
			}
			if(a[i]=='W'){
				w++;
			}
			if(a[i]=='E'){
				e++;
			}
			if(a[i]=='N'){
				n++;
			}
		}
		
		int aux1=s-n;
		int aux2=e-w;
		if(s!=0 && n!=0 && w!=0 && e!=0){
			printf("Yes\n");
		}
		else if(s>0 && n>0 && e==0 && w==0){
			printf("Yes\n");
		}
		else if(s==0 && n==0 && e>0 && w>0){
			printf("Yes\n");
		}
		else 
			printf("No\n");
	}
return 0;
}

Measured memory_bytes: 256
import collections as coll

n = int(input())
v = list(map(int,input().split()))
even = v[0::2]
odd = v[1::2]

oddc = coll.Counter(odd).most_common()[:2]
evenc = coll.Counter(even).most_common()[:2]

if(len(oddc) == 1):
	oddc.append((0,0))
if(len(evenc) == 1):
	evenc.append((0,0))


if(oddc[0][0] != evenc[0][0]):
	print(n - oddc[0][1] - evenc[0][1])
else:
	print(min(n-oddc[0][1]-evenc[1][1],n-oddc[1][1]-evenc[0][1]))

Measured memory_bytes: 17500
import collections
n = int(input())
a = [int(i) for i in input().split()]
c = collections.Counter(a)
if n%2==0:
	if all(c[i]==2 for i in range(1,n+1,2)):
		answer = (2**(n//2))%(10**9+7)
	else: answer = 0
else:
	if all(c[i]==2 for i in range(2,n+1,2)) and c[0]==1:
		answer = (2**((n-1)//2))%(10**9+7)
	else: answer = 0
print(answer) 

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

typedef unsigned long long uLL;
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;
typedef pair <long long,long long> pll;
typedef pair <long long,pll> plll;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int MOD = 1000000007;

/**
knapsack for huge capacity but smaller values
*/

int n;
LL cap;
LL v[ N ] , w[ N ];
LL dp[ 101 ][ N ];

LL solve( int idx , int rem ) {
        if( rem < 0 ) return INF;
        if( rem == 0 ) return 0;
        if( idx > n ) return rem == 0 ? 0 : INF;
        if( dp[idx][rem] != -1 ) return dp[idx][rem];
        LL ret = INF;
        ret = solve( idx + 1 , rem );
        ret = min( ret , solve( idx + 1 , rem - v[idx] ) + w[idx] );
        return dp[idx][rem] = ret;
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( NULL );
        cin >> n >> cap;
        LL tot = 0;
        for( int i = 1; i <= n; i++ ) cin >> w[i] >> v[i] , tot += v[i];
        LL ans = 0;
        memset( dp , -1, sizeof( dp ) );
        for( LL i = tot; i >= 0; i-- ) {
                LL mn_weight = solve( 1 , i );
                if( mn_weight <= cap ) ans = max( ans , i );
        }
        cout << ans << endl;
        return 0;
}













Measured memory_bytes: 80128
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

string yorn(bool a){if(a) return"Yes" ; return "No" ;}
string YorN(bool a){if(a) return"YES" ; return "NO" ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll h,w ;
	cin >> h >> w ;
	if(h==1||w==1){
		cout << 1 << endl ;
		return 0 ;
	}
	if(h%2==0||w%2==0) cout << h*w/2 << endl ;
	else cout << h*w/2+1 << endl ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int A[N];
int n;

void solve()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int sum = 0;
	
	sum += min(k,a);
	k -= min(k,a);
	if(k > 0)
	{
		k -= min(k,b);
	}
	if(k > 0)
	{
		sum -= min(k,c);
	}

	cout << sum;
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	

 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
    int i, x, n, p[105], j;
    scanf("%d %d", &x, &n);
    if(n==0)
    {
        printf("%d", x);
        return 0;
    }
    for(i=0; i<n; i++)
    {
        scanf("%d", &p[i]);
    }
    for(i=0; i<n+1; i++)
    {
        int a=0, b=0;
        for(j=0; j<n; j++)
        {
            if(x-i==p[j])
            {
                a++;
            }
            if(x+i==p[j])
            {
                b++;
            }
        }
        if(a<1)
        {
            printf("%d", x-i);
            return 0;
        }
        if(b<1)
        {
            printf("%d", x+i);
            return 0;
        }
    }
}


Measured memory_bytes: 1728
import { readFileSync } from 'fs'

function main(input: string) {
  const [n, ...rots] = input.split(/\s/).map(Number)

  rots.sort((a, b) => a - b)

  let res = 0

  for (let a = 0; a < n; a++) {
    for (let b = a + 1; b < n; b++) {
      if (rots[b] === rots[a]) continue

      for (let c = b + 1; c < n; c++) {
        if (rots[c] === rots[a] || rots[c] === rots[b]) continue

        if (rots[a] + rots[b] > rots[c]) {
          res += 1
        }
      }
    }
  }

  console.log(res)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 32436
n,m,x = map(int,input().split())
a_list = list(map(int,input().split()))
n_to_0 = 0
n_to_n = 0
t = x
while t > 0:
  if t in a_list:
    n_to_0 += 1
  t -= 1
u = x
while u < n:
  if u in a_list:
    n_to_n += 1
  u += 1
print(min(n_to_n, n_to_0))

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

int main(void){
    int a,b;
    cin >> a >> b;
    int c[4] = {};
    c[a]++;
    c[b]++;
    for(int i =1;i < 4;i++){
        if(c[i] == 0)cout << i;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
  cin>>a>>b>>c;
  int temp=a;
  a=b;
  b=temp;
  int temp2=a;
  a=c;
  c=temp2;
  cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
vector<int> G[100000];
bool used[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  queue<P> q;
  q.push(P(0, 0));
  q.push(P(N-1, 1));
  used[0] = true;
  used[N-1] = true;
  int A = 0, B = 0;
  while (!q.empty()) {
    int x = q.front()._1,
        turn = q.front()._2;
    q.pop();
    if (turn == 0) A++;
    else B++;

    for (int t : G[x]) {
      if (used[t]) continue;
      used[t] = true;
      q.push(P(t, turn));
    }
  }
  if (A <= B) cout << "Snuke\n";
  else cout << "Fennec\n";
  return 0;
}


Measured memory_bytes: 6144
import collections

def main():
    N, M = map(int, input().split())
    p = list(map(int, input().split()))
    graph = collections.defaultdict(set)
    for _ in range(M):
        a, b = map(int, input().split())
        graph[a].add(b)
        graph[b].add(a)

    sets = []
    visited = set()
    idx = [-1 for _ in range(N+1)]
    j = 0
    for a in range(1, N+1):
        if a not in visited:
            visited.add(a)
            cur = [a]
            j += 1
            idx[a] = j
            while cur:
                temp = []
                for a in cur:
                    for b in graph[a]:
                        if b not in visited:
                            visited.add(b)
                            idx[b] = j
                            temp.append(b)
                cur = temp
    # print(idx)
    count = 0
    for i in range(N):
        if idx[i+1] == idx[p[i]]:
            count += 1
    return count



if __name__ == '__main__':
    print(main())

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

double solve() {
    ll N, a;
    cin >> N;
    double ans = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        ans += 1/(double)a;
    }
    return 1/ans;
}

int main() {
    cout.precision(15);
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

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

    int maxScore = 1;
    for (int i = 1; i <= N; i++) {
        if (i * (i + 1) / 2 >= N) {
            maxScore = i;
            break;
        }
    }

    for (int i = 1; i <= maxScore; i++) {
        if (i == maxScore * (maxScore + 1) / 2 - N) continue;
        cout << i << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

using Edge = pair<int, ll>;
using Graph = vector<vector<Edge>>;

Graph G;
vector<ll> dist;

void dfs(int cur, int pre, ll sum) {
	dist[cur] = sum;
	
	for (auto to : G[cur]) {
		if (to.first != pre) {
			dfs(to.first, cur, sum + to.second);
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n;
	cin >> n;
	
	G.resize(n);
	
	rep(i, n - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		G[a].push_back(make_pair(b, c));
		G[b].push_back(make_pair(a, c));
	}

	int q, k;
	cin >> q >> k;
	k--;

	dist.resize(n, 0);

	dfs(k, -1, 0);

	rep(i, q) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		out(dist[x] + dist[y]);
	}

	return 0;
}

Measured memory_bytes: 14336
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int min = 1000;
    for(int i = 0; i < str.length() - 2; i++){
      String tmp = str.substring(i, i+3);
      int d = Math.abs(753 - Integer.parseInt(tmp));
      min = min < d ? min : d;
    }
    System.out.println(min);
  }
}

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

int main() {
	ll h, n;
	cin >> h >> n;
	vector<ll> a(n);
	rep(i, n) { cin >> a[i]; }

	sort(a.begin(), a.end(), greater<ll>());
	for (ll i = 0; i < n; i++) {
		h -= a[i];
		if (h <= 0) {
			break;
		}
	}

	if (h <= 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

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

int main() {
	string S;
	cin>>S;
	int f=-1;
	int e=S.size();
	int i,j;
	int total=0;
	while(1){
		for(i=f+1;i<e&&S[i]=='x';++i);
		for(j=e-1;j>f&&S[j]=='x';--j);
		if(S[i]!=S[j]){
			total=-1;
			break;
		}
		total+=abs((i-f)-(e-j));
		f=i;
		e=j;
		if(e-f<2)break;
	}
	cout<<total<<endl;
	return 0;

}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;


int main(){

  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;

  set<int>w;
  int water;
  set<int>::iterator itr;

  //---------------------前処理開始

  //水の量の組み合わせ（重複なし）
  for(int i=f/(100*a);i>=0;i--){
    for(int j=(f-100*a*i)/(100*b);j>=0;j--){
      water=100*(a*i+b*j);
      if(w.find(water)==w.end()){
        w.insert(water);
      }
    }
  }
  //砂糖の組み合わせ（100g毎の最大の溶ける量）
  int ma=0;
  int s[35]={0};
  for(int k=0;k<f/100;k++){
    for(int i=0;c*i<=e*k;i++){
      for(int j=0;c*i+d*j<=e*k&&c*i+d*j<=f-100*k;j++){
        ma=max(c*i+d*j,ma);
      }
    }
    s[k]=ma;
    ma=0;
  }
  //----------------------前処理終了

  double den=0,now=0;
  int sum=100*a,salt=0;
  for(itr = w.begin(); itr != w.end();) {
    ++itr;
    int num=(*itr)/100;
    now=(double)100*s[num]/((*itr)+s[num]);
    if(den<now){
      den=now;
      sum=(*itr)+s[num];
      salt=s[num];
    }
  }

  cout<<sum<<" "<<salt<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
 
int main() {
	ios::sync_with_stdio(0); 
	cin.tie(0);
 
ll n;
cin>>n;

ll x;
if(n%1000==0)cout<<0;
else
{
	x=(n+1000)/1000;
	ll ans=1000*x-n;
	cout<<ans;
}


	
}
 

Measured memory_bytes: 3624
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using llv = vector<ll>;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD7 = 1000000007;
	constexpr ll MOD9 = 1000000009;

	template<typename T>
	void init(vector<T>& v, T initVal = T()){
		for(auto& e : v){
			e = initVal;
		}
	}

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	void reverse(vector<T>& v){
		reverse(all(v));
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T1, typename T2>
	inline vector<T1>& operator+=(vector<T1>& v1, const vector<T2>& v2){
		for(const auto& e : v2) v1.push_back(e);
		return v1;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T1, typename T2>
	void in(vector<T1>& v1, vector<T2>& v2){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i];
	}
	template<typename T1, typename T2, typename T3>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i];
	}
	template<typename T1, typename T2, typename T3, typename T4>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3, vector<T4>& v4){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i] >> v4[i];
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	template<typename T>
	inline set<T>& operator+=(set<T>& v, const T& e){
		v.insert(e);
		return v;
	}

	template<typename T1, typename T2>
	inline set<T1>& operator+=(set<T1>& v1, const set<T2>& v2){
		for(const auto& e : v2) v1.insert(e);
		return v1;
	}

	constexpr ll modPow(ll x, ll n, ll m){ // O(logn)
		if(n == 0) return 1;
		else if(n % 2 == 0) return modPow((x * x) % m, n / 2, m);
		else return x * modPow(x, n - 1, m) % m;
	}
}
using namespace atcoder;
#endif



int main(){
	cout << fixed << setprecision(15);
	
	ll X;cin>>X;

	for(ll A=1;A<=200;A++){
		ll B5 = A*A*A*A*A-X;
		if(B5==0){
			cout << A << " " << 0 << endl;
			return 0;
		}
		bool neg = false;
		if(B5<0){
			neg = true;
			B5 *= -1;
		}
		ll B = (ll)(pow(B5, 0.2) + 0.5);
		
		if(B*B*B*B*B==B5){
			B *= neg ? -1 : 1;
			cout << A << " " << B << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 4100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var points = int.Parse(Console.ReadLine());
            bool flg = true;
            int fromX = 0;
            int fromY = 0;
            int startTime = 0;
            for (int i = 0; i < points; i++)
            {
                var r = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                flg = CanArrive(fromX, fromY, r[1], r[2], startTime, r[0]);
                fromX = r[1];
                fromY = r[2];
                startTime = r[0];


                if (!flg)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }

        private static bool CanArrive(int fromX,int fromY,int toX,int toY,int startTime,int endTime)
        {
            var difTime = endTime - startTime;
            var difX = Math.Abs(toX - fromX);
            var difY = Math.Abs(toY - fromY);
            if (difTime < difX + difY)
            {
                return false;
            }

            if (difTime == difX + difY)
            {
                return true;
            }

            if (difTime % 2 == 1 && (difX + difY) % 2 == 1 ||
                difTime % 2 == 0 && (difX + difY) % 2 == 0)
            {
                return true;
            }

            return false;
        }
    }
}

Measured memory_bytes: 15404
#include <stdio.h>
int s[1000000];
int main(void)
{
	int n;
	int i;
	int j;
	int c;
	
	for (i = 2; i * i <= 1000000; i++){
		if (s[i] == 0){
			for (j = i; j < 1000000; j += i){
				if (!(i == j)){
					s[j] = 1;
				}
			}
		}
	}
	
	while (scanf("%d", &n) != EOF){
		c = 0;
		for (i = 2; i <= n; i++){
			if (s[i] == 0){
				c++;
			}
		}
		printf("%d\n", c);
	}
	
	return (0);
}

Measured memory_bytes: 4500
#include<bits/stdc++.h>
using namespace std;
#define f(a,b,c) for(int a=(b);a<=(c);++a)
const int maxn=3e4+2;
int he[maxn],ne[maxn],to[maxn],w[maxn],cnt=1;
inline void addedge(int x,int y,int z)
{
	ne[++cnt]=he[x],he[x]=cnt,to[cnt]=y,w[cnt]=z;
	ne[++cnt]=he[y],he[y]=cnt,to[cnt]=x,w[cnt]=0;
}
int S,T;
int dis[maxn],inq[maxn];
int bfs()
{
	f(i,1,T)inq[i]=dis[i]=0;
	queue<int>q;q.push(S),dis[S]=1;
	while(q.size())
	{
		int x=q.front();q.pop();inq[x]=0;
		for(int i=he[x];i;i=ne[i])
		{
			if(w[i]&&!dis[to[i]])
			{
				dis[to[i]]=dis[x]+1;
				if(!inq[to[i]])
				{
					inq[to[i]]=1;
					q.push(to[i]);
				}
			 } 
		}
	}
	return dis[T];
}
int cur[maxn];
int dfs(int x,int f)
{
	if(f==0||x==T)return f;
	int ans=0;
	for(int i=cur[x];i&&ans<f;i=ne[i])
	{
		cur[x]=i;
		if(dis[x]+1==dis[to[i]]&&w[i]){
			int qwq=dfs(to[i],min(f-ans,w[i]));
			ans+=qwq;w[i]-=qwq;w[i^1]+=qwq;
		}
	}
	return ans;
}
int dinic()
{
	int ans=0;
	while(bfs())
	{
		f(i,1,T)cur[i]=he[i];
		ans+=dfs(S,1e9);
	}
	return ans;
}
vector<int>c[101][101];
int n,m;
int a[101][101];
int e[101][101];
int b[101][101];
void clear()
{
	cnt=1;
	f(i,1,T)he[i]=0;
}
int qwq[101];
int main()
{
	scanf("%d%d",&n,&m);
	f(i,1,n)f(j,1,m)scanf("%d",&a[i][j]),c[i][(a[i][j]-1)/m+1].push_back(a[i][j]);
	S=n+n+1,T=S+1;
    f(k,1,m)
    {
//    	cout<<k<<":\n";
    	f(i,1,n)f(j,1,n)
    	{
    		e[i][j]=-1;
    		if(c[i][j].size())
    		{
    			addedge(i,n+j,1);
    			e[i][j]=cnt-1;
//    			cout<<i<<" "<<j<<"\n";
			}
		}
		f(i,1,n)
		{
		    addedge(S,i,1);
		    addedge(i+n,T,1);
		}
		dinic();
		f(i,1,n)f(j,1,n)
		{
			if(e[i][j]>=0&&w[e[i][j]]==0)
			{
				b[i][k]=c[i][j][c[i][j].size()-1];
				c[i][j].pop_back();
				break;
			}
		}
		clear();
	}
	f(i,1,n)f(j,1,m)printf("%d%c",b[i][j]," \n"[j==m]);
	f(j,1,m)
	{
		f(i,1,n)qwq[i]=b[i][j];
		sort(qwq+1,qwq+n+1);
		f(i,1,n)b[i][j]=qwq[i];
	}
	f(i,1,n)f(j,1,m)printf("%d%c",b[i][j]," \n"[j==m]);
	return 0;
	
}

Measured memory_bytes: 1280
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

c1 = readInts()
c2 = readInts()
c3 = readInts()

for a1 in range(-100,101):
	b1 = c1[0]-a1
	b2 = c1[1]-a1
	b3 = c1[2]-a1
	a2 = c2[0]-b1
	a3 = c3[0]-b1
	if c2[1]==a2+b2 and c2[2]==a2+b3 and c3[1]==a3+b2 and c3[2]==a3+b3:
		print("Yes")
		exit()

print("No")

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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

/* --------------- template start --------------- */
template <typename T> 
struct BinaryIndexTree { // [1, n]
    vector<T> array;
    int n;

    BinaryIndexTree(int _n) {
        array.resize(_n + 1, 0);
        n = _n;
    }

    T cumsum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i;
        }

        return s;
    }

    T sum(int i, int j) {
        T ret_i = cumsum(i - 1);
        T ret_j = cumsum(j);

        return ret_j - ret_i;
    }

    void add(int i, T x) {
        while (i <= n) {
            array[i] += x;
            i += i & -i;
        }
    }
};

template<typename T>
struct UnionFind {
    vector<int> par;
    vector<T> sz;

    UnionFind(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }

    T size_of_tree(int x) {
        return sz[find_root(x)];
    }
};
/* --------------- template end --------------- */

/* --------------- function start --------------- */
llong my_gcd(llong a, llong b) {
    return (a ? my_gcd(b % a, a) : b);
}
llong my_lcm(llong a, llong b) {
    return a * b / my_gcd(a, b);    
}

llong facmod(llong n) {
    if (n == 0) return 1;

    llong res = n;
    for (int i = n - 1; i > 0; --i) {
        res = (res * i) % MOD;
    }

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

    return res;
}
llong modinv(llong n) {
    return powmod(n, MOD - 2);
}
llong combmod(llong n, llong k) {
    llong res = 1;
    for (int i = 0; i < k; ++i) {
        res = (res * (n - i)) % MOD;
    }
    res = (res * modinv(facmod(k))) % MOD;

    return res;
}
/* --------------- function end --------------- */

int n;

void dfs(string S, char mc) {
    if ((int)S.size() == n) cout << S << endl;
    else for (char c = 'a'; c <= mc; ++c) dfs(S + c, ((c == mc) ? (char)(mc + 1) : mc)); 
}

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;

    dfs("", 'a');

    return 0;
}

Measured memory_bytes: 1536
import sys
arr = {}
for i in sys.stdin:
    if int(i) in arr:
        arr[int(i)] += 1
    else:
        arr[int(i)] = 1
max = 0
ans = []
for i in arr.keys():
    if arr[i] > max:
        ans = [i]
        max = arr[i]
    elif arr[i] == max:
        ans.append(i)
for i in ans:
    print(i)

Measured memory_bytes: 7620
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;
double getRadian(double x, double y)
{
    double radian = atan2(y, x);
    return radian;
}
//radianをdegreeに変換

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    if (2*x <= a * a * b)
    {
        double l = 2 * x / (a * b);
        double radian = atan2(b, l);
        double ans = radian * 180 / M_PI;
        cout << setprecision(12) << ans << endl;
    }
    else
    {
        double y =  a * a * b - x;
        double l = 2 * y / (a * a);
        
        double radian = atan2(l,a);
        double ans = radian * 180 / M_PI;
        cout << setprecision(12) << ans << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int N,a,b,m=-1;
ll k[100005]={0},K;
int main()
{
	scanf("%d%lld",&N,&K);
	for(int i=0;i<N;i++)
	{
		scanf("%d%d",&a,&b);
		k[a]+=b;
		m=max(a,m);
	}
	ll t=0,r=-1;
	for(int i=0;i<=m&&t<K;i++)
	{
		if(k[i]>0)
			r=i;
		t+=k[i];
	}
	printf("%d\n",r);
	return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/

int main(){
	ll k,a,b;
	inl3(k,a,b);
	if(k>a&&a<=b)out(-1);
	 else {
	 	k-=a;
	 	if(k<=0)out(1);
	 	 else {
	 	 	int c=0;
	 	 	if(k%(a-b)==0)c=0;
	 	 	 else c=1;
	 	 	outl((k/(a-b)+c)*2+1);
	 	 }
	 }
}


































Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int a,b;
    cin>>a>>b;

    if (a<b) cout<<"a < b\n";
    else if (a>b) cout<<"a > b\n";
    else cout<<"a == b\n";
    return 0;
}


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

const int INF = 1001001001;



int main(){
    int n;cin>>n;
    vector<ll>x(n);
    vector<ll>y(n);
    rep(i,n){
      cin>>x[i]>>y[i];
    }
     double sum=0;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        sum+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
      }
    }
    cout<<fixed<<setprecision(7);
    cout<<sum*2/n<<endl;
}


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

using namespace std;
int n,a[1000005],fac[1000025],p;

inline int power(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = res * a % p;
		a = a * a % p, b >>= 1;
	}
	return res;
}

inline int C(int n, int m) {
	if (m > n) return 0;
	return fac[n] * power(fac[m], p - 2) % p *  power(fac[n - m], p - 2) % p;
}

inline int Lucas(int n, int m) {
	if (!m) return 1;
	return C(n % p, m % p) * Lucas(n / p, m / p) % p;
}
inline void init() {
	int maxn = p;
	fac[0] = 1;
	for (int i = 1; i <= maxn; i++) fac[i] = fac[i - 1] * i % p;
}


int main()
{
    scanf("%d\n",&n);
    if(n==1)
    {
        printf("%d\n",getchar()-'0');
        return 0;
    }
    char now;
    bool oex = false;int cc = 1;
    for(int i=0;i<n;++i){
        a[i] = getchar()-'0';
        a[i]-=1;
        if(a[i]==1) oex = true;
    }
    int ocnt =0;n-=1;
    int tcnt = 0;p=2;

    for(int i=0;i<=n;++i)
    {
        init();
        if(a[i]==1){
            ocnt += (Lucas(n,i) +2);
            ocnt %= 2;
        }
        if(a[i]==2){
            tcnt += (Lucas(n,i) +2);
            tcnt %= 2;
        }
    }

    if(ocnt) {
        printf("1\n");return 0;
    }

    if(oex) {
        printf("0\n");return 0;
    }

    if(tcnt) printf("2\n");
    else printf("0\n");

    return 0;
}


Measured memory_bytes: 6016
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func scanInts(n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = nextInt()
	}
	return is
}

func main() {
	s := nextString()
	if s[len(s)-1:len(s)] == "s" {
		fmt.Printf("%v%v\n", s, "es")
	} else {
		fmt.Printf("%v%v\n", s, "s")
	}
}


Measured memory_bytes: 1812
N = gets.chomp.to_i
s = gets.chomp

l_cnt = 0
r_cnt = 0

N.times do |i|
  if s[i] == '('
    l_cnt += 1
  end

  if s[i] == ')'
    if l_cnt == 0
      r_cnt += 1
    else
      l_cnt -= 1
    end
  end
end

# p l_cnt
# p r_cnt

puts '(' * r_cnt + s + ')' * l_cnt


Measured memory_bytes: 1788