akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a>=b && a>=c)
	{
		printf("%d",10*a+b+c);
	}
	
	else if(b>=a&& b>=c)
	{
		printf("%d",10*b+a+c);
	}

	else if(c>=b && c>=a)
	{
		printf("%d",10*c+b+a);
	}
	
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<vector<bool>> found(4, vector<bool> (13));
    vector<char> d = {'S', 'H', 'C', 'D'};
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        char c;
        cin >> c;
        int num;
        cin >> num;
        for (int j = 0; j < 4; ++j) {
            if (c == d[j]) {
                found[j][--num] = true;
                break;
            }
        }
    }
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 13; ++j) {
            if (!found[i][j]) {
                cout << d[i] << " " << j + 1 << '\n';
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3208
program kenken
 implicit none
 integer n, a, b, c, d
 integer i, p, q, r, sum
 character(200001) s
 read*, n, a, b, c, d
 read*, s
 p=0
 q=0
 r=0
 sum=0
 
 if (c < d) then
 
 do i=b+1, d-1
  p=index(s(i:i),"#")
  q=index(s(i+1:i+1),"#")
   if ((p+q).eq.2) then
   print*, "No"
   return
   end if
 end do
  s(d:d)="#"
  do i=a+1, c-1
  p=index(s(i:i),"#")
  q=index(s(i+1:i+1),"#")
   if ((p+q).eq.2) then
   print*, "No"
   return
   end if
  end do
  print*, "Yes"
  return
 end if
 
 if (c > d) then
  
  do i=b-1,d-2
  p=index(s(i:i),".")
  q=index(s(i+1:i+1),".")
  r=index(s(i+2:i+2),".")
   if((p+q+r).eq.3) then
   sum = i+1
   exit
   end if
  end do
  
  if(sum.ne.0) then
   s(sum:sum)="#"
    do i=a, c-1
    p=index(s(i:i),"#")
    q=index(s(i+1:i+1),"#")
     if ((p+q).eq.2) then
     print*, "NO"
     return
     end if
    end do
    s(c:c)="#"
  do i=sum+1, d-1
  p=index(s(i:i),"#")
  q=index(s(i+1:i+1),"#")
   if ((p+q).eq.2) then
   print*, "NO"
   return
   end if
  end do
  print*, "Yes"
  return
 end if
 
 if (sum.eq.0) then
 do i=b+1, d-1
  p=index(s(i:i),"#")
  q=index(s(i+1:i+1),"#")
   if ((p+q).eq.2) then
   print*, "No"
   return
   end if
  end do
  s(d:d)="#"
  do i=a+1, c-1
  p=index(s(i:i),"#")
  q=index(s(i+1:i+1),"#")
   if ((p+q).eq.2) then
   print*, "No"
   return
   end if
  end do
  print*, "Yes"
  return
 end if
 end if
end program

Measured memory_bytes: 1084
import sys
sys.setrecursionlimit(10**8)
class FK:
    def __init__(self,n):
        self.table=[[0]*n for i in range(n)]
        self.n=n
    
    def add(self,x,y,f):
        self.table[x][y]=f
        
    def ford(self,s,t,f):
        self.visit[s]=True
        if s==t:
            return f
        for i in range(self.n):
            if (not self.visit[i]) and self.table[s][i]>0:
                df=self.ford(i,t,min(f,self.table[s][i]))
                if df>0:
                    self.table[s][i]-=df
                    self.table[i][s]+=df
                    return df
        return 0
    
    def flow(self,s,t):
        ans=0
        inf=10**20
        while True:
            self.visit=[False]*(self.n)
            df=self.ford(s,t,inf)
            if df==0:
                break
            ans+=df
        return ans

H,W=map(int,input().split())
C=[input() for i in range(H)]
maxflow=FK(W+H+2)
inf=10**20
for i in range(W):
    for j in range(H):
        if C[j][i]=='S':
            sx=i
            sy=j
            maxflow.add(0,i+1,inf)
            maxflow.add(0,W+1+j,inf)
            continue
        if C[j][i]=='T':
            gx=i
            gy=j
            maxflow.add(i+1,W+H+1,inf)
            maxflow.add(W+1+j,W+H+1,inf)
            continue
        if C[j][i]=='o':
            maxflow.add(i+1,W+1+j,1)
            maxflow.add(W+1+j,i+1,1)
#print(maxflow.table)
if gx==sx or gy==sy:
    print('-1')
    sys.exit()
ans=maxflow.flow(0,H+W+1)
print(ans)

Measured memory_bytes: 3572
module Main where
    import Data.List
    import Control.Monad
    
    main = do
        n <- getLine
        lines<-getLines (read n ::Int)
        let clocks = map read' lines
        let answer = foldr getLCM 1 clocks
        putStrLn $ show answer

    read' s = read s ::Integer

    getLines n = do
        lines <- (replicateM n getLine)
        return lines

    getGCD::Integer->Integer->Integer
    getGCD m n 
        | m < n = (getGCD n m)
        | n == 0 = m
        | otherwise = getGCD (mod m n) n

    getLCM::Integer->Integer->Integer
    getLCM m n = div (m * n) (getGCD m n)


Measured memory_bytes: 1020
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
 
#include <iostream>
 
static void print_ints(const int as[], const unsigned int n) {
  const char* sep = "";
  for (unsigned int i = 0; i < n; ++i) {
    std::cout << sep << as[i];
    sep = " ";
  }
  std::cout << std::endl;
}

static unsigned int swap_count = 0;

static void print_swap_count(void) {
  std::cout << swap_count << std::endl;
}

static void swap(int* a, int* b) {
  ++swap_count;
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void selection_sort(int as[], const unsigned int n) {
  for (unsigned int i = 0; i < n-1; ++i) {
    unsigned int min_j = i;
    for (unsigned int j = i+1; j < n; ++j) {
      if (as[min_j] > as[j]) {
        min_j = j;
      }
    }
    if (i != min_j) {
      swap(&as[i], &as[min_j]);
    }
  }
}
 
int main(void) {
  unsigned int n;
  std::cin >> n;
  int as[n];
  for (unsigned int i = 0; i < n; ++i) {
    std::cin >> as[i];
  }

  selection_sort(as, n);
  print_ints(as, n);
  print_swap_count();

  return 0;
}
// end

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

using namespace std;

int lcs(string a, string b)
{
	vector<vector<int> > dp(1001, vector<int>(1001));
	for (int i = 0; i < a.size(); ++i)
	{
		for (int j = 0; j < b.size(); ++j)
		{
			if (a[i] == b[j])
			{
				dp[i + 1][j + 1] = dp[i][j] + 1;
			}
			else
			{
				dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}
	return(dp[a.size()][b.size()]);
}

void solve()
{
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		string a, b;
		cin >> a >> b;
		cout << lcs(a, b) << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 5048
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N; cin >> N;
	set<ll> se;
	rep(i, 0, N) {
		ll a; cin >> a;
		se.insert(a);
	}
	cout << se.size() << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

def cmb2(n):
    return n * (n-1) // 2

nums = {}
for a in A:
    if a in nums:
        nums[a] += 1
    else:
        nums[a] = 1

sum = 0
for key in nums:
    num = nums[key]
    sum += cmb2(num)

for k in range(N):
    ans = sum - cmb2( nums[A[k]] ) + cmb2( nums[A[k]]-1 )
    print(ans)


Measured memory_bytes: 26140
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author shangu
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastReader in = new FastReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ATableTennisTraining solver = new ATableTennisTraining();
    solver.solve(1, in, out);
    out.close();
  }

  static class ATableTennisTraining {
    public void solve(int testNumber, FastReader in, PrintWriter out) {
      long n = in.nextLong(), a = in.nextLong(), b = in.nextLong();
      if ((b - a) % 2 == 1) {
        if (a > b) {
          long x = a;
          a = b;
          b = x;
        }
        long ans = (b - a - 1) / 2 + a, tmp = (b - a - 1) / 2 + n - b + 1;
        out.println(Math.min(ans, tmp));
      } else out.println(Math.abs(a - b) >> 1);
    }

  }

  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream), 32768);
      st = null;
    }

    public String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

  }
}



Measured memory_bytes: 22612
#include <stdio.h>

#define MAX 25

struct Node{
  int parent;
  int right;
  int left;
  int degree;
};

int n;
struct Node u[MAX];

int sibling(int);
int depth(int);
int height(int);

int main(){
  int i,id,r,l;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    u[i].parent=-1;
    u[i].right=-1;
    u[i].left=-1;
    u[i].degree=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    u[id].left=l;
    u[u[id].left].right=r;
    if(u[id].left!=-1){
      u[u[id].left].parent=id;
      u[id].degree++;
    }
    if(u[u[id].left].right!=-1){
      u[u[u[id].left].right].parent=id;
      u[id].degree++;
    }
  }

  for(i=0;i<n;i++){
    if(u[i].parent==-1)
      printf("node %d: parent = -1, sibling = -1, degree = %d, depth = 0, height = %d, root\n",i,u[i].degree,height(i));

    else if(u[i].degree==0)
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",i,u[i].parent,sibling(i),u[i].degree,depth(i),height(i));

    else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n",i,u[i].parent,sibling(i),u[i].degree,depth(i),height(i));
  }

  return 0;
}

int sibling(int x){
  if(u[x].right!=-1) return u[x].right;
  else if(u[u[x].parent].left!=x) return u[u[x].parent].left;
  else return -1;
}

int depth(int x){
  int d=0,p;
  p=u[x].parent;

  while(p!=-1){
    p=u[p].parent;
    d++;
  }

  return d;
}

int height(int i) {
  int j, x, y;
 
  x = 0;
 
  for(j = 0; j < n; j++) {
    if(u[j].parent == i) {
      y = height(j) + 1;
      if(y > x) x = y;
    }
  }
 
  return x;
}

Measured memory_bytes: 604
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

k = int(input())

ans = 1
mod = 7
flag = False
for i in range(k):
    if (mod % k == 0):
        flag = True
        break
    ans+=1
    mod = (mod * 10 + 7) % k
if flag:
    print(ans)
else:
    print(-1)




Measured memory_bytes: 9092
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    a=parseMap(split(readline()))
    num=Tuple{Int,Int}[(a[i],i) for i in 1:n]
    sort!(num,by=x->x[1])
    println(join([num[i][2] for i in 1:n]," "))
end
main()

Measured memory_bytes: 139404
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define en '\n'

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a, sum = 0;
    cin >> a;
    for(int i = 1; i <= a; ++i){
        for(int j = 1; j <= a; ++j){
            for(int k = 1; k <= a; ++k){
                sum += gcd(i, gcd(j, k));
            }
        }
    }
    cout << sum;
}

Measured memory_bytes: 3652
#include <iostream>
#include <map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int n, p, all;
  vector<int> r;
  while (cin >> n >> p && n && p) {
    bool flag = false;
    all = p;
    map<int, int> m;
    rep(i, n) m[i] = 0;
    while (!flag) {
      // cout << n << ' ' << p << endl;
      rep(i, m.size()) {
        if (p > 0) {
          p--;
          m[i]++;
        } else {
          p += m[i];
          m[i] = 0;
        }
      }
      rep(i, m.size()) {
        if (m[i] == all) {
          r.push_back(i);
          flag = true;
        }
      }
    }
  }
  rep(i, r.size()) { cout << r[i] << endl; }
  return 0;
}



Measured memory_bytes: 3024
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <cctype>
//小文字を大文字 c-0x20;


#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define vvll(z,a,b) vector<vector<ll>>z(a,vector<ll>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
using namespace std;


int main(){
  string w;
  cin>>w;
int flag=0;
while(1){
  string t;
cin>>t;
if(t=="END_OF_TEXT")break;
size_t sin=t.length();
rep(i,sin){
if(t[i]>='A'&&t[i]<='Z')t[i]+=0x20;
}
if(t==w)flag++;

}
cout<<flag<<endl;
}


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

int main() {
  int n;
  cin >> n;
  string s[n];
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  vector<vector<int>> alp(26, vector<int>(n));


  for (i = 0; i < n; i++) {
    for (j = 0; j < s[i].length(); j++) {
      alp[s[i].at(j) - 'a'][i]++;
    }
  }

  for (i = 0; i < 26; i++) {
    sort(alp[i].begin(), alp[i].end());
  }

  for (i = 0; i < 26; i++) {
    for (j = 0; j < alp[i][0]; j++) {
      cout << (char)(i + 'a');
    }
  }

  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int N, K; cin >> N >> K;
    vector<int> A(N);
    for(int &a:A) cin >> a;
    
    vector<ll> Asum(N+1);
    vector<ll> Psum(N+1);
    
    for(int i=0; i<N; i++){
        Asum[i+1] = Asum[i] + A[i];
        Psum[i+1] = Psum[i] + max(0, A[i]);
    }
    
    ll ret =  0;
    for(int i=0; i<N-K+1; i++){
        ll b = Asum[i+K]-Asum[i] + Psum[i]-Psum[0] + Psum[N]-Psum[i+K];
        ll w = Psum[i]-Psum[0] + Psum[N]-Psum[i+K];
        ret = max(ret, max(b, w));
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair <int,int> P;
string mp[501];
int m,n,used[30],ans;
vector <P>  a[30];

int saiki(int);

bool check(int c,int s,int t,int f){
  int res=1;
  for(int i=s+1;i<t;i++){
    if(!f&&mp[i][c]!='.'&&!saiki(mp[i][c]-'A'))res=0;
    if(f&&mp[c][i]!='.'&&!saiki(mp[c][i]-'A'))res=0;
  }
  return res;
}

int saiki(int ch){
  int x1=a[ch][0].x,x2=a[ch][1].x;
  int y1=a[ch][0].y,y2=a[ch][1].y;
  int res=0;
  if(used[ch])return 0;
  used[ch]=1;
  
  if(x1==x2&&y2-y1!=1) res=check(x1,y1,y2,0);
  if(y1==y2&&x2-x1!=1) res=check(y1,x1,x2,1);
  
  if(x1!=x2&&y1!=y2) {
    if(x1<x2){
      res=check(y1,x1,x2+1,1)&check(x2,y1,y2,0);
      res|=check(x1,y1,y2+1,0)&check(y2,x1,x2,1);
    }
    else{
      swap(x1,x2);
      res=check(y1,x1-1,x2,1)&check(x1,y1,y2,0);
      res|= check(x2,y1,y2,0)&check(y2,x1,x2+1,1);
      swap(x1,x2);
    }
  }
  
  if(res) {
    mp[y1][x1]=mp[y2][x2]='.';
    a[ch].clear();
    ans+=2;
  }
  return res;
}

int main(){
  
  cin>>m>>n;
  for(int i=0;i<m;i++)cin>>mp[i];
  
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      if(mp[i][j]!='.')a[mp[i][j]-'A'].push_back(P(j,i));
  
 
  int f=1;
  while(f--) 
    for(int i=0;i<30;i++){
      memset(used,0,sizeof(used));
      if(a[i].size()) f|=saiki(i);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1480
a,b,c,d = 0,0,0,0
for N in range(int(input())):
    s = input()
    if s == 'AC':
        a+=1
    if s == 'WA':
        b+=1
    if s == 'TLE':
        c+=1
    if s == 'RE':
        d+=1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)

Measured memory_bytes: 9176
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String sl[] = s.split(" ");
            String s1 = sl[0];
            String s2 = sl[1];
            String s3 = sl[2];

            String ans = String.format("%c", s1.charAt(0) - 32);
            ans += String.format("%c", s2.charAt(0) - 32);
            ans += String.format("%c", s3.charAt(0) - 32);
            System.out.println(ans);
        }
    }
}


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

int main()
{
	string s;
	cin >> s;
	int n=s.size()-1;
	
	if (s[n]=='s')
	{
		s+="es";
	}
	else 
	{
		s+="s";
	}
	
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int N;

deque<int> pos[300];

string S;

class BITree {
 public:
 	void build() {
 		SET(bit, 0);
	}

	void update(int idx, int val) {
		while (idx < TREE_SIZE) {
			bit[idx] += val;
			idx += idx & -idx;
		}
	}

	int query(int idx) {
		int ret = 0;
		while (idx) {
			ret += bit[idx];
			idx -= idx & -idx;
		}
		return ret;
	}

 private:
 	static const int TREE_SIZE = 3 * 100000;
 	int bit[TREE_SIZE];
};

BITree moved;

bool done[3 * 100000];

int main() {
	FOR (i, 256)
		pos[i].clear();
	cin >> S;
	N = S.sz;
	FOR (i, N)
		pos[S[i]].push_back(i);
	int cnt = 0;
	FOR (i, 256)
		cnt += (pos[i].sz % 2);
	if (cnt > 1) {
		cout << -1 << endl;
		return 0;
	}
	
	SET(done, 0);
	moved.build();
	int cntDone = 0;
	LL ret = 0LL;
	bool add = false;
	
	FOR (i, N) {
		if (done[i])
			continue;
		char ch = S[i];
		if (pos[ch].sz == 1) {
			add = true;
			continue;
		}
		
		pos[ch].pop_front();
		int p = pos[ch].back();
		pos[ch].pop_back();
		done[p] = true;
		if (add)
			ret++;
		ret += moved.query(p + 1);
		int goalPos = N - cntDone - 1;
		ret += goalPos - p;
		
		moved.update(p + 1, 1);

		cntDone++;
		
		if (cntDone == N / 2)
			break;
	}
	
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

const int MAXN=1e6+1;

int t;

void solve(){
    string s;
    cin>>s;
    char c=s[s.length()-1];
    if(c=='2' || c=='4' || c=='5' || c=='7' || c=='9'){
        cout<<"hon"<<endl;
        return;
    }
    if(c=='0' || c=='1' || c=='6' || c=='8'){
        cout<<"pon"<<endl;
        return;
    }
    cout<<"bon"<<endl;
    return;
}

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

    if(S.length() % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    REP(i, S.length()){
        if(i % 2 == 0){
            if(S[i] != 'h'){
                cout << "No" << endl;
                return 0;
            }
        }
        if(i % 2 == 1){
            if(S[i] != 'i'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
const double = Float64
const int = Int64
const vint = Vector{int}
const vdouble = Vector{double}

int(x) = parse(int,x)
parseint(x) = parse(int, x)

function readint()
  moji = readline(stdin)
  moji = split(moji)
  return map(parseint,moji)

end

function main()
  x = readint()[1]
  
  year = 0
  m = 100
  while  m < x
    year +=1
    m += div(m,100)
  end
  println(year)
end

main()

Measured memory_bytes: 222752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main(){
  string s;
  cin >> s;
  int ans = 0;
  string r=regex_replace(s,regex("BC"), "X");
  //cout << r << endl;
  int acount = 0;
  rep(i,r.size()){
    if(r[i] == 'A'){
      acount++;
    }
    else if(r[i] == 'X'){
      ans += acount;
    }
    else{
      acount = 0;
    }
    //cout << acount << " " << ans << endl;
  }
  cout << ans << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;
int C[111111];
int A[111111],B[111111];

vint G[111111];
vint rG[111111];
bool used[111111];
int cmp[111111];
vint vs;

void dfs(int v){
    used[v]=1;
    for(int i=0;i<G[v].size();i++){
        if(!used[G[v][i]])dfs(G[v][i]);
    }
    vs.pb(v);
}

void rdfs(int v,int k){
    used[v]=true;
    cmp[v]=k;
    for(int i=0;i<rG[v].size();i++){
        if(!used[rG[v][i]])rdfs(rG[v][i],k);
    }
}


vector<vint>lis;
vector<vint>H;
bool isbi[111111];
int col[111111];

bool paint(int v,int c){
    used[v]=1;
    col[v]=c;
    for(auto u:H[v]){
        if(used[u]){
            if(col[u]==c)return false;
            continue;
        }
        if(!paint(u,c^1))return false;
    }
    return true;
}

int dp[111111][2];

signed main(){
    scanf("%lld%lld",&N,&M);
    rep(i,N)scanf("%lld",&C[i]);
    rep(i,M){
        scanf("%lld%lld",&A[i],&B[i]);
        G[A[i]].pb(B[i]);
        rG[B[i]].pb(A[i]);
    }

    rep(i,N)if(!used[i])dfs(i);
    memset(used,0,sizeof(used));
    int K=0;
    for(int i=vs.size()-1;i>=0;i--){
        if(!used[vs[i]])rdfs(vs[i],K++);
    }
    lis.resize(K);
    rep(i,N)lis[cmp[i]].pb(i);

    H.resize(N);
    rep(i,M)if(cmp[A[i]]==cmp[B[i]])H[A[i]].pb(B[i]);
    memset(used,0,sizeof(used));
    rep(i,K){
        int v=lis[i][0];
        isbi[i]=paint(v,0);
    }

    rep(i,N)G[i].clear();
    rep(i,M){
        int x=cmp[A[i]];
        int y=cmp[B[i]];
        if(x!=y)G[x].pb(y);
    }
    vs.clear();
    memset(used,0,sizeof(used));
    dfs(cmp[0]);
    reverse(all(vs));

    vector<vint>GG(N);
    rep(i,M)GG[A[i]].pb(B[i]);

    fill_n(*dp,111111*2,INT_MIN);
    dp[vs[0]][0]=0;
    for(auto v:vs){
        int sum[2]={};
        for(auto u:lis[v])sum[col[u]]+=C[u];

        if(!isbi[v]){
            dp[v][0]=max(dp[v][0],dp[v][1]);
            dp[v][1]=dp[v][0];
            dp[v][0]+=sum[0]+sum[1];
            dp[v][1]+=sum[0]+sum[1];
        }
        else{
            dp[v][0]+=sum[col[lis[v][0]]];
            dp[v][1]+=sum[col[lis[v][0]]^1];
        }

        rep(i,2){
            for(auto w:lis[v]){
                for(auto u:GG[w]){
                    if(cmp[u]==v)continue;
                    int p=i^(col[lis[v][0]]!=col[w])^1;
                    p^=col[lis[cmp[u]][0]]!=col[u];
                    chmax(dp[cmp[u]][p],dp[v][i]);
                }
            }
        }

    }

    int ans=0;
    rep(i,K)rep(j,2)chmax(ans,dp[i][j]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 37304
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b, t;
	cin >> a >> b >> t;
	cout << (int)((t + 0.5) / a) * b << endl;
}


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

int main(){
    int  n,m;
    cin >> n >> m;
    int sc[m][2];
    for(int i=0;i<m;i++){
        cin >> sc[i][0];
        cin >> sc[i][1];
    }
    bool flag = true;
    int list[3]={10,10,10};
    for(int i=0;i<m;i++){
        if(sc[i][0]==1&&sc[i][1]==0&&n!=1) flag = false;//1桁目が0
        else{
            if(sc[i][1] == list[sc[i][0]-1]||list[sc[i][0]-1]==10){
                list[sc[i][0]-1] = sc[i][1];
            }
            else flag = false;
        }
    }

    if(!flag) cout << -1 << endl;
    else if(n==1&&list[0]==10) cout << 0 << endl;
    else{
        for(int i=0;i<n;i++){
            if(list[i]==10&&i==0) cout << 1;
            else if(list[i]==10) cout << 0;
            else cout << list[i];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 


int main(void){
    int n,m;
    cin>>n>>m;
    vector<int>a(n);
    int sum = 0;
    int ans = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]*4*m>=sum)ans++;
    }
    if(ans>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



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

using namespace std;

int main()
{
	long long N;
	cin >> N;

	vector<long long> d;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			d.push_back(i);
			if (N / i != i) {
				d.push_back(N / i);
			}
		}
	}

	long long ans = 0;

	for (auto x : d) {
		if (x > 1) {
			long long m = x - 1;
			if (N / m == N % m) {
				ans += m;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 384
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let n: usize = lines.next().unwrap().unwrap().parse().unwrap();
  let mut vs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  vs.sort();
  let mut ans: f64 = vs[0] as f64;
  for i in 1..n {
    ans = (ans + vs[i] as f64) / 2.0;
  }
  println!("{}", ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;

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

    int n,k; cin >> n >> k;
    vector<ll> x(n); cinf(n,x);//x0,x1,...,x[n-1]
    vector<ll> d(n-k+1);
    
    sort(x.begin(),x.end()); 
    ll ans=10e9;
    for(int i=0;i<=n-k;i++){
    d[i]=x[i+k-1]-x[i];//d0,d1,...,dn-k
    ans=min(ans,d[i]);
    }
    cout << ans << endl;
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 2e5 + 5;
const long long MOD = 1e9 + 7;


int N, M, cnt, res;
vector<int> adj[SIZE];
unordered_map<int, bool> was[SIZE];
bool used[SIZE];

void dfs (int v) {
	++cnt;
	res = max(res, cnt);

	used[v] = true;

	for (int to : adj[v]) {
		if (used[to]) 
			continue;
		dfs (to);
	}
}


int main() { speedhack()

	cin >> N >> M;

	forn (i, M) {
		int u, v;
		cin >> u >> v;
		if (u > v)
			swap (u, v);

		if (was[u][v])
			continue;
		
		was[u][v] = true;

		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	
	forn (i, N) {
		if (!used[i]) {
			cnt = 0;
			dfs (i);
		}
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 44420
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int kMod = 1e9+7;

int main()
{
  string limit;
  cin >> limit;
  vector<vector<long long>> dp(limit.size()+1, vector<long long>(2));
  dp.at(0).at(0) = 1;
  dp.at(0).at(1) = 0;
  for (int i = 0; i < (int)limit.size(); i++) {
    if (limit.at(i) == '1') {
      dp.at(i+1).at(1) = (dp.at(i).at(1) * 3 + dp.at(i).at(0)) % kMod;
      dp.at(i+1).at(0) = (dp.at(i).at(0) * 2) % kMod;
    } else {
      dp.at(i+1).at(1) = (dp.at(i).at(1) * 3) % kMod;
      dp.at(i+1).at(0) = dp.at(i).at(0);
    }
  }
  cout << (dp.back().at(0) + dp.back().at(1)) % kMod << '\n';
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
int main()
{
    lg d,s,t;
    cin>>d>>s>>t;
    if(s*t>=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3652
N,K=map(int,input().split())
A=list(map(int,input().split()))
d=[0 for _ in range(40)]
att=[[0,i] for i in range(40)]
x=0
s=sum(A)
num=0
for i in range(N):
    x=A[i]
    for j in range(40):
        if (x>>j)&1:
            d[j]=d[j]+1
#print(d)
for i in range(40):
    att[i][0]=(N-2*d[i])*pow(2,i)
att.sort(key=lambda x:x[0],reverse=True)
#print(att,s)
for i in range(40):
    if (att[i][0]>0)and(num+pow(2,att[i][1])<=K):
        s=s+att[i][0]
        num=num+pow(2,att[i][1])
print(s)


Measured memory_bytes: 69264
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};



int main(){
    ll H,W,D;
    cin>>H>>W>>D;
    vector<int> x(H*W),y(H*W);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int a;
            cin>>a; a--;
            y[a]=i; x[a]=j;
        }
    }

    vector<ll> dist(H*W,0);

    for(int i=0;i<D;i++){
        int j=i;
        while(j+D<H*W){
            dist[j+D]=dist[j]+abs(y[j+D]-y[j])+abs(x[j+D]-x[j]);
            j+=D;
        }
    }

    int Q;
    cin>>Q;
    vector<ll> l(Q),r(Q);
    for (int i = 0; i < Q; ++i) {
        cin>>l[i]>>r[i];
        l[i]--; r[i]--;
    }

    for (int i = 0; i < Q; ++i) {
        cout<<dist[r[i]]-dist[l[i]]<<endl;
    }

    return 0;
}



Measured memory_bytes: 4096
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)


int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int x[100005]={};
    REP(i,m)scanf("%d",&x[i]);
    sort(x,x+m);
    int sa[100005]={};
    REP(i,m-1)sa[i]=x[i+1]-x[i];
    sort(sa,sa+m-1);
    int sum=0;
    REP(i,m-n)sum+=sa[i];
    printf("%d\n",sum);
    return 0;
}

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

int main() {

	// input
	int N = 0;
	cin >> N;

	vector<string> s(N);
	vector<int> t(N);

	for (int i = 0; i < N; i++) {
		cin >> s[i] >> t[i];

	}

	string X;
	cin >> X;

	// implementation

	bool flag = false;
	int sum = 0;

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

		if (flag == true) {
			sum += t[i];
		}

		if (s[i] == X) {
			flag = true;
		}

	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 256
my $num = <STDIN>;
chomp $num;
my $loop_num = int(sqrt($num) + 1);

my $min = length("$num");
for(my $i=1; $i<= $loop_num; $i++) {

	if($num%$i == 0) {
		my $big = $num/$i;
		if($min > length("$big")) {
			$min = length("$big");
		}
	}

}
print $min, "\n";

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}


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

	ll  d, n, m, k, ans = 0, ret = M;
	bool flag = false, flag2 = false;
	string s, t;
	cin >> n >> m;
	vP v(n);
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		v[i] = P(a, b);
	}
	sort(all(v));
	rep(i, n) {
		ret = min(m, v[i].second);
		ans += v[i].first * ret;
		m -= ret;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
from collections import defaultdict

def dfs(i,j,dx,dy,kum):
    visited[i][j] = 1
    if grid[i][j]!="#" and visited[i][j]!=1:
        num[i][j]=max(num[i][j],dfs(i+dx,j+dy,dx,dy,kum+1))
    num[i][j] = max(num[i][j],kum)
    return kum
def main():
    h,w = map(int, input().split())
    grid = []
    for i in range(h):
        s = list(input().rstrip())
        grid.append(s)
    l = [[0]*w for _ in range(h)]
    r = [[0]*w for _ in range(h)]
    d = [[0]*w for _ in range(h)]
    u = [[0]*w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if grid[i][j]!="#":
                if j==0:
                    l[i][j]=1
                else:
                    l[i][j]=l[i][j-1]+1
            if grid[i][j]=="#":
                l[i][j]=0
    for i in range(h):
        for j in range(w-1,-1,-1):
            if grid[i][j]!="#":
                if j==w-1:
                    r[i][j]=1
                else:
                    r[i][j]=r[i][j+1]+1
            if grid[i][j]=="#":
                r[i][j]=0
    for i in range(h):
        for j in range(w):
            if grid[i][j]!="#":
                if i==0:
                    d[i][j]=1
                else:
                    d[i][j]=d[i-1][j]+1
            if grid[i][j]=="#":
                d[i][j]=0
    for i in range(h-1,-1,-1):
        for j in range(w):
            if grid[i][j]!="#":
                if i==h-1:
                    u[i][j]=1
                else:
                    u[i][j]=u[i+1][j]+1
            if grid[i][j]=="#":
                u[i][j]=0
    tmp = 0

    for i in range(h):
        for j in range(w):
            tmp = max(tmp, l[i][j]+r[i][j]+u[i][j]+d[i][j]-3)



    print(tmp)

if __name__ == '__main__':
    main()


Measured memory_bytes: 308744
class combination():
    #素数のmod取るときのみ　速い
    def __init__(self, n, mod):
        self.n = n
        self.fac = [1] * (n + 1)
        self.inv = [1] * (n + 1)
        for j in range(1, n + 1):
            self.fac[j] = self.fac[j - 1] * j % mod

        self.inv[n] = pow(self.fac[n], mod - 2, mod)
        for j in range(n - 1, -1, -1):
            self.inv[j] = self.inv[j + 1] * (j + 1) % mod

    def comb(self, n, r, mod):
        if r > n or n < 0 or r < 0:
            return 0
        return self.fac[n] * self.inv[n - r] * self.inv[r] % mod

def examD(mod):
    N = I()
    a = LI()
    c = Counter(a)
    db = c.most_common()[0][0]
    curL = a.index(db)
    curR = a.index(db, curL + 1)
    L = curL; M = curR-curL-1;  R = N - curR
#    print(curL,curR)
#    print(L,M,R)
    C = combination(N+1,mod)
    ans = []
    ans.append(N)
    for i in range(2,N+2):
        cur = C.comb(N+1,i,mod)
        if N-1-M-(i-1)>=0:
            cur -= C.comb(N-1-M,i-1,mod)
        if cur<0:
            cur += mod
        ans.append(cur)
    for v in ans:
        print(v)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD(mod)


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

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

    int c = 0;
    int max_c = 0;
    for(int i = 0; i < (int)s.length(); i++) {
        if(s[i] == 'R') {
            c++;
            if(c > max_c) {
                max_c = c;
            }
        } else {
            c = 0;
        }
    }

    cout << max_c << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int x;
    cin >> x;
    int ans;
    rep(n, 100000) {
        int y = n * (n + 1) / 2;
        if(y >= x) {
            ans = n;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
//ƒxƒ‹ƒ}ƒ“ƒtƒH[ƒh–@
#include<iostream>
#define MAX_V 100000
#define MAX_E 500000
#define INF 1e9
using namespace std;
struct edge {
	int from, to, cost;
};
edge es[MAX_E];
int d[MAX_V];
int V;
int E;



bool find_negative_loop(int s)
{
	d[s] = 0;
	int count = 0;
	while (true)
	{
		bool update = false;
		count++;
		for (int i = 0; i < MAX_E; i++)
		{

			if (d[es[i].from] != INF && d[es[i].to] > d[es[i].from] + es[i].cost)
			{
				if (count == V)
				{
					return true;
				}
				d[es[i].to] = d[es[i].from] + es[i].cost;
				update = true;
			}
		}
		if (update == false)
		{
			break;
		}


	}
	return false;
}

int main()
{

	int r;
	cin >> V >> E >> r;
	for (int i = 0; i < MAX_V; i++)
	{
		d[i] = INF;
	}
	for (int i = 0; i < E; i++)
	{
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	if (find_negative_loop(r))
	{
		cout << "NEGATIVE CYCLE" << endl;
	}
	else
	{
		for (int i = 0; i < V; i++)
		{
			if (d[i] == INF)
			{
				cout << "INF" << endl;
			}
			else
			{
				cout << d[i] << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 9212
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>

using namespace std;

int gcd(int n, int m) {
    if (n == 0)
        return m;
    return gcd(m % n, n);
}

int bit_count(int i) {
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    i = (i + (i >> 4)) & 0x0f0f0f0f;
    i = i + (i >> 8);
    i = i + (i >> 16);
    return i & 0x3f;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (size_t i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<bool> visited(n, false);
    int pushed = 1;
    int last = 0;
    visited[0] = true;
    while (true) {
        if (a[last] == 2) {
            break;
        }
        last = a[last] - 1;
        if (visited[last]) {
            cout << -1 << endl;
            return 0;
        } else {
            pushed++;
            visited[last] = true;
        }
    }
    cout << pushed << endl;
}


Measured memory_bytes: 640
N= int(input())
       
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if N != 1:  
 listA=factorization(N) 
 nagasa=len(listA)
 nn=0
 kk=1
 count=0
 while nn<nagasa:
   while kk*(kk+1)/2 <=listA[nn][1]:
     count=count+1
     kk=kk+1
   kk=1
   nn=nn+1
 print(count)
if N==1:
  print(0)


Measured memory_bytes: 9500
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        int ans = -1, cur = 0;
        for (int i = 0; i < n; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            if(b+c > ans){
                ans = b+c;
                cur = a;
            }
        }
        cout << cur << " " << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second

using namespace std;

const long long INF = 1LL<<50;

int N,M;
long long a[2010], b[2010], c[2010];

int main() {
  cin>>N>>M;

  REP(i,0,M){
    cin>>a[i]>>b[i]>>c[i];
    c[i] = (-1)*c[i];
  }

  //BF
  long long d[1010];
  REP(i,0,N) d[i] = INF;
  d[0] = 0;

  REP(i,0,N-1){
    REP(j,0,M){
      if(d[a[j]-1]==INF) continue; /*0から到達不可能な起点は除外*/
      long long t;
      if(d[a[j]-1]+c[j] <= (-1)*INF) t = (-1)*INF;
      else t = d[a[j]-1]+c[j];
      d[b[j]-1] = min(d[b[j]-1], t);
    }
  }
  long long ans = d[N-1];

  REP(i,0,2*N){
    REP(j,0,M){
      if(d[a[j]-1]==INF) continue;
      long long t;
      if(d[a[j]-1]+c[j] <= (-1)*INF) t = (-1)*INF;
      else t = d[a[j]-1]+c[j];
      d[b[j]-1] = min(d[b[j]-1], t);
    }
  }

  /*d[N-1]が更新される => 0->N-1 の経路のどっかで正の閉路が存在する
  (２回めの更新はN回回すだけでいいのか？)*/
  if(ans != d[N-1]) cout<<"inf"<<endl;
  else cout<<(-1)*ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

constexpr int MAX_M = 30;
int N, M;
int A[MAX_M];

void _main() {
  cin >> N >> M;

  rep(i, 0, N) {
    int K;
    cin >> K;
    rep(j, 0, K) {
      int t;
      cin >> t;
      A[t-1]++;
    }
  }

  int ans = count_if(A, A + M, [](int x){ return x == N; });
  cout << ans << "\n";
}

Measured memory_bytes: 256
d,g = map(int,input().split())
g //= 100
P,C = [],[]
for i in range(1, d+1):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c//100)
ans = 10**9
for bin in range(1, 1<<d):
    cnt = tot = 0
    for i in range(d):
        if bin & 1<<i:
            cnt += P[i]
            tot += P[i]*(i+1) + C[i]
    if tot < g: continue
    ans = min(ans, cnt)
    for i in range(d):
        if bin & 1<<i:
            rest_g = g - (tot - P[i]*(i+1) - C[i])
            p = max(0, (rest_g+i)//(i+1)) # round up
            ans = min(ans, cnt - (P[i] - p))
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int a,b,c,d,e,f;
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF){
	
	double x = (double)(c*e-b*f)/(a*e-b*d);
	double y = (double)(c*d-f*a)/(b*d-a*e);
	
	//it is very important of this below  to anser collectly  
    if(x == -0.000){
      x = 0.000;
    }
    if(y == -0.000){
      y = 0.000;
    }
	
	printf("%.3lf %.3lf\n",x,y);
	
	}
	
	return 0;
}

Measured memory_bytes: 632