akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v;
    long double value = 0;

    int input;
    for (int i = 0; i < n; i++)
    {
        cin >> input;
        v.push_back(input);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    if (n > 2)
    {
        value += v[n - 1] * pow(0.5, n-1);
        for (int i = 1; i < n - 1; i++)
        {
            value += v[i] * pow(0.5, i + 1);
        }
    }
    else
    {
        value += v[1] * 0.5;
    }

    value += v[0] * 0.5;
    cout << value;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a[2005], dp[2005];
int mod = 1e9 + 7;
int binpow(int a, int b){
	if (b == 0) return 1;
	int x = binpow(a, b / 2);
	x *= x; x %= mod;
	if (b % 2) return (x * a) % mod;
	else return x;
}
signed main(){
	int n, k; cin >> n >> k;
	int cur = 0;
	for (int i = 1; i <= sqrt(n); i++){
		if (n % i == 0){
			a[cur] = i; cur++;
			if (i * i != n){
				a[cur] = n / i; cur++;
			}
		}
	}
	sort(a, a + cur);
	for (int i = 0; i < cur; i++){
		dp[i] = binpow(k, (a[i] + 1) / 2);
		for (int j = 0; j < i; j++){
			if (a[i] % a[j] == 0){
				((dp[i] -= dp[j]) += mod) %= mod;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < cur; i++){
		if (a[i] % 2) (ans += (dp[i] * a[i])) %= mod;
		else (ans += (dp[i] * (a[i] / 2))) %= mod;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	vector<int> pos_list(5, 0);

	for (int i = 0; i < 5; i++)
	{
		cin >> pos_list[i];
	}

	int k;
	cin >> k;

	bool check = false;
	for (int i = 0; i < 4; i++)
	{
		for (int j = i + 1; j < 5; j++)
		{
			if (pos_list[j] - pos_list[i] > k)
			{
				check = true;
				break;
			}
		}
	}

	if (check)
	{
		cout << ":(";
	}
	else
	{
		cout << "Yay!";
	}

	return 0;
}


Measured memory_bytes: 3600
// AOJ 0132: Jigsaw Puzzle
// 2017.12.16 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char puzzle[22][22]; int h, w;

char parts[11][4][22][22];
int n, ph[11][4], pw[11][4], ps[11];

typedef struct { int id, s; } T;
T sel[11]; int m;						// ?????????????????????

char mk[22][22];

int cmp(T *a, T *b) { return b->s - a->s; }

void rotate(int i, int j)
{
	int r, c;

	ph[i][j+1] = pw[i][j], pw[i][j+1] = ph[i][j];
	for (r = 0; r < ph[i][j]; r++) for (c = 0; c < pw[i][j]; c++)
		parts[i][j+1][c][ph[i][j]-r-1] = parts[i][j][r][c];
}

int check(int k)
{
	int i, j, kk, r, c, rr, cc;

	memset(mk, 0, sizeof(mk));
	for (r = 0; r < h; r++) for (c = 0; c < w; c++) if (puzzle[r][c] == '.' && !mk[r][c]) {
		for (kk = k; kk < m; kk++) {
			i = sel[kk].id; for (j = 0; j < 4; j++) {
				rr = r - ph[i][j] + 1; if (rr < 0) rr = 0;
				for ( ; rr <= r && rr <= h-ph[i][j]; rr++) {
					cc = c - pw[i][j] + 1; if (cc < 0) cc = 0;
					for (; cc <= c && cc <= w-pw[i][j]; cc++) {
						int r2, c2;
						for (r2 = 0; r2 < ph[i][j]; r2++) for (c2 = 0; c2 < pw[i][j]; c2++) {
							if (parts[i][j][r2][c2] == '#' && puzzle[r2+rr][c2+cc] == '#') goto next;
						}
						for (r2 = 0; r2 < ph[i][j]; r2++) for (c2 = 0; c2 < pw[i][j]; c2++)
							if (parts[i][j][r2][c2] == '#') mk[r2+rr][c2+cc] = 1;

next:					;
					}
				}
			}
		}
		if (!mk[r][c]) return 0;
	}
	return 1;
}

int combi(int k)
{
	int i, j, r, c, rr, cc, t;

	if (k == m) return 1;
	if (!check(k)) return 0;

	i = sel[k].id;
	for (j = 0; j < 4; j++) {
		for (r = 0; r <= h-ph[i][j]; r++) for (c = 0; c <= w-pw[i][j]; c++) {
			for (rr = 0; rr < ph[i][j]; rr++) for (cc = 0; cc < pw[i][j]; cc++)
				if (parts[i][j][rr][cc] == '#' && puzzle[r+rr][c+cc] == '#') goto next;
			
			for (rr = 0; rr < ph[i][j]; rr++) for (cc = 0; cc < pw[i][j]; cc++)
				if (parts[i][j][rr][cc] == '#') puzzle[r+rr][c+cc] = '#';
			
			t = combi(k+1);

			for (rr = 0; rr < ph[i][j]; rr++) for (cc = 0; cc < pw[i][j]; cc++)
				if (parts[i][j][rr][cc] == '#') puzzle[r+rr][c+cc] = '.';
				
			if (t) return 1;
next:		;
		}
	}
	return 0;
}

int main()
{
	int p, i, j, k, r, c, s, t;

	while (scanf("%d%d", &h, &w) && h > 0) {
		for (s = 0, r = 0; r < h; r++) {
			scanf("%s", puzzle[r]);
			for (c = 0; c < w; c++) if (puzzle[r][c] == '.') s++;
		}
		
		scanf("%d", &n);
		for (i = 0; i < n; i++) {
			scanf("%d%d", &ph[i][0], &pw[i][0]);
			for (ps[i] = 0, r = 0; r < ph[i][0]; r++) {
				scanf("%s", parts[i][0][r]);
				for (c = 0; c < pw[i][0]; c++) if (parts[i][0][r][c] == '#') ps[i]++;
			}
			for (j = 0; j < 3; j++) rotate(i, j);
		}

		scanf("%d", &p);
		while (p-- > 0) {
			scanf("%d", &m);
			for (t = 0, i = 0; i < m; i++) {
				scanf("%d", &k), sel[i].id = --k, sel[i].s = ps[k], t += ps[k];
			}
			if (s != t) puts("NO");
			else {
				qsort(sel, m, sizeof(T), cmp);
				puts(combi(0) ? "YES" : "NO");
			}
		}
	}
	return 0;
}

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

int main(){
    /*int A,B,C;

    cin >> A >> B >> C;

    if(A==B || A==C || B==C){
        if(A==B && A==C && B==C) cout << "No";
        else cout << "Yes";
    }
    else cout << "No";*/

    /*int n;
    cin >> n;
    int a[n] ={};
    for(int i=0; i < n; i++) cin >> a[i];

    for(int i=0; i < n; i++){
        if(a[i]%2 == 0){
            if((a[i]%3 != 0) && (a[i]%5 != 0)){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;*/

    /*int n,r;
    cin >> n >> r;
    if(n>=10) cout << r << endl;
    else cout << r+(100*(10-n)) << endl;
    return 0;*/

    /*int n,k;
    cin >> n >> k;
    int count = 0;
    while(n!=0){
        n=n/k;
        count++;
    }
    cout << count << endl;
    return 0;*/

    int n,max,min,result=99999999,temp=0;
    int x[101] = {};
    int average_number=0,sum_enegy=0;
    cin >> n;
    /*max = 0;
    min = 101;*/
    for(int i=0; i < n; i++){
        cin >> x[i];
        /*if(max < x[i]) max = x[i];
        if(min > x[i]) min = x[i];*/
    }
    for(int i=1; i < 101; i++){
        temp=0;
        for(int j=0; j < n; j++){
            temp += (x[j]-i)*(x[j]-i);
        }
        if(result > temp) result = temp;
    }
    
    //cout << average_number << endl;
    /*for(int i=0; i < n; i++) sum_enegy += (x[i]-average_number)*(x[i]-average_number);*/
    cout << result << endl;
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  //t r = n / k;
  //int g = n % k;
  if (n % k == 0 ) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}


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

int main() {

    int a, b;
    cin >> a >> b;

    rep(i, 100000){
        if((int)(i * 0.08) == a && (int)(i * 0.1) == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	/**
	 * ??\?????¶?´??????¶??????????????????
	 * @param parse
	 * @param len
	 * @return
	 */
   public static int judge(ArrayList<Integer> parse, int len){
	   int result = 0;
	   int count = 0;
	   while(count<len){
		   if(parse.get(count) < 1 || parse.get(count) > 100){
			   result = 1;             //??\??????????????????????????????:1
		   }
		   else{
			   result = 0;             //??\??????????????????????????????:0
		   }
		   ++count;
	   }
	   return result;
   }
   /**
    * ??¢????¨???????????????????????????¢???
    * @param a
    * @param b
    * @return
    */
   public static int calcarea(int a, int b){
	   int area = a*b;
	   return area;
   }
   /**
    * ??¨??????????¨????????????????(????????¢)
    * @param a
    * @param b
    * @return
    */
   public static int calccir(int a, int b){
	   int cir = 2*a+2*b;
	   return cir;
   }

	public static void main(String[] args) throws IOException{
		int a,b;
		int temp=0;
		String str;

		/* ???????????£?¨? */
		ArrayList<String> st = new ArrayList<String>();
		ArrayList<Integer> parse = new ArrayList<Integer>(); // int??????

		/**
		 * ?????????????????\???
		 */
		Scanner scan = new Scanner(System.in);
		for (int i = 0; i < 2; i++) {
			st.add(scan.next());
		}

		int len = st.size(); // ?????????????´???°

		/**
		 * String???int????????¨int????????????????´?
		 */
		for (int p = 0; p < len; p++) {
			str = st.get(p);
			temp = Integer.parseInt(str);
			parse.add(temp);
		}

		a = parse.get(0);
		b = parse.get(1);

		/**
		 * ??????????????¨??¶?´???????
		 */
		if(judge(parse,len) == 0){
		System.out.println(calcarea(a,b)+(" ")+calccir(a,b));
		}
		else if(judge(parse,len) ==1){
			System.out.println("??\????????????1~100??\?????§???.???????????????");
		}

	}

}

Measured memory_bytes: 25980
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;} // ver. 2020-02-17
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

int main() {
    int d, k;
    cin >> k >> d;
    cout << d + 100 * (10 - min(10, k)) << endl;
    return 0;
}


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


// DAME:
int main() {
    ll n;
    cin >> n;
    vector<int> a(n+1);
    for(ll i=1; i<=n; i++){
        cin >> a[i];
    }
    vector<int> ans(n+1);

    for(ll i=n; i>=1; i--){
        ll tmp = i;
        int sum = 0;
        while(tmp+i<=n){
            tmp += i;
            sum += ans[tmp];
        }
        if(sum%2 != a[i]){
            ans[i] = 1;
        }
    }
    int size = 0;
    for(ll i=1; i<=n; i++){
        if(ans[i]){
            size++;
        }
    }
    cout << size << endl;
    for(ll i=1; i<=n; i++){
        if(ans[i]){
            cout << i << ' ';
        }
    }

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <utility>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 100000
#define MAXL 100
typedef long long int lli;

int notpflag[MAXSIZE + 1] = {1, 1};
int simto2017num[MAXSIZE + 1] = {};

int simto2017(int n);

int main(){
    for(lli i = 2; i < MAXSIZE + 1; i++){
        for(lli j = i * i; j < MAXSIZE + 1; j += i){
            if(notpflag[j] == 0){
                notpflag[j] = 1;
            }
        }
    }
    /* prime number has 0, else has 1 */

    for(int i = 2; i < MAXSIZE + 1; i++){
        simto2017num[i] = simto2017num[i - 1] + simto2017(i);
    }
    /* num of similar-to-2017 from 1 to max-index every x (1 <= x <= 100000) */

    int q;
    cin >> q;

    vector<int> l_vec, r_vec;
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l_vec.push_back(l);
        r_vec.push_back(r);
    }

    for(int i = 0; i < q; i++){
        if(l_vec[i] == 1){
            cout << simto2017num[r_vec[i]] << endl;
        }else{
            cout << simto2017num[r_vec[i]] - simto2017num[l_vec[i] - 1] << endl;
        }
    }
    return 0;
}

int simto2017(int n){
    if(notpflag[n] == 1){
        return 0;
    }
    int m = (n + 1) / 2;
    return (notpflag[m] == 0)? 1 : 0;
}

Measured memory_bytes: 2420
#include <cstdio> 
#include <algorithm>

int main() {
	
	int card[100000];
	int n;
	scanf("%d", &n);
	
	
	for(int i = 0; i < n ; i++) {
		scanf("%d", &card[i]);
	}
	
	std::sort(card, card + n);
	
	
	int count = 0;
	for(int i = 1; i < n; i++) {
		if(card[i] == card[i - 1]) count++;
	}
	
	count & 1 ? printf("%d\n", n - count - 1) : printf("%d\n", n - count);
	
	return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


void Main()
{
    int n;cin>>n;
    string s;cin>>s;

    int r=0;
    int b=0;

    REP(i,n){
        if(s[i] == 'R'){
            r++;
        }
        else{
            b++;
        }
    }

    if(r>b){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
	return;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<vector>
using namespace std;
int main(){
    string s;
    cin>>s;
    string t="ATCG";
    int ans=0;
    for(int i=0;i<s.size();i++){
        int now=0;
        for(int j=i;j<s.size();j++){
            bool judge=false;
            for(int k=0;k<t.size();k++){
                if(s[j]==t[k])judge=true;
            }
            if(judge){
                now++;
                ans=max(ans,now);
            }else{
                break;
            }
        }
    }
    cout<<ans<<endl;
}

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

#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
#define int LL
const int MAXN = 20+5;
int n,m,x;
int c[MAXN],a[MAXN][MAXN];
int sm[MAXN];

signed main(){
	scanf("%lld%lld%lld",&n,&m,&x);
	FOR(i,1,n){
		scanf("%lld",c+i);
		FOR(j,1,m) scanf("%lld",&a[i][j]),sm[j] += a[i][j];
	}
	FOR(i,1,m){
		if(sm[i] < x){
			puts("-1");return 0;
		}
	}
	LL ans = 1e18;
	FOR(S,0,(1<<n)-1){
		FOR(i,1,m) sm[i] = 0;int cst = 0;
		FOR(i,0,n-1){
			if((S>>i)&1){
				FOR(j,1,m) sm[j] += a[i+1][j];
				cst += c[i+1];
			}
		}bool flag = true;
		FOR(i,1,m){
			if(sm[i] < x){
				flag = false;
				break;
			}
		}
		if(flag) ans = std::min(ans,cst);//,DEBUG(cst),DEBUG(S);
	}
	printf("%lld\n",ans);
	return 0;
}

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

const llong MOD = 1e9+7;
const llong inf = 1<<30;

int main() {
    string S; cin >> S;
    string word[2] = {"ABC", "ARC"};
    string res;
    if (S == word[0]) {
        res = word[1];
    }else{
        res = word[0];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}    


signed main()
{
    showoff;
   	int n,it = 1,ans = 0;
   	cin >>n;
   	vector<int>v(n+5);
   	FOR(i,1,n+1)cin >> v[i];
   	FOR(i,1,n+1){
   		while(i <= n && v[i] != it)++i,++ans;
   		if(i <= n && v[i] == it)++it;
   	}
   	if(ans == n)cout << -1;
   	else cout << ans;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string s;
    cin>>s;
    bool yy = false;
    bool mm = false;
    if(s[0] == '1'&&(s[1] == '0'||s[1] == '1'||s[1] == '2')){
      yy = true;
    }
    if(s[0] == '0'&&s[1]!='0') yy =true;
    if(s[2] == '1'&&(s[3] == '0'||s[3] == '1'||s[3] == '2')){
      mm = true;
    }
    if(s[2] =='0'&&s[3]!='0') mm =true;
    if(yy && mm ==false) cout<<"MMYY";
    if(yy == false&&mm) cout<<"YYMM";
    if(yy&&mm) cout<<"AMBIGUOUS";
    if(yy == false&&mm ==false) cout<<"NA";
    return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    LL x,n=1,ans=0;
    cin >> x;
    while(x > 0)
    {
        ans+=n;
        n*=2;
        x/=2;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

int main() {
    ll n;cin>>n;set<ll>a;
    rep(i,n){
        ll A;
        cin>>A;
        a.insert(A);
    }
    if(a.size()==n)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 9600
import sys
import numpy as np
import math
read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    A = np.array(readline().split(), np.int64)

    low = 0
    high = 10**10
    while high-low>0.000001:
        mid = (high+low)/2
        k = np.sum(np.ceil(A/mid-1))
        if k>K:
            low = mid
        else:
            high = mid
    print(math.ceil(low))


if __name__ == '__main__':
    main()


Measured memory_bytes: 40256
import java.util.Scanner;
public class Main
{
	public static void main(String aeg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			char b[][] = new char[8][8];
			for(int i=0; i<8; i++)
				b[i] = in.next().toCharArray();
			for(int i =0; i<8; i++)
			{
				for(int j=0; j<8; j++)
				{
					if(j<7&&b[i][j]=='1'&&b[i][j+1]=='1')
						if(i<7&&b[i+1][j]=='1'&&b[i+1][j+1]=='1')
							System.out.println("A");

					if(i<5&&b[i][j]=='1')
						if(b[i+1][j]=='1')
							if(b[i+2][j]=='1')
								if(b[i+3][j]=='1')
									System.out.println("B");
					
					if(j<5&&b[i][j]=='1'&&b[i][j+1]=='1'&&b[i][j+2]=='1'&&b[i][j+3]=='1')
							System.out.println("C");

					if(i<6&&b[i][j]=='1'&&b[i+1][j]=='1')
						if(j>0&&b[i+1][j-1]=='1'&&b[i+2][j-1]=='1')
							System.out.println("D");
					
					if(j<6&&b[i][j]=='1'&&b[i][j+1]=='1')
						if(i<7&&b[i+1][j+1]=='1'&&b[i+1][j+2]=='1')
							System.out.println("E");
					
					if(i<6&&b[i][j]=='1'&&b[i+1][j]=='1')
						if(j<7&&b[i+1][j+1]=='1'&&b[i+2][j+1]=='1')
							System.out.println("F");
					
					if(j<7&&b[i][j]=='1'&&b[i][j+1]=='1')
						if(j>0&&i<7&&b[i+1][j-1]=='1'&&b[i+1][j]=='1')
							System.out.println("G");
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
int main(){
    /*
    int a;
    int b;
    cin >> a;
    cin >> b;
    cout << a*b << endl;
    cout << 2*a + 2*b << endl;
    */

    int a, b;
    cin >> a >> b;
    cout << a*b << " " << 2*(a+b) << endl;


    return 0;
}



Measured memory_bytes: 3076
n = int(input())
a = list(map(int, input().split()))
mod = 998244353
if a[0]!=0:
  print(0)
  quit()
#a.sort()
l=max(a)+1
dp1 = [0]*l
dp2 = [0]*l
ans=0
for i in a:
  dp1[i]+=1
#print(dp1)  

if dp1[0]!=1:
  print(0)
  quit()

dp2[0]=1
#print(dp2)
for i in range(1, l):
  dp2[i]=dp2[i-1]*(dp1[i-1]**dp1[i])
  dp2[i]%=mod

#print(dp2)
print(dp2[l-1])

Measured memory_bytes: 20756
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int *A, int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (int i = 0; i < n1; i++) L[i] = A[left + i];
  for (int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if (left+1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for (i = 0; i < n; i++) cin >> A[i];

  mergeSort(A, n, 0, n);

  for (i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 7004
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
int main() {
	int n, m, x, y, i, ma, mb,a,b;
	cin >> n >> m >> x >> y;
	ma = -11111;
	mb = 11111;
	for (i = 0; i < n; i++) {
		cin >> a;
		if (a > ma)
			ma = a;
	}
	for (i = 0; i < m; i++) {
		cin >> b;
		if (b < mb)
			mb = b;
	}
	for (i = x + 1; i <= y; i++) {
		if (i > ma&&i <= mb) {
			cout << "No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;
}

Measured memory_bytes: 256
def dfs(v,N,visited):
  if sum(visited) == len(visited):
    return 1
  
  ret =0
  for i in range(N):
    if graph[v][i] == 0:
      continue
    if visited[i]:
      continue
    
    visited[i] = 1
    ret += dfs(i,N,visited)
    visited[i] = 0
    
  return ret


n,m = map(int,input().split())
graph = [[False]*n for _ in range(n)]

for mi in range(m):
  a,b = map(int,input().split())
  graph[a-1][b-1] = 1
  graph[b-1][a-1] = 1
  
visited = [0]*n
visited[0]= 1
print(dfs(0,n,visited))

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

int main(){
  int x,y;
  cin >> x >> y;
  rep(i,x+1){
    if(2*i+4*(x-i)==y){
      cout <<"Yes"<<endl;
      return 0;
    }
  }
  cout << "No"<< endl;


  return 0;
}


Measured memory_bytes: 3628
import math

N, M = map(int,input().split())
A = list(map(int,input().split()))

pow2 = 0
while A[0] % 2 == 0:
    A[0] //= 2
    pow2 += 1

for i in range(1,N):
    cnt = 0
    while A[i] % 2 == 0:
        A[i] //= 2
        cnt += 1
    if cnt != pow2:
        print(0)
        exit()

LCM = 2**max(0,pow2-1)
for i in range(N):
    LCM = LCM * A[i] // math.gcd(LCM,A[i])

ans = M // LCM
print((ans+1)//2)

Measured memory_bytes: 20776
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,mn=10000000; 
    cin>>n; vi a(n);
    for (int &i: a) cin>>i;
    for (int i=1;i<=100;i++){
        int sum=0;
        for (int j=0;j<n;j++){
            sum += (i-a[j])*(i-a[j]);
        }
        mn = min(mn,sum);
    }
    cout << mn << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vvl csf(N - 1, vl(3));
  rep(i, N - 1) cin >> csf[i][0] >> csf[i][1] >> csf[i][2];

  rep(i, N){
    ll station = i;
    ll x = 0;
    while(station < N - 1){
      if(x <= csf[station][1]){
	x = csf[station][1] + csf[station][0];
      } else{
	if(x % csf[station][2] == 0){
	  x += csf[station][0];
	} else{
	  x = (x / csf[station][2] + 1) * csf[station][2] + csf[station][0];
	}
      }
      station++;
    }
    cout << x << endl;
  }
  
  return 0;
}


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

int main(void){
	int N;
	cin >> N;
	int mod = N%10;
	switch (mod) {
		case 0:
			cout << "pon" << endl;
			break;
		case 1:
			cout << "pon" << endl;
			break;
		case 6:
			cout << "pon" << endl;
			break;
		case 8:
			cout << "pon" << endl;
			break;
		case 3:
			cout << "bon" << endl;
			break;
		default:
			cout << "hon" << endl;
			break;
	}
return 0;
}


Measured memory_bytes: 3120
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	string s;
	while (cin >> s){
		vector<int> num;
		REP(i, s.length()){
			int a;
			if (s[i] == 'I')
				a = 1;
			if (s[i] == 'V')
				a = 5;
			if (s[i] == 'X')
				a = 10;
			if (s[i] == 'L')
				a = 50;
			if (s[i] == 'C')
				a = 100;
			if (s[i] == 'D')
				a = 500;
			if (s[i] == 'M')
				a = 1000;
			num.push_back(a);
		}
		int ans = 0;
		REP(i,num.size()){
			
			if (i==num.size()-1||num[i] >= num[i + 1]){
				ans += num[i];
			}
			else{
				ans += num[i + 1] - num[i];
				i++;
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

ll x, y, a, b, c;
ll p[100000], q[100000], r[100000];

int main() {
    priority_queue<ll> que;
    cin >> x >> y >> a >> b >> c;
    for (int i = 0; i < a; ++i)
        cin >> p[i];
    for (int i = 0; i < b; ++i)
        cin >> q[i];
    for (int i = 0; i < c; ++i) {
        cin >> r[i];
        que.push(r[i]);
    }
    sort(p, p + a);
    sort(q, q + b);
    for (int i = 0; i < x; ++i)
        que.push(p[a - i - 1]);
    for (int i = 0; i < y; ++i)
        que.push(q[b - i - 1]);

    ll ans = 0;
    for (int i = 0; i < x + y; ++i) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8816
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	defer stdout.Flush()

	x := readInt()
	y := readInt()

	if x == y {
		println(-1)
		return
	}

	g := gcd(x, y)
	if g == y {
		println(-1)
		return
	}

	yg := y / g
	println(int64(x) * int64(yg+1))
}


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

int main() {
  ll r; cin >> r;
  double ans = r*2*3.14;
  cout << ans << endl;

  return 0;
}

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

int main() {
  int A, B;
  string S;
  cin >> A >> B >> S;
  
  string ans = "Yes"; 
  for(int i=0; i<A+B+1; i++){
    if(i==A && S.at(i)!='-')ans="No";
    if(i!=A && S.at(i)=='-')ans = "No";
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define inf 1000000007

int dp[1010][1010];

int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    for(int i=1;i<=n;i++){
        dp[0][i] = i;
    }
    for(int i=1;i<=m;i++){
        dp[i][0] = i;
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(t[i-1]==s[j-1]){
                dp[i][j] = min(min(dp[i-1][j]+1,dp[i][j-1]+1),dp[i-1][j-1]);
            }else{
                dp[i][j] = min(min(dp[i-1][j]+1,dp[i][j-1]+1),dp[i-1][j-1]+1);
            }
        }
    }
    cout << dp[m][n] << endl;
    return 0;
}


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

int main(void) {
  int N;
  int K;
  int Q;
  cin >> N >> K >> Q;
  vector<int> A(Q+1);
  vector<int> C(N+1,0);
  
  for(int i = 1; i <= Q; i++) {
    cin >> A[i];
    C[A[i]]++;
  }
  
  for(int i = 1; i <= N; i++) {
    if(Q - C[i] >= K ) {
      cout << "No" << endl; 
    }
    else {
      cout << "Yes" << endl; 
    }
  }
  
  return 0; 
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int a,b;
cin>>a>>b;
cout<<1+2+3-a-b;
}

Measured memory_bytes: 764
# include <bits/stdc++.h>
# define il inline
# define fi first
# define se second
# define pb push_back
# define mem(x,v) memset(x,v,sizeof x)
# define rep(i,x,y) for(int i=x;i<=y;++i)
# define re(i,x,y) for (int i=x;i<y;++i)
using namespace std;
typedef long long ll;
il ll read(){
	ll x=0; char c=getchar();
	for(;c<'0'||c>'9';c=getchar());
	for(;c>='0'&&c<='9';c=getchar())x=x*10+c-'0';
	return x;
}
const int maxm = 100+10;
int n,m;
int a[maxm];
vector<int> b;
int main(){
//	freopen("tmp.in","r",stdin);
	n=read(); m=read();
	rep(i,1,m) a[i]=read();
	if (m == 1){
		b.pb(1); b.pb(n-1);
	}
	else{
		int cnt = 0;
		rep(i,1,m) cnt += a[i] % 2;
		if (cnt > 2){
			puts("Impossible"); return 0;
		}
		rep(i,2,m-1)
			if (a[i]%2==1){
				if (a[1]%2==0)swap(a[1],a[i]);
				else swap(a[m],a[i]);
			}
		b.pb(a[m]+1);
		for (int i=m-1;i>1;--i) b.pb(a[i]);
		b.pb(a[1]-1);
	}
	rep(i,1,m) printf("%d ",a[i]); printf("\n");
	/*printf("%d\n",m);
	printf("%d ",a[1]-1);
	rep(i,2,m-1) printf("%d ",a[i]);
	printf("%d\n",a[m]+1);*/
	int bs=b.size();
	if (b[bs-1] == 0)--bs;
	printf("%d\n",bs);
	for (int i=bs-1;i>=0;--i) printf("%d ",b[i]); printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
constexpr int  mod = 1e9 + 1;
int main() {
	int n, k;
	cin >> n >> k; set<int>s;
	while (k--) {
		int d; cin >> d;
		while (d--) {
			int x; cin >> x; s.insert(x);
		}
	}
	cout << n - s.size();
	return 0;
}

Measured memory_bytes: 3632
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	ll a[N];

	//std::priority_queue<ll> q;

	rep(i, N)
	{
		cin >> a[i];
		//q.push(a[i]);
	}

	/*
	while(q.size() > 1)
	{
		

	}
	*/
	int index = 0;
	int n_index = index;
	sort(a, a+N);
	while(a[N-2] > 0)
	{
		//sort(a, a+N);

		for(int i = 0; i < N; i++)
		{
			if (a[i] != 0)
			{
				n_index = i;
				break;
			}
		}

		index = n_index;

		for(int i=index+1; i < N; i++)
		{
			a[i] = a[i] % a[index];
		}

		/*
		cout << "------------" << endl;
		rep(i, N)
		{
			cout << a[i] << endl;
		}
		*/
		sort(a, a+N);
	}

	cout << a[N-1] << endl;
	
	return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int ans=0,pre=0,now=0;
    for (int i=0;i<S.size();++i){
        if (S[i]=='R') ++now;
        else --now;
        if (now%4==0){
            if (pre<now) ++ans;
            pre=now;
        }
    }
    cout << ans << '\n';
}


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

int main(){
    int a, b;
    cin >> a;
    cin >> b;
    int c = (a + b) / 2;
    if((a + b) % 2 == 0){
        cout << c << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
    int n;
    cin >> n;

    int ans = 0;
    for(int i = 0; i <= n; i++){
        int m = 0;
        int tmp = i;
        while(tmp > 0){
            tmp /= 10;
            m++;
        }

        if(m % 2 != 0){
            ans++;
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	cout << (N+1)/2 << "\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

int main()
{
    std::string s;
    std::cin >> s;

    lint k;
    scanf("%lld", &k);

    std::set<std::string> subs;

    for (int i = 0; i < s.size(); ++i)
    {
        for (int j = 0; j < k && i + j < s.size(); j++)
        {
            subs.insert(s.substr(i, j + 1));
        }
    }

    auto ans_iter = subs.begin();

    for (int i = 0; i < k - 1; ++i)
    {
        ans_iter++;
    }

    std::cout << *ans_iter << "\n";

    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>

#define MAX 2000001
#define vMAX 10000


int main() {
    int n;
    int C[vMAX];
    for (int i = 0; i < vMAX; i++) C[i] = 0;
    
    scanf("%d", &n);
    int *A = new int[n+1];
    int *B = new int[n+1];
    
    
    for (int i = 1; i <= n; i++) {
        scanf("%d", &A[i]);
        C[A[i]] += 1;
    }
    
    for (int i = 1; i < vMAX; i++) {
        C[i] = C[i] + C[i-1];
    }
    
    for (int i = n; i >= 1; i--) {
        B[C[A[i]]] = A[i];
        C[A[i]] --;
    }
    
    for (int i = 1; i <=n; i++) {
        if (i > 1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");
    delete [] A;
    delete [] B;
    return 0;
}

Measured memory_bytes: 18336
#include <stdio.h>

int main(void)
{
	// n?????\???
	int n;
	scanf("%d", &n);

	// ???????????¨???
	int a[100];
	
	// n????????????
	for(int i = 0;i < n; i++){
		// a?????\???
		scanf("%d", &a[i]);
	}
		
	// n????????????
	for(int i = 0; i < n; ++i){
		// a??????????????????
		printf("%d", a[n - 1 - i]);
		if(i != n - 1){
			printf(" ");
		}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 2748
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
h,w=map(int,input().split())
x,y=map(int,input().split())

print((h-x)*(w-y))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
string xx[]={"7","5","3"};
string k;
int n,x3,x5,x7,ans;
void dfs(){
	if(k.size()==9)return;
	if(x3&&x5)if(n>=stoi(k+xx[0]))ans++;
	if(x3&&x7)if(n>=stoi(k+xx[1]))ans++;
	if(x7&&x5)if(n>=stoi(k+xx[2]))ans++;
	k+=xx[0];x7++;dfs();
	k = k.substr(0,k.size()-1) + xx[1];
	x7--;x5++;dfs();
	k = k.substr(0,k.size()-1) + xx[2];
	x5--;x3++;dfs();x3--;
	k = k.substr(0,k.size()-1);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	dfs();
	cout << ans << endl;
}

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

int main()
{
	int ABCD;
	cin >> ABCD;
	string s = "+-";
	int A = ABCD / 1000, B = (ABCD / 100) % 10, C = (ABCD / 10) % 10, D = ABCD % 10;
	for (int i = 0; i < (1 << 3); i++) {
		if (A + ((i & 4) ? -B : B) + ((i & 2) ? -C : C) + ((i & 1) ? -D : D) == 7) {
			cout << A << s[(i >> 2) & 1] << B << s[(i >> 1) & 1] << C << s[i & 1] << D << '=' << 7 << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
# https://beta.atcoder.jp/contests/abc065/tasks/abc065_b

import sys


def input_lines():
    """hell?"""
    lines = sys.stdin.readlines()
    for i in range(1, int(lines[0])+1):
        yield i, int(lines[i].strip())


def solve():
    d = {i: button for i, button in input_lines()}
    count = 1
    index = 1

    while True:
        try:
            prev = index
            index = d[index]

            if index == 2:
                print(count)
                exit()
            else:
                del d[prev]
                count += 1
        except KeyError:
            print(-1)
            exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 24212
from copy import deepcopy
def bit_s(bit, n):
    l = []
    for i in range(n):
        if bit & (1 << i):
            l.append(i)
    return l
h, w, k = map(int, input().split())
c = [list(input()) for i in range(h)]
ans = 0
c2 = deepcopy(c)
for bit in range(1 << h):
    l = bit_s(bit, h)
    for i in l[::-1]:
        del c2[i]
    for bit2 in range(1 << w):
        cnt = 0
        l2 = bit_s(bit2, w)
        for i in c2:
            for j in l2:
                if i[j] == "#":
                    cnt += 1
        if cnt == k:
            ans += 1
    c2 = deepcopy(c)
print(ans)

Measured memory_bytes: 70400
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll fac[2000010], finv[2000010], inv[2000010];

void init(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(ll i=2;i<2000010;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll C(ll n, ll k){
  return fac[n] %mod * finv[k] %mod * finv[n-k] %mod;
}

int main(){FIN
    ll ans=1;
    init();
    ll n,m;cin>>n>>m;
    if (abs(n-m)>1) {
        cout<<0<<endl;
        return 0;
    }
    if(n==m){
        ans *= fac[n] % mod;
        ans %= mod;
        ans *= fac[n] % mod;
        ans %= mod;
        ans *= 2;
        ans %= mod;

    }
    else{
        ll mx = max(n,m);
        ans *= fac[mx] % mod;
        ans %= mod;
        ans *= fac[mx-1] % mod;
        ans %= mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 50488
#include<stdio.h>
int main()
{
    int i,n;
    char ch;
    int test[26];

    for(i=0;i<26;i++)
        {
            test[i]=0;
        }
        while(scanf("%c",&ch)!=EOF)
        {
            if(ch>='A' && ch<='Z')
            {
                n = ch-'A';
                test[n]++;
            }
            else if(ch>='a' && ch<='z' )
            {
                n = ch-'a';
                test[n]++;
            }
        }
        for(i=0;i<26;i++)
        {
            printf("%c : %d\n",i+'a',test[i]);
        }
return 0;
}



Measured memory_bytes: 2128