akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    LL n, K;
    cin >> n >> K;
    vector< LP > v(n);
    for( int i = 0; i < n; ++i ) {
        cin >> v[i].F >> v[i].S;

    }

    LL res = LINF;
    for( int i = 0; i < n; ++i ) {
        for( int j = 0; j < n; ++j ) {
            for( int k = 0; k < n; ++k ) {
                for( int l = 0; l < n; ++l ) {
                    LL xmin, xmax, ymin, ymax;
                    xmin = min(v[i].F, min(v[j].F, min(v[k].F, v[l].F)));
                    xmax = max(v[i].F, max(v[j].F, max(v[k].F, v[l].F)));
                    ymin = min(v[i].S, min(v[j].S, min(v[k].S, v[l].S)));
                    ymax = max(v[i].S, max(v[j].S, max(v[k].S, v[l].S)));
                    int cnt = 0;
                    for( int m = 0; m < n; ++m ) {
                        if( xmin <= v[m].F && v[m].F <= xmax &&
                                ymin <= v[m].S && v[m].S <= ymax ) {
                            ++cnt;

                        }
                    }
                    if( K <= cnt ) {
                        res = min(res, (xmax - xmin) * (ymax - ymin));

                    }
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
/*
*ID: juryc
*LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
const int N = 2*1e5+5; 
set<int> adj[N]; 
vector<int> vis(N,0);
int dfs(int u){
vis[u]=1; 
int cnt=1; 
for(int i:adj[u]){
if(!vis[i]) cnt+=dfs(i); 
}
return cnt; 
} 
int main(){
int n,m; cin>>n>>m;
int u,v; 
for(int i=0;i<m;i++){ cin>>u>>v; adj[u].insert(v); adj[v].insert(u); }
int mx=0; 
for(int i=1;i<=n;i++) { if(!vis[i]) mx=max(mx,dfs(i));  }
cout<<mx<<endl;
return 0;
}


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

using namespace std;

char p[3][3][4];
char pz[9][4];

bool check(char a,char b){
    return (a-32 == b || b-32 == a);
}

int rec(int now,int S){
    if(now == 9) return 1;
    int res = 0;
    int X = now%3, Y = now/3;
    for(int s = 0 ; s < 9 ; s++){
        if(S >> s & 1) continue;
        for(int i = 0 ; i < 4 ; i++){
            for(int j = 0 ; j < 4 ; j++){
                p[Y][X][j] = pz[s][(i+j)%4];
            }
            bool can = true;    
            if(X > 0 && !check(p[Y][X][0],p[Y][X-1][2])){
                can = false;
            }
            if(Y > 0 && !check(p[Y][X][1],p[Y-1][X][3])){
                can = false;            
            }
            if(can) res += rec(now+1,S|(1<<s));
        }
    }
    return res;
}

int main(){
    int Tc;
    cin >> Tc;
    while(Tc--){
        for(int i = 0 ; i < 9 ; i++){
            for(int j = 0 ; j < 4 ; j++){
                cin >> pz[i][j];
            }
        }
        cout << rec(0,0) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>

void showDeck(int *a,int l){
	std::cout << "[";
	for(int i=0;i<l;i++){
		std::cout << a[i] ;
		if(i!=l-1) std::cout << ", ";
	}
	std::cout << "]" << std::endl;
}
int main(void) {
	int n,r;
	int p,c;
	int a[2];
	while(true){
		std::cin >> n;
		std::cin >> r;
		if(n == 0 || r == 0) break;
		int deck[n];
		for(int i=0;i<n;i++){
			deck[i] = n-i;
		}
		for(int ii=0;ii<r;ii++){
			std::cin >> p;
			std::cin >> c;
			int set1[p-1];
			int set2[c];
			for(int i=0; i<p-1;i++){
				set1[i]=deck[i];
			}
			for(int i=0; i<c;i++){
				set2[i]=deck[p-1+i];
			}
			// showDeck(deck,n);
			// showDeck(set1,p-1);
			// showDeck(set2,c);
			for(int i=0;i<c;i++){
				deck[i]=set2[i];
			}
			for(int i=0;i<p-1;i++){
				deck[c+i]=set1[i];
			}
			// showDeck(deck,n);
		}
		std::cout << deck[0] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;
const int nmax=100005;
int p[nmax],b[nmax];
int n,m,x,y,ans,i;
int main()
{
    cin>>n>>m;
    for(i=1;i<=n;i++)
        b[i]=1;
    p[1]=1;
    for(i=1;i<=m;i++)
    {
        cin>>x>>y;
        b[x]--;b[y]++;
        p[y]|=p[x];
        if(!b[x]) p[x]=0;
    }
    for(i=1;i<=n;i++)
        ans+=p[i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
//ABC109A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if(a%2 == 1 && b%2 == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

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

    char s[n+1];
    scanf("%s", s);
    if(n%2==1){
        printf("No\n");
        return 0;
    }
    int i;
    for(i=0;i<n/2;i++){
        if(s[i]!=s[n/2+i]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;
typedef long long LL;

int main()
{
	int res = 700;
	char ch;
	for (int i = 0; i < 3; i++) {
		cin >> ch;
		if (ch == 'o') {
			res += 100;
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 1000006, MAXM = 102, Mod = 998244353, MAXLog = 20;


int solve1(int n, int idx, int sum, int half, vector<int> &arr, vector<vector<int>> &memo) {
    if (idx == n)
        return sum >= half;
    int &ret = memo[idx][sum];
    if (~ret)
        return ret;
    ret = solve1(n, idx + 1, sum, half, arr, memo) * 2;
    ret %= Mod;
    ret += solve1(n, idx + 1, sum + arr[idx], half, arr, memo);
    ret %= Mod;
    return ret;
}

int solve2(int n, int idx, int sum, int half, vector<int> &arr, vector<vector<int>> &memo) {
    if (idx == n)
        return sum == half;
    int &ret = memo[idx][sum];
    if (~ret)
        return ret;
    ret = solve2(n, idx + 1, sum, half, arr, memo);
    ret %= Mod;
    ret += solve2(n, idx + 1, sum + arr[idx], half, arr, memo);
    ret %= Mod;
    return ret;
}

int power(int b, int e, int mod = Mod) {
    if (e == 0) return 1;
    int x = power(b, e >> 1, mod);
    x = 1LL * x * x % mod;
    if (e & 1)
        x = 1LL * x * b % mod;

    return x;
}

int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout
            << fixed;

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

    vector<vector<int>> memo1(n, vector<int>(90001, -1));
    int ans = (power(3, n) - 3LL * solve1(n, 0, 0, (sum + 1) / 2, arr, memo1) % Mod + Mod) % Mod;


    vector<vector<int>> memo2(n, vector<int>(90001, -1));
    cout << (ans + ((sum & 1) ? 0 : 3LL * solve2(n, 0, 0, sum / 2, arr, memo2) % Mod)) % Mod << '\n';






    return 0;
}

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

void black(int sx,int lx,int sy,int ly,vector<vector<int>>& a){
	for(int i=sx;i<lx;i++){
    	for(int j=sy;j<ly;j++){
        	a[j][i]=0;
        }
    }
}

int main(){
	//2次元配列で解いてみる
  	int w,h,n;cin>>w>>h>>n;
  	vector<vector<int>> a(h,vector<int>(w,1));
  	int x,y,t;
  	for(int i=0;i<n;i++){
    	cin>>x>>y>>t;
      	if(t==1) black(0,x,0,h,a);
      	if(t==2) black(x,w,0,h,a);
      	if(t==3) black(0,w,0,y,a);
      	if(t==4) black(0,w,y,h,a);
    }
  	int ans=0;
  	for(int i=0;i<w;i++){
    	for(int j=0;j<h;j++){
        	ans+=a[j][i];
        }
    }
  cout<<ans<<endl;
}    


Measured memory_bytes: 256
n = int(input())

cnt_ac = 0
cnt_wa = 0
cnt_tle = 0
cnt_re = 0

for i in range(n):
  s = str(input())
  if s == 'AC':
    cnt_ac += 1
  elif s == 'WA':
    cnt_wa += 1
  elif s == 'TLE':
    cnt_tle += 1
  elif s == 'RE':
    cnt_re += 1
    
print('AC x {}'.format(cnt_ac))
print('WA x {}'.format(cnt_wa))
print('TLE x {}'.format(cnt_tle))
print('RE x {}'.format(cnt_re))




Measured memory_bytes: 9204
#include<stdio.h>
int main()
{
    int i;
    int sum = 0;
    char W[11], T[1001];

    scanf("%s", W);
    for( i = 0; W[i]; ++i ) W[i] = tolower(W[i]);
    while( 1 ){
        scanf("%s", T);
        if( strcmp("END_OF_TEXT", T) == 0 ) 
        break;
        for( i = 0; T[i]; ++i )
        T[i] = tolower(T[i]);
        if( strcmp(W, T) == 0 ) 
        ++sum;
    }

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

    return 0;
}


Measured memory_bytes: 2128
def main():
    n = int(input())
    if n == 0:
        print('0')
    elif n > 0:
        c = 1
        cnt = 0
        while True:
            if c + (4**cnt) > n:
                break
            else:
                c += (4**cnt)
                cnt+=1

        ans = '1'
        for i in range(cnt):
            ans+='10'
        
        print(bin(int(ans,2)^int(bin(n-c)[2:],2))[2:])

    else:
        n = abs(n)
        c = 1
        cnt = 0
        while True:
            if c+2*(4**cnt) > n:
                break
            else:
                c+= 2*(4**cnt)
                cnt+=1
        
        ans = '1'
        for i in range(cnt):
            ans+='10'
        ans += '1'
        print(bin(int(ans,2)^int(bin(n-c)[2:],2))[2:])




main()

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


int main(){
	ll n;
	cin >> n;
	ll ans(INF);
	for(ll i(1);i*i<=n;++i){
		if(n%i == 0){
			ll t = n/i + i;
			if(t < ans) ans = t;	
		}
	}
	if(ans>=2) ans -= 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class SegmentTree:
    def __init__(self, init_value: list, segfunc, ide_ele):
        n = len(init_value)
        self.N0 = 1 << (n - 1).bit_length()
        self.ide_ele = ide_ele
        self.data = [ide_ele] * (2 * self.N0)
        self.segfunc = segfunc
        
        for i, x in enumerate(init_value):
            self.data[i + self.N0 - 1] = x
        for i in range(self.N0 - 2, -1, -1):
            self.data[i] = self.segfunc(self.data[2 * i + 1], self.data[2 * i + 2])
    
    def update(self, _k, x):
        k = _k + self.N0 - 1
        self.data[k] = x
        while k:
            k = (k - 1) // 2
            self.data[k] = self.segfunc(self.data[k * 2 + 1], self.data[k * 2 + 2])
    
    def query(self, left, right):
        L = left + self.N0
        R = right + self.N0
        res = self.ide_ele
        
        while L < R:
            if L & 1:
                res = self.segfunc(res, self.data[L - 1])
                L += 1
            if R & 1:
                R -= 1
                res = self.segfunc(res, self.data[R - 1])
            L >>= 1
            R >>= 1
        
        return res


def solve():
    N, x = map(int, rl().split())
    a = list(map(int, rl().split()))
    
    seg_tree = SegmentTree(a, min, 10 ** 15)
    ans = 10 ** 15
    for i in range(N):
        get_cost = 0
        for j in range(N):
            if i <= j:
                get_cost += seg_tree.query(j - i, j + 1)
            else:
                get_cost += min(seg_tree.query(0, j + 1), seg_tree.query(N - i + j, N))
        ans = min(ans, i * x + get_cost)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 70188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 200000;
ll mod = INF;


int main(){
    int n;
    int ans=0;
    int m=INF;
    cin >> n;
    rep(i,n){
        int t;cin >> t;
        m=min(m,t);
        if(m>=t){
            ans++;
        }
    }

    cout << ans<<endl;
    return 0;
}

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

signed main() {
	ll N, A, B; cin >> N >> A >> B;
	if (N == 1) {
		if (A == B)cout << 1 << endl;
		else cout << 0 << endl;
	}
	else if (A > B)cout << 0 << endl;
	else {
		ll ans = (B - A)*(N - 2) + 1;
		cout << ans << endl;
	}
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
using namespace std;
int x[9],y[9];
float cal(int a,int b)
{
    int dx=x[a]-x[b];
    int dy=y[a]-y[b];
  return pow(dx*dx+dy*dy,0.5);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>x[i]>>y[i];
  int a[n];
  for(int i=0;i<n;i++)
    a[i]=i;
  double ans=0;
  		do
        {
           // for(int i=0;i<n;i++)
             //   cout<<a[i]<<" ";
          for(int i=0;i<n-1;i++)
          {
            ans+=cal(a[i],a[i+1]);
          }
            //cout<<endl;
        }while(next_permutation(a,a+n));
    int x=1;
    	for(int i=1;i<=n;i++)
            x*=i;
        cout<<fixed<<setprecision(10)<<ans/x<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, a[N];
namespace Seg {
	int xb, f[N << 2];
	inline void Pre() {
		xb = n * 2 + 1;
		for (int i = 1; i <= xb * 2; ++i) f[i] = 0;
	}
	inline void Add(int x, int y = 1) {
		x += n + 1;
		for (int i = xb + x; i; i >>= 1) f[i] += y;
	}
	inline int Ask(int x, int y) {
		x += n + 1; y += n + 1;
		int ans = 0;
		for (int l = xb + x - 1, r = xb + y + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
			if (~l & 1) ans += f[l ^ 1];
			if ( r & 1) ans += f[r ^ 1];
		}
		return ans;
	}
}
inline long long Calc(int x) {
	long long ans = 0;
	Seg::Pre();
	int sm = 0;
	Seg::Add(sm);
	for (int i = 1; i <= n; ++i) {
		sm += (a[i] >= x ? 1 : -1);
		ans += Seg::Ask(-n, sm);
		Seg::Add(sm);
	}
	return ans;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	int ans = 0;
	long long cnt = 1ll * n * (n + 1) / 2;
	long long fit = cnt - cnt / 2;
	for (int l = 1, r = 1e9, mid; l <= r; Calc(mid = (l + r) >> 1) >= fit ? ans = mid, l = mid + 1 : r = mid - 1);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2176
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int a = input[0];
		int b = input[1];

		string ans = "Alice";
		if (a == b) { ans = "Draw"; }
		else if (b == 1 || (a != 1 && a < b)) { ans = "Bob"; }

		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13268
#input one int
#a = int(input())

#input some val
#a, b, c = (int(i) for i in input().split())
#val = [[int(i) for i in input().split()] for i in range(N)]

#input matrix
#a = [input().split() for i in range()]

#Input	script	結果
#abcde	s=input()	s='abcde'
#abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
#5(1つだけ)	a=int(input())	a=5
#1 2	x,y = map(int,input().split())	x=1,y=2
#1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
#1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
#FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

import math

def my_abs(x):
    if(x < 0):
        return (-x)
    else:
        return x


N = int(input())
T, A = (int(i) for i in input().split())
H = list(map(int,input().split()))

res = []
j = 0

for j in range(N):
    res.append(my_abs(A - (T - H[j]*0.006)))

print(res.index(min(res))+1)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  string S;
  cin>>S;
  bool flag=true;
  rep(i,S.size()){
    if(i%2==0){
      if(S[i]=='R'||S[i]=='U'||S[i]=='D'){
        flag=true;
      }
else{
flag=false;
  break;
}
    }
else{
      if(S[i]=='L'||S[i]=='U'||S[i]=='D'){
        flag=true;
      }
else{
flag=false;
  break;
}
}
  }

  if(flag){
    cout<<"Yes"<<endl;
  }
  else{
cout<<"No"<<endl;
  }
}


        
      

Measured memory_bytes: 256
def GCD(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    else:
        return GCD(b, a % b)


def LCM(a, b):
    return a * b // GCD(a, b)

a, b, c, d = [int(i) for i in input().split()]

cnt_c = b//c - (a-1)//c
cnt_d = b//d - (a-1)//d
cd = LCM(c, d)
cnt_cd = b//cd - (a-1)//cd

print(b-a+1-(cnt_c + cnt_d - cnt_cd))

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

int main(){
    int X, N, near=0, dif, count=0, ans1, ans2, ans=0;
    cin >> X >> N;

    if(N == 0){
        cout << X << endl;
        return 0;
    }

    vector<int> P(N);

    for(int n=0; n<N; n++){
        cin >> P.at(n);
    }

    for(int i=0; i<N; i++){
        count = 0;
        for(int n=0; n<N && count != 2; n++){
            dif = X - P.at(n);
            if(abs(dif) == near){
                ans1 = dif;
                count++;
            } else if(abs(dif) == near && count == 1) {
                count++;
            }
        }
        if(count == 0){
            ans = X - near;
            break;
        } else if(count == 1 && ans1 != 0){
            ans = X + ans1;
            break;
        }
        near++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    string s;
    cin >> s;
    int ans = 0;
    rep(i, s.size()) {
        if(s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    long long x;
    long long s, e, m;
    
    scanf("%lld", &x);
    s = 1;
    e = 100000;
    //printf("[%d]\n", e);
    while(s < e) {
        m = (s + e) / 2;
        if(m * (m + 1) / 2 < x) s = m + 1;
        else e = m;
    }
    printf("%lld", s);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int max = 1;
  int mcounter = 0;
  for (int i = 1; i <= N; i++) {
    int num = i;
    int counter = 0;
    while (true) {
      if (num % 2 == 0) {
        num /= 2;
        counter++;
      } else {
        break;
      }
    }
    if (counter > mcounter) {
      max = i;
      mcounter = counter;
    }
  }
  cout << max << endl;
}


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

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

    if ((N[0]==N[1] && N[1]==N[2]) | (N[1]==N[2] && N[2]==N[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }



    return 0;
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())

# input black cells
black_cells = []

for h in range(H):
    line = list(input())
    for w in range(W):
        if line[w] == "#":
            black_cells.append(h * W + w)


# Graph
def r(p):
    q_list = []
    h = p // W
    w = p % W
    if h != 0:
        q_list.append(p - W)
    if h != H-1:
        q_list.append(p + W)
    if w != 0:
        q_list.append(p - 1)
    if w != W-1:
        q_list.append(p + 1)
    return q_list


queue = deque(black_cells)
d = [10000] * (H * W)
for i in black_cells:
    d[i] = 0

# dijkstra
while len(queue) > 0:
    p = queue.popleft()
    for q in r(p):
        if d[q] > d[p] + 1:
            d[q] = d[p] + 1
            queue.append(q)

print(max(d))

Measured memory_bytes: 118956
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;

int main(void){
	int a;
	while(cin>>a){
		int b;
		cin >> b;
		int c = a + b;
		stringstream ss;
		string s;
		ss << c;
		s = ss.str();
		cout << s.size() << endl;
	}


	return 0;	
}

Measured memory_bytes: 1216
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;
    
    string s;
    ll k;
    cin>>s>>k;
    bool ok=false;
    char c;
    if((ll)s.size()>=k){
        rep(i,k){
            if(s[i]!='1'){
                ok=true;
                c=s[i];
                break;
            }
        }
        if(ok) cout<<c<<endl;
        else cout<<1<<endl;
    }
    else{
        rep(i,(ll)s.size()){
            if(s[i]!='1'){
                cout<<s[i]<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, M;
    cin >> A >> B >> M;
    vint a(A), b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    vint x(M), y(M), c(M);
    rep(i, M) cin >> x[i] >> y[i] >> c[i];


    int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
    rep(i, M) {
        int cost = max(0, a[x[i] - 1] + b[y[i] - 1] - c[i]);
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

int main()
{
    rep(i,5){
      int x;
      cin >> x;

      if(x==0) {
        cout << i+1 << endl;
        return 0;
      }
    }
}


Measured memory_bytes: 3624
#include <stdio.h>
int main()
{
  int cou,a,i;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    cou=0;
    for(i=2;i<=a/2+1;i++){
      if(i%2==0&&a%i==0)continue;
      if(i%2==0&& a*2%i == 0 &&a/i>=i/2){
	cou++;
	//printf("%d\n",i);
      }
      if(i%2!=0&&a%i==0&&a/i>=i/2+1){
	cou++;
	//printf("%d\n",i);
      }
      if(i%2!=0&&a%i!=0)continue;
    }
    printf("%d\n",cou);
  }
  return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<math.h>
main(){
  double r,m,s;
  scanf("%lf",&r);
  /*gcc -lm programname.c*/
  m=r*r*M_PI;
  s=2*r*M_PI;
  printf("%f %f\n",m,s);
  return 0;
}

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

int main() {
  int N, K;
  string S;

  cin >> N >> K >> S;
  
  locale loc;
  for (int i = 0;i < N;i++) {
    if (i == K -1) {
      cout << tolower(S[i], loc);
    }
    else {
      cout << S[i];
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define clr(x) memset(x, 0, sizeof(x))
#define all(a) a.begin(),a.end()
#define forn(i, a,b) for(int i = int(a); i < int(b); ++i)
#define forn_r(i, b, a) for(int i = int(b); i > int(a); i--)
#define trav(a,x) for (auto& a : x)
#define printArray(array, length) for(int i = 0; i < length; i++) cout<< array[i] << (i == length - 1 ? '\n' : ' '); 
#define print(x) cout << x << '\n'
#define print2(x, y) cout << x << ' ' << y << '\n'
#define debug(x) cout << #x << "=" << x << endl
#define debug2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
template <typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template <typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const ll LNF  = 0x3f3f3f3f3f3f;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline ll  gcd(ll  a, ll  b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t =1;
    //cin>>t;
    while(t--){
    	int n;
    	cin>>n;
    	int count=0;
    	ll rem = 0; 
  		//if(n==1 || n==7) {print(1);return 0;}
     	if(n%2==0 || n%5==0){print(-1); return 0 ;}
     	bool start=1;
    	while (start || rem != 0) { 
  
        	rem = (rem * 10 + 7) % n; 
        	count++;
        	start=0;	 
       }	
       print(count);
       	 
    }
    return 0;
}

Measured memory_bytes: 3660
from itertools import permutations

n = int(input())
N = [i+1 for i in range(n)]

P = list(map(int, input().split()))
Q = list(map(int, input().split()))

C = list(permutations(N))

for i, c in enumerate(C):
    if list(c) == list(P):
        f = i
    if list(c) == Q:
        s = i
print(abs(s-f))


Measured memory_bytes: 46064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
//b
int main(){

    int N; cin >> N;
    vector<int64_t> A(N);
    rep(i, N) cin >> A[i];

    rep(i, N){
        if(A[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    int64_t ans = 1;
    rep(i, N){
        int64_t x = 1000000000000000000/ans;
        if(A[i]>x){
            cout << "-1" << endl;
            return 0;
        }
        ans*=A[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 4000
def primes(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2,n+1,i):
            is_prime[j] = False
    return is_prime

e = primes(10**5)

tc = 0
li = []

for i in range(len(e)):
    if i%2 == 0:
        li.append(tc)
    else:
        if e[i] and e[(i+1)//2]:
            tc += 1
        li.append(tc)

Q = int(input())
for i in range(Q):
    l,r = map(int,input().split())
    print(li[r]-li[l-1])


Measured memory_bytes: 5144
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for i in range(m)]

bad=[]
for i in ab:
  a,b=h[i[0]-1],h[i[1]-1]
  if a<b:
    bad+=[i[0]]
  elif a>b:
    bad+=[i[1]]
  else:
    bad+=[i[0],i[1]]
print(n-len(set(bad)))

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

int main() {
    int n;
    cin >> n;
    int a[n];
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    for (int i = n - 1; i >= 0; i--) {
        if (i == 0) {
            cout << a[i] << endl;
            break;
        }
        cout << a[i] <<" ";
    }
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
    string s;
    cin>>s;
    // Initialize String Array 
    string p[7] = { "SAT", "FRI", 
                         "THU", "WED","TUE","MON","SUN" }; 
  
    // Print Strings 
    int i;
    for ( i = 0; i < 7; i++) 
        if(s==p[i]){
            cout<<i+1;
        }
        return 0;
} 
  

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


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;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    cout << u << endl;
    return u;
}

ll paty_counter(ll level, ll x){
    ll size = pow(2, level+2) - 3;
    ll pmi = pow(2, level) - 1;
    if(x == 0){
        return 0;
    }else if(level == 0){    
        return 1;
    }else{
        if(x <= (size - 1)/2){
            return paty_counter(level-1, x-1);
        }else{
            return pmi + 1 + paty_counter(level-1, x - pow(2, level+1) + 3 - 2);
        }
    }

}
 
int main() {
    string s;
    cin >> s;
    ll ans = 0;
    REP(i, s.size()){
        ans += s[i] - 48;
        //cout << ans << endl;
    }
    if(ans % 9 == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}



Measured memory_bytes: 3732
def solve()
  n = gets.to_i
  h = gets.split.map!(&:to_i)
  h = h.reverse!
  ans = 0
  cnt = 0
  (1..n-1).each do |i|
    if (h[i-1] <= h[i])
      cnt += 1
    else
      cnt = 0
    end
    if ans < cnt
      ans = cnt
    end
  end
  print(ans)
end
solve()

Measured memory_bytes: 9732
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int A,B,C;cin >> A >> B >> C;
    int res = 0;
    rep(i,10000){
        if(A%2||B%2||C%2)break;
        int Ao=A,Bo=B,Co=C;
        A=(Bo+Co)/2;
        B=(Ao+Co)/2;
        C=(Ao+Bo)/2;
        res++;
    }
    if(res==10000)cout << -1 << endl;
    else cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP=pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

signed main() {
	int a;
	cin >> a;
	cout << a * a * 3 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
    long long n,i,j,x;
    scanf("%lld", &n);

    i=sqrt(n);
    while(n%i!=0) i--;
    j=n/i;
    x=(i-1)+(j-1);
    printf("%lld\n", x);
    return 0;
}


Measured memory_bytes: 128
#import <stdio.h>
typedef long long INT;
int main(){
    INT x;
    scanf("%lld",&x);
    INT n = x/11;
    INT r = x%11;
    INT ans;
    if(r==0){
        ans = 2*n;
    } else if (r<=6){
        ans = 2*n+1;
    } else {
        ans = 2*n+2;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 7116
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>


using namespace std;


int main(){
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        string temp;
        cin>>temp;
        int h=(temp[0]-'0')*10+(temp[1]-'0');
        int m=(temp[3]-'0')*10+(temp[4]-'0');
        
        double h_angle;
        h_angle = 360.0/12.0 * h + (360.0/12.0)/60.0 * m;
        double m_angle;
        m_angle = 360.0/60.0 * m;
        
        double angle = max(h_angle,m_angle)-min(h_angle,m_angle);
        if(angle>180.0)angle=360.0-angle;
        
        if(angle<30.0)cout<<"alert"<<endl;
        else if(angle>=90.0)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;

    }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 4000000000000000000LL
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int K,N;
ll x[55],y[55];
vector<ll> zx,zy;
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++){
		cin >> x[i] >> y[i];
		zx.pb(x[i]);
		zy.pb(y[i]);
	}
	sort(all(zx));
	sort(all(zy));
	zx.erase(unique(all(zx)),zx.end());
	zy.erase(unique(all(zy)),zy.end());
	ll ans = LLINF;
	//cout << ans << endl;
	for(int i=0;i<zx.size();i++){
		for(int j=i;j<zx.size();j++){
			for(int k=0;k<zy.size();k++){
				for(int l=k;l<zy.size();l++){
					int c=0;
					for(int d=0;d<N;d++){
						if(zx[i]<=x[d]&&x[d]<=zx[j]&&zy[k]<=y[d]&&y[d]<=zy[l]){
							c++;
						}
					}
					if(c>=K)ans = min(ans,(zx[j]-zx[i])*(zy[l]-zy[k]));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def split_w(rows, ans, g):
    last_col = 0
    for i in xrange(len(rows[0])):
        for a in ans:
            a[i] = g
        if sum(r[i] for r in rows):
            g += 1
            last_col = i
    for i in xrange(last_col + 1, len(rows[0])):
        for a in ans:
            a[i] = g - 1
    return g


def split_h(cake, ans):
    g = 1
    rows = []
    aa = []
    last_row = 0
    for i, (row, a) in enumerate(zip(cake, ans)):
        rows.append(row)
        aa.append(a)
        if sum(row):    
            g = split_w(rows, aa, g)
            rows = []
            aa = []
            last_row = i
    for j in xrange(last_row + 1, len(cake)):
        ans[j] = ans[last_row]


def main():
    h, w, k = map(int, raw_input().split())
    cake = []
    for _ in xrange(h):
        row = []
        for c in raw_input():
            if c == '#':
                row.append(1)
            else:
                row.append(0)
        cake.append(row)
    ans = [[0] * w for _ in xrange(h)]
    split_h(cake, ans)
    for a in ans:
        print ' '.join(map(str, a))


main()


Measured memory_bytes: 6788
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        m: usize,
        e: [(usize1, usize1); m],
    }
    let mut g = vec![vec![]; n];
    for (a, b) in e {
        g[a].push(b);
        g[b].push(a);
    }
    let mut x = 0;
    let mut y = 0;
    let mut z = 0;
    let mut used = vec![false; n];
    let mut depth = vec![0; n];
    for r in 0..n {
        if used[r] {
            continue;
        }
        used[r] = true;
        if g[r].is_empty() {
            z += 1;
            continue;
        }
        let mut q = vec![];
        let mut stack = vec![r];
        while let Some(v) = stack.pop() {
            q.push(v);
            for &u in &g[v] {
                if used[u] {
                    continue;
                }
                used[u] = true;
                depth[u] = depth[v] ^ 1;
                stack.push(u);
            }
        }
        let mut cond = true;
        for &v in &q {
            for &u in &g[v] {
                if depth[u] == depth[v] {
                    cond = false;
                }
            }
        }
        if cond {
            x += 1;
        } else {
            y += 1;
        }
    }
    let mut ans = 0;
    ans += z * z;
    ans += 2 * (n - z) * z;
    ans += x * x * 2;
    ans += y * y;
    ans += 2 * x * y;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 20724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int C = Integer.parseInt(sc.nextLine());
		if (C >= 30) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35692
#include<stdio.h>

int main( void )
{
    int num[3];
    for( int i = 0; i < 3; i++ )
    {
        scanf("%d", &num[i]);
    }

    if( num[0] == num[1] ) printf("%d\n", num[2]);
    else if( num[0] == num[2] ) printf("%d\n", num[1] );
    else printf("%d\n", num[0]);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n; cin>>n;
  vector<tuple<string,int,int>> a;
  for(int i=1;i<=n;i++){
     string s; cin>>s;
     int p; cin>>p;
     //tuppleのソートは小さい順番　-1かけることで大きい順にする
     p=-p;
     //tuppleに突っ込む
     a.push_back(tie(s,p,i));
  }
  sort(a.begin(),a.end());
  //tuppleのindexをとる
  for(int i=0;i<n;i++) cout<<get<2>(a[i])<<endl;
  return 0;
  /*別解
  //tuppleに突っ込む
  tie(s,p,id)=a[i];
  cout<<id<<endl;
  */
}

Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$b=explode(" ",trim(fgets(STDIN)));
$ans=0;
$i=0;
while($i<$n){
  if($b[$i]>$a[$i]){
    $ans+=$a[$i];
    $m=min($b[$i]-$a[$i],$a[$i+1]);
    $ans+=$m;
    $a[$i+1]-=$m;
  }else{
    $ans+=$b[$i];
  }
  ++$i;
}
echo $ans;

Measured memory_bytes: 20980
s1 = input()
s2 = input()

dp = [[0] * (len(s2)+1) for _ in range(len(s1)+1)]
for i in range(len(s1)+1):
    dp[i][0] = i
for i in range(len(s2)+1):
    dp[0][i] = i
        
for i in range(1, len(s1)+1):
    for j in range(1, len(s2)+1):
        dp[i][j] = min(
                dp[i-1][j-1] + (0 if s1[i-1] == s2[j-1] else 1),
                dp[i-1][j] + 1,
                dp[i][j-1] + 1
        )
#print(s1)
#print(s2)

#print('      '+', '.join(list(s2)))
#for i,v in enumerate(dp):
    #if i != 0:
        #print(s1[i-1], v)
        #continue
    #print(' ', v)
print(dp[len(s1)][len(s2)])



Measured memory_bytes: 43072
N, M, K = map( int, input().split())
Flag = False
ans = 'No'
for i in range(N+1):
    for j in range(M+1):
        if (M-j)*i + (N-i)*j == K:
            ans = 'Yes'
            Flag = True
            break
    if Flag == True:
        break
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int a, b, c; cin >> a >>b >> c;
    cout << (a*b)/2 << ln;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a=="SAT") cout<<1;
	else if(a=="SUN") cout<<7;
	else if(a=="MON") cout<<6;
	else if(a=="TUE") cout<<5;
	else if(a=="WED") cout<<4;
	else if(a=="THU") cout<<3;
	else if(a=="FRI") cout<<2;
	
	return 0;
} 

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

const ll MAXN = 200000;

ll N, ans=0, tmp=0, DP[100005][13]={{0}};
string S;

signed main(){
    cin >> S;
    DP[0][0]=1;
    for(int i=1;i<=S.size();i++) {
        if(S[i-1]=='?') {
            for(int l=0;l<10;l++) {
                for(int j=0;j<13;j++) {
                    DP[i][(10*j+l)%13] += DP[i-1][j];
                    DP[i][(10*j+l)%13] %= 1000000007;
                }
            }
        }
        else {
            ll num = S[i-1]-'0';
            for(int j=0;j<13;j++) {
                DP[i][(10*j+num)%13] = DP[i-1][j];
            }
        }
    }
    cout << DP[S.size()][5] << endl;
    return 0;
}

Measured memory_bytes: 10624
# coding: utf-8
# Your code here!

X=int(input())
a=X%100
b=X//100
c=a%5
d=a//5
e=c%4
f=c//4
g=e%3
h=e//3
i=g%2
j=g//2
if b>=(d+f+h+j+(X-100*b-5*d-4*f-3*h-2*j)):
    print("1")
else:
    print("0")

Measured memory_bytes: 3064
#include<stdio.h>
main(){
  int x,i,j;
  int a[10];
  for(i=0;i<10;i++){
    scanf("%d",&a[i]);
}
  for(i=0;i<10;i++){
    for(j=i+1;j<10;j++){
      if(a[i]<a[j]){
	x=a[i];
	a[i]=a[j];
	a[j]=x;
      }
    }
  }

  for(i=0;i<=2;i++){
    printf("%d\n",a[i]);
}

  return 0;
}

Measured memory_bytes: 0