akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int inf = 1e9;

int main() {
	string S;
	cin>>S;
	string ans="yes";
	sort(all(S));
	rep(i,S.size()-1){
		if(S[i]==S[i+1])ans="no";
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    while (cin >> N) {
        if (!N) { break; }

        int ans = 0, t = 0;

        for (int i = 1; i < N; i++) {
            t = i;
            for (int j = i+1; j < N; j++) {
                t += j;
                if (t == N) {
                    ans++;
                    break;
                }
                else if (t > N) {
                    break;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2956
#include<stdio.h>
int main()
{
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c))
    {
        int remain=0;
        if(c-a+b>0)
            remain=c-a+b;
        printf("%d\n",remain);
    }
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<list>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;
typedef pair<P,double> C;

const double PI = acos(-1);

namespace std{
  bool operator<(const P &a,const P &b){
    return real(a)==real(b)?imag(a)<imag(b):real(a)<real(b);
  }
}

//for vector
P unit(P p){return p / abs(p);}

pair<P,P> norm(P p){return make_pair(p*P(0,1),p*P(0,-1));}

double dot(P x,P y){return real(conj(x)*y);}

double cross(P x,P y){return imag(conj(x)*y);}

//rotate a point counter-clockwise on the origin
P rotate(P v,double s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

//for point set
vector<P> convex_hull(vector<P> v){
  int n = v.sz, k = 0;
  sort(v.begin(),v.end());
  vector<P> r(2*n);
  for(int i=0;i<n;i++){
    while(k>1 && cross(r[k-1]-r[k-2],v[i]-r[k-1]) <= EPS)k--;
    r[k++] = v[i];
  }
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t && cross(r[k-1]-r[k-2],v[i]-r[k-1]) <= EPS)k--;
    r[k++] = v[i];
  }
  r.resize(k-1);
  return r;
}

//return seta A
double arg(P a,P b,P c){return acos(dot(b-a,c-a)/(abs(b-a)*abs(c-a)));}
double arg(double a,double b,double c){return acos( (b*b+c*c-a*a)/(2*b*c) );}


//for line(segment)
int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

//for polygon

//all vertex is already sorted.
double area(Poly p){
  if(p.size()<3)return 0;
  double res = cross(p[p.size()-1],p[0]);
  for(int i=1;i<p.size();i++)res += cross(p[i-1],p[i]);
  return res/2;
}

Poly convex_cut(Poly p,L l){
  Poly res;
  int n = p.size();
  for(int i=0;i<n;i++){
    int nxt = (i+1)%n;
    if(ccw(l.fs,l.sc,p[i]) != -1)res.pb(p[i]);
    if(ccw(l.fs,l.sc,p[i]) * ccw(l.fs,l.sc,p[nxt]) < 0){
      res.pb( line_cp(l, L(p[i],p[nxt]) ) );
    }
  }
  return res;
}

double cut_area(Poly p, double seta){
  return area(convex_cut(p,L(P(0.0),rotate(P(100,0),seta))));
}

int main(){
  int n;
  double x,y,seta,eps;
  P po;
  Poly p;
  
  while(scanf("%d",&n),n){
    p.clear();
    for(int i=0;i<n;i++){
      scanf("%lf%lf",&x,&y);
      po.real() = x; po.imag() = y;
      p.pb(po);
    }

    double s = area(p)/2;
    //printf("%lf\n",s);
    double l = 0,r = PI;
    double a,b;
    for(int i=0;i<1000;i++){
      double mid = (l+r)/2;
      a = cut_area(p,l), b = cut_area(p,mid);
      if( (s-a<EPS) && (s-b<EPS))l = mid;
      else if( (s-a>EPS) && (s-b>EPS))l = mid;
      else r = mid;
    }
    P res = rotate(P(100,0),l);
    //printf("%lf\n",cut_area(p,l));
    printf("%.15lf %.15lf\n",res.real(),res.imag());
  }
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int calc(int lhs, int rhs, char op){
    if(op == '+') return lhs | rhs;
    else if(op == '*') return lhs & rhs;
    else return lhs ^ rhs;
}

int expr(string &s, int &i, string &p);
int number(string &s, int &i, string &p);

int expr(string &s, int &i, string &p){
    if(s[i] == '['){
        ++i;
        char op = s[i];
        ++i;
        int lhs = expr(s, i, p), rhs = expr(s, i, p);
        ++i;
        return calc(lhs, rhs, op);
    }
    return number(s, i, p);
}

int number(string &s, int &i, string &p){
    int ret = p[s[i]-'a'] - '0';
    ++i;
    return ret;
}

void dfs(int cur, int tmp, int &cnt, string &t, string &s){
    if(cur == 4){
        int i = 0;
        cnt += (expr(s, i, t) == tmp);
        return;
    }
    for(char c='0'; c<='9'; ++c){
        t += c;
        dfs(cur + 1, tmp, cnt, t, s);
        t.pop_back();
    }
}

int main(){
    string s, p;
    while(cin >> s && s != "."){
        cin >> p;
        int i = 0;
        int tmp = expr(s, i, p);
        int cnt = 0;
        string t;
        dfs(0, tmp, cnt, t, s);
        printf("%d %d\n", tmp, cnt);
    }
}


Measured memory_bytes: 3264
n=int(input())
l=list(map(int,input().split()))
m=max(l)

from math import gcd
g=gcd(l[0],l[1])
for i in range(2,n):
  g=gcd(g,l[i])
if g!=1:
  print('not coprime')
  exit()

prime=[True]*(m+1)
prime[0]=False
prime[1]=False
d=[0]*(m+1)
for i in range(2,int(m**0.5)+1):
  if prime[i]:
    for j in range(i*2,m+1,i):
      prime[j]=False
      d[j]=i
s=[i for i in range(m+1) if prime[i]]
for ss in s:
  d[ss]=ss

sl=set()
for i in range(n):
  div=set()
  ll=l[i]
  while ll>1:
    div.add(d[ll])
    ll//=d[ll]
  div=list(div)
  for dd in div:
    if dd not in sl:
      sl.add(dd)
    else:
      print('setwise coprime')
      exit()

print('pairwise coprime')

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REP_REV(i,a,b) for (int i = a; i >= b; i--)
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;

void solve() {
	float d, t, s;
	cin >> d >> t >> s;
	float min = d / s;
	if (min <= t) cout << "Yes";
	else cout << "No";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	//freopen("measurement.in", "r", stdin);
	//freopen("measurement.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//ll t;
	//cin >> t;
	//while (t--) {
	solve();
	//}
	return 0;
}

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

int main()
{
    int n; cin >> n;
    string ans = "No";

    for(int i = 1; i <= 9; i++){
        for (int j = i; j <= 9; j++){
            if(n == i*j){
                ans = "Yes";
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer;

public class Main {
	static class IO 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public IO() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
        int [] readarray(int sz){
            int [] ret = new int[sz];
            for(int i = 0; i<sz; i++)ret[i] = nextInt();
            return ret;
        }
    }
    public static class power{
        long x;long y;long mod;
        power(long a,long b){
            this.x = a;this.y = b;
        }
        power(long a,long b,long c){
            this.x = a;this.y = b;this.mod = c;
        }
        long power_without_mod(){
            long res = 1;
            while(y>0){
                if(y%2 == 1)res = (res*x);
                y>>=1;
                x = x*x;
            }
            return res;
        }
        long power_with_mod(){
            long res = 1;
            while(y>0){
                if(y%2 == 1)res = (res*x)%mod;
                y>>=1;
                x = (x*x)%mod;
            }
            return res;
        }
    } 
    public static void main(String[] args){
        IO fs = new IO();
        int n = fs.nextInt();
        int [][] a = new int[n][3];
        for(int i = 0; i<n; i++){
            a[i][0] = fs.nextInt();a[i][1] = fs.nextInt();a[i][2] = fs.nextInt();
        }
        int [] dp = new int[3];
        for(int i = 0; i<n; i++){
            int [] dp1 = new int[3];
            for(int j = 0; j<3; j++){
                for(int k = 0; k<3; k++){
                    if(j!=k)dp1[k] = Math.max(dp1[k],dp[j]+a[i][j]);
                }
            }
            dp = dp1;
        }
        System.out.println(Math.max(dp[0],Math.max(dp[1],dp[2])));
    }
}


Measured memory_bytes: 51332
#include <iostream>
using namespace std;
typedef long long int LLI;
int main()
{
	LLI n, k, sum = 0;
	cin >> n >> k;
	if( k == 0 )
		cout << n*n;
	else{
		for(int i = k+1; i <= n; i++)
		{
			sum += n/i*(i-k);
			if( n % i >= k )
				sum += n % i - k+1;
		}
		cout << sum;
	}
}

Measured memory_bytes: 3564
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto abc = readln.chomp.split.to!(int[]);
  abc.sort();
  writeln(abc[0] + abc[1] + abc[2] * 10);
}


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

#define rep(i, n) for (ll i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  rep(b, n) ans += (n / b) * max(0LL, b - k) + max(0LL, n % b - k + 1);

  if (k == 0) ans -= n;

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


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

l = [0 for i in range(n)]
r = [0 for i in range(n)]
for i in range(1, n):
  rev = -(i+1)
  l[i] = l[i-1] + 1 if s[i-1] == "W" else l[i-1]
  r[rev] = r[rev+1] + 1 if s[rev+1] == "E" else r[rev+1]

ans = 1e+9
for i in range(n):
  ans = min(ans, l[i] + r[i])
print(ans)

Measured memory_bytes: 17848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mxn= 5e5+5;
// check for forloop
// take input
// overflow
// intialize variable
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    int n;
    cin>>n;
    int arr[n];
    map<ll,int> mp;
    vector<ll> vec;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        mp[arr[i]]++;
    }
    ll ans=0;
    for(auto x: mp){
        if(x.second>1)vec.push_back(x.first);
        if(x.second>3)ans=max(ans,x.first*x.first);
    }
    sort(vec.begin(),vec.end());
    if(vec.size()>1)
    ans=max(ans,vec[vec.size()-1]*vec[vec.size()-2]);
    cout<<ans;
}


Measured memory_bytes: 10140
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

const int INFTY=1<<29;

int main()
{
	for(int n,m,w;cin>>n>>m>>w && n|m|w;){
		vector<vector<int> > a(n);
		vector<int> ws;
		for(int i=0;i<n;i++){
			int k; cin>>k;
			for(int j=0;j<k;j++){
				int w; cin>>w;
				a[i].push_back(ws.size());
				ws.push_back(w);
			}
		}
		
		// SÄÌ×¨ª1KÉ éÈçCGx[^ðmK©ç1KÖÚ·KvÍÈ¢
		if(ws.size()==a[0].size()){
			cout<<0<<endl;
			continue;
		}
		
		vector<int> sum(1<<ws.size());
		for(int i=0;i<ws.size();i++)
			sum[1<<i]=ws[i];
		for(int i=1;i<(1<<ws.size());i++)
			sum[i]=sum[i&-i]+sum[i&i-1];
		
		vector<int> dp(1<<ws.size(),INFTY);
		dp[0]=0;
		for(int i=0;i<ws.size();i++)
			dp[1<<i]=1;
		for(int i=0;i<(1<<ws.size());i++)
			for(int j=i;j;j=i&j-1){
				if(sum[j]<=w)
					dp[i]=min(dp[i],dp[i^j]+1);
			}
		
		int top;
		for(top=n-1;a[top].size()==0;top--)
			;
		
		int res=abs(top-(m-1));
		for(int i=top,bit=0;i>0;i--){
			for(int j=0;j<a[i].size();j++)
				bit|=1<<a[i][j];
			res+=dp[bit]*2-1;
		}
		cout<<res<<endl;
	}
	
	return 0;
}

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

int a[200005];
int ans[200005];

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

    ll n,sum=0;
    cin>>n;
    for(ll i=1; i<=n; i++){
        if(i%3==0 || i%5==0 || (i%3==0 && i%5==0)){
            continue;
        }
        else{
            sum += i;
        }
    }
    cout<<sum<<"\n";

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque


def input():
    return sys.stdin.readline()[:-1]


def solve():
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    a_min = min(a)
    b_min = min(b)
    memo = [0]*(M+1)
    memo[0] = a_min + b_min
    for m in range(M):
        x, y, c = map(int, input().split())
        memo[m+1] = a[x-1]+b[y-1]-c
    print(min(memo))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 18872
#nの素因数分解(O(n**0.5)
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n%i == 0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

#a,bの最大公約数
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

a,b = map(int,input().split())

print(len(set(prime_factor(gcd(a,b))))+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((b*10+c)%4 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;

#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif
#define out(v) cout<<v<<"\n"
#define _overload3(_1,_2,_3,name,...) name
#define _all1(a) (a).begin(),(a).end()
#define _all2(a,n) (a),(a)+n
#define all(...) _overload3(__VA_ARGS__,42,_all2,_all1,)(__VA_ARGS__)
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

  ll A[N];
  ll sum = 0;
  rep(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  ll _sum = 0;
  ll ans = 2e15;
  rep(i, N) {
    ans = min(abs((sum - _sum) - _sum), ans);
    _sum += A[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
# coding:utf-8
while True:
    m,f,r = map(int, raw_input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print 'F'
    elif m + f >= 80:
        print 'A'
    elif m + f >= 65:
        print 'B'
    elif m + f >= 50:
        print 'C'
    elif m + f >= 30:
        if r >= 50:
            print 'C'
        else:
            print 'D'
    else:
        print 'F'



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

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    ll ans = 0, b = 0;
    rep(i, n)
    {
        if (s[i] == 'B')
            b++;
        else
            ans += b;
    }
    cout << ans << endl;
}

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

int main() {
  ll x, a = 100, cnt = 0; cin >> x;
  while (1) {
    if (x <= a) {
      cout << cnt << endl;
      break;
    }
    a = a + a / 100;
    cnt++;
  }
  return 0;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c&&c==a){
    cout<<1<<endl;
  }
  else if(a==b){
    cout<<2<<endl;
    }
   else if(a==c){
    cout<<2<<endl;
    }
   else if(c==b){
    cout<<2<<endl;
    }
  else {
    cout<<3<<endl;
  }
}

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

using namespace std;

int main(){

    int N, k;
    cin >> N >> k;
    int h[N];

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

        cin>>h[i];
    }

    int* table = new int[N];

    table[0] = 0;
	table[1] = abs(h[0] - h[1]);
    int mini;
    for(int i = 2; i < N; i++){

        mini = table[i-1] + abs(h[i-1] - h[i]);
		for(int j = 2; j <= k && j <= i; j++){

			mini = min(mini, table[i-j] + abs(h[i-j] - h[i]));
		}
        table[i] = mini;
    }

    cout<<table[N-1]<<"\n";

    return 0;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	string S; cin >> S;
	int A = stoi(S.substr(0,2));
	int B = stoi(S.substr(2,2));
	if(1<=A&&A<=12&&1<=B&&B<=12) cout << "AMBIGUOUS" << endl;
	else if(1<=A&&A<=12&&(B>12||B==0)) cout << "MMYY" << endl;
	else if((A>12||A==0)&&1<=B&&B<=12) cout << "YYMM" << endl;
	else cout << "NA" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <bitset>
#include <string>
#include <array>
#include <queue>
#include <set>

using namespace std;

int main()
{
    int s;
    cin >> s;
    set<int> num;
    int itr = 1;
    int n = s;
    while(num.find(n) == num.end()){
        num.insert(n);
        if(n % 2 == 0){
            n /= 2;
        }
        else {
            n = 3 * n + 1;
        }
        ++itr;
    }
    cout << itr << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	int n;
	ll x;
	cin >> n >> x;
	if (!cin) return false;
	vi v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());

	int nf = 0;
	ll c = 0;
	for (int i = 0; i < n; ++i) {
		c += v[i];
		if (c <= x) ++nf;
		else break;
	}

	if (c < x) --nf;

	cout << nf << '\n';

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 764
H, W, K = [int(i) for i in input().split()]

def cake_search(s_list):
    cake_index = []
    for i in range(len(s_list)):
        if "#" == s_list[i]:
            cake_index.append(i)
    
    return cake_index

def cake_assign(cake_index, mark_counter):
    cand_list = list()
    count = 0
    for i in range(W):
        if count < len(cake_index):
            if cake_index[count] > i:
                cand_list.append(mark_counter)
            else:
                cand_list.append(mark_counter)
                count += 1
                mark_counter += 1
        else:
            cand_list.append(mark_counter-1)

    return cand_list, mark_counter

s = list()
for i in range(H):
    tmp = [a for a in input()]
    s.append(tmp)

mark_counter = 1
mark_list = [[0]*W for i in range(H)]
emp_list = list()
for i in range(H):
    emp_list.append(i)
    if "#" in s[i]:
        cake_index = cake_search(s[i])
        if len(cake_index) == 1:
            cand_list = [mark_counter] * W
            mark_counter += 1
        else:
            cand_list, mark_counter = cake_assign(cake_index, mark_counter)
        for index in emp_list:
            mark_list[index] = cand_list
        emp_list = []

if emp_list == []:
    pass
else:
    for index in emp_list:
        mark_list[index] = cand_list
                
for i in range(H):
    for j in range(W):
        if j == 0:
            print(mark_list[i][j], end="")
        else:
            print(" ", mark_list[i][j], end="")
    print()

Measured memory_bytes: 8436
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]

for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K :
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i+j)
  
print(ans)

Measured memory_bytes: 47208
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
CD = [list(map(int, input().split())) for _ in range(M)]

for ab in AB:
    a = ab[0]
    b = ab[1]

    mr = 10 ** 9
    cp = 1

    for i, cd in enumerate(CD, 1):
        c = cd[0]
        d = cd[1]

        l = abs(a-c) + abs(b-d)

        if l < mr:
            mr = l
            cp = i

    print(cp)

Measured memory_bytes: 9192
use std::collections::VecDeque;
fn read<T: std::str::FromStr>() -> T {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
	(0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
	/// Return `true` if the slice was permuted, `false` if it is already
	/// at the last ordered permutation.
	fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
	/// Original author in Rust: Thomas Backman <serenity@exscape.org>
	fn next_permutation(&mut self) -> bool {
		// These cases only have 1 permutation each, so we can't do anything.
		if self.len() < 2 { return false; }

		// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
		let mut i = self.len() - 1;
		while i > 0 && self[i-1] >= self[i] {
			i -= 1;
		}

		// If that is the entire vector, this is the last-ordered permutation.
		if i == 0 {
			return false;
		}

		// Step 2: Find the rightmost element larger than the pivot (i-1)
		let mut j = self.len() - 1;
		while j >= i && self[j] <= self[i-1]  {
			j -= 1;
		}

		// Step 3: Swap that element with the pivot
		self.swap(j, i-1);

		// Step 4: Reverse the (previously) weakly decreasing part
		self[i..].reverse();

		true
	}
}

fn main() {
	let n: usize = read();
	let mut v: Vec<usize> = read_vec();

	v.sort_by(|a, b| a.cmp(b));
	let mut queue: VecDeque<f64> = VecDeque::new();
	for vi in v {
		queue.push_back(vi as f64);
	}
	for _ in 0..n-1 {
		let gen = (queue[0] + queue[1]) / 2.0f64;
		queue.pop_front();
		queue.pop_front();
		queue.push_front(gen);
	}
	println!("{:?}", queue[0]);
}


Measured memory_bytes: 4352
n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 10**9 + 7
x = (k*(k+1)//2)%mod
y = (k*(k-1)//2)%mod

r = 0
for i in range(n):
    right = sum(a[i] > j for j in a[i:])
    left = sum(a[i] > j for j in a[:i+1])
    r = (r+((right*x) + (left*y))%mod)%mod
print(r)

Measured memory_bytes: 9336
n,q=map(int,input().split())
s=input()
cnt=0
ans=[0]*(n+1)
for i in range(n-1):
    if s[i:i+2].count("AC"):
        ans[i+1]=1
from itertools import accumulate
ans=list(accumulate(ans))
for i in range(q):
    l,r=map(int,input().split())
    l-=1
    r-=1
    print(ans[r]-ans[l])

Measured memory_bytes: 54048
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int x, y;
    cin >> x >> y;
    if ((y - 2 * x) % 2 == 0) {
        int b = (y - 2 * x) / 2;
        int a = x - b;
        if (a >= 0 && b >= 0 && a + b == x && 2 * a + 4 * b == y) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


void atcoder_beginner_contest999()
{
  string n;
  cin >> n;

  for (int i = 0; i < n.size(); ++i)
  {
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << "\n";
}


void programming_education()
{
  int n;
  cin >> n;
  
  if (n == 1)
  {
    cout << "Hello World\n";
    return;
  }
  else
  {
    int a, b;
    cin >> a >> b;
    cout << a + b << "\n";
  }
}

void discount_fare()
{
  int x, y;
  cin >> x >> y;

  cout << x + y / 2 << "\n";
}


void A_114()
{
  int x;
  cin >> x;

  if (x == 3 || x == 5 || x == 7) cout << "YES\n";
  else cout << "NO\n";
}


void christmas_eve_eve_eve()
{
  int d;
  cin >> d;

  if (d == 25) cout << "Christmas\n";
  else if (d == 24) cout << "Christmas Eve\n";
  if (d == 23) cout << "Christmas Eve Eve\n";
  if (d == 22) cout << "Christmas Eve Eve Eve\n";
}


void right_triangle()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << a * b / 2 << "\n";
}


void entrance_examination()
{
  int t, x;
  cin >> t >> x;

  cout << (double)t / (double)x << "\n";
}


void A_118()
{
  int a, b;
  cin >> a >> b;

  if (b % a == 0) cout << a + b << "\n";
  else cout << b - a << "\n";
}


void still_TBD()
{
  string s;
  cin >> s;

  if (s[5] == '1' || s[6] >= '5') cout << "TBD\n";
  else cout << "Heisei\n";
}


void favorite_sound()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << min(b / a, c) << "\n";
}


void atcoder_beginner_contest111()
{
  int n;
  cin >> n;

  if (n % 111 == 0) cout << n << "\n";
  else
  {
    int a = n / 111;
    ++a;
    cout << a * 111 << "\n";
  }
}


void time_limit_exceeded()
{
  int N, T;
  cin >> N >> T;

  int ans = 1001;
  for (int i = 0; i < N; ++i)
  {
    int c, t;
    cin >> c >> t;

    if (t <= T && c < ans) ans = c;
  }
  if (ans == 1001) cout << "TLE\n";
  else cout << ans << "\n";
}


int main()
{
  //atcoder_beginner_contest999();
  //programming_education();
  //discount_fare();
  //A_114();
  //christmas_eve_eve_eve();
  //right_triangle();
  //entrance_examination();
  //A_118();
  //still_TBD();
  //favorite_sound();

  //atcoder_beginner_contest111();
  time_limit_exceeded();
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a = 0;
	int b = 0;
	//double i = 1;
	//double j = 2;
	
	//printf("");
	scanf("%d",&a);
	scanf("%d",&b);

	printf("%d %d\n",a*b,a+a+b+b);
	
	return 0;
}

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

int main(){
	int a[4];
	for(int i = 1;i <= 3;i++){
		cin >> a[i];
	}
	int oper = 0;
	int t = max(max(a[1],a[2]),max(a[2],a[3]));
	for(int i = 1;i <= 3;i++){
		if((t + a[i]) % 2 == 0) oper++;
	}
	oper--;
	if(oper == 2){
		int ans = 0;
		for(int i = 1;i <= 3;i++){
			ans += t - a[i];
		}
		cout << ans / 2;
		return 0;
	}
	else{
		if(oper == 1){
			int ans = 0;
			for(int i = 1;i <= 3;i++){
				ans += t - a[i];
			}
			cout << ans / 2 + 2;
			return 0;
		}
		else{
			int ans = 0;
			for(int i = 1;i <= 3;i++){
				ans += t - a[i];
			}
			cout << ans / 2;
			return 0;
		}
	}
	return 0;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  int result=0;
  for (int i=0;i<N;i++){
    if (i ==0){
      result = K;
    }
    else{
      result *= K-1;
    }
  }
  cout <<result<<endl;
}

Measured memory_bytes: 256
while True:
    h, w = map(int, input().split())
    if h == w == 0:
        break
    l1 = ['#' if i % 2 == 0 else '.' for i in range(w)]
    l2 = ['.' if i % 2 == 0 else '#' for i in range(w)]
    for n in range(h):
        print(''.join(l1) if n % 2 == 0 else ''.join(l2))
    print()


Measured memory_bytes: 5616
function main(input) {
  var n = input[0];
  var len = n.length;
  var ans = 0;
  for(var i=0;i<Math.trunc(len/2);i++){
    var a = n[i], b=n[len-i-1];
    if(a!=b)ans++;
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))

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

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, A[200005];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N;
    REP(i, N) cin >> A[i];

    int ans = 0;
    int r = 0;
    int x = 0;
    REP(l, N) {
        while (r < N && (x ^ A[r]) == (x + A[r])) {
            x ^= A[r];
            r++;
        }
        ans += r - l;
        l == r ? r++ : x ^= A[l];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
/*
    AUTHOR : TANMAY SINHA
    INFORMATION TECHNOLOGY
    BIT MESRA ,RANCHI
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(i,L,R) for(i=L;i<R;i++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 1e5,MAX = 5000000;
#define sq(X) ((X)*(X))

int main()
{
    ll n;
    cin>>n;
    cout<<(n+1)/2<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=55,M=N*N*N,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,X,D,ans,fa[N],f[M];
struct node{int w,t,vt,v;}a[N];
bool cmp(node x,node y){return x.w*y.v<y.w*x.v;}
struct que{
	int l,r,pos[M];ll val[M];
	void clear(){l=1,r=0;}
	void add(int x,ll v){
		while ((l<=r)&&(val[r]>v)) r--;
		pos[++r]=x;val[r]=v;
	}
	void del(int x){if ((l<=r)&&(pos[l]==x)) l++;}
	ll query(){return val[l];}
}g;
int getans(int R){
	int curans=0;
	for (int i=1;i<=n;i++){
		int t=min(a[i].t-a[i].vt,R/a[i].w);
		curans+=t*a[i].v;
		R-=a[i].w*t;
	}
	return curans;
}
int main(){
	n=read();X=read();D=read();
	for (int i=1;i<=n;i++){
		a[i].w=read();a[i].v=1;a[i].t=(i==1) ? X : D;
		a[i].vt=min(a[i].t,n);
		if (i!=1) fa[i]=read();
	}
	for (int i=n;i;i--){
		a[fa[i]].w=min(inf,a[fa[i]].w+a[i].w);
		a[fa[i]].v+=a[i].v;
		m+=a[i].v*a[i].vt;
	}
	sort(a+1,a+n+1,cmp);
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	for (int i=1;i<=n;i++){
		int w=a[i].w,v=a[i].v,t=a[i].vt;
		for (int j=0;(j<v)&&(j<=m);j++){
			g.clear();
			for (int kk=(m-j)/v,k=kk*v+j,r=kk;k>=0;k-=v,kk--){
				while ((r>=0)&&(kk-r<=t)) {g.add(r,f[r*v+j]-(ll)r*w);r--;}
				f[k]=g.query()+(ll)kk*w;
				g.del(kk);
			}
		}
	}
	for (int i=0;i<=m;i++){
		if (f[i]>X) break;
		ans=max(ans,i+getans(X-f[i]));
	}
	printf("%d\n",ans);
	return 0;
}

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

typedef long long ll;

int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll,ll> cnt;
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++){
        ll x = a[i];
        for(ll j=2;j*j<=x;j++){
            if(x%j==0){
                cnt[j] += a[i];
                while(x%j==0) x /= j;
            }
        }
        if(x != 1) cnt[x] += a[i];
    }
    ll ans = 0;
    for(auto p : cnt){
        ans = max(ans, p.second);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	cout<<( n*(n+1) )/2;
	
	return 0;
}


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

#define ll long long
#define ld long double
#define pb push_back
#define x first
#define y second
#define sz(v) (int)(v.size())
#define all(v) v.begin(),v.end()

using namespace std;

int main()
{
    //freopen("test.in","r",stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    ll n,k; cin>>n>>k;
    n-=k*(ll)(n/k);
    cout<<min(k-n,n);
    return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s;cin>>s;
    ll res = 0;
    rep(i,3){
        if(s[i]=='1')res++;
    }
    out(res);
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,d;cin>>n;
    ll temp=0,i=1;
    for(i=1;i<=1e8;i++)
    {
      temp=(temp*10 +7)%n;
      if(temp==0) break;
    }
    if(i>1e8) cout<<-1;
    else cout<<i;
}

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

int main() {

  int K;
  cin >> K;
  
  // 配列に入力
  vector<int> vec;
  vec = {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};
  
  // K番目の値を出力
  cout << vec.at(K-1);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;

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



int main()
{

    string S;
    cin >> S;
    int N = (S.length());
    ve<ve<int>> dp(N+1,vi(2,-1));
    dp[0][0] = 1;
    dp[1][1] = 1;
    
    rep(i,N){
        if(dp[i][0] > 0){
            if(i+1 < N){
                if(S[i] != S[i+1]) chmax(dp[i+1][0],dp[i][0]+1);
            }
            if(i+2 < N){
                chmax(dp[i+2][1],dp[i][0]+1);
            }
        }
        if(dp[i][1] > 0){
            if(i+1 < N){
                chmax(dp[i+1][0],dp[i][1]+1);
            }
            
        }
    }
    
    //outmat(dp);
    cout << max(dp[N-1][0],dp[N-1][1]) << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 11396
#include<iostream>
using namespace std;
int main()
{

  int n,m,d;
  char c;
  int mp[105][105] = {};
  int count = 0;
  int flag = 0;
  cin >> n >> m >> d;
  
  for( int i=0;i<n;i++ ){
    for( int j=0;j<m;j++ ){
      cin >> c;
      if( c == '.' ) mp[i][j] = 1;
    }
  }
  
  for( int i=0;i<n;i++ ){
    for( int j=0;j<m;j++ ){
      if( mp[i][j] == 1 ){
	for( int k=0;k<d;k++ ){
	  if( mp[i][j+k] == 0 ){
	    flag = 0;
	    break;
	  }
	  else flag = 1;
	}
	if( flag == 1 ) count++;
	flag = 0;
      }
    }
  }
  
  for( int i=0;i<n;i++ ){
    for( int j=0;j<m;j++ ){
      if( mp[i][j] == 1 ){
	for( int k=0;k<d;k++ ){
	  if( mp[i+k][j] == 0 ){
	    flag = 0;
	    break;
	  }
	  else flag = 1;
	}
	if( flag == 1 ) count++;
	flag = 0;
      }
    }
  }

  cout << count << endl;

  return 0;

}




Measured memory_bytes: 3156
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let a: usize = sc.read();
    let b: usize = sc.read();
    for i in 0..1000000 {
        if i * 8 / 100 == a && i * 10 / 100 == b {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N + 1);
	for (auto i = 0; i <= N; ++i)
	{
		cin >> A[i];
	}
	vector<long long> B(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> B[i];
	}

	auto result = 0ll;
	for (auto i = 0; i < N; ++i)
	{
		if (A[i] < B[i])
		{
			result += A[i];
			auto temp = min(A[i + 1], B[i] - A[i]);
			result += temp;
			A[i + 1] -= temp;
		}
		else
		{
			result += B[i];
		}
	}

	cout << result << endl;

	return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();

    string ans="UNRESTORABLE";
    for(int i=0;i<=n-m;i++){
        bool flag=true;
        string S=s;
        for(int j=0;j<m;j++){
            if(s[i+j]!='?'&&s[i+j]!=t[j]) flag=false;
            S[i+j]=t[j];
        }
        if(flag){
            replace(S.begin(),S.end(),'?','a');
            ans=S;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import bisect

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

for i in range (1, N):
    A[i]+=A[i-1]

for i in range (1, M):
    B[i]+=B[i-1]

V = 0
ACount = bisect.bisect_right(A, K)
if ACount !=0:
    V = K- A[ACount-1]
else:
    V=K

AInitial = ACount

BCount = bisect.bisect_right(B, V)
final = ACount+BCount

for i in range (1, AInitial):
    V = K - A[AInitial-1-i]
    BCount = bisect.bisect_right(B, V)
    final = max(final, AInitial-i+BCount)

final = max(final, bisect.bisect_right(B,K))
print(final)

Measured memory_bytes: 40872