akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

// 22
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[A];
        int[] b = new int[B];
        for(int i = 0; i < A; i++)
            a[i] = sc.nextInt();
        for(int i = 0; i < B; i++)
            b[i] = sc.nextInt();

        ArrayList<Integer> list = new ArrayList<Integer>();
        for(int i = 0; i < M; i++) {
            int ai = sc.nextInt() - 1;
            int bi = sc.nextInt() - 1;
            list.add(a[ai] + b[bi] - sc.nextInt());
        }
        Arrays.sort(a);
        Arrays.sort(b);
        Collections.sort(list);

        System.out.println(Math.min(a[0] + b[0], list.get(0)));
    }

}


Measured memory_bytes: 63284
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
int dfs(vector<int>&f,int st,int par,vector<vector<int>>&adj){
    for(auto j:adj[st]){
        if(j!=par){
            f[st]++;
            f[st]+=dfs(f,j,st,adj);
        }
    }
    return f[st];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x1=a*c;
    x1=max(x1,a*d);
    x1=max(x1,b*c);
    x1=max(x1,b*d);
    cout<<x1<<endl;
}
 

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fr first 
#define se second
using namespace std;
char s1[2100],s2[2100];
int len;
pair<int,int>a[2100];
int maxx[2100];
int minl[2100],minr[2100];
int ans;
int main()
{
	scanf("%s",s1);
	scanf("%s",s2);
	len=strlen(s1);
	int minn=1e9;
	for (int i=0;i<len;i++)
	{
		int flag=1;
		for (int j=0;j<len;j++)
			if (s1[(j+i)%len]!=s2[j])
			{
				flag=0;
				break;
			 } 
		if (flag)
		{
			minn=min(minn,min(i,len-i));
		}
	}
	if (minn!=1e9)
	{
		printf("%d\n",minn);
		return 0;
	}
	int flag=0;
	for (int i=0;i<len;i++)
		flag|=(s2[i]=='1');
	if (!flag)
	{
		printf("-1\n");
		return 0;
	}
	for (int i=0;i<len;i++)
	{
		minl[i]=len,minr[i]=len;
		for (int j=0;j<len;j++)
			if (s2[j]=='1')
			{
				minl[i]=min(minl[i],(i+len-j)%len);
				minr[i]=min(minr[i],(j+len-i)%len);
			}
	}
	int ans=1e9;
	for (int i=0;i<len;i++)
	{
		int sum=0,num=0;
		for (int j=0;j<len;j++)
			if (s2[(j+i)%len]=='1') sum+=(s1[j]=='0');
			else if (s2[(j+i)%len]=='0'&&s1[j]=='1')
			{
			 	 sum++;
				 a[++num].fr=minl[j],a[num].se=minr[j]-i;
				} 
		sort(a+1,a+num+1);
		maxx[num+1]=0;
		int s=1e9;
		for (int i=num;i>=0;i--)
		{ 
			maxx[i]=max(maxx[i+1],a[i].se);
			s=min(s,maxx[i+1]+a[i].fr); 
		} 
		ans=min(ans,sum+i+s*2); 
		//printf("%d\n",ans); 
	}
	for (int i=0;i<len;i++) 
	{
		int sum=0,num=0;
		for (int j=0;j<len;j++)
			if (s2[(j-i+len)%len]=='1') sum+=(s1[j]=='0');
			else if (s2[(j-i+len)%len]=='0'&&s1[j]=='1')
			{
			 	sum++;
				a[++num].fr=minr[j],a[num].se=minl[j]-i;
				} 
	//	printf("%d\n",ans);
		sort(a+1,a+num+1);
		maxx[num+1]=0;
		int s=1e9;
		for (int i=num;i>=0;i--)
		{ 
			maxx[i]=max(maxx[i+1],a[i].se);
			s=min(s,maxx[i+1]+a[i].fr); 
		} 
		ans=min(ans,sum+i+s*2); 
	}
	printf("%d\n",ans);
 } 

Measured memory_bytes: 256
N=int(input())
tabi=[0]*(N+1)
dic={'t':0,'x':0,'y':0}
tabi[0]=dic

for i in range(1,N+1):
  te=input()
  t=int(te.split()[0])
  x=int(te.split()[1])
  y=int(te.split()[2])
  
  dic={'t':t,'x':x,'y':y}
  tabi[i]=dic

flag=True
temp=tabi[0]
for dic in tabi:
  if temp['t']==dic['t']:
    continue
    
  diff_t=dic['t']-temp['t']
  diff_x=dic['x']-temp['x']
  diff_y=dic['y']-temp['y']
  if abs(diff_x+diff_y)>diff_t:
    flag=False
    break
  if abs(abs(diff_x+diff_y)-diff_t)%2!=0:
    flag=False
    break
  
  temp=dic

if flag:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 39924
#include<iostream>
using namespace std;
#include<cstring>
int main()
{
	int a[105];
	int n;
	int sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	double avi=sum*1.0/n;
	int ne=avi;
	if(avi-ne>=0.5)
	ne++;
	int ans=0;
	for(int i=0;i<n;i++)
	ans+=(a[i]-ne)*(a[i]-ne);
	printf("%d",ans);
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,S;
  cin >> K >> S;
  
  int cnt = 0;
  for(int x=0;x<=K;x++){
    for(int y=0;y<=K;y++){
      if( 0 <= S -(x + y) && S -(x + y) <= K ){
        cnt ++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<iomanip>

using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = ceil(N/1.08);    
    if(floor(ans*1.08)!=N) {
        cout << ":(" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a, b, c;
  
  cin >> a >> b >> c;
  
  if (a > c) {
    cout << "NO" << endl;
  }
  else if (a + b >= c) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
num = int(input())
words = input()
mod = 10**9+7

words_count = {}
for key in words:
    if key in words_count:
        words_count[key] += 1
    else:
        words_count[key] = 1

ans = 1
for key, val in words_count.items():
    ans *= (val + 1)

print((ans - 1) % mod)

Measured memory_bytes: 3188
n = gets.to_i
ary = Array.new(5,0)
n.times do
  a = gets.chomp.to_s
  if a[0]=="M"
    ary[0] += 1
  elsif a[0]=="A"
    ary[1] += 1
  elsif a[0]=="R"
    ary[2] += 1
  elsif a[0]=="C"
    ary[3] += 1
  elsif a[0]=="H"
    ary[4] += 1
  end
end
x = ary.combination(3).to_a
sum = 0
x.each do |y|
  sum += y[0]*y[1]*y[2]
end
puts sum

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

int dp[100001];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// your code goes here
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	 cin>>a[i];
	 
	memset(dp,-1,sizeof(a[0])*100001);
    dp[0] = 0;
    dp[1] = abs(a[0]-a[1]);
    for(int i=2;i<n;i++){
    	int hd = INT_MAX;
    	int k1 = k;
    	for(int j=i-1;j>=0 && k1>0;j--,k1--){
    		hd = min(abs(a[i]-a[j])+dp[j],hd);
    	}
    	dp[i] = hd;
    }
    cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	int i;
	while (1) {
		cin >> s;
		if (s[0]=='0') break;
		int sum = 0;
		for (i = 0; i < s.length(); i++)
			sum += s[i] - '0';
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
// ABC091B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>// 配列を使う
#include<algorithm>// maxを使う
using namespace std;
int main()
{
	int N;
	cin >> N;

	string s;
	int count = 0;
	vector<int> blue;
	vector<string>blue_s;
	for (int i = 0; i < N; i++)
	{
		cin >> s;
		auto ite = find(blue_s.begin(), blue_s.end(), s);
		if (ite != blue_s.end())// すでに単語が登録されているなら、そのカウントを１増やす
		{
			int pos = distance(blue_s.begin(), ite);
			blue.at(pos)++;
		}
		else
		{
			blue_s.push_back(s);// 単語が登録されていないなら、単語を登録して、そのカウントは１にする
			blue.push_back(1);
			count++;
		}
	}
	int M;
	cin >> M;
	string s2;
	vector<int> red;
	vector<string>red_s;

	for (int j = 0; j < M; j++)
	{
		cin >> s2;
		auto ite2= find(blue_s.begin(), blue_s.end(), s2);
		if (ite2!=blue_s.end())// 単語があったら、そのカウントを１減らす
		{
			int pos2 = distance(blue_s.begin(), ite2);
			blue.at(pos2)--;
		}
	}
	int max_v = 0;
	for (int k = 0; k < count; k++)
	{
		if (max_v<blue.at(k))
		{
			max_v = blue.at(k);
		}
	}
	cout << max(0, max_v) << endl;
}


Measured memory_bytes: 256
S=input()
n=len(S)

ans=0
for i in range(2**(n-1)):
    a = [1&(i>>j) for j in range(n)]
    ind = set([i for i, x in enumerate(a) if x==1])
    nums=[]
    tmp=0
    for j in range(n):
        tmp = tmp*10 + int(S[j])
        if j in ind:
            nums += [tmp]
            tmp=0
    nums += [tmp]
    #print(nums)
    ans += sum(nums)

print(ans)


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

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int main() {
    int n = 10;
    int h,w; cin>>h>>w;
    
//    ll INF =100000007;
    ll a[n][n];
    rep(i,n){
        rep(j,n){
            cin>>a[i][j];
        }
    }
    
    rep(k,n){
        rep(i,n){
            rep(j,n){
                a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
                }
            }
        }
    
    ll ans = 0;
    ll tmp;
    rep(i,h){
        rep(j,w){
            cin>>tmp;
            if(tmp!=-1) ans+= a[tmp][1];
        }
    }
    
    cout<<ans<<endl;
 	return 0;
}

Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
for i in range(1, n):
    ans = max(ans, abs(a[i - 1] - a[i]))
        
ans = max(abs(a[0] + k - a[n - 1]), ans)

print(k - ans)        


Measured memory_bytes: 26444
#include<stdio.h>

int main(){
  char S[5];
  int i;
  bool frag=false;
  scanf("%s",S);
  for(i=0;i<3;i++){
    if(S[i]==S[i+1]){
      frag=true;
      break;
    }
  }
  printf((frag)? "Bad\n":"Good\n");
  return 0;
}

  
	
      


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    ll ar[n];
    vector<int> occur(1000001,0);
    for(int x=0;x<n;x++){
        cin>>ar[x];
        occur[ar[x]]++;
    }
    // debr(occur.begin(),occur.begin()+25);
    sort(ar,ar+n);
    ll count=0;
    for(int x=0;x<n;x++){
        ll upto=sqrt(ar[x]);
        bool pre=false;
        for(ll y=1;y<=upto;y++){
            if(ar[x]%y==0){
                if(y!=ar[x]){
                    pre|=occur[y];
                }else{
                    pre|=(occur[y]>1);
                }
                if(ar[x]/y!=ar[x]){
                    pre|=occur[ar[x]/y];
                }else{
                    pre|=(occur[ar[x]/y]>1);
                }
                if(pre)break;
            }
        }
        // deb(pre);
        count+=pre;
    }
    ll ans=n-count;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8724
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
 
int main() {
  int N, Z, W; cin >> N >> Z >> W;
  int A[N]; for (int i=0; i<N; i++) cin >> A[i];

  int result;
  if ( N != 1 ) result = max( abs(A[N-1]-W), abs(A[N-1]-A[N-2]) );
  else result = abs(A[N-1]-W);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b, road, area;
    cin >> a >> b;
    area = a*b;
    road = a+b-1;
    area -= road;
    cout << area << endl;
    return 0;
}



Measured memory_bytes: 256
a=[int(input()) for _ in range(5)]
one = 10
for i in range(5):
    if a[i] % 10 != 0 and a[i]%10 <one:
        one = a[i]%10
for i in range(5):
    if a[i] % 10 == 0:
        a[i] = a[i] // 10
    else:
        a[i] = a[i] // 10 + 1
print(sum(a)*10 -10 +one) 

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
int main(){
  int K, res;
  rd(K);
  res = (K/2) * (divup_L(K,2));
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int K, res;
//   rd(K);
//   res = (K/2) * (K/+2);
//   wt(res);
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int a,b,ct;

int main(){
    cin>>a>>b;
    int x=1;
    while(x<b){
        x+=(a-1);
        ct++;
    }
    cout<<ct;
}
/*
    Good Luck
        -Lucina
*/


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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
double min(double a,double b){
  if(a<b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
int sum_keta(int n){
  if(n==0) return 0;
  return n%10 + sum_keta(n/10);
}
int main(void){
  int A,B,C; cin >> A >> B >> C;
  int K; cin >> K;
  
  int localmax = max(A,max(B,C));
  while(K>0){
  	localmax *= 2;
    K--;
  }
  cout << localmax +  A+B+C - max(A,max(B,C)) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	char S1[200];
	
	scanf("%s",S1);
	
	int i = 0;
	int a = 0;
	while(S1[i] != NULL) {
		a = a + 1;
		i++;
	}
	
	char S[a];
	for(i = 0; i <= a; i++) {
		S[i] = S1[i];
	}
	
	int b = a-2;
	while(b >= 0) {
		int c = 0;
		for(i = 0; i < b/2; i++) {
			if(S[i] != S[b/2+i]) {
				c = 1;
			}
			if(c == 1) {
				break;
			}
		}
		if(c == 0) {
			printf("%d",b);
			break;
		}
		b = b-2;
	}
	
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lop ios; ll t; cin>>t; while(t--)
#define pb push_back
#define vi vector<ll>
#define vivi vector<vector<ll>> 
#define vipa vector<pair<ll,ll>>
#define F first
#define S second
#define M 1000000007
#define kl "\n"
typedef long long ll;
ll lcm(ll x, ll y){ll k=x*y; k/=(__gcd(x,y)); return k;}
ll power(ll x,ll y){ ll r= 1;x = x % M;if(x==0) return 0; while(y>0) {if(y&1) r=(r*x)%M; y=y>>1; x=(x*x)%M;} return r;}  
void solve()
{ 
 ll n,m;
 cin>>n>>m;
 ll cnt=0;
 while(n--){
    ll x,y;
    cin>>x>>y;
    double d;
    d=sqrt(x*x+y*y);
    if(d<=m) cnt++;
    // cout<<d<<" ********* ";
 }
 cout<<cnt;
}
int main() 
{ 
    //lop
    solve();
	return 0; 
} 




Measured memory_bytes: 3636
n, x, m = map(int, input().split())

mn = min(n, m)
S = set()
A = []
a = x
ans = 0

for i in range(mn):
    if a in S: break
    S.add(a)
    A.append(a)
    ans += a
    a = a*a%m
    if a == 0:
        print(ans)
        exit()

if len(A) >= mn:
    print(ans)
    exit()

st_len = 0
while st_len < len(A) and a != A[st_len]: st_len += 1
st = sum(A[:st_len])
cyc_sum = sum(A[st_len:])
cyc_len = len(A) - st_len
cyc_num = (n - st_len) // cyc_len
cyc = cyc_sum * cyc_num
ed_len = (n - st_len) % cyc_len
ed = sum(A[st_len:][:ed_len])
print(st + cyc + ed)


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }
template <class... Args> inline void rf(Args&... args) { (cin >> ... >> args); }
template <class... Args> inline void pr(Args&&... args) { (cout << ... << args); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;

	int cur = 1000;
	while(cur < n) cur += 1000;

	cout << cur - n << "\n";

	
}

Measured memory_bytes: 3568
from heapq import heappop, heappush 
from collections import deque
def dijkstra(xs, ys, xg, yg,h,w,k,field):
    # que->(cost, x, y, direction)
    inf = 1e18
    dist = [[inf]*w for _ in range(h)]
    dist[xs][ys] = 0
    que = deque([(0, xs, ys)])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
    while que:
        cost, x, y = que.popleft()
        if cost > dist[x][y]:
            continue
        for v in range(4):
            nx, ny = x, y
            for _ in range(k):
                nx += dx[v]
                ny += dy[v]
                if not field[nx][ny]:
                    break
                if dist[nx][ny]<=dist[x][y]:
                    break
                if dist[nx][ny] > dist[x][y]+1:
                    dist[nx][ny] = dist[x][y]+1
                    que.append((dist[nx][ny], nx, ny))

    if dist[xg][yg] == inf:
        print(-1)
    else:
        print(dist[xg][yg])

        

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    h, w, k = map(int, input().split())
    xs, ys, xg, yg = map(int, input().split())
    field = [[False]*(w+2) for _ in range(h+2)]
    for i in range(h):
        # False で覆うことでx,yの制限をなくす。
        s = [True if _ == '.' else False for _ in input()]
        field[i+1] = [False]+s+[False]
    h += 2
    w += 2
    dijkstra(xs, ys, xg, yg, h, w, k, field)

if __name__ == '__main__':
    main()


Measured memory_bytes: 82472
def main():
    h, w = map(int, input().split())
    a = [[j for j in input()] for i in range(h)]

    x, flg = (0, -1), False
    for i in range(h):
        for j in range(w):
            if a[i][j] == "#":
                if i == x[0] and j == x[1] + 1 or i == x[0] + 1 and j == x[1]:
                    x = i, j
                else:
                    break

        else:
            continue
        break

    else:
        flg = True

    if flg:
        print("Possible")
    else:
        print("Impossible")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
bool compare(const pair<int , int>&a , const pair<int,int>&b){
	return a.fi<b.fi ; 
}
void solve()
{
	int n ; 
	cin>>n ;
	if(n%2){
		cout<<n/2 + 1 ;
	}
	else{

		cout<<n/2 ;
	}

}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(int, i, a, b)        for (int i=a; i<(b); i++)
#define forev(int, i, b, a)     for (int i = (b)-1; i >= a; i--)
#define uns                     unsigned
#define lli                     long long int
#define ld                      long double
#define all(x)                  x.begin(), x.end()
#define sortall(x)              sort(all(x))
#define enl                     "\n"
// #define PI 3.1415926535897932384626
// const int MOD = 1000000007; // const ll INF = 1e18; // const int MX = 100001;
//==================================================================================

void solve() {
    ld a, b; cin >> a >> b;
    b *= 100;
    a /= 100;
    int64_t ans = a * b;
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // int testcase; cin >> testcase; for (int i = 1; i <= testcase; ++i)
    solve();
    return 0;
}

Measured memory_bytes: 3692
//---------------prashant Sharma------------

#include<bits/stdc++.h>

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cerr << #x << " is " << x << endl;
#define endl                           '\n'

using namespace std;


int main()
{
    
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b<c)
    {
        cout<<a+b+1+b;
        return 0;
    }
    if(a+b==c)
    {
        cout<<c+b;
        return 0;
    }
    cout<<c+b;
   
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

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

   for(int i=0;i<n;i++){
      if(b[i]>i+1){
         cout<<-1<<endl;
         return 0;
      }
   }
   for(int i=0;i<n;i++){
      for(int j=b.size()-1;j>=0;j--){
         if(b[j]==j+1){
            a[i]=b[j];
            b.erase(b.begin()+j);
            break;
         }
      }
   }
   
   reverse(a.begin(),a.end());
   a.push_back(1);
   for(int i=0;i<n;i++)cout<<a[i]<<endl;
   
   
}

   


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

#define MAX 100001
long double ans[MAX];
long double *memo,*prev;
long double buff[2][110];
long double pp[110];

int main(){
  memo = buff[0];
  prev = buff[1];

  prev[1] = 1.0;
  ans[1] = 1.0;
  REP(i,110) pp[i] = pow(1.0/2.0, i);
  rep(i,2,MAX){
    ans[i] = ans[i-1];
    memo[0] = 0.0;
    rep(j,1,110){
      double tmp = prev[j-1] * pp[j-1];
      memo[j]  = tmp;
      memo[0] += prev[j-1] - tmp;
        ans[i] += tmp;
    }
    swap(prev, memo);
  }

  int n;
  while(n = getInt()) printf("%.8f\n",(double)ans[n]);
  return 0;
}

Measured memory_bytes: 1856
#include <iostream>

using namespace std;

int main(void){
    int i,j,k,l;
    int year_f,year_l;
    bool fast_f=false;
    bool flag;

    while(cin>>year_f>>year_l,year_f&&year_l){
        flag=true;
        if(fast_f){
            cout<<endl;
        }
        fast_f=true;
        for(i=year_f;i<=year_l;i++){
            if(i%4==0&&i%100!=0||i%400==0){
                cout<<i<<endl;
                flag=false;
            }
        }
        if(flag){
            cout<<"NA"<<endl;
        }
    }
    return(0);
    
}

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

const int mxn = 1e5+2;
vector<int> a1;
vector<int> a2;
vector<int> p(mxn);
bool vis[100001];
vector<int> g[100001];
vector<int> st(mxn);
int cnt = 0;
void dfs(int x){
	vis[x] = 1;
	if(st[x]>0) return;
	st[x] = cnt;
	for(auto to : g[x]){
		if(vis[to]) continue;
		dfs(to);
	}
}

int main(){
	int n,m;
	cin>>n>>m;
	for(int i = 1; i <= n; i++) cin>>p[i];
	for(int i = 0; i < m; i++){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for(int i = 1; i < n; i++){
		if(!vis[i]){
			cnt++;
			dfs(i);
		}
	}
    int res = 0;
	for(int i = 1; i <= n; i++){
		if(st[i]==st[p[i]]) res++;
	}
	 cout<<res;
}

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

int main() {
	int w[10],k[10];
	for(int i=0;i<10;i++){
		cin >> w[i];
	}
    for(int i=0;i<10;i++){
    	cin >> k[i];
    }
    sort(w,w+10);
    sort(k,k+10);
    
    cout << (w[9]+w[8]+w[7]) << " " << (k[9]+k[8]+k[7]) << endl;
    
	return 0;
}

Measured memory_bytes: 3136
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



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


	double pi = acos(-1.0);
	int a, b;
	cin >> a >> b;
	int ab = max(a, b);
	printf("%.8f\n", pi * ab*ab*b / 3 * 4);


	return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;

  int l = S.length();
  if (l == 1) {
    cout << "No" << endl;
    return 0;
  }

  if (l % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }

  string expected = "";
  while (l > 0) {
    expected += "hi";
    l -= 2;
  }

  if (S == expected) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
 
using namespace std;
 
#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int dx[] = {-1,0,1,0}; const int dy[] = {0,1,0,-1};
 
int main() {
    set<char> l = {'q', 'w', 'e', 'r', 't', 'a', 's', 'd', 'f', 'g', 'z', 'x', 'c', 'v', 'b'};
    set<char> r = {'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'};
 
    string s;
    while(cin >> s, s != "#") {
        int r_p__l_m = 0;
        int cnt = 0;
        int d = 0;
        for(auto c:s){
            int k = 0;
            if(EXIST(l, c)){
                k = -1;
            }else if(EXIST(r, c)){
                k = 1;
            }
 
            if(k != r_p__l_m) {
                cnt += d;
                r_p__l_m = k;
            }
            d = 1;
        }
 
        cout << cnt << endl;
    }
}

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

int main()
{
	double x1, x2, y1, y2, ans;

	scanf("%lf", &x1); 
	scanf("%lf", &y1); 
	scanf("%lf", &x2);
	scanf("%lf", &y2);

	ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

	printf("%.5lf", ans);
	
	return 0;
}

Measured memory_bytes: 1808
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;

int ctoi(char c) {
    switch (c) {
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
}


int main(int argc, const char * argv[]) {

    long long a, b;
    
    cin >> a >> b;
    
    if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    
    
    return 0;
    
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

string T0[3] = {"aa.",
                "..b",
                "..b"};
string T1[4] = {"aabc",
                "ddbc",
                "bcaa",
                "bcdd"};
string T2[5] = {"aabba",
                "bcc.a",
                "b..cb",
                "a..cb",
                "abbaa"};
string T3[6] = {"aabc..",
                "ddbc..",
                "..aabc",
                "..ddbc",
                "ab..aa",
                "ab..bb"};
string T4[7] = {"aabbcc.",
                "dd.dd.a",
                "..d..da",
                "..d..db",
                "dd.dd.b",
                "..d..dc",
                "..d..dc"};

int main() {
    ll N;
    cin >> N;
    if (N == 2) {
        cout << -1 << endl;
        return 0;
    }

    if (N == 3) {
        REP(i, N) {
            cout << T0[i] << endl;
        }
        return 0;
    }

    REP(i, N) {
        if (N - 4 * i > 7)
            continue;

        REP(j, i) {
            REP(t, 4) {
                REP(k, N) {
                    if (j * 4 <= k && (j + 1) * 4 > k)
                        cout << T1[t][k - j * 4];
                    else
                        cout << '.';
                }
                cout << endl;
            }
        }

        ll n = N - 4 * i;
        REP(t, n) {
            REP(j, N) {
                if (i * 4 <= j) {
                    if (n == 4)
                        cout << T1[t][j - i * 4];
                    else if (n == 5)
                        cout << T2[t][j - i * 4];
                    else if (n == 6)
                        cout << T3[t][j - i * 4];
                    else
                        cout << T4[t][j - i * 4];
                }
                else
                    cout << '.';
            }
            cout << endl;
        }
        break;
    }
    return 0;
}

Measured memory_bytes: 1280
k, s = map(int, input().split())
count = 0
for ai in range(k+1):
    remain = s - ai
    if remain > k * 2 or remain < 0:
        continue
    if remain <= k:
        count += remain + 1
    else:
        count += k * 2 - remain + 1
print(count)

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

using namespace std;
int main()
{
	int m;
	int n;
	cin>>m;
	cin>>n;
	int s=0;
	int a=0;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		s+=a;
	}
	if(s>m)
	{
		cout<<-1;
	}
	else
	{
		cout<<m-s;
	}
}


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

int main() {
  string S; 
  cin >> S;
  
  int n = S.size();
  int ans = 2;
  // i文字＊２になっているか？をチェックしていく
  for (int i = 0; i < n/2; i++) {
    bool cond = true;
    for (int j = 0; j < i; j++) {
      if (S[j] != S[j+i]) {
        cond = false;
        break;
      }
    }
    if (cond) ans = 2 * i;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3552
#include <stdio.h>

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

int max(int a,int b){
	return a >= b ?a :b;
}
int main()
{
    int n;
    int a[100001];
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
    	scanf("%d",&a[i]);
	}
	
	int b[100002] = {0};
	for(int i = 0;i < n;i++){
		b[i + 1] = gcd(b[i],a[i]);
	}
	int c[100002] = {0};
	for(int i = n;i > 0;i--){
		c[i - 1] = gcd(c[i],a[i - 1]);
	}
	
	int s = 0;
	for(int i = 0;i < n;i++){
		s = max(s,gcd(b[i],c[i + 1]));
	}
	printf("%d",s);
    return 0;
}

Measured memory_bytes: 1280
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

// Implementation according to Solution 1 in the editorial

#[fastout]
fn main() {
    input! {
        n: usize,
        xyp: [(isize, isize, usize); n],
    }
    macro_rules! pow2 (($i:expr) => (1 << $i));
    macro_rules! has_railway (($bits:expr, $i:expr) => ($bits & pow2!($i-1) != 0));
    // Precompute the distances
    let mut tate_costs: Vec<Vec<usize>> = vec![vec![0; n]; pow2!(n)];
    for bits in 0..pow2!(n) {
        for i in 1..=n {
            let (x, y, p) = xyp[i - 1];
            let mut min_dist = x.abs().min(y.abs()) as usize;
            for j in 1..=n {
                if has_railway!(bits, j) {
                    let (xx, _yy, _pp) = xyp[j - 1];
                    let dist = (xx - x).abs() as usize;
                    min_dist = min_dist.min(dist);
                }
            }
            tate_costs[bits][i - 1] = min_dist * p;
        }
    }
    let mut yoko_costs: Vec<Vec<usize>> = vec![vec![0; n]; pow2!(n)];
    for bits in 0..pow2!(n) {
        for i in 1..=n {
            let (x, y, p) = xyp[i - 1];
            let mut min_dist = x.abs().min(y.abs()) as usize;
            for j in 1..=n {
                if has_railway!(bits, j) {
                    let (_xx, yy, _pp) = xyp[j - 1];
                    let dist = (yy - y).abs() as usize;
                    min_dist = min_dist.min(dist);
                }
            }
            yoko_costs[bits][i - 1] = min_dist * p;
        }
    }
    // Check patterns
    let mut min_costs: Vec<usize> = vec![10000 * 1000000 * 15; n + 1];
    for either_railways in 0..pow2!(n) {
        let num_railways = (either_railways as u64).count_ones() as usize;
        let mut yoko_railways = either_railways+1;
        while yoko_railways > 0 {
            yoko_railways -= 1;
            yoko_railways &= either_railways;
            let tate_railways = either_railways - yoko_railways;
            let mut cost = 0;
            for j in 1..=n {
                cost += tate_costs[tate_railways][j - 1].min(yoko_costs[yoko_railways][j - 1]);
            }
            // Update
            min_costs[num_railways] = min_costs[num_railways].min(cost);    
        }
    }
    for c in min_costs {
        println!("{}", c);
    }
}


Measured memory_bytes: 11804
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;

    map<int,int> events;
    for(int i=0;i<m;++i)
    {
        int l, r;
        cin >> l >> r;
        events[l] += 1;
        events[r+1] -= 1; 
    }

    int score = 0;
    int ret = 0;
    int prev_event = -1;
    for(const auto& event : events)
    {
        if(score == m)
        {
            ret += event.first - prev_event;
        }
        prev_event = event.first;
        score += event.second;
    }
    cout << ret << endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int k;
    cin>>k;
    int ls[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<ls[k-1]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1, 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    ll sum  = 0;
    int ans = 0;
    REP(i, N) {
        if (N <= sum)
            break;
        sum += i + 1;
        ans++;
    }
    print(ans);

    return 0;
}

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

ll solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N+2);
    for ( int i = 1; i <= N; i++ ) {
        cin >> H[i];
    }
    const ll INF = 1LL<<60;
    vector<vector<ll>> dp(N+2, vector<ll>(K+1, INF));
    dp[0][0] = 0;
    for ( int n = 1; n <= N+1; n++ ) {
        for ( int k = 0; k <= K; k++ ) {
            for ( int j = 1; j <= min(k+1, n) ; j++ ) {
                ll x = dp[n-j][k-(j-1)] + max(0LL, H[n]-H[n-j]);
                dp[n][k] = min(dp[n][k], x);
            }
        }
    }
    ll ans = dp[N+1][K];
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
program name
    implicit none
    integer(4):: n,m,i
    integer(4),allocatable:: x(:), dst(:)

    read*, n,m
    if (m==1) then
        print*, 0
        stop
    end if
    allocate(x(m),dst(m-1))
    read*, x(:)
    call merge_sort(x,1,m)
    do i=1,m-1
        dst(i) = x(i+1)-x(i)
    end do
    call merge_sort(dst,1,m-1)
    print*, sum(dst(1:m-n))

contains
    recursive subroutine merge_sort(ar, fst, lst)
        integer(4),intent(inout):: ar(:)
        integer(4),intent(in):: fst,lst
        integer(4):: mdl

        if (lst-fst < 2) then
            if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
            return
        end if

        mdl = (fst+lst)/2
        call merge_sort(ar, fst, mdl)
        call merge_sort(ar, mdl+1, lst)
        call merge_(ar, fst, mdl, lst)
    end subroutine

    subroutine merge_(ar, fst, mdl, lst)
        integer(4),intent(inout):: ar(:)
        integer(4),intent(in):: fst, mdl, lst
        integer(4),allocatable:: tmp(:)
        integer(4):: li, ri, ti

        allocate(tmp(lst-fst+1))

        li=fst
        ri=mdl+1   
        ti=1

        do while (li <= mdl .and. ri <= lst)
            if (ar(li) <= ar(ri)) then
                tmp(ti) = ar(li)
                li=li+1
            else
                tmp(ti) = ar(ri)
                ri=ri+1
            end if
            ti=ti+1
        end do

        if (li <= mdl) then
            tmp(ti:) = ar(li:mdl)
        else
            tmp(ti:) = ar(ri:lst)
        end if

        ar(fst:lst) = tmp(:)
        deallocate(tmp)
    end subroutine

    subroutine swap(x,y)
        integer(4),intent(inout):: x,y
        integer(4):: tmp
        tmp = x
        x = y
        y = tmp
    end subroutine
end program name

Measured memory_bytes: 1844
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
constexpr double EPS = 1e-8;

int main() {
    double a, b, c, d, e, f, x, y;
    while (cin >> a >> b >> c >> d >> e >> f) {
        x = (c * e - b * f) / (a * e - b * d);
        y = (c - a * x) / b;
        if (abs(x) < EPS) x = 0;
        if (abs(y) < EPS) y = 0;
        cout << fixed << setprecision(3) << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 3252
//abc175_c.cpp
//Sat Aug 15 20:46:13 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll x,k,d;
	cin >> x >> k >> d;

	if (abs(x)/d>=k){
		ll ans = abs(x)-d*k;
		cout << ans << endl;
		return 0;
	}else{
		ll tmp = abs(x)/d;
		ll ans;
		if ((k-tmp)%2==0){
			ans = abs(x)%d;
		}else {
			ans = d-abs(x)%d;
		}
		cout << ans << endl;
		return 0;
	}
}

Measured memory_bytes: 3628
use std::io;


fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let mut input:Vec<char> = read_line().chars().collect::<Vec<char>>();
    input.reverse();
    let mut S:String = input.iter().cloned().collect::<String>();
    let word:Vec<&str> = vec!["maerd","remaerd","esare","resare"];
    let mut start:usize = 0;
    let mut flag:bool = false;
    for i in 0..(S.len()+1) {
        let slice = &S[start..i];
        if word.iter().any(|x|x == &slice) {
            flag = true;
            start = i;
        }else{
            flag = false;
        }
    }

    if flag {
        println!("YES");
    }else{
        println!("NO");
    }
}

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

int main() {
  int H, W; cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) cin >> S.at(i);
  vector<vector<int>> U(H, vector<int>(W));
  vector<vector<int>> D(H, vector<int>(W));
  vector<vector<int>> L(H, vector<int>(W));
  vector<vector<int>> R(H, vector<int>(W));
  for (int x = 0; x < W; x++) {
    int tmp = 0;
    for (int y = 0; y < H; y++) {
      if (S.at(y).at(x) == '#') tmp = 0;
      else tmp++;
      U.at(y).at(x) = tmp;
    }
  }
  for (int x = 0; x < W; x++) {
    int tmp = 0;
    for (int y = H-1; y >= 0; y--) {
      if (S.at(y).at(x) == '#') tmp = 0;
      else tmp++;
      D.at(y).at(x) = tmp;
    }
  }
  for (int y = 0; y < H; y++) {
    int tmp = 0;
    for (int x = W-1; x >= 0; x--) {
      if (S.at(y).at(x) == '#') tmp = 0;
      else tmp++;
      L.at(y).at(x) = tmp;
    }
  }
  for (int y = 0; y < H; y++) {
    int tmp = 0;
    for (int x = 0; x < W; x++) {
      if (S.at(y).at(x) == '#') tmp = 0;
      else tmp++;
      R.at(y).at(x) = tmp;
    }
  }
  int ans = 0;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (S.at(y).at(x) == '#') continue;
      int cnt = U.at(y).at(x) + D.at(y).at(x) + L.at(y).at(x) + R.at(y).at(x) - 3;
      ans = max(ans, cnt);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 69120
import string
N = int(input())
tmp = 0
for digit in range(1, 100):
    tmp += 26**digit
    if tmp >= N:
        break
N -= sum(26**i for i in range(1, digit)) + 1
ans = []
while N:
    ans += [N % 26]
    N //= 26
ans += [0] * (digit - len(ans))
ans = ans[::-1]
print(''.join(string.ascii_lowercase[i] for i in ans))


Measured memory_bytes: 9972
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
#define pb push_back
#define IM_N00B ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;


int main(){

int h,a;
cin >> h >> a;
int ans = h/a;
if(h%a!=0) cout << ans + 1;
else cout << ans;
return 0;
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
  double X;
  cin >> X;
  ull ans = 0LL;
 
  for(double r = 100.0; r < X; ++ans, r = floor(1.01 * r));

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

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

int main() {
  int n,x;cin>>n>>x;
  vector<int> m(n);
  for(int i=0;i<n;++i) cin>>m[i];
  sort(m.begin(), m.end());
  int sm=0,ans=0;
  for(int i=0;i<n;++i) {
    sm += m[i];
    if(sm>x) break;
    ++ans;
  }
  if(sm>0) ans += (x-sm)/m[0];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256