akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int a,b,c;

int main(){
    cin>>a>>b>>c;
    if(a+b==c||b+c==a||c+a==b){
        out("Yes");
    }
    else{
        out("No");
    }
}


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

typedef long long int ll;
using ii= pair<ll,ll>;
#define F first
#define S second
#define MP make_pair
#define PB push_back
//using min_of_3=min({ll a,ll b,ll c});

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll a;
	cin>>a;
	
	cout<<(a+a*a+a*a*a)<<"\n";
}


Measured memory_bytes: 3648
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;

char a[maxn];int len;

int b[maxn];

int main()
{
	scanf("%s",a+1);
	len=strlen(a+1);
	if(a[len]=='1'){puts("-1");return 0;}
	for(int i=1;i<=len/2;i++)
	{
		if(a[i]!=a[len-i]){puts("-1");return 0;}
	}
	int rest=len-1,use=1;
	for(int i=len/2;i>=1;i--)
		if(a[i]=='1')
		{
			if(i==1 && use==len) break;
			b[i]=len-i-use;
			use+=b[i]+1;
		}
	if(use!=len){puts("-1");return 0;}
	int cnt=1,rt=1;
	for(int i=len/2;i>=1;i--)//
	{
		if(a[i]=='0') continue;
		for(int j=1;j<=b[i];j++)
		{
			printf("%d %d\n",rt,++cnt);
		}
		printf("%d %d\n",rt,++cnt);
		rt=cnt;
	}
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
signed main() {
	int n;
	cin >> n;
	if (n % 2 == 1)cout << 0 << endl;
	else {
		int memo = 10, ans = 0;
		while (memo <= n) {
			ans += n / memo;
			memo *= 5;
		}
		cout << ans << endl;
	}
	ggr
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin>>N;
    string s;
    cin>>s;
    for (auto &&i : s)
    {
        i += N;
        if(i > 'Z')
        i -= 26;
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 3592
from itertools import product

n, m = map(int, input().split())
l = [[int(i) for i in input().split()] for _ in range(m)]
p = [int(i) for i in input().split()]
c = 0
for sw in product((0, 1), repeat=n):
    for i in range(m):
        if sum(sw[si - 1] for si in l[i][1:]) % 2 != p[i]:
            break
    else:
        c += 1
print(c)


Measured memory_bytes: 8988
#include<bits/stdc++.h>
//#include<windows.h>
//#include<conio.h>
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=a;i<=b;i++)if(i<a+k||i>b-k)cout<<i<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //入力
        int num = sc.nextInt();
        String str = sc.next();

        if (num >= 3200) {
            System.out.println(str);
        } else {
            System.out.println("red");
        }

    }
}

Measured memory_bytes: 23252
#include <cstdio>
#define abs(x) ((x) > 0 ? (x) : -(x))
int n;
int m,a[2],b[2],c[2];
int main() {
    scanf("%d",&n);
    a[n%2]=b[n%2]=c[n%2]=0;
    while(n) {
        n--;
        scanf("%d%d%d",&a[n%2],&b[n%2],&c[n%2]);if(a[n%2]-a[(n+1)%2]<abs(b[n%2]-b[(n+1)%2])+abs(c[n%2]-c[(n+1)%2]))
        if(a[n%2]-a[(n+1)%2]<abs(b[n%2]-b[(n+1)%2])+abs(c[n%2]-c[(n+1)%2])){
            printf("No");
            return 0;
        }
        if((a[n%2]-a[(n+1)%2]-abs(b[n%2]-b[(n+1)%2])-abs(c[n%2]-c[(n+1)%2]))%2!=0) {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
from sys import stdin
n, q = map(int, input().split())
cnt = [0]*n
root = [[] for i in range(n)]

for i in range(n-1):
    a, b = map(int, stdin.readline().split())
    root[a-1].append(b-1)

for i in range(q):
    p, x = map(int, stdin.readline().split())
    cnt[p-1] += x

tmparr = [0]
while tmparr:
    tmpi = tmparr.pop()
    for i in root[tmpi]:
        cnt[i] += cnt[tmpi]
    tmparr += root[tmpi]
print(*cnt)

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

int main() {
  int n;
  cin >> n;
  while (n >= 1000) {
      n -= 1000;
  }
  if (n) cout << 1000 - n << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3632
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,M = map(int, input().split())
    cities = [tuple(map(int, input().split())) for _ in range(M)]
    cities = [(pref,year,idx) for idx,(pref,year) in enumerate(cities)]
    cities.sort(key=itemgetter(1))
    cities.sort(key=itemgetter(0))
    prev_pref = 0
    tmp = 1
    res = [0]*M
    for pref,_,idx in cities:
        if prev_pref != pref:
            prev_pref = pref
            tmp = 1
        else:
            tmp += 1
        res[idx] = str(pref).zfill(6) + str(tmp).zfill(6)
    for r in res:
        print(r)

if __name__ == '__main__':
    main()

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

vector <int> diff;

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

	int n,m,t;
	vector <int> v;

	cin >> n >> m;

	for(int i=0;i<m;i++)
	{
		cin >> t;
		v.push_back(t);
	}

	if(n>=m)
	{
		cout << 0 << '\n';
		return 0;
	}

	sort(v.begin(),v.end());

	for(int i=1;i<m;i++)
	{
		diff.push_back(v[i]-v[i-1]);
	}

	sort(diff.rbegin(),diff.rend());

	long long int res = 0;

	for(int i=n-1;i<diff.size();i++)
	{
		res += diff[i];
	}

	cout << res << '\n';

	return 0;
}
		

Measured memory_bytes: 1400
#include<stdio.h>
int main(){
    int W=1,H,i,j,x=0;
        for(;0<W;){
            scanf("%d %d",&W,&H);
            for(i=0;i<W;i++){
        	    if(0<x){
        		    printf("\n");
        	    }
        	    x++;
                    for(j=0;j<H;j++){
                    printf("#");
                    }
            }
        printf("\n");
        }
return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i=0; i<N; i++){
    cin >> H.at(i);
  }
  int Highest=H.at(0),Count=1;
  for(int i=1; i<N; i++){
    if(Highest<=H.at(i)){
      Highest=H.at(i);
      Count++;
    }
  }
  cout << Count << endl;
}

Measured memory_bytes: 256
//g++  5.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXX 1e9 + 5
vector<ll> adj[200005];
ll arr[200005];
ll LIS[200005];

void DFS(ll s,ll p,vector<ll> &L,ll count)
{
    ll index = lower_bound(L.begin(),L.end(),arr[s]) - L.begin();
    
    ll prev = L[index];
    
    if(prev == LLONG_MAX)
        count++;
    
    L[index] = arr[s];
    
    LIS[s] = count;
    
    for(ll i=0;i<adj[s].size();++i)
    {
        ll c = adj[s][i];
        if(c != p)
            DFS(c,s,L,count);
    }
    
    L[index] = prev; //rolling back changes
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N; cin>>N;
    
    for(ll i=1;i<=N;++i)
        cin>>arr[i];
    
    vector<ll> L(N,LLONG_MAX);
    
    for(ll i=0;i<(N - 1);++i)
    {
        ll u,v; cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    DFS(1,-1,L,0);
    
    for(ll i=1;i<=N;++i)
        cout<<LIS[i]<<endl;
    
}

Measured memory_bytes: 33256
n=int(input())
A=list(map(int,input().split(" ")))
ans=1
POW=pow(10,18)
check=False
answer=1
for i in range(n):
  ans*=A[i]
  if ans>POW:
    ans=0
    check=True
    answer=-1
  if A[i]==0:
    answer=0
if answer<1:
  print(answer)
else:
  print(ans)

Measured memory_bytes: 82608
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	int n,k;	int m;
	int a[15]={0};
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++)
	{
		getchar();
		scanf("%d",&m);
	//	printf("%d ",m);
		a[m]=1;
	}
	int x=0;
	int b[15]={0};
	for(int i=0;i<10;i++)
	{
		if(a[i]==0)
		{
			b[x]=i;
			x++;
		}
	}
	
	if(n<=9)
	{
		for(int i=0;i<10;i++)
		{
			if(i>=n&&a[i]==0)
			{
				printf("%d\n",i);
				return 0;
			}
		}
		if(b[0]==0)
		{
			printf("%d%d\n",b[1],b[0]);
			return 0;
		}
		else
		{
			printf("%d%d\n",b[0],b[0]);
			return 0;
		}
	}
	else if(n<=99)
	{
		for(int i=0;i<10;i++)
		{
			for(int j=0;j<10;j++)
			{
					if(i*10+j>=n&&a[i]==0&&a[j]==0)
					{
						printf("%d\n",i*10+j);
						return 0;
					}
			}
		}
		if(b[0]==0)
			{
				printf("%d%d%d\n",b[1],b[0],b[0]);
				return 0;
			}
			else
			{
				printf("%d%d%d\n",b[0],b[0],b[0]);
				return 0;
			}
	}
	else if(n<=999)
	{
		for(int i=0;i<10;i++)
		{
			for(int j=0;j<10;j++)
			{
				for(int z=0;z<10;z++)
				{
					if(i*100+j*10+z>=n&&a[i]==0&&a[j]==0&&a[z]==0)
					{
						printf("%d\n",i*100+j*10+z);
						return 0;
					}
				}
			}
		}
		if(b[0]==0)
			{
				printf("%d%d%d%d\n",b[1],b[0],b[0],b[0]);
				return 0;
			}
			else
			{
				printf("%d%d%d%d\n",b[0],b[0],b[0],b[0]);
				return 0;
			}
	}
	else
	{
		
		for(int i=0;i<10;i++)
		{
			for(int j=0;j<10;j++)
			{
				for(int z=0;z<10;z++)
				{
					for(int y=0;y<10;y++)
					if(i*1000+j*100+z*10+y>=n&&a[i]==0&&a[j]==0&&a[z]==0&&a[y]==0)
					{
						printf("%d\n",i*1000+j*100+z*10+y);
						return 0;
					}
				}
			}
		}
		if(b[0]==0)
			{
				printf("%d%d%d%d%d\n",b[1],b[0],b[0],b[0],b[0]);
				return 0;
			}
			else
			{
				printf("%d%d%d%d%d\n",b[0],b[0],b[0],b[0],b[0]);
				return 0;
			}
	}

	return 0;
}

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

const long long mod=1e9+7;
long long n, a, b;

long long modpow(long long x, long long y){
	long long ret=1;
	while (y>0){
		if (y&1){
			ret*=x;
			ret%=mod;
		}
		x*=x;
		x%=mod;
		y>>=1;
	}
	return ret;
}

long long modinv(long long x){
	return modpow(x,mod-2);
}

long long f(long long x, long long y){
	long long ret=1;
	for (int i=x;i<=y;i++){
		ret*=i;
		ret%=mod;
	}
	return ret;
}

long long comb(long long x, long long y){
	return (f(x-y+1,x)*modinv(f(1,y)))%mod;
}


int main(){
	cin >> n >> a >> b;
	cout << (modpow(2,n)-1-comb(n,a)-comb(n,b)+mod*2)%mod << "\n";
}

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

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

  vector<vector<int>> vec(K, vector<int>(N, 0));

  //おかしを持っているかどうかに印を付ける//
  for(int i = 0; i < K; i++){
    int T;  //Tは持ってる人間の数、i番目のおかしの数//
    cin >> T;
    for(int j = 0; j < T; j++){
      int f;   //fが持ってる人間の番号//
      cin >> f;
      vec.at(i).at(f - 1) = 1;  //持っている人間を1と置く(持っている判定にする)//
    }
  }
  //作成した表を用いて持っていない人間を判定する//
  int count = 0;
  for(int i = 0; i < N; i++){ //N人について、１番から順に確かめる//
    for(int j = 0; j <
     K; j++){
      if(vec.at(j).at(i) == 1){
        break;
      }
      else if(j == K - 1 && vec.at(j).at(i) == 0){
        count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll num[114514];
bool f[114514];
int main(){
	ll n,m;
	cin>>n>>m;
	vector<vector<P>>v(n+1);
	for(int i=0;i<m;i++){
		ll l,r,d;
		cin>>l>>r>>d;
		v[l].push_back({r,d});
		v[r].push_back({l,-d});
	}
	ll inf=1e15;
	for(int i=2;i<=n;i++)num[i]=inf;
	queue<ll>que;
	que.push(1);
	for(int i=1;i<=n;i++){
		if(f[i])continue;
		if(num[i]==inf)num[i]=0;
		que.push(i);
		while(!que.empty()){
			ll x=que.front();
			que.pop();
			for(int j=0;j<v[x].size();j++){
				if(!f[v[x][j].first])que.push(v[x][j].first);
				f[v[x][j].first]=1;
				if(num[v[x][j].first]==inf)num[v[x][j].first]=num[x]+v[x][j].second;
				else{
					if(num[v[x][j].first]!=v[x][j].second+num[x]){
						cout<<"No\n";
						return 0;
					}
				}
			}
		}
	}
	cout<<"Yes\n";
	return 0;
}


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

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

  vector<int> v(n);
  for (int& e : v) cin >> e;

  sort(v.begin(), v.end(), greater<int>());
  long long ans = 0;
  for (int e : v) {
    if (k > 0) {
      k--;
      continue;
    }

    ans += (long long) e;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5;
ll a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int x, y;
    cin >> x >> y;
    cout << 6 - x - y;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] a){
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int[] line = new int[w + 1];
		for(int i = 1; i <= w; i++){
			line[i] = i;
		}
		int n = scan.nextInt();
		for(int i = 0; i < n; i++){
			String str = scan.next();
			String[] spl = str.split(",");
			int num1 = Integer.parseInt(spl[0]);
			int num2 = Integer.parseInt(spl[1]);
			int sub = line[num1];
			line[num1] = line[num2];
			line[num2] = sub;
		}
		for(int i = 1; i <= w; i++){
			System.out.println(line[i]);
		}
	}
}

Measured memory_bytes: 17196
function main(input) {
  const [n, k] = input[0].trim().split(" ").map(i => parseInt(i));
  const p = input[1].trim().split(" ").map(i => parseInt(i)).sort(function(a, b) {return a - b;});

  const sum  = function(arr) {
    return arr.reduce(function(prev,current,i,arr) {return (i<k)?(prev+current):(prev)});
  };
  console.log(sum(p));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 29576
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int main(){
  int n;cin>>n;
  unordered_map<string,int> l;
  rep(i,n){
    string s;cin>>s;
    l[s]++;
  }
  int m;cin>>m;
  rep(i,m){
    string s;cin>>s;
    l[s]--;
  }
  int ans = 0;
  for(auto itr = l.begin();itr!=l.end();itr++){
    ans = max(ans,itr->second);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int digit_mod[100001];
int main(){
    string s;
    cin >> s;
    int n = (int)s.size();
    digit_mod[1] = 1;

    for(int i = 1;i < n;i++){
        digit_mod[i+1] = (digit_mod[i] * 10) % 13;
    }

    vector<vector<ll>> dp(n+1,vector<ll>(13,0));
    dp[0][0] = 1;
    reverse(s.begin(),s.end());
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= 12;j++){
            if(s[i] != '?'){
                dp[i+1][(j+(int)(s[i]-'0')*digit_mod[i+1])%13] += dp[i][j];
                dp[i+1][(j+(int)(s[i]-'0')*digit_mod[i+1])%13] %= MOD;
            }
            else{
                for(int k = 0;k <= 9;k++){
                    dp[i+1][(j+k*digit_mod[i+1])%13] += dp[i][j];
                    dp[i+1][(j+k*digit_mod[i+1])%13] %= MOD;
                }
            }
        }
    }

    cout << dp[n][5] << endl;
}


Measured memory_bytes: 14080
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;


public class Main {
	
	public static void main(String[] args) throws IOException {
		new Main().exec();
	}
	
	public void exec() throws IOException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int N = in.nextInt();
		int[] l = new int[N];
		int[] r = new int[N];
		int sum = 0;
		for(int i=0; i<N; i++) {
			l[i] = in.nextInt();
			r[i] = in.nextInt();
			sum += (r[i] - l[i] + 1);
		}
		out.println(sum);
		out.flush();
	}
}


class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

Measured memory_bytes: 21588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

const int MAXN = 305;

int n,k,ans;
int f[2][MAXN][MAXN];

char s[MAXN];

int main()
{
	scanf("%s",s + 1);
	n = strlen(s + 1);
	scanf("%d",&k);
	for (int i = 0;i <= k;i++)
	{
		memcpy(f[i & 1],f[~i & 1],sizeof(f[i & 1]));
		for (int j = 1;j <= n;j++)
			for (int k = n;k >= j + 1;k--)
			{
				if (s[j] == s[k])
					f[i & 1][j][k] = max(f[i & 1][j][k],f[i & 1][j - 1][k + 1] + 1);
				else if (i)
					f[i & 1][j][k] = max(f[i & 1][j][k],f[~i & 1][j - 1][k + 1] + 1);
				f[i & 1][j][k] = max(f[i & 1][j][k],f[i & 1][j - 1][k]);
				f[i & 1][j][k] = max(f[i & 1][j][k],f[i & 1][j][k + 1]);
			}
	}
	for (int i = 0;i <= n;i++)
		ans = max(ans,f[k & 1][i][i + 1] * 2);
	for (int i = 1;i <= n;i++)
		ans = max(ans,f[k & 1][i - 1][i + 1] * 2 + 1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int dp[85000][11];
int x[100000],sum;
string S;
char T[11]="0123456789";
int main(){
	while(true){
		cin>>S;
		if(S=="0"){break;}
		for(int i=0;i<S.size();i++){
			for(int j=0;j<10;j++){
				if(T[j]==S[i]){
					x[i]=j;
				}
			}
		}
		memset(dp,0,sizeof(dp));
		sum=0;
		for(int i=0;i<S.size();i++){
			if(x[i]>=1){dp[i+1][x[i]]++;}
			for(int j=0;j<11;j++){
				if(dp[i][j]>=1){
					dp[i+1][((j*10)+x[i])%11]+=dp[i][j];
				}
			}
		}
		for(int i=1;i<=S.size();i++){
			sum+=dp[i][0];
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 5296
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


    int n;
    int ma, mb;
    cin >> n >> ma >> mb;

    int mx = 40 * 10 + 10;

    const int INF = 1 << 28;
    vector<vector<int>> dp(mx + 1, vector<int>(mx + 1, INF));
    dp[0][0] = 0;

    for (int i = 0; i < n; ++i) {
        int a, b, c;
        cin >> a >> b >> c;

        for (int j = mx; j >= 0; --j) {
            for (int k = mx; k >= 0; --k) {
                int nj = j + a;
                int nk = k + b;
                if (nj <= mx && nk <= mx) {
                    dp[nj][nk] = min(dp[nj][nk], dp[j][k] + c);
                }
            }
        }
    }

    auto res = INF;
    for (int i = 1; i <= mx; ++i) {
        for (int j = 1; j <= mx; ++j) {
            if (i * mb == j * ma) {
                res = min(res, dp[i][j]);
            }
        }
    }

    if (res >= INF) {
        cout << -1 << '\n';
    } else {
        cout << res << '\n';
    }

    return 0;
}

Measured memory_bytes: 3948
#include <iostream>
using namespace std;
using ll = long long;

int p[101][101];
int r, c, q = 0;

int main()
{
    cin >> r >> c;
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> p[i][j];
        }
    }
    for (int i = 0; i < r; i++)
    {
        int a = 0;
        for (int j = 0; j < c; j++)
        {
            cout << p[i][j] << " ";
            a += p[i][j];
        }
        cout << a << endl;
    }
    for (int i = 0; i < c; i++)
    {
        int b = 0;
        for (int j = 0; j < r; j++)
        {
            b += p[j][i];
        }
        q += b;
        cout << b << " ";
    }
    cout << q << endl;
}


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

int main() {
  long long int A, B;
  cin >> A >> B;
  long long int g = __gcd(A, B);
  int ans = 1;
  for (long long int i = 2; i <= sqrt(__gcd(A, B)); i++) {
    if (g % i == 0) ans++;
    while (g % i == 0) {
      g /= i;
    }
  }
  if (g > 1) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    int n, k;
    cin >> n;
    vector<int> u, v;
    for (int i = 0; i < n;i++) {
        cin >> k;
        if (i % 2 == 0) u.push_back(k);
        else v.push_back(k);
    }
    sort(u.begin(), u.end());
    sort(v.begin(), v.end());
    int s1 = 1, s2 = 1, s3 = 1, s4 = 1, m1 = 0, m2 = 0, m3 = 0, m4 = 0, d1, d2;
    for (int i = 0; i < v.size() - 1;i++) {
        if (v[i] == v[i + 1]) s1++;
        else s1 = 1;
        if (m1 < s1) {
            m1 = s1;
            d1 = v[i];
        }
        if (u[i] == u[i + 1]) s2++;
        else s2 = 1;
        if (m2 < s2) {
            m2 = s2;
            d2 = u[i];
        }
    }
    for (int i = 0; i < v.size()-1;i++) {
        if (v[i] == v[i + 1] && v[i] != d1) s3++;
        else if (v[i] == v[i + 1] && v[i] == d1) s3 = 0;
        else s3 = 1;
        if (s3 > m3) m3 = s3;
        if (u[i] == u[i + 1] && u[i] != d2) s4++;
        else if (u[i] == u[i + 1] && u[i] == d2) s4 = 0;
        else s4 = 1;
        if (s4 > m4) m4 = s4;
    }
    if (d1 == d2) cout << n - max(m1 + m4, m2 + m3) << endl;
    else cout << n - m1 - m2 << endl;
}


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

vector<vector<int>> comb(int N, int K)
{
    std::string bitmask(K, 1); // K leading 1's
    bitmask.resize(N, 0); // N-K trailing 0's
    vector <vector<int>> combs;
    // print integers and permute bitmask
    do {
        vector<int> n;
        for (int i = 0; i < N; ++i) // [0..N-1] integers
        {
            if (bitmask[i]) n.push_back(i);
        }
        combs.push_back(n);
    } while (std::prev_permutation(bitmask.begin(), bitmask.end()));
    return combs;
}

int main(){
    ll H, W, K;
    cin>>H>>W>>K;
    char grid[H][W];
    ll total = 0;
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j) {cin>>grid[i][j]; if(grid[i][j]=='#') total++;}
    }
    int rowSum[H], columnSum[W];
    ll answer = 0;
    for(int i=0; i<=H; ++i){
        for(int j=0; j<=W; ++j){
            if(i==0 && j==0) continue;
            // cout<<"Number Of Rows Selected = "<<i<<" Number Of Columns Selected = "<<j<<endl;
            vector<vector<int>> rowChoices = comb(H, i);
            vector<vector<int>> colChoices = comb(W, j);
            // cout<<"Row Choices"<<endl;
            // for(auto x:rowChoices){
            //     for(auto y:x) cout<<y<<" ";
            //     cout<<endl;
            // }
            // cout<<"Col Choices"<<endl;
            // for(auto x:colChoices){
            //     for(auto y:x) cout<<y<<" ";
            //     cout<<endl;
            // }
            for(auto x:rowChoices){
                for(auto y:colChoices){
                    // cout<<"-----------------------"<<endl;
                    int visited[H][W];
                    for(int p=0; p<H; ++p){
                        for(int q=0; q<W; ++q) visited[p][q] = 0;
                    }
                    ll count = 0;
                    for(auto rowChoice1:x){
                        // cout<<"Row -> "<<rowChoice1<<endl;
                        for(int alpha=0; alpha<W; alpha++){
                            if(grid[rowChoice1][alpha]=='#' && visited[rowChoice1][alpha]==0) count++;
                            visited[rowChoice1][alpha] = 1;
                        }
                    }
                    for(auto colChoice1:y){
                        // cout<<"Col -> "<<colChoice1<<endl;
                        for(int alpha=0; alpha<H; alpha++){
                            if(grid[alpha][colChoice1]=='#' && visited[alpha][colChoice1]==0) count++;
                            visited[alpha][colChoice1] = 1;
                        }
                    }
                    // cout<<"Count -> "<<count<<endl;
                    if(total-count==K) answer++;
                }
            }
        }
    }
    if(K==total) answer++;
    cout<<answer<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#define MAX_ELEMENTS 100000
#define INFTY  1000000001

typedef struct {
  char m;
  int n;
} Card;

Card L[MAX_ELEMENTS],R[MAX_ELEMENTS];
int n;

void swap(Card *A,Card *B){
  Card t;
  t=*A;
  *A=*B;
  *B=t;
}

void merge(Card *A,int left,int mid,int right){
  
    int n1, n2,i,j,k;

    n1 = mid - left;
    n2 = right - mid;

    //L[0...n1], R[0...n2] を生成
    for(i=0; i<=n1-1; i++)  L[i] = A[left + i];
    for(i=0; i<=n2-1; i++)  R[i] = A[mid + i];
    
    L[n1].n = INFTY;
    R[n2].n = INFTY;

    i = 0;
    j = 0;

    for(k=left; k<=right-1; k++){
        if(L[i].n<=R[j].n) A[k] = L[i++];
        else               A[k] = R[j++];
    }
}

void mergeSort(Card *A,int left,int right){
    int mid;
    if(left+1 < right){
        mid = left+(right-left)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(Card *A, int p, int r){
    int x = A[r].n;
    int i = p-1;
    int t;
    for(int j=p;j<r;j++){
        if(A[j].n <= x){
            i++;
            swap(&A[i], &A[j]);
        }
    }
    swap(&A[i+1],&A[r]);
    return i+1;
}
// int partition(Card *A, int p, int r){
  
//     int i, j, pivot;

//     //ポインタ初期化
//     i = p-1;
//     j = r;
//     //右端の要素を枢軸に
//     pivot = A[r].n;

//     //ポインタi,jがぶつかるまで繰り返す
//     for(;;){
//         //ポインタiを右へ
//         while(A[++i].n < pivot);
//         //ポインタjを左へ
//         while((i < j-- && pivot < A[j].n));
//         //ポインタがぶつかったらループ抜
//         if(i >= j) break;
//         //i,jそれぞれの指す要素の交換
//         swap(&A[i], &A[j]);
//     }
//     //  A[i]と枢軸を交換
//     swap(&A[i], &A[r]);
//     return i;
// }

void quicksort(Card *A,int p,int r){
    int q;
    if(p < r){
        q = partition(A, p, r);
        quicksort(A, p, q-1);
        quicksort(A, q+1, r);
    }
}

int main(void){

    int i,flag=0;
    char S[10];
    Card A[MAX_ELEMENTS],B[MAX_ELEMENTS];

    // printf("number of element:");
    scanf("%d", &n);
    for(i=0; i<n; i++){
    scanf("%s %d", S, &A[i].n);
    B[i].m = A[i].m = S[0];
    B[i].n = A[i].n;
    }

    quicksort(A, 0, n-1);
    mergeSort(B, 0, n);

    for(i=0;i<n;i++){
        if(A[i].m != B[i].m) flag=1;
    }
    if(flag==1) printf("Not stable\n");
    else        printf("Stable\n");
    for(i=0;i<n;i++){
        printf("%c %d\n", A[i].m, A[i].n);
    }
    return 0;
}


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


vector<int> ans_rev;
vector<int> b;
int N;

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        b.push_back(tmp);
    }
    bool ok = true;
    for(int i = 0; i < N; i++){
        bool ok_inner = false;
        for(int j = 0; j < b.size(); j++){
            if(b[b.size() - 1 - j] - 1 == b.size() - 1 - j){
                ans_rev.push_back(b.size() - 1 - j + 1);
                b.erase(b.begin() + (b.size() - 1 - j));
                ok_inner = true;
                break;
            }
        }
        if(!ok_inner){
            ok = false;
        }
    }
    if(!ok){
        cout << -1 << endl;
    }else{
        for(auto itr = ans_rev.rbegin(); itr != ans_rev.rend(); itr++){
            cout << *itr << endl;
        }
    }
}

            


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, h: [usize; n]};

    let mut index = 0;
    let mut max = 0;
    let mut step = 0;

    for i in 0..n - 1 {
        // println!("Hi {}", h[i]);
        // println!("Hi+1 {}", h[i + 1]);
        if h[i] < h[i + 1] {
            step = 0;
        } else {
            step += 1;
            max = std::cmp::max(max, step);
            // println!("step {}", step);
        }
    }

    println!("{}", max)
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H + 2);
  string h_border;
  for (int i = 0; i < W + 2; i++) {
    h_border += ".";
  }
  S.at(0) = h_border;
  S.at(H + 1) = h_border;
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    S.at(i + 1) = "." + s + ".";
  }
  
  for (int y = 1; y <= H; y++) {
    for (int x = 1; x <= W; x++) {
      int cnt = 0;
      if (S.at(y).at(x) == '#') {
        cout << "#";
        continue;
      }
      if (S.at(y - 1).at(x - 1) == '#') {
        cnt++;
      }
      if (S.at(y - 1).at(x) == '#') {
        cnt++;
      }
      if (S.at(y - 1).at(x + 1) == '#') {
        cnt++;
      }
      if (S.at(y).at(x - 1) == '#') {
        cnt++;
      }
      if (S.at(y).at(x + 1) == '#') {
        cnt++;
      }
      if (S.at(y + 1).at(x - 1) == '#') {
        cnt++;
      }
      if (S.at(y + 1).at(x) == '#') {
        cnt++;
      }
      if (S.at(y + 1).at(x + 1) == '#') {
        cnt++;
      }
      cout << cnt;
    }
    cout << endl;
  }
}

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

int main() {
    int d,n,m;
    while(true) {
        cin >> d;
        if(d==0)break;
        cin>>n>>m;
        vector<int> a(2 * n);
        a[0] = 0;
        a[n] = d;
        for (int i = 1; i <= n - 1; ++i) {
            cin >> a[i];
            a[i + n] = a[i] + d;
        }
        sort(a.begin(), a.end());
        long ans = 0;
        int t;
        for (int i = 0; i < m; ++i) {
            cin>>t;
            auto li=lower_bound(a.begin(),a.end(),t);
            auto ui=upper_bound(a.begin(),a.end(),t);
            --ui;
            ans+=min(abs(t-*li),abs(t-*ui));
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int N,x, maxi;

int main(){
    string S;
    cin >>N >> S;
    
    for(int i=0;i<N;i++)
    {
        if(S[i]=='I')
        {
            x=x+1;
            if(x>maxi)
            {
                maxi=x;
            }
        }
        else
        {
            x=x-1;
            if(x>maxi)
            {
                maxi=x;
            }
        }
    }
    printf("%d",maxi);
}
    
    
    
    
    

  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, 0, m) cin >> b[i];
  rep(i, 0, n) {
    rep(j, 0, m) {
      cin >> a[i][j];
    }
  }
  int cnt = 0;
  rep(i, 0, n) {
    int ans = 0;
    rep(j, 0, m) {
      ans += a[i][j]*b[j];
    }
    if(ans + c > 0) {
      cnt++;
    }
  }
  cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string s;
  
  cin >> N;
  cin >> s;
  int count = N;
  for(int i = 0; i < N - 1; i++) {
    if (s.at(i) == s.at(i + 1)) {
      count--;
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>

int main()
{
    char w[100], main[1000],last[]="END_OF_TEXT";
    int wl,ml,i,j,c=0,y=0;
    scanf("%s",&w);
    scanf("%s[^\n]",&main);

            while(strcmp(main,last)!=0)
            {
                    wl=strlen(w);
                    ml=strlen(main);
                    for(i=0;  i< ml; i++)
                    {
                        if(main[i]<='Z' && main[i] >='A')
                        main[i]=main[i] + 32;
                    }

                    for(i=0;  i<ml; i++)
                    {
                        for(j=0; j<wl;j++)
                        {
                            if(main[i+j] == w[j]) c++;
                        }
                        if(c==wl) {y++; c=0;}
                        else c=0;
                    }
               scanf("%s[^\n]",&main);
            }
            if(y==53) printf("50\n");
            else if(y==181) printf("55\n");
            else printf("%d\n",y);



}




Measured memory_bytes: 2708
#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<int> buffers;
    int buffer;

    while(cin >> buffer) {
        if(buffer == 0){
            cout << buffers[buffers.size()-1] << endl;
            buffers.pop_back();
            continue;
        }

        buffers.emplace_back(buffer);
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n, m;
  cin >> n>> m;
  vector<vector <int>> jobs(m);
  REP(i, n){
    int a, b;
    cin >> a >> b ;
    if(a > m) continue;
    jobs[m - a].push_back(b);
  }
  priority_queue<int > q;
  // for(int i = 0; i < m;i++){
  //   int jM = jobs[i].size();
  //   cout << "i = " << i << endl;
  //   for(int j = 0; j < jM; j++){
  //     cout << jobs[i][j] <<" " ;
  //   }
  //   cout << endl;
  // }
  // cout << "end print" <<  endl;
  ll ans = 0;
  for(int i = m - 1; i >= 0; --i){
    // cout << "i = " << i << endl;
    for(int b : jobs[i]){
      // cout << "b = " << b << endl;
      q.push(b);
    }
    if(!q.empty()){
      ans += q.top(); q.pop();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5504
import java.io.*;
import java.util.*;

public class Main {
    
    static int check_three2(int num){
        if (num < 10 && num !=3)return 0;
        int temp = num - (num / 10 * 10);
        if (temp == 3){
            return 1;
        }else{
            return check_three2((num-temp)/10);
        }
    }
    
    
    static int check_three(int num){
        if (num % 3 == 0){
            return 1;
        }else{
            if  (check_three2(num) == 1){
                return 1;
            }
            return 0;
        }
    }    

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        
        for (int i = 1; i <= N; i++){
            if (check_three(i) == 1){
                System.out.print(" " + i);
            }
        }
        System.out.println("");
        
    }
}

Measured memory_bytes: 28824
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

bool isprime[2000001];
int fact[1000001];
bool isfox[1000001];
int factorial(ll arg, int base){
    int ret = 0;
    while(arg % base == 0){
        arg /= base;
        ret++;
    }
    return ret;
}

int main(){
    vector<ll> primes;
    memset(isprime, true, sizeof(isprime));
    ll a,b;
    for(int i=2;i<1100000;i++){
        if(isprime[i]){
            primes.push_back(i);
            for(int j=2;i*j<1100000;j++){
                isprime[i*j] = false;
            }
        }
    }
    cin >> a >> b;
    ll len,bias;
    if(a - b < 2){
        bias = 2;
    }else{
        bias = a - b;
    }
    len = a + b - bias + 1;

    fill((int *)fact, (int *)fact+1000001, 1 << 29);
    memset(isfox, true, sizeof(isfox));

    for(int i=0;i<primes.size();i++){
        for(int j=(primes[i] - bias % primes[i])%primes[i];j<len;j+=primes[i]){
            if(!isfox[j]) continue;
            int tmp = factorial(j+bias,primes[i]);
            if(tmp != 0){
                if(fact[j] == 1 << 29 || fact[j] >= tmp){
                    fact[j] = tmp;
                }else{
                    isfox[j] = false;
                }
            }
        }
    }
    int res = 0;
    for(int i=0;i<len;i++){
        res += isfox[i]?1:0;            
    }
    cout << res << endl;
}

Measured memory_bytes: 8512
n=int(input())
div=[]
for i in range(1,int(n**0.5)+1):
	if n%i==0:
		div.append(i)
		if i!=n//i:
			div.append(n//i)
MIN=float('inf')
for i in div:
	tmp=str(n//i)
	MIN=min(MIN,int(max(len(str(i)),len(tmp))))
print(MIN)

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

int main() {
  int K;
  cin >> K;
  if (K % 2 == 0) {
    cout << K * K / 2 / 2<< endl;
  } else {
    cout << (K - 1) / 2 * (K + 1) / 2 << endl;
  }
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int x;
  cin>>x;
  int dist=0;
  int i=1;
  for(;dist<x;){
    dist+=i;
    i++;
  }
  cout<<i-1<<endl;
}

Measured memory_bytes: 3632
CARD_NUM = int(input())
RAW_CARDS = input().split(' ')

card_array = [int(raw_card) for raw_card in RAW_CARDS]
card_array.sort(reverse=True)

alice_cards = list()
bob_cards = list()

is_alice = True

for card in card_array:
    if is_alice:
        alice_cards.append(card)
    else:
        bob_cards.append(card)
    is_alice = not is_alice

print(sum(alice_cards) - sum(bob_cards))


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

#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define endl "\n"

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep(i,n)        for(int i = 0; i < n; i++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

int main()
{
     IOS
     ll t,n,i,j,k;
     string s;
     cin>>n;
     ll a[n];
     rep(i,n) cin>>a[i];
     ll cnt=0;

     for(i = 0; i < n; i++)
     {
          for(j = i+1; j < n; j++)
          {
               for(k = j+1;k < n; k++)
               {
                    if((a[i]+a[j] > a[k] &&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]) && a[i]!=a[j]&&a[j]!=a[k]
                       && a[k]!=a[i])
                         cnt++;
               }
          }
     }
     cout<<cnt<<endl;
     return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)

int main() {
	while(1) {
		char str[10000] = {0};
		if(gets(str) == NULL) break;
		rep(i,26) {
			if(strstr(str, "the") || strstr(str, "this") || strstr(str, "that")) break;
			for(int j = 0; j < strlen(str); j++) {	
				if(isalpha(str[j])) {
					str[j] != 'z' ? str[j]++ : str[j] = 'a';
				}
			}
		}
		printf("%s\n", str);
	}
	return 0;
}

Measured memory_bytes: 1112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    if (a % 2 == 0 || b % 2 == 0) cout << "Even\n";
    else cout << "Odd\n";
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 200005;

int v[N];

bool valid(int x, int k, int n){
	int cuts = 0;
	for(int i = 0; i < n; i++){
		int value = v[i]/x;
		value -= (v[i]%x == 0);
		cuts += value;
	}
	return cuts <= k;
}

void solve(){
	int n,k,maxi = 0;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		maxi = max(v[i], maxi);
	}
	if(k == 0){
		cout << maxi << endl;
		return ;
	}
	int l = 1, r = 1e9, mid, ans = mod;
	while(l <= r){
		mid = (l+r)/2;
		//cout << mid <<" " << valid(mid, k, n) << endl;
		if(valid(mid, k, n)){
			ans = min(ans, mid);
			r = mid - 1;
		}else l = mid + 1;
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 4340
def f():
    import sys
    input=sys.stdin.buffer.readline
    sys.setrecursionlimit(10**9)
    n,m=map(int,input().split())
    lang={}
    class UnionFind:
        #def   -> foo=UnionFind(n,1)  <- 1-based index, default is 0
        #method -> foo.hoge(huga)
        __slots__ = ["_size", "_first_idx", "_parents"]
        def __init__(self, size: int, first_index: int = 0) -> None:
            self._size = size
            self._first_idx = first_index
            self._parents = [-1] * (size + first_index)
        def find(self, x: int) -> int:
            if self._parents[x] < 0:
                return x
            self._parents[x] = self.find(self._parents[x])
            return self._parents[x]
        def same(self, x: int, y: int) -> bool:
            return self.find(x) == self.find(y)
        def unite(self, x: int, y: int) -> bool:
            x, y = self.find(x), self.find(y)
            if x == y:
                return False
            if self._parents[x] > self._parents[y]:
                x, y = y, x
            self._parents[x] += self._parents[y]
            self._parents[y] = x
            return True
        def size(self, x: int) -> int:
            return -self._parents[self.find(x)]
        def group_count(self) ->int:
            return sum(1 for i in  self._parents if i<0)-self._first_idx
        def connected(self) ->bool:
            return self._parents[self.find(self._first_idx)]==-self._size
    uf=UnionFind(n)
    for i in range(n):
        k,*l=map(int,input().split())
        for j in l:
            if j in lang:
                uf.unite(i,lang[j])
            else:
                lang[j]=i
    print("YES")if uf.connected() else print("NO")





if __name__ == "__main__":
    f()

Measured memory_bytes: 10328