akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end

struct Trie{
    int val; vector<Trie*> nxt;
    Trie(){nxt=vector<Trie*>(26,nullptr); val=0;}
    void insert(string &s,int w){
        if(s.empty())chmax(val,w);
        else{
            char c=s.back(); s.pop_back();
            if(nxt[c-'0']==nullptr)nxt[c-'0']=new Trie();
            nxt[c-'0']->insert(s,w);
        }
    }
};

void test(){
    int g[20]; g[0]=0;
    rep(i,1,20){
        set<int> st; int rui=0;
        rrep(j,i-1,-1)st.insert(rui),rui^=g[j];
        rep(j,0,st.size()+1)if(!st.count(j)){
            printf("%d\n",g[i]=j); break;
        }
    }
}

vector<ll> comp;
void search(Trie t,ll l){
    if(!l)return;
    Trie* nxt1=t.nxt[0]; Trie* nxt2=t.nxt[1];
    if(nxt1!=nullptr^nxt2!=nullptr)comp.push_back(l);
    if(nxt1!=nullptr)search(*t.nxt[0],l-1);
    if(nxt2!=nullptr)search(*t.nxt[1],l-1);
}

int main(){ 
    //test(); return 0;
    int n; ll l; scanf("%d%lld",&n,&l);
    vector<string> a(n);
    Trie* t=new Trie();
    rep(i,0,n){
        cin>>a[i]; reverse(ALL(a[i]));
        t->insert(a[i],0);
    }
    ll g=0; search(*t,l);
    rep(i,0,comp.size())g^=(comp[i]&(-comp[i]));
    printf(g?"Alice":"Bob");
    return 0;
}

Measured memory_bytes: 62068
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n)  for(int i = 0;i<n;++i)
#define fri(i,a,b) for(int i= a;i<=b;++i)
#define fro(i,a,b) for(int i= a;i>=b;--i)
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define fi first
#define se second
#define pb(x) push_back(x)
#define  mp(x,y) make_pair(x,y)
#define endl  "\n"
#define  ii  pair<int,int>
#define  LL  long long
#define  maxm(a,b,c)  max(a,max(b,c))
const int INF = 1e9+7;
int main(){
  int n;
  cin>>n;
  int a[n],b[n],c[n];
  fr(i,n)cin>>a[i]>>b[i]>>c[i];
  int dp[n][3];
  dp[0][0] = a[0],dp[0][1] = b[0],dp[0][2] = c[0];
  fri(i,1,n){
  		  dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i];
  		  dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b[i];
  		  dp[i][2] = max(dp[i-1][1],dp[i-1][0])+c[i];
	  }
	  cout<<maxm(dp[n-1][0],dp[n-1][1],dp[n-1][2]);
  }
  

Measured memory_bytes: 2560
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
ll x;

int main(){
	cin>>n>>x;
	ll t,s;
	cin>>t;
	t=abs(t-x);
	for(int i=1;i<n;i++){
		cin>>s;
		s=abs(s-x);
		t=gcd(t,s);
	}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
_,M,s,*A=`dd`.split.map &:to_i
*b=a=[r=0]*(2*M)
s-=1
A.each{|e|
	e-=1
	if e==s || e==(s+1)%M
	elsif e>s
		a[e] += e - s - 1
		b[e] -=1
		b[s+1] +=1
	else
		a[e+M] += e + M - s - 1
		b[e+M] -=1
		b[s+1] +=1
	end
	r += (e - s) % M
	s = e
}
(2*M-2).downto(0){|i|
	a[i] += a[i+1]
	b[i] += b[i+1]
	a[i] += b[i+1]
}
M.times{|i|a[i]+=a[i+M]}
p r - a[0,M].max

Measured memory_bytes: 12044
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int judge=0, k=sc.nextInt(), a=sc.nextInt(), b=sc.nextInt();
    for(int i=a; i<=b; i++){
      if(i%k==0){
        judge=1;
        break;
      }
    }
    if(judge==1) System.out.print("OK");
    else System.out.print("NG");
  }
}

Measured memory_bytes: 35800
data=input()
temp=[chr(97+i) for i in range(26)]
for i in range(len(data)):
    temp[ord(data[i])-97]=0
cnt=26
for i in range(26):
    if temp[i]!=0:
        cnt=i
        break
if cnt<=25:print(temp[cnt])
else:print("None")
        
    

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <utility>

using namespace std;

/*--------------------------------------------*/
/* 0 : insert                                 */
/* 1 : dump                                   */
/* 2 : splice                                 */
/*--------------------------------------------*/

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

  std::vector< std::list<int> > li(n);
  list<int>::iterator c;
  list<int>::iterator d;

  int order, num;
  int t, s;
  int cnt=0;

  for(int i=0; i<q; ++i){
    cin >> order;

    if(order == 0){
      cin >> t >> num;
      li[t].push_back(num);
    }
    else if(order == 1){
      cin >> t;
      for(c = li[t].begin(); c != li[t].end(); c++){
        if(c != li[t].begin() && c != li[t].end()){cout << " ";}
        cout << *c;
      }
      cout << endl;
    }
    else if(order == 2){
      cin >> s >> t;
      li[t].splice(li[t].end(), li[s]);
      /*
      for(d = li[s].begin(); d != li[s].end(); d++){
        li[t].push_back(*d);
      }
      li[s].clear();
      */
    }
  }

  return 0;
}



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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, m = 0, ans = 0;
    cin >> n;
    vector<ll> p(n);
    
    rep(i, n) {
        cin >> p[i];
        m = max(m, p[i]);
        ans += p[i];
    }
    ans -= m;
    ans += m/2;
    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = input[0];
            int W = input[1];
            string[,] a = new string[H, W];
            bool[] Hok = new bool[H];
            bool[] Wok = new bool[W];
            for(var i = 0; i < H; i++)
            {
                Hok[i] = true;
            }
            for(var i = 0; i < W; i++)
            {
                Wok[i] = true;
            }


            for(var i = 0; i < H; i++)
            {
                string ain = Console.ReadLine();
                int cnt = 0;
                for(var j = 0; j < W; j++)
                {
                    a[i, j] = ain[j].ToString();
                    if (a[i, j] == ".") { cnt++; }
                }

                if (cnt == W) { Hok[i] = false; }
            }
            for(var i = 0; i < W; i++)
            {
                int cnt = 0;
                for(var j = 0; j < H; j++)
                {
                    if (a[j, i] == ".") { cnt++; }

                }
                if (cnt == H) { Wok[i] = false; }
            }
            for(var i = 0; i < H; i++)
            {
                for(var j = 0; j < W; j++)
                {
                    if (Hok[i] && Wok[j])
                    {
                        Console.Write(a[i, j]);
                    }

                }
                if (Hok[i]) { Console.WriteLine(); }
            }


            Console.Out.Flush();
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}
    

Measured memory_bytes: 13312
using System;

namespace Atcoder
{
    class Program
    //ABC126 A - Changing a Character
    {
        private static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split(' ');
            var n = int.Parse(nk[0]);
            var k = int.Parse(nk[1]);
            var s = Console.ReadLine();
            var ans = "";

            for (var i = 0; i < n; i++)
            {
                if (i == k-1)
                {
                    ans += s.Substring(i, 1).ToLower();
                    continue;
                }
                ans += s.Substring(i, 1);
            }
            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 13140
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {


	int m = 0;
	int n = 0;
	int i = 0;
	int j = 0;
	int check = 1;
	char origin[150][150];
	
	cin>>m>>n;
	
	for(i=0;i<=m+3;i++)
	{
		for(j=0;j<=n+3;j++)
		{
			origin[i][j] = '1';
		}
	}
	i = 0;
	j = 0;
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
			cin>>origin[i][j];
		}
	}
	
	
	
	for(i=0;i<m;i++)
	{
		check = 0;
		if(origin[i][0] == '.')
		{
			
			for(j=0;j<n;j++)
			{
				if(origin[i][j] == '.')
				{
					check = check + 1;
				}
			}
		}
		if(check==n)
		{
			for(j=0;j<n;j++)
			{
				origin[i][j] = '0';
			}
			check = 0;
		}
	}
	
	
	for(i=0;i<n;i++)
	{
		check = 0;
		if((origin[0][i]=='.')||(origin[0][i]=='0'))
		{
			for(j=0;j<m;j++)
			{
				if((origin[j][i]=='.')||(origin[j][i]=='0'))
				{
					check = check + 1;
				}
			}
		}
		if(check==m)
		{
			for(j=0;j<m;j++)
			{
				origin[j][i] = '0';
			}
			check = 0;
		}	
	}
	
	
	
	for(i=0;i<m;i++)
	{
		check = 0;
		if((origin[i][0]=='.')||(origin[i][0]=='0'))
		{
			for(j=0;j<n;j++)
			{
				if((origin[i][j]=='.')||(origin[i][j]=='0'))
				{
					check = check + 1;
				}
				else if(origin[i][j]=='#')
				{
					break;
				}
			}
		}
		
		if(check==n)
		{
			continue;
			check = 0;
		}
		else
		{
			for(j=0;j<n;j++)
			{
				if(origin[i][j]=='0')
				{
				}
				else
				{
					cout<<origin[i][j];
				}
			}
			if(check==n)
			{
				check = 0;
			}
			else
			{
				cout<<endl;
			}

		}
	}

	

}



Measured memory_bytes: 256
#include<stdio.h>

int N,T,S;
int a[3000],t[3000];
int **data;				//data[i][j]は、i番目(i>=0)の夜店を時刻jから楽しむ前の楽しさの合計(の最大値)を入れる。

int MAX(int *a,int index){
	int max = a[0];
	for(int i = 1;i < index;i++){
		if(max < a[i])
			max = a[i];
	}
	return max;
}
int play(int tenpo){	//何店舗見たのか
	int i;
	if(tenpo >= N){
		return MAX(data[N],T+1);
	}
	for(i = 0;i <= T;i++){
		//遊ばない場合
		if(data[tenpo][i] > data[tenpo+1][i]){
			data[tenpo+1][i] = data[tenpo][i];
		}
		//遊ぶ場合
		if(i+t[tenpo] > T)
			continue;
		if(i < S && i+t[tenpo] > S)
			continue;
		if(data[tenpo][i]+a[tenpo] > data[tenpo+1][i+t[tenpo]]){
			data[tenpo+1][i+t[tenpo]] = data[tenpo][i]+a[tenpo];
		}
	}
	return play(tenpo+1);
}
int main(){
	int i,j,max;
	scanf("%d%d%d",&N,&T,&S);
	data = new int*[N+1];
	for(i = 0;i < N+1;i++){
		data[i] = new int[T+1];
		for(j = 0;j < T+1;j++){
			data[i][j] = 0;
		}
		if(i < N)
			scanf("%d%d",a+i,t+i);
	}
	max = play(0);
	printf("%d\n",max);
	for(i = 0;i < N;i++)
		delete[] data[i];
	delete[] data;
	return 0;
}

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

int main() {
  string s; ll k; cin >>s >>k;
  int onecnt = 0;
  char nextn;
  for (int i=0; i<s.size(); i++){
    if (s.at(i)=='1') onecnt++;
    else{
      nextn = s.at(i); break;
    }
  }
  char ans;
  if (k<=onecnt) ans = '1';
  else ans = nextn;
  
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
#!/usr/bin/ruby -Ku

require 'pp'

n = gets.split(nil)[0].to_i

b = [100, 0]

n.times{
  data = gets.split(nil)
  a, v = data.map{|e|e.to_i}
  if b[1] < v then
    b[0] = a
    b[1] = v
  elsif b[1] == v
    b[0] = [a, b[0]].min
  end
}

puts "#{b[0]} #{b[1]}"

Measured memory_bytes: 6256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
long long m=1e9+7;
int main()
{
	long long n,k,i,j,cnt,ans;
	cin>>n>>k;
	ans=0;
	for (i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	for (i=0;i<n;i++)
	{
		cnt=0;
		for (j=(i+1);j<n;j++)
		{
			if (arr[j]<arr[i])
			{
				//cout<<"yo"<<endl;
				cnt++;
			}
		}
		ans=(ans+((k*(k+1)/2)%m*cnt)%m)%m;
	}
	for (i=n-1;i>=0;i--)
	{
		cnt=0;
		for (j=i-1;j>=0;j--)
		{
			if (arr[j]<arr[i])
			{
				//cout<<"yo"<<endl;
				cnt++;
			}
		}
		ans=(ans+((k*(k-1)/2)%m*cnt)%m)%m;
	}
	cout<<ans%m<<endl;	
}

Measured memory_bytes: 256
#include <cstdio>

#define vowel "vowel"
#define conso "consonant"

using namespace std;

int main() {
    char s[1];
    scanf("%s",s);
    switch(s[0]){
        case 'a':
        case 'i':
        case 'u':
        case 'e':
        case 'o':
            printf(vowel);
            break;
        default:
            printf(conso);
            break;
    }
    printf("\n");
}

Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    for a in range(1,3501):
        for b in range(a,3501):
            if 4*a*b-n*(a+b)>0 and n*a*b%(4*a*b-n*(a+b))==0:
                print(a,b,n*a*b//(4*a*b-n*(a+b)))
                sys.exit()

if __name__=='__main__':
    main()


Measured memory_bytes: 64924
#include<bits/stdc++.h>
using namespace std;
#define INF 2*1e9
int main(){
  
  int n;
  int cost[100][100];
  int mincost[100];
  int used[100]={};
  
  cin>>n;
  for(int i=0;i<n;i++){
    mincost[i]=INF;
    for(int j=0;j<n;j++){
      cin>>cost[i][j];
      if(cost[i][j]==-1)cost[i][j]=INF;
    }
  }

  mincost[0]=0;
  int ans=0;

  while(1){
    int v=-1;
    for(int u=0;u<n;u++){
      if(used[u]==0&&(v==-1||mincost[u]<mincost[v]))v=u;
    }
    
    if(v==-1)break;
    used[v]=1;
    ans+=mincost[v];
    
    for(int u=0;u<n;u++){
      mincost[u]=min(mincost[u],cost[v][u]);
    }
  }
  
  cout<<ans<<endl;
  
  return 0;
  
}

Measured memory_bytes: 3092
h,w,k = map(int,input().split())
c = []
for i in range(h):
    c.append(input())
ans = 0
# 0から1<<Hまで
for i in range(1<<h):
    # 0から1<<Wまで
    for j in range(1<<w):
        count = 0
        for l in range(h):
            # l行目が選んだ行か調べる
            if not (i>>l)&1:
                for m in range(w):
                    # m列目が選んだ列か調べる
                    if not (j>>m)&1:
                        if c[l][m]=='#':
                            count += 1
        # 黒のマスがKと一致したら1足す
        if count==k:
            ans += 1
print(ans)

Measured memory_bytes: 9156
x,y = map(int,input().split())
ans = 0
if x==3:
    ans += 100000
elif x==2:
    ans+=200000
elif x==1:
    ans+=300000

if y == 3:
    ans += 100000
elif y == 2:
    ans += 200000
elif y == 1:
    ans += 300000

if x==1 and y==1:
    ans+=400000
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define INF (1<<29)
int N,M,R;
int d[201][201];
int r[9];
int A,B,C;
int res;
bool used [9];

void dfs(int c,int las,int dist) {
    if(c==R+1) {
        if(res>dist)res=dist; return;
    }
    for(int i=1;i<=R;i++)if(!used[i]) {
        used[i]=true;
        if(las==-1)dfs(c+1,i,0);
        else dfs(c+1,i,dist+d[r[las]][r[i]]);
        used[i]=false;
    }
}
int main () {
    scanf("%d%d%d",&N,&M,&R);
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            if(i!=j)d[i][j]=INF;
            
        }
    }
    for(int i=1;i<=R;i++)scanf("%d",&r[i]);
    
    for(int i=1;i<=M;i++)
    {
        scanf("%d%d%d",&A,&B,&C);
        if(d[A][B]>C)d[A][B]=d[B][A]=C;
    }
    for(int k=1;k<=N;k++){
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                if(d[i][j]>d[i][k]+d[k][j]) d[i][j]=d[i][k]+d[k][j];
            }
        }
    }
    res=INF;
    dfs(1,-1,0);
    printf("%d\n",res);
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
  long long a,b,c,i,r=0,p,ff,ss;
  scanf("%lld%lld",&a,&b);
  if(a==b){
    printf("1\n");
    return 0;
  }
  for(i=61;i>=0;i--){
    if((a&(1ll<<i))!=(b&(1ll<<i))){p=i;break;}
    if((a&(1ll<<i))!=0){
      a^=(1ll<<i);
      b^=(1ll<<i);
    }
  }
  r+=((1ll<<p)-a);
  ff=(1ll<<p);
  for(i=p-1;i>=0;i--){
    if((b&(1ll<<i))!=0){
      ff+=(1ll<<(i+1));
      ff--;break;
    }
  }
  ss=(1ll<<p)+a;
  if(ff<ss){
    r+=(ff-(1ll<<p)+1);
    r+=((1ll<<(p+1))-ss);
  }
  else{
    r+=(1ll<<p);
  }
  printf("%lld\n",r);
  return 0;
}


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

#define SIZE(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n); ++i)
#define print(x) cout<<x<<endl;

typedef long long ll;

int gcd(int a, int b) { return min(a,b) ? gcd(min(a,b), max(a,b)%min(a,b)) : max(a,b); }
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
ll inf = 1LL <<61;
ll mod7 = 1000000007;
ll mod9 = 1000000009;

int main() {
    int n,W;
    cin>>n>>W;
    vector<int> w(n+1);
    vector<int> v(n+1);
    vector<vector<ll>> dp(n+1,vector<ll>(W+1));
    rep(i,n)cin>>w[i+1]>>v[i+1];
    for(int i = 0;i<=n;++i){
        for(int j = 1;j<=W;++j){
            if(i==0){
                dp[i][j] = 0;
            }else{
                if(j<w[i]){
                    dp[i][j]=dp[i-1][j];
                }else{
                    dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
                }
            }
        }
    }
    // rep(i,n+1){
    //     rep(j,W+1){
    //         cout << dp[i][j]<<endl;;
    //     }
    //     cout<<endl;
    // }
    cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 80256
#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
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 300000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}
int 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;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
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;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
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 kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	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;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
map<int, int>mp;
signed main() {
	int n, p;
	cin >> n >> p;
	int memo = p, ans = 1;
	for (int i = 2; i <= sqrt(p); i++) {
			while (memo % i == 0) {
				memo /= i;
				mp[i]++;
			}
	}
	if (memo != 1)mp[memo]++;
	for (auto x : mp)ans *= pow(x.first, x.second / n);
	cout << ans << endl;
	ggr
}


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

int main(void){
  int n,m;
  cin>>n>>m;
  int a[m],b[m];
  for(int i=0;i<m;i++) cin>>a[i]>>b[i];
  int road[60]={};
  for(int i=0;i<m;i++){
    road[a[i]]++;
    road[b[i]]++;
  }
  for(int j=1;j<=n;j++) cout<<road[j]<<endl;
  return 0;
}


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

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	auto isEvenA = A % 2 == 0;
	auto isEvenB = B % 2 == 0;
	auto isEvenC = C % 2 == 0;
	auto count = 0;
	if (isEvenA)
	{
		if (isEvenB)
		{
			if (!isEvenC)
			{
				++A;
				++B;
				++count;
			}
		}
		else if (isEvenC)
		{
			++A;
			++C;
			++count;
		}
		else
		{
			++B;
			++C;
			++count;
		}
	}
	else
	{
		if (isEvenB)
		{
			if (isEvenC)
			{
				++B;
				++C;
				++count;
			}
			else
			{
				++A;
				++C;
				++count;
			}
		}
		else if (isEvenC)
		{
			++A;
			++B;
			++count;
		}
	}

	auto m = max(A, max(B, C));
	if (A < m)
	{
		count += (m - A) / 2;
	}
	if (B < m)
	{
		count += (m - B) / 2;
	}
	if (C < m)
	{
		count += (m - C) / 2;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    IO;
    int n;
    cin >> n;
    vector<double> v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    sort(v.begin(), v.end());
    for(int i = 0; i < n - 1; i++)
    {
        double c1 = v[i];
        double c2 = v[i + 1];
        double extra = (c1 + c2) / 2;
        v[i + 1] = extra;
    }
    cout << v[n - 1];
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)

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

typedef long long ll;

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

    int n;
    cin >> n;

    vector<int> nums(n);
    rep(i, n){
        cin >> nums[i];
    }

    for(int i = nums.size()-1; i >= 0; i-=2){
        cout << nums[i] << " ";
    }
    for(int i = nums.size()%2; i < nums.size(); i+=2){
        cout << nums[i] << " ";
    }

    cout << endl;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


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

int n;
vector<int> g[100000];
int d1[100000],d2[100000];

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

	cin>>n;
	REP(i,n-1) {
		int a,b;cin>>a>>b;a--,b--;
		g[a].pb(b),g[b].pb(a);
		d1[i]=d2[i]=INF;
	}
	d1[n-1]=d2[n-1]=INF;
	d1[0]=0;
	priority_queue<P,vector<P>,greater<P> > pq;
	pq.push(P(0,0));
	while (!pq.empty()) {
		P p=pq.top();pq.pop();
		int v=p.se;
		if(d1[v]<p.fi) continue;
		d1[v]=p.fi;
		for(auto u:g[v]) {
			if(d1[u]>p.fi+1) {
				d1[u]=p.fi+1;
				pq.push(P(d1[u],u));
			}
		}
	}
	d2[n-1]=0;
	pq.push(P(0,n-1));
	while (!pq.empty()) {
		P p=pq.top();pq.pop();
		int v=p.se;
		if(d2[v]<p.fi) continue;
		d2[v]=p.fi;
		for(auto u:g[v]) {
			if(d2[u]>p.fi+1) {
				d2[u]=p.fi+1;
				pq.push(P(d2[u],u));
			}
		}
	}
	int x=0,y=0;
	REP(i,n) {
		if(d1[i]>d2[i]) y++;
		else x++;
	}
	cout<<(x>y?"Fennec":"Snuke")<<endl;

	return 0;
}


Measured memory_bytes: 6912
#include<cstdio>
int p[100001], n[100001];
int main() {
	int i, j;
	p[0] = 0;
	p[1] = 0;
	for (i = 3; i < 100000; i = i + 2) {
		p[i - 1] = 0;
		p[i] = 1;
	}
	for (i = 3; i <= 313; i = i + 2) {
		j = 2;
		while (i*j < 100000) {
			p[i*j] = 0;
			j++;
		}
	}
	for (i = 99991; i >= 5;i-=2) {
		if (p[i] == 1 && p[(i + 1) / 2] == 0) {
			p[i] = 0;
		}
	}
	n[0] = 0;
	for (i = 1; i < 100000; i++) {
		n[i] = n[i - 1] + p[i];
	}
	int q, l, r, ans;
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d%d", &l, &r);
		printf("%d\n", n[r] - n[l-1]);
	}
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
using namespace std ;
int main(){
  int W,H,n;
  for( ; ; ){
    cin >> H >> W; 
    if(H==0 && W==0)break;
    for(int i=0;i<H;i++){
      for(int k=0;k<W;k++){
	n=i+k;
	if(n%2==1){
	  printf(".");
	}else{
	  printf("#");
	} 
      }
    cout<<endl;
    }
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
string s;
int g=0,p;
int main()
{
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;++i)
		if(s[i]=='g')
			g++;
	p=len-g;
	cout<<min(len/2,g)-min(len/2,p)<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

#define DIGITS_MAX	5

int main(void)
{
	int num;
	int numA;
	int numB;
	int digitsTotal;
	int allTotal = 0;
	int ret;
	int i;
	char numS[DIGITS_MAX+1] = {0};

	ret = scanf("%d", &num);
	ret = scanf("%d", &numA);
	ret = scanf("%d", &numB);

	for(i=1; i<=num; i++)
	{
		ret = snprintf(numS, sizeof(numS), "%d", i);
		digitsTotal = 0;
		for(ret-=1; ret>=0; ret--)
		{
			digitsTotal += (numS[ret] - '0');
		}
		if((numA <= digitsTotal) && (digitsTotal <= numB))
		{
			allTotal += i;
		}
	}
	printf("%d\n", allTotal);

	return(0);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;
int main() {
	int x = 0, max = 0,N;
	string s;
	cin >> N >> s;
	
	for (int i = 0; i < N; i++) {
		if (s[i] == 'I') {
			x++;
		}
		else {
			x--;
		}
		if (x > max) {
			max = x;
		}
	}

	cout << max << endl;

	return 0;
}

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

struct zahyou {
    int H;
    int W;
};

int yoko[4] = {-1, 1, 0, 0};
int tate[4] = {0, 0, 1, -1};

int main() {
    // スタート地点を決めて、BFSして一番遠かったところをゴールとする。という処理をH * W回やる。
    int H, W;
    cin >> H >> W;
    vector<string>maze(H);
    for (int i=0; i < H; i++) {
        cin >> maze.at(i);
    }

    int max_len = 0;
    for (int i=0; i < H; i++) {
        for (int j=0; j < W; j++) {
            if (maze[i][j] == '#') {
                continue;
            }

            vector<vector<int>> dist(H, vector<int>(W, -1));
            queue<zahyou> que;
            dist[i][j] = 0;
            que.push(zahyou{i, j});
            while (!que.empty()) {
                zahyou p = que.front();
                que.pop();
                for (int k=0; k < 4; k++) {
                    int newH = p.H + tate[k];
                    int newW = p.W + yoko[k];
                    if (newH < 0 || newH >= H) {
                        continue;
                    }

                    if (newW < 0 || newW >= W) {
                        continue;
                    }

                    if (maze[newH][newW] == '#') {
                        continue;
                    }

                    if (dist[newH][newW] != -1) {
                        continue;
                    }

                    que.push(zahyou{newH, newW});
                    dist[newH][newW] = dist[p.H][p.W] + 1;
                }
            }

            for (int l=0; l < H; l++) {
                for (int m=0; m < W; m++) {
                    if (dist[l][m] > max_len) {
                        max_len = dist[l][m];
                    }
                }
            }
        }
    }

    cout << max_len << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
list($n) = ints();
list($s) = strs();
for ($i = 0; $i < $n; ++$i) $a[] = 1 << (ord($s[$i]) - 97);
$st = new SegmentTree($a);
list($q) = ints();
for ($i = 0; $i < $q; ++$i) {
    list($type, $a, $b) = strs();
    if ($type === '1')
        $st->set((int)$a - 1, 1 << (ord($b) - 97));
    else
        $output[] = popcount($st->get((int)$a - 1, (int)$b));
}
echo implode(PHP_EOL, $output);
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
function popcount($x)
{
    $res = 0;
    while ($x > 0) {
        $x &= $x - 1;
        ++$res;
    }
    return $res;
}
// セグメントツリー
// 更新と取得を O(logN) で行う
class SegmentTree
{
    public $n;
    private $node;
    const UNIT = 0; // 単位元 問題に応じて変更する

    public function __construct(array $a)
    {
        $l = count($a);
        $this->n = 1;
        while ($this->n < $l) $this->n *= 2;
        $this->node = array_fill(0, 2 * $this->n - 1, self::UNIT);
        for ($i = 0; $i < $l; ++$i) $this->node[$i + $this->n - 1] = $a[$i];
        $this->updateAll();
    }

    private function updateAll(): void
    {
        for ($i = $this->n - 2; $i >= 0; --$i)
            $this->node[$i] = $this->op($this->node[2 * $i + 1], $this->node[2 * $i + 2]);
    }

    public function set(int $x, int $v): void
    {
        $x += $this->n - 1;
        $this->node[$x] = $v;
        $this->updateUp($x);
    }

    private function updateUp(int $x): void
    {
        while ($x > 0) {
            $x = intdiv($x - 1, 2);
            $this->node[$x] = $this->op($this->node[2 * $x + 1], $this->node[2 * $x + 2]);
        }
    }

    // 区間 [a, b)
    public function get(int $a, int $b): int
    {
        return $this->getProc($a, $b, 0, 0, $this->n);
    }

    private function getProc(int $a, int $b, int $k, int $l, int $r): int
    {
        // 範囲外
        if ($a >= $r || $b <= $l) return self::UNIT;
        // 完全に含む
        if ($a <= $l && $b >= $r) return $this->node[$k];
        // 一部含む
        $lc = $this->getProc($a, $b, 2 * $k + 1, $l, intdiv($l + $r, 2));
        $rc = $this->getProc($a, $b, 2 * $k + 2, intdiv($l + $r, 2), $r);
        return $this->op($lc, $rc);
    }

    // 二項演算 問題に応じて変更する
    private function op(int $a, int $b): int
    {
        return $a | $b;
    }
}


Measured memory_bytes: 66572
import static java.lang.Integer.parseInt;
import static java.lang.System.out;
import static java.lang.Math.pow;
import java.io.File;
import java.util.Scanner;


public class Main extends BaseExe {

    private final int MAXX = 600;

    public static void main(String[] args) {
        new Main().exeSysIn();
    }

    @Override
    protected void execute() {
        while (judgeInData()) {
            out.println(getAria(parseInt(getInData())));
        }
    }

    private int getAria(int d) {
        int loopCount = getLoopCount(d);
        int sumArea = 0;
        for (int count = 1; count < loopCount; count++) {
            sumArea += getVertical(d * count) * d;
        }
        return sumArea;
    }

    private int getVertical(int d) {
        return (int) pow(d, 2);
    }

    private int getLoopCount(int d) {
        return MAXX / d;
    }
}


abstract class BaseExe {

    private Scanner scan;

    private String inData;

    public void exeSysIn() {
        try (Scanner scan = new Scanner(System.in)) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void exeFileIn(String inDataPath) {
        try (Scanner scan = new Scanner(new File(inDataPath))) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void exeCtrl(Scanner scan) {
        this.scan = scan;
        execute();
    }

    protected abstract void execute();

    protected String nextLine() {
        return scan.nextLine();
    }

    protected boolean judgeInData() {
        return hasNextLine() && isNotEmptyInData();
    }

    protected boolean hasNextLine() {
        return scan.hasNextLine();
    }

    protected boolean isNotEmptyInData() {
        return !"".equals(inData = nextLine());
    }

    protected String getInData() {
        return inData;
    }

}

Measured memory_bytes: 25884
#include <stdio.h>

int min(int m[],int N){
  int i,min = m[0];
  for(i = 1; i < N; i++){
    if(m[i] < min) min = m[i];
  }
  return min;
}

  int main(){
  
  int N,X,ans;
  scanf("%d%d",&N,&X);
  
  int i,m[N];
  for(i = 0; i < N; i++){
    scanf("%d",&m[i]);
  }
  
  int sum = 0; //お菓子m1～mNまでに必要なお菓子の素の重さ
  for(i = 0; i < N; i++){
    sum += m[i];
  }
  
  int min_donut = min(m,N),rest = X - sum,rest_maxnum = rest / min_donut;
  ans = N + rest_maxnum;
    
  printf("%d",ans);
    
  return 0;
 }

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
//const int mod = 1000000007;
const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  ll x;
  cin >> n >> x;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  for(int i = 1; i < n; ++i) {
    ll del = max(0ll, a[i-1]+a[i]-x);
    ans += del;
    a[i] -= min(del, a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int S;
  cin>>S;
  
  int L=S/100;
  int R=S%100;
  
  string ans;
  
  
  if(1<=L&&L<=12){
    if(1<=R&&R<=12){
      ans="AMBIGUOUS";
    }
    else{
      ans="MMYY";
    }
  }
  else{
    if(1<=R&&R<=12){
      ans="YYMM";
    }
    else{
      ans="NA";
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3544
a, b, k = map(int, input().split())
l = []

for i in range(a, min(a + k, b + 1)):
    l.append(i)

for i in range(max(b - k + 1, a), b + 1):
    l.append(i)
l = list(set(l))
l.sort()
for i in l:
    print(i)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
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 (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

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


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 1000000000000000007
#define MOD 1000000007
#define int long// long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};
typedef long long ll;

int ans,ans2;

signed main(){

    double w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<w*h/2<<" ";
    if(x==w/2 && y==h/2)cout<<1<<endl;
    else cout<<0<<endl;
    
}


Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void print(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}

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

    

    
}  
/*
0011
1210

0011001011
1210121210

11011010001011
12123232101012
*/


Measured memory_bytes: 256
A, B,C,D = map(int, input())

MINUS = '-'
PLUS = '+'

def cal(a,b, what):
    if what == MINUS:
        return a - b
    else:
        return a+b


def print_ans(v):
    print('{}{}{}{}{}{}{}=7'.format(A,v[0],B,v[1],C,v[2],D))
    
    
li = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            op1 = PLUS if i %2==0 else MINUS
            op2 = PLUS if j %2==0 else MINUS
            op3 = PLUS if k %2==0 else MINUS
            li.append([op1, op2, op3])

for v in li:
    t = cal(A, B, v[0])
    t = cal(t, C, v[1])
    t = cal(t, D, v[2])
    if t == 7:
        print_ans(v)
        break


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int i, j;
    int a[9] = { 0 };
    int c[9] = { 0 };
    int n;
    int ans;
    int b;

    for (i = 0; i < 9; i++) {
        cin >> a[i];
    }
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> b;
        for (j = 0; j < 9; j++) {
            if (b == a[j]) {
                c[j] = 1;
                continue;
            }
        }
    }

    if ((c[0] && c[1] && c[2]) || (c[3] && c[4] && c[5]) || (c[6] && c[7] && c[8]) ||
        (c[0] && c[3] && c[6]) || (c[1] && c[4] && c[7]) || (c[2] && c[5] && c[8]) ||
        (c[0] && c[4] && c[8]) || (c[2] && c[4] && c[6])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//AOJ-DSL-2-A
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

/*
    SegmentTree<int> seg(f, def) のように宣言する
    RMQ の場合 : 
    auto f = [](int a, int b){return min(a, b);};
    int def = INF;
*/
template <typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;
    int n;
    vector<Monoid> dat;
    F f;
    Monoid def;

    SegmentTree(F f, Monoid def) : f(f), def(def) {}

    void build(const vector<Monoid> & vec){
        int sz = vec.size();
        n = 1;
        while(n < sz) n *= 2;
        dat.assign(2 * n - 1, def);
        for(int i = 0; i < sz; i++) dat[n - 1 + i] = vec[i];
        for(int i = n - 2; i >= 0; i--) dat[i] = f(dat[2 * i + 1], dat[2 * i + 2]);
    }

    void update(int k, Monoid x){
        k += (n - 1);
        dat[k] = x;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    Monoid query(int a, int b){
        return query(a, b, 0, 0, n);
    }

private:
    Monoid query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return dat[k];
        Monoid vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        Monoid vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
};

signed main(){
    int n,q;
    cin >> n >> q;
    auto f = [](int a, int b){return min(a, b);};
    SegmentTree<int> seg(f, INT_MAX);
    seg.build(vector<int>(n, INT_MAX));
    int c,x,y;
    REP(i,q){
        cin >> c >> x >> y;
        if(c == 0){
            seg.update(x, y);
        }else{
            cout << seg.query(x, y + 1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4180
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define mod 1000000007
#define ll long long int
using namespace std;


ll fermat(ll base, ll exp)
{
	ll result = 1;
	while(exp > 0)
	{
		if(exp % 2 == 1)
			result = ((result % mod) * (base % mod)) % mod; 
		base = ((base % mod) * (base % mod)) % mod; 
		exp /= 2;
	}

	return result;
}

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

    ll fact[200001];
    fact[0] = 1;

    for(i = 1; i < 200001; i ++)
    	fact[i] = ((i % mod) * (fact[i - 1] % mod)) % mod;

    ll totalAns = 1;
    for(i = 0; i < min(n - 1, k); i ++)
    {
    	ll num1 = fact[n]; 
    	ll den1 = ((fact[i + 1] % mod) * (fact[n - i - 1] % mod)) % mod;
    	ll denInv1 = fermat(den1, mod - 2) % mod;

    	ll num2 = fact[n - 1];
    	ll den2 = ((fact[i + 1] % mod) * (fact[n - i - 2] % mod)) % mod;
    	ll denInv2 = fermat(den2, mod - 2) % mod;

    	ll ans1 = (num1 * denInv1) % mod;
    	ll ans2 = (num2 * denInv2) % mod;
    	// cout << ans1 << " " << ans2 << endl;
    	totalAns = ((totalAns % mod) + ((ans1 % mod) * (ans2 % mod)) % mod) % mod;
    }
    cout << totalAns << endl;
}

Measured memory_bytes: 1792