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

int main(){
	int n,m;
	int a[200],b[200];
	cin>>n>>m;
	for(int i=0;i<2*n;i++)a[i]=i+1;
	while(m--){
		int k;
		cin>>k;
		if(k==0){
			for(int i=0;i<n;i++){
				b[2*i]=a[i];
				b[2*i+1]=a[n+i];
			}
		}
		else{
			copy(a+k,a+(2*n),b);
			copy(a,a+k,b+(2*n-k));
		}
		copy(b,b+(2*n),a);
	}
	for(int i=0;i<2*n;i++)cout<<a[i]<<endl;
	return 0;
}

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

int main () {
  for (int i = 0; i < 2; ++i) {
    char c;
    cin >> c;
    if (c == '9') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
long long int h,n=0;
int i=1;  
cin>>h;
  while(h>0)
  {if(h==1)
  {  n++;
   h=0;
  }
   else
   {  n=n+pow(2,i);
    h=h/2;
    i++;
   }
  }
   cout<<n;
   return 0;
}


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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  int waru = b/k - a/k;
  if(waru > 0){
      cout << "OK" << endl;
  } 
  else if(b % k == 0 || a%k == 0){
      cout << "OK" << endl;
  }
  else{
      cout << "NG" << endl;
  }
}


Measured memory_bytes: 3636
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    # 1 line 1 int
    return int(sys.stdin.readline().rstrip())
def LI():
    # 1 line n ints
    return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    # 1 line 1 string
    return sys.stdin.readline().rstrip()
def LS():
    # 1 line n strings
    return list(sys.stdin.readline().rstrip().split())

C1 = S()
C2 = S()

if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
    print("YES")
else:
    print("NO")


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

#include <atcoder/all>
typedef long long lint;
using namespace std;
using namespace atcoder;

int n, m;
vector<lint> a, b;

int main() {
    cin >> n >> m;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    b.resize(m);
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    auto res = convolution<998244353>(a, b);
    for (auto e : res) {
        cout << e << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 27268
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		char[]s = stdIn.next().toCharArray();
		
		String a = "CODEFESTIVAL2016";
		int cnt = 0;
		
		for(int i = 0; i < a.length(); i++) {
			if(a.charAt(i)!=s[i]) {
				cnt++;
			}
		}
		System.out.println(cnt);
		
		
	}

}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 2e5 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int n,m,k;
char grid[10][10];

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

  scanf("%d %d %d", &n , &m , &k);
  for(int i = 0 ; i < n ; ++i)
    scanf("%s" , grid[i]);
    
  int ans = 0 , cnt = 0;
  for(int mskR = 0 ; mskR < (1 << n) ; ++mskR){
    for(int mskC = 0 ; mskC < (1 << m) ; ++mskC){
      cnt = 0;
      for(int i = 0 ; i < n ; ++i){
        if(mskR & (1 << i)){
          for(int j = 0 ; j < m ; ++j){
            if(mskC & (1 << j)){
              cnt += (grid[i][j] == '#');
            }
          }
        }
      }
      ans += (cnt == k);
    }
  }

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

  return 0;
}


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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define RFOR(i,e,s) for(int (i)=(e)-1;(i)>=(int)(s);(i)--)
#define RREP(i,e) RFOR(i,e,0)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;
typedef priority_queue<int> PQI;
typedef priority_queue<PII> PQII;

const int N = 50;
int c[N];

int main() {
  int n, p;
  while (1) {
    scanf("%d%d ", &n, &p);
    if (!n && !p) break;
    memset(c, 0, sizeof(c));
    int i = 0, ap = p;
    while (1) {
      if (p == 0) {
        p += c[i];
        c[i] = 0;
      } else {
        p--;
        c[i]++;
      }
      if (c[i] == ap) {
        printf("%d\n", i);
        break;
      }
      i = (i+1)%n;
    }
  }
  return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define il inline
#define ri register int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 100050
#define MAXM
#define MOD
#define INF (1<<25)
#define eps (1e-6)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair <int, int> pii;
typedef pair <LL, int> pli;
typedef pair <int, LL> pil;
typedef pair <LL, LL> pll;
int n, a[MAXN];
int main() {
//	freopen("nim.in", "r", stdin);
//	freopen("nim.out", "w", stdout);
    scanf("%d", &n);
    for(ri i = 1; i <= n; ++i) scanf("%d", &a[i]), a[i] *= -1;
    sort(a+1, a+n+1);
    for(ri i = 1; i <= n; ++i) a[i] *= -1;
    int pos = 0;
    for(ri i = 1; i <= n; ++i) 
        if(a[i] >= i) pos = i;
    int ans = 0;
    if((a[pos]-pos) & 1) ans |= 1;
    int k = pos+1;
    while(a[k] == pos) ++k;
    --k;
    if(k >= pos && (k-pos) & 1) ans |= 1;
//  cout<<pos<<' '<<k<<endl;
    if(ans) cout<<"First\n";
    else cout<<"Second\n";
    return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> job(100100);

    rep(i,N){
        int a,b;
        cin >> a >> b;
        job[a].push_back(b);
    }

    priority_queue<int> que;

    int ans = 0;

    for(int left = 1; left <= M; left++){
        for(int b : job[left]) que.push(b);

        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 5632
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
  while (true) {
    int n;
    scanf("%d", &n);
    if (n == 0) { break; }

    vector<vector<int>> matrix;
    for (int i = 0; i < n; ++i) {
      matrix.emplace_back(vector<int>(n));
      for (int j = 0; j < n; ++j) { scanf("%d", &matrix[i][j]); }
    }

    vector<int> col_sums(n);
    for (const auto& row : matrix) {
      int row_sum = accumulate(row.cbegin(), row.cend(), 0);
      for (int i = 0; i < n; ++i) {
        printf("%5d", row[i]);
        col_sums[i] += row[i];
      }
      printf("%5d\n", row_sum);
    }
    for (const auto elm : col_sums) { printf("%5d", elm); }
    printf("%5d\n", accumulate(col_sums.cbegin(), col_sums.cend(), 0));
  }

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

vec tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    ll tmp=i;
    ll cnt=0;
    while(tmp&&tmp%2==0) {
      tmp/=2;
      cnt++;
    }
    tfact[i]=cnt;
    if(i) {
      tfact[i]+=tfact[i-1];
    }
  }
}

ll comb(ll n, ll k) {
  return (tfact.at(n)-tfact.at(k)-tfact.at(n-k))==0;
}

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  fact(n);
  vec a(n);
  for(ll i=0;i<n;i++) {
    a[i]=s[i]-'0';
  }
  ll f=0;
  for(ll i=0;i<n;i++) {
    if(a[i]==2) f=1;
  }
  if(f) {
    for(ll i=0;i<n;i++) {
      a[i]%=2;
    }
    ll ans=0;
    for(ll i=0;i<n;i++) {
      ans+=comb(n-1,i)*a[i];
      ans%=2;
    }
    cout << ans << endl;
  }
  else {
    for(ll i=0;i<n;i++) {
      if(a[i]==3) a[i]=2;
    }
    ll ans=0;
    for(ll i=0;i<n;i++) {
      ans+=comb(n-1,i)*a[i];
      ans%=2;
    }
    if(ans) ans++;
    cout << ans << endl;
  }
}

Measured memory_bytes: 90264
/*
Though leaves are many, the root is one;
Through all the lying days of my youth
I swayed my leaves and flowers in the sun,
Now may I wither into the truth.

- William Butler Yeats
*/
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
#include <bitset>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:6
*Problem:Distance Sums
*Date:2019-7-12
*Algorithm:Orange Boy's Greedy and Sorting
*Stats:WA*/

bool debug=false;


template<typename T1,typename T2> ostream& operator<<(ostream& o,pair<T1,T2> p){
	o<<"{";
	o<<p.first<<","<<p.second;
	o<<"}";
	return o;
}

ll n;
ll d[100005];
map <ll,ll> m;
pair<ll,ll> p[100005];
ll sub[100005];
ll sz[100005];
vector <pair<ll,ll> >res;
 
 int fa[100005];
 
int getFa(int x){
	if(fa[x]==x){
		return x;
	}
	return fa[x]=getFa(fa[x]);
}
 
 
void Union(int a,int b){
	if(fa[a]==fa[b]){
		return;
	}
	fa[getFa(a)]=getFa(b);
}

ll dp[100005];

ll dis[100005];

vector<int> nei[100005];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>d[i];
		if(d[i]>n*(n-1)/2){
			cout<<-1;
			return 0;
		}
		m[d[i]]=i;
		p[i].first=d[i];
		p[i].second=i;
		sz[i]=1;
	}
	sort(p,p+n);
	reverse(p,p+n);
	memset(sub,-1,sizeof(sub));
	for(ll i=0;i<n-1;i++)
	{
		ll de=p[i].first;
		ll x=p[i].second;
		sub[x]=n-sz[x]*2;
		if(sub[x]==0){
			cout<<-1;
			return 0;	
		}
		if(m.find(de-sub[x])==m.end()){
			cout<<-1;
			return 0;
		}
		ll par=m[de-sub[x]];
		sz[par]+=sz[x];
		dp[par]+=dp[x]+sz[x];
		res.push_back(make_pair(x,par));
	}
	
	for(int i=0;i<n-1;i++){
		nei[res[i].first].push_back(res[i].second);
		nei[res[i].second].push_back(res[i].first);
	}
	
	queue<int> q;
	memset(dis,-1,sizeof(dis));
	q.push(p[n-1].second);
	dis[p[n-1].second]=0;
	
	while(!q.empty()){
		int last=q.front();
		q.pop();
		
		for(int to:nei[last]){
			if(dis[to]==-1){
				dis[to]=dis[last]+1;
				q.push(to);
			}
		}
	}
	
	ll sm=0;
	for(int i=0;i<n;i++){
		sm+=dis[i];
	}
	if(sm!=p[n-1].first){
		cout<<-1;
		return 0;
	}
	
	for(ll i=0;i<n-1;i++)
	{
		cout<<res[i].first+1<<" "<<res[i].second+1<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 20596
import collections

def poll():
    # 入力
    N = int(input())
    S = list()
    for _ in range(N):
        S.append(input())
    # 各文字列の出現回数をカウント
    count_list = collections.Counter(S)
    # 最大の出現回数のvalueのみ抽出
    max_count = max(count_list.values())
    max_count_str = list()
    for key, value in count_list.items():
        if value == max_count:
            max_count_str.append(key)
    # ソート
    return sorted(max_count_str)
           
result = poll()
for string in result:
    print(string)

Measured memory_bytes: 38744
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//?¨??????\???????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		//??????????????????????????´??°?????¨????????????????????????
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		int length = (a + b) * 2;
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 25960
#include <iostream>

using namespace std;

int cnt = 0;
void merge(int a[], int left,int right){
  int i = left;
   int mid = left + (right - left) / 2;
    int j = mid + 1;
     int k = 0;
      int temporary[500100];

     while(i <= mid && j <= right){
       if(a[i] <= a[j]){
        cnt++;
           temporary[k] = a[i]; i++;
       }
       else {
        cnt++;
          temporary[k] = a[j]; j++;
       }
       k++;
     }
     while(i <= mid){
      cnt++;
       temporary[k] = a[i];
       i++; k++;
     }
     while(j <= right){
      cnt++;
      temporary[k] = a[j];
      j++; k++;
     }

     for(int i = 0; i < k; i++){
       a[left + i] = temporary[i];
     }
}
void mergeSort(int a[], int left, int right){
  if(left < right){
    int mid = (left + right) / 2;

    mergeSort(a, left, mid);
    mergeSort(a, mid + 1, right);
    merge(a, left, right);
  }
}


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

   int a[n];

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

   mergeSort(a, 0, n - 1);

   for(int i = 0; i < n; i++){
    if(i != n - 1)
    cout << a[i] << " ";
    else
       cout << a[i] << endl;
   }


   cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 6928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if((e-a) <= k){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
}


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

bool even(int x[], int n);

int main() {
  int n;
  cin >> n;
  int a[201];
  rep(i, n) cin >> a[i];
  int cnt = 0;

  while(even(a, n)) {
    rep(i, n) a[i] /= 2;
    cnt += 1;
  }

  cout << cnt << endl;

  return 0;
}

bool even(int x[], int n) {

  for(int i=0; i<n; ++i) {
    if(x[i]%2) return false;
  }

  return true;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Dice2{
	int a[] = new int[6];
	int temp;
	Dice2(int face[]){
		for(int i = 0; i < 6; i++) {
			a[i] = face[i];
		}
	}

	void roll(char c) {
		switch(c) {
		case 'E':
			temp = a[5];
			a[5] = a[2];
			a[2] = a[0];
			a[0] = a[3];
			a[3] = temp;
			break;
		case 'N':
			temp = a[5];
			a[5] = a[4];
			a[4] = a[0];
			a[0] = a[1];
			a[1] = temp;
			break;
		case 'S':
			temp = a[5];
			a[5] = a[1];
			a[1] = a[0];
			a[0] = a[4];
			a[4] = temp;
			break;
		case 'W':
			temp = a[5];
			a[5] = a[3];
			a[3] = a[0];
			a[0] = a[2];
			a[2] = temp;
			break;
		}
	}
	void rota() {
		temp = a[1];
		a[1] = a[2];
		a[2] = a[4];
		a[4] = a[3];
		a[3] = temp;
	}
}

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int face[] = new int[6];
		for(int i = 0; i < 6; i++) {
			face[i] = sc.nextInt();
		}

		int n = sc.nextInt();

		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();


			Dice2 d2 = new Dice2(face);

			//まず初めに上面を合わせる
			while(true) {
				if(d2.a[0] == a) break;
				d2.roll('E');
				if(d2.a[0] == a) break;
				d2.roll('E');
				if(d2.a[0] == a) break;
				d2.roll('E');
				if(d2.a[0] == a) break;
				d2.roll('N');
				if(d2.a[0] == a) break;
				d2.roll('N');
				d2.roll('N');
			}

			for(int j = 0; j < 4; j++) {  //このforループで前面を合わせる
				if(d2.a[1] == b) {
					System.out.println(d2.a[2]);
				}
				d2.rota();
			}
		}
	}

}



Measured memory_bytes: 26088
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=1<<18;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int L[N],R[N],x[N];
int p[18][N],q[N];
int ans[N];
inline void umin(int &x,int y) { y<x?x=y:0; }
inline void umax(int &x,int y) { x<y?x=y:0; }
int main()
{
	int n=gi()-1,v=gi(),i,j,k=v,m=0,u[20]={},s;
	while (k) u[m++]=k>>=1;

	for (i=0;i<=n;i++) x[i]=gi();
	for (i=n;i;i--) x[i]-=x[i-1];

	for (i=0;i<m;i++) {
		p[i][n+1]=n+1;
		for (j=n;j;j--)
			p[i][j]=x[j]<=u[i]?p[i][j+1]:j;
	}
	for (s=0;s<1<<m;s++)
		for (i=0;i<m;i++)
			if (!(s>>i&1))
				umax(L[s|1<<i],p[i][L[s]+1]);

	for (i=0;i<m;i++)
		for (j=1;j<=n;j++)
			p[i][j]=x[j]<=u[i]?p[i][j-1]:j;
	for (s=0;s<1<<m;s++) R[s]=n+1;
	for (s=0;s<1<<m;s++)
		for (i=0;i<m;i++)
			if (!(s>>i&1))
				umin(R[s|1<<i],R[s|1<<i]?p[i][R[s]-1]:0);

	memset(ans,0x3f,sizeof(ans));
	for (s=0;s<1<<m;s++)
		umin(ans[L[s]],R[((1<<m)-1)^s]);
	for (i=1;i<=n;i++) umin(ans[i-1],ans[i]);

	for (i=n,q[n+1]=n+1;i;i--)
		q[i]=x[i]>v?i:q[i+1];
	for (i=0;i<=n;i++) {
		if (!i||x[i]>v) k=i;
		puts(ans[k]<=q[i+1]?"Possible":"Impossible");
	}
	return 0;
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define endl        '\n'
#define ll          long long int
#define pb          push_back
#define sz(x)       (int)(x).size()
const ll mod = 1e9 + 7;

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


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

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

ll dp[100005];
int main() {
	fast
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, k;
	cin >> n >> k;
	int h[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	for (int i = 1; i < n; i++) {
		dp[i] = 1e9;
		for (int j = i - 1; j >= max(0, i - k); j--)
			dp[i] = min(dp[j] + abs(h[i] - h[j]) , dp[i]);

	}
	cout << dp[n - 1] << endl;


	return 0;

}





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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> hs(n);
    for(int i=0; i<n; ++i){
        cin >> hs[i];
    }
    int ans=0;
    int cnt=0;
    for(int i=n-2; i>=0; --i){
        if(hs[i]>=hs[i+1]) ++cnt;
        else{
            ans=max(ans, cnt);
            cnt=0;
        }
    }
    ans=max(ans, cnt);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<vector<vector<int>>> num(4, vector<vector<int>>(3, vector<int>(10,0)));
	for (int i = 0; i < n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		b--, f--, r--, v;
		num.at(b).at(f).at(r) += v;
	}
	for (int h = 0; h < 3; h++) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 10; j++) {
				cout << " " << num.at(h).at(i).at(j);
			}
			cout << endl;
		}
		cout << "####################" << endl;
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 10; j++) {
			cout << " " << num.at(3).at(i).at(j);
		}
		if (i < 3) { cout << endl; }
	}
}


Measured memory_bytes: 3152
#include <stdio.h>

int coordinates[1005][1005];

int main() {
  int n, i, j, out = 0;
  int x1, x2, y1, y2;
  int xMin = 1000, xMax = 0, yMin = 0, yMax = 1000;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

    coordinates[x1][y1]++;
    coordinates[x2][y2]++;
    coordinates[x1][y2]--;
    coordinates[x2][y1]--;

    if (x1 < xMin)
      xMin = x1;
    if (x2 > xMax)
      xMax = x2;
    if (y1 < yMin)
      yMin = y1;
    if (y2 > yMax)
      yMax = y2;
  }
  
  for (i = xMin; i < xMax + 1; i++) {
    for (j = yMin; j < yMax + 1; j++) {
      if (i)
	coordinates[i][j] += coordinates[i - 1][j];
      if (j)
	coordinates[i][j] += coordinates[i][j - 1];

      if (i && j)
	coordinates[i][j] -= coordinates[i - 1][j - 1];

      if (coordinates[i][j] > out)
	out = coordinates[i][j];
    }
  }

  printf("%d\n", out);
}



Measured memory_bytes: 5720
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int k,x;
	cin>>k>>x;
	for(int i=max(-1000000,x-k+1);i<=min(1000000,x+k-1);i++)
		cout<<i<<" ";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>

using namespace std;
char s[12];

int main() {

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

	int cnt1 = 0;
	int cnt2 = 0;
	int cnt3 = 0;

	for (int k = 0; k < a; ++k) {
		for (char tmp = '0'; tmp <= '9'; ++tmp) {
			if (s[k] == tmp) {
				cnt1++;
			}
		}
		//if (s[k] >= '0' && s[k] <= '9') {
			//cnt1++;
		//}
	}

	if (s[a] == '-') {
		cnt2++;
	}

	for (int k = a + 1; k <= a + b; ++k) {
		if (s[k] >= '0' && s[k] <= '9') {
			cnt3++;
		}
	}

	if (cnt1 == a && cnt2 == 1 && cnt3 == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int i=0;
	set<int> s;
	while(i<k){
		int d;
		cin>>d;
		while(d--){
			int a;
			cin>>a;
			s.insert(a);
		}
		i++;
	}
	cout<<n-static_cast<int>(s.size());
}



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

int N;
int x[1002],y[1002],r[1002];
double z[1002][1002];
pair<double,int>p[1002];
bool f[1002];

main(){
	cin>>x[0]>>y[0]>>x[1]>>y[1];
	cin>>N;
	N+=2;
	for(int i=2;i<N;++i){
		cin>>x[i]>>y[i]>>r[i];
	}
	for(int i=0;i<N;++i){
		for(int j=0;j<N;++j){
			z[i][j]=z[j][i]=max(0.0,hypot(x[i]-x[j],y[i]-y[j])-r[i]-r[j]);
		}
	}
	for(int i=1;i<N;++i){
		p[i]={1e10,0};
	}
	int v=0;
	p[0]={0,0};
	f[0]=true;
	while(v!=1){
		for(int i=0;i<N;++i){
			if(!f[i]&&p[v].first+z[v][i]<p[i].first){
				p[i]={p[v].first+z[v][i],v};
			}
		}
		double d=1e10;
		for(int i=0;i<N;++i){
			if(!f[i]&&p[i].first<d){
				d=p[i].first;
				v=i;
			}
		}
		f[v]=true;
	}
	printf("%.15f",p[1].first);
}


Measured memory_bytes: 8064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    ll n;
    cin>>n;
    V<ll> a(n);
    set<P> st_l,st_r;
    set<ll> st;
    map<ll,ll> mp;
    rep(i,n){
        cin>>a[i];
        st.insert(i+1);
        mp[a[i]]=i+1;
        st_r.insert(P(a[i],i));
    }
    st.insert(-1);
    st.insert(0);
    st.insert(n+1);
    st.insert(n+2);
    ll ans=0;
    for(ll i=1;i<n;i++){
        ll s,t,u,v;
        auto it1=st.find(mp[i]);
        auto it2=st.find(mp[i]);
        auto it3=st.find(mp[i]);
        auto it4=st.find(mp[i]);
        auto it=st.find(mp[i]);
        it1--;
        it1--;
        it2--;
        it3++;
        it4++;
        it4++;
        if(*it1==-1) s=0;
        else s=*it1;
        t=*it2;
        u=*it3;
        if(*it4==n+2) v=n+1;
        else v=*it4;
        ans+=((t-s)*(u-*it)+(*it-t)*(v-u))*i;
        it=st.erase(it);
    }
    /*rep(i,n){
        if(a[i]==n) continue;
        ll s,t,u,v;
        P p=P(a[i],i);
        st_r.erase(p);
        auto it=st_r.ub(P(a[i],i));
        u=*it;
        cout<<u<<' ';
        //ll p=a[i];
        
        t=ub(b.begin()+n-i-1,b.end(),p)-b.begin();
        u=ub(a.begin()+i,a.end(),p)-a.begin();
        if(t>=n-1){
            s=n;
        }else{
            s=ub(b.begin()+t+1,b.end(),p)-b.begin();
        }
        if(u>=n-1){
            v=n;
        }else{
            v=ub(a.begin()+u+1,a.end(),p)-a.begin();
        }
        cout<<n-s-1<<' '<<n-t-1<<' '<<i<<' '<<u<<' '<<v<<endl;
        ans+=((s-t)*(u-i)+(v-u)*(t-(n-i-1)))*p;
        //cout<<(s-t)*(u-i)+(v-u)*(t-(n-i-1))<<' '<<p<<endl;
    }*/
    //cout<<endl;
    cout<<ans<<endl;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const int dr[]={0,1,0,-1,0};


ll f(ll n, ll x=3){
	ll res = 1LL;
	for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
	return res;
}

ll f2(ll a,ll b){
 return (a * f(b) %mod + (b * f(b-1))%mod) %mod;
}
int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s; cin >>s;
	
	int n=sz(s);
	vector<ll> sma(n+1), smc(n+1), smh(n+1);
	rep(i,n){
		sma[i+1] = sma[i] + (s[i]=='A' );
		smc[i+1] = smc[i] + (s[i]=='C' );
		smh[i+1] = smh[i] + ( s[i]=='?');
	}
	ll ans = 0;
	rep2(i,1,n-1) if(s[i] =='B' || s[i]=='?'){
		ll z1 = f2(sma[i], smh[i]);
		ll z2 = f2(smc[n] - smc[i+1], smh[n] - smh[i+1]);
		ans = (ans + (z1*z2)%mod) % mod;
		//dbg(i, z1,z2, ans);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 2816
import sys
import itertools
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

# combs = list(itertools.product(range(1,int(N**0.5)), repeat=3))
combs = list(itertools.combinations_with_replacement(range(1,int(N**0.5)), 3))
sum = [0] * (N+1)

for comb in combs:
    temp = comb[0]**2 + comb[1]**2 + comb[2]**2+ comb[0]*comb[1]+ comb[1]*comb[2] + comb[2]*comb[0]
    if temp <= N:
        if comb[0] != comb[1] and comb[1] != comb[2] and comb[2] != comb[0]:
            sum[temp] += 6
        elif comb[0] == comb[1] == comb[2]:
            sum[temp] += 1
        else:
            sum[temp] += 3


for i,s in enumerate(sum):
    if i == 0:
        continue
    print(s)

Measured memory_bytes: 21272
n = int(input())
a = list(map(int, input().split()))
num = 0
while(len(a) > 2):
  n1 = a.pop(a.index(min(a)))
  n2 = a.pop(a.index(min(a)))
  n3 = (n1 + n2) / 2
  a.append(n3)
ans = (a[0]+a[1])/2
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
  int n;
  double disp = 0; // 分散
  double sd = 0, ave = 0;
  vector<double> ans;

  while(1){
    cin >> n;
    if(n == 0) break;
    int *input = new int[n];
    ave = 0;
    disp = 0;
    sd = 0;
    for(int i = 0; i < n; i++){
      cin >> input[i];
      ave += input[i];
    }
    
    ave /= n;
    for(int i = 0; i < n; i++){
      disp += pow((input[i] - ave), 2);
    }
    disp /= n;
    sd = sqrt(disp);
    ans.push_back(sd);
  }

  for (vector<double>::size_type i = 0; i < ans.size(); i++)
  {
    cout << fixed << setprecision(8) << ans[i] << endl;
  }
  

}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);


int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<vector<int>> params(n);

  rep(i, n) {
    int c, s, f;
    cin >> c >> s >> f;
    params[i].push_back(c);
    params[i].push_back(s);
    params[i].push_back(f);
  }

  for (int i = 0; i < n; i++) {
    int now = 0;
    for (int j = i; j < n; j++) {
      if (j == n-1) {
        continue;
      }
      int wait;
      int c = params[j][0];
      int s = params[j][1];
      int f = params[j][2];
      if (now <= s) {
        wait = s - now;
      } else if ((now - s) % f == 0) {
        wait = 0;
      } else {
        wait = f - (now - s) % f;
      }
      int start = now + wait;
      now = start + c;
      // cerr << wait << " " << start << " " << now << endl;
    }
    cout << now << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

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

	rep(i, s.size()) {
		cout << "x";
	}
	cout << endl;
}

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

using namespace std;

int main(){
  int n,k;cin>>n>>k;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  sort(l.begin(),l.end());
  int ans=0;
  for(int i=0;i<k;i++){
    ans += l[n-1-i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
 int n,j,i;
  cin>>n;
  for(i=0;i<10;i++){for(j=1;j<10;j++){if(i*j==n){cout<<"Yes"<<endl;return 0;}}}
  cout<<"No"<<endl;return 0;
  return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();
        final int Q = sc.nextInt();
        final String S = sc.next();

        int[] a = new int[N+1];
        for (int i = 0; i < N; i++) {
            a[i+1] = a[i];
            if (i+1 < N && S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
                a[i+1]++;
            }
        }

        for (int i = 0; i < Q; i++) {
            int l = Integer.parseInt(sc.next());
            int r = Integer.parseInt(sc.next());
            System.out.println(a[--r] - a[--l]);
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<int,ll> pil;
const int maxN = 100010;
const int maxC = 1e6 + 10;
const int INF = 1e9; 

int a[maxN];
int main()
{
   	for(int i=1;i<=3;i++)
   		scanf("%d",&a[i]);
    sort(a+1,a+4);
    printf("%d\n",(a[1]*a[2]/2));
    return 0;
}

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

constexpr long long MOD = 998244353;

long long Pow(long long X, long long Y) {
	if (Y == 0) return 1;
	if (Y % 2 == 0) {
		long long Z = Pow(X, Y / 2);
		return (Z * Z) % MOD;
	}
	return (X * Pow(X, Y - 1)) % MOD;
}

long long INV = Pow(2, MOD - 2);

int main() {
	long long N, S;
	cin >> N >> S;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	vector<vector<long long> > DP(N + 1, vector<long long>(S + 1, 0));
	DP[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= S; j++) {
			DP[i + 1][j] += DP[i][j];
			DP[i + 1][j] %= MOD;
			if (j + A[i] <= S) {
				DP[i + 1][j + A[i]] += (DP[i][j] * INV) % MOD;
				DP[i + 1][j + A[i]] % MOD;
			}
		}
	}
	long long ANS = DP[N][S];
	ANS *= Pow(2, N);
	cout << ANS % MOD << endl;
}

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

using namespace std;

typedef long long ll;

int N;
vector<int> a, b, c, x, y, z;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    a.resize(N);
    b.resize(N);
    c.resize(N);
    x.resize(N);
    y.resize(N);
    z.resize(N);
    for (int i = 0; i < N; i++)
        cin >> a[i] >> b[i] >> c[i];
    x[0] = a[0];
    y[0] = b[0];
    z[0] = c[0];
    for (int i = 1; i < N; i++) {
        x[i] = a[i] + max(y[i - 1], z[i - 1]);
        y[i] = b[i] + max(x[i - 1], z[i - 1]);
        z[i] = c[i] + max(x[i - 1], y[i - 1]);
    }
    int result = 0;
    result = max(result, x[N - 1]);
    result = max(result, y[N - 1]);
    result = max(result, z[N - 1]);
    cout << result << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
#include <ext/hash_set>
struct Hasher
{int operator()(int x)const{return x^0x45678901;}};
typedef __gnu_cxx::hash_set<int,Hasher> hashset_int;
int n,m;
ll MOD=1e9+7;
ll qp(ll a,ll b)
{
	ll x=1; a%=MOD;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
int main()
{
	cin>>n>>m;
	ll tt=1;
	for(int i=1;i<=n;i++) tt=tt*i%MOD;
	for(int i=1;i<=m;i++) tt=tt*i%MOD;
	if(n==m)
	{
		cout<<tt*2%MOD<<"\n";
		return 0;
	}
	if(abs(n-m)!=1)
	{
		puts("0");
		return 0;
	}
	cout<<tt<<"\n";
}
/*
x1+x2+...+x[n-1]+x0+xn+2=m+2
C(m+1,n+1)
*/

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n = getN()
    k = getN()
    nums = getList()

    ans = 0
    for i, num in enumerate(nums):
        ans += 2 * (min(abs(k - num), num))


    print(ans)
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 65236
#include<bits/stdc++.h>
#define int unsigned long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    string s;
    cin>>n>>s;
    for(int i=s.size()/2;i>=1;i--){
        deque<int>d;
        set<int>st;
        int t=1;
        for(int j=0;j<i;j++)
            t*=mod;
        int h=0;
        for(int j=0;j<i;j++)
            h=h*mod+s[j];
        for(int j=0;j+i<=s.size();j++){
            d.push_back(h);
            if(j>=i){
                st.insert(d[0]);
                d.pop_front();
            }
            if(st.find(h)!=st.end()){
                cout<<i<<endl;
                return 0;
            }
            if(j+i<s.size())
                h=h*mod+s[j+i]-s[j]*t;
        }
    }
    cout<<0<<endl;
}


Measured memory_bytes: 540
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  int now = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      now++;
      ans = max(ans, now);
    }
    else{
      now = 0;
    }
  }
  cout << ans << endl;
}

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

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    double odd = 0;
    if (N % 2 == 0) {
        odd = N / 2;
    } else {
        odd = N / 2 + 1;
    }
    double ans = odd / N;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, a, b, result int

	fmt.Scanf("%d %d %d", &n, &a, &b)

	for i := 1; i <= n; i++ {
		var tmp, sum int
		tmp = i

		for tmp != 0 {
			sum += tmp % 10
			tmp /= 10
		}

		if sum >= a && sum <= b {
			result += i
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (a, b) = getLongs()
    (0..9).map { b * 10 + it.toLong() }
            .forEach {
                if (it * 8 / 100 == a) {
                    println(it)
                    return
                }
            }
    println(-1)
}


fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }

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

typedef long long int ll;

int main()
{
    ll x;
    cin >> x;

    for(ll i = 0;i <= x;i++){
        if(i * (i + 1) / 2 >= x){
            cout << i;

            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int x,y,z,k;cin>>x>>y>>z>>k;
    while(x>=y&&k){
        y*=2;k--;
    }
    while(y>=z&&k){z*=2;k--;}
    if(x<y&&y<z)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3620
trait BinarySearch<T> {
	fn binary_search_by<F>(&self, f: F) -> Result<T, T>
	where
		F: FnMut(&T) -> std::cmp::Ordering;
}

impl<
		T: PartialOrd
			+ std::ops::Add<Output = T>
			+ std::ops::Sub<Output = T>
			+ std::ops::Div<Output = T>
			+ Copy
			+ From<u8>,
	> BinarySearch<T> for std::ops::Range<T>
{
	fn binary_search_by<F>(&self, mut f: F) -> Result<T, T>
	where
		F: FnMut(&T) -> std::cmp::Ordering,
	{
		use std::cmp::Ordering::*;
		if self.end <= self.start {
			return Err(self.start);
		}
		let mut base = self.start;
		let mut size = self.end - base;
		loop {
			let half = size / T::from(2);
			let mid = base + half;
			let cmp = f(&mid);
			match cmp {
				Less => base = mid,
				Equal => return Ok(mid),
				_ => {}
			}
			if size <= half || T::from(0) == half {
				return Err(base + T::from((cmp == Less) as u8));
			}
			size = size - half;
		}
	}
}

fn main() {
	let n: usize;
	let k: i64;
	let a: Vec<i64>;

	text_io::scan!("{} {}", n, k);
	a = (0..n).map(|_| text_io::read!()).collect();

	use std::cmp::Ordering::*;
	let ans = (0..1_000_000_001)
		.binary_search_by(|m| {
			if 1 == *m {
				// m が 1 未満になることはない
				return Equal;
			};
			if k >= a.iter().map(|a| (a + m - 1) / m - 1).sum() {
				Greater
			} else {
				Less
			}
		})
		.and_then(|q: i64| -> Result<i64, i64> { Err(q) })
		.err();
	println!("{}", ans.unwrap());
}


Measured memory_bytes: 3556
#include <cstdio>
#include <algorithm>
#define NUM 100000
#define LL long long
using namespace std;

int main()
{

    LL i, pos, j, m, buf, n, first_max, second_min, K, N, d[NUM];

    scanf("%lld", &N);

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

        scanf("%lld", &d[i]);
    }

    sort(d, d + N); 

    //条件を満たすKの値を求める
    first_max = N / 2 - 1;
    second_min = N / 2;

    //Kの初期化
    K = 0;

    for (n = d[first_max] + 1; n <= d[second_min]; n++)
    {
        K++;
    }

  
    //結果の表示
    printf("%lld\n", K);

    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ll c = 1, cnt = 0;
    REP(i,0,N) {
        if(A[i] == c) ++c;
        else ++cnt;
    }
    if(cnt < N) PR(cnt);
    else PR(-1);

    return 0;
}

/*



*/

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

using namespace std;
 
#define debug(s) cerr << #s << " = " << s << '\n'
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;

const int N = 200010;
const int mod = 1e9 + 7;
int n, k;
ll arr[N];

bool cmp(ll A, ll B) {
  return abs(A) > abs(B);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  bool noneg = false;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    if (arr[i] >= 0) noneg = true;
  }
  sort(arr + 1, arr + 1 + n, cmp);
  if (n == k) {
    ll ans = 1LL;
    for (int i = 1; i <= n; ++i) ans = (ans * arr[i]) % mod;
    if (ans < 0) ans += mod;
    cout << ans << '\n';
    return 0;
  }
  if (!noneg) {
    if (k & 1) {
      ll ans = 1LL;
      reverse(arr + 1, arr + 1 + n);
      for (int i = 1; i <= k; ++i) ans = (ans * arr[i]) % mod;
      if (ans < 0) ans += mod;
      cout << ans << '\n';
      return 0;
    } else {
      ll ans = 1LL;
      for (int i = 1; i <= k; ++i) ans = (ans * arr[i]) % mod;
      if (ans < 0) ans += mod;
      cout << ans << '\n';
      return 0;
    }
  }
  int lstneg = -1, lstnon = -1;
  int cntn = 0;
  for (int i = 1; i <= k; ++i) {
    if (arr[i] < 0) {
      lstneg = i;
      cntn++;
    }
    else lstnon = i;
  }
  if (!(cntn & 1)) {
    ll ans = 1LL;
    for (int i = 1; i <= k; ++i) ans = (ans * arr[i]) % mod;
    cout << ans << '\n';
    return 0;
  }
  int nxtneg = -1, nxtnon = -1;
  for (int i = k + 1; i <= n; ++i) {
    if (arr[i] < 0 && nxtneg == -1) {
      nxtneg = i;
    } else if (arr[i] >= 0 && nxtnon == -1) {
      nxtnon = i;
    }
  }
  if (lstnon == -1) {
    swap(arr[lstneg], arr[nxtnon]);
  } else if (nxtneg == -1) {
    swap(arr[lstneg], arr[nxtnon]);
  } else if (nxtnon == -1) {
    swap(arr[lstnon], arr[nxtneg]);
  } else {
    ll va = arr[lstnon]*arr[nxtnon];
    ll vb = arr[lstneg]*arr[nxtneg];
    if (va > vb) swap(arr[lstneg], arr[nxtnon]);
    else swap(arr[lstnon], arr[nxtneg]);
  }
  ll ans = 1LL;
  for (int i = 1; i <= k; ++i) ans = (ans * arr[i]) % mod;
  if (ans < 0) ans += mod;
  cout << ans << '\n';
}

Measured memory_bytes: 5128
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;




int a[100005];

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

  int a,b;
  cin >> a >> b;
  int ans = a*b-a-b+1;
  prints(ans);

  return 0;

}


Measured memory_bytes: 892
public class Main {

	public static int calc(int num){
		int ans = 1;
		for(int i=0;i<3;i++){
			ans = ans * num;
		}
		return ans;
	}

	public static void main(String[] args){
		int result;

		//System.out.print("You input any number  : ");
		int number = new java.util.Scanner(System.in).nextInt();
		//System.out.print("You input repeat times  : ");
		//double  repeat = new java.util.Scanner(System.in).nextInt();
		result = calc(number);
		System.out.println(result);
	}
}

Measured memory_bytes: 26224
def solve():
    N = int(input())

    if N <= 10:
        return N

    # 10の位 = 上位、1の位 = 下位とする
    numberCount = [0] * 100
    for i in range(10):
        numberCount[i] = 1
        numberCount[i*10+i] = 1

    ans = 9
    for i in range(11, N+1):

        # 下位が 0 の場合は無視
        if str(i)[-1] == "0":
            continue

        # 11等の上位桁と下位桁が同じ場合をカウント
        if str(i)[0] == str(i)[-1]:
            ans += 1

        # 対応するパターン数を加算
        ans += numberCount[int(str(i)[-1])*10 + int(str(i)[0])] * 2

        # 登録
        numberCount[int(str(i)[0])*10 + int(str(i)[-1])] += 1

    return ans


print(solve())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	string s;
	cin >> s;
	cout << s.substr(0,4) << " " << s.substr(4,8) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[110];
int temp,tempp;
int main() {
	cin>>s;
	for(int i=0; i<=101; i++) {
		if(s[i]=='C') {
			temp++;
		}
		if(temp!=0) {
			if(s[i]=='F') {
				tempp++;
			}
		}
		if(temp!=0&&tempp!=0) {
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,k,a;

int gcd(int x,int y){
    if(x>y){
        int t=x;
        x=y;
        y=t;
    }if(x==0) return y;
    return gcd(y%x,x);
}

int main(){
    cin>>n>>k;
    bool big=false;
    int g=0;
    for(int i=0;i<n;i++){
        cin>>a;
        if(k<=a)big=true;
        g=gcd(g,a);
    }
    if(big&&k%g==0){
        cout<<"POSSIBLE";
    }else{
        cout<<"IMPOSSIBLE";
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
#else
using LONG = long long int;
#endif

int main(void) {
  string S;
  int N, A, B;
  cin >> N >> A >> B;
  cin >> S;
  int count = 0;
  int count2 = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'a') {
      if (count < A + B) {
        count++; cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
    else if (S[i] == 'b') {
      if (count < A + B && count2 < B) {
        count++; count2++; cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 896