akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
using namespace std::chrono;

#define ll long long
#define ld long double
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#ifdef LL
const ll inf = 1e9;
#else 
const ll inf = 1e18;
#endif

const int mod = 1e9 + 7;
const int mod2 = 998244353;

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

high_resolution_clock::time_point curTime() { return high_resolution_clock::now(); }
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} //Just add this as a third argument to sort() while sorting an array of pairs; NO NEED FOR ANY ARGUMENTS;
template <typename T>
T fact(T a, T mod){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=mod;} return res; }
template <typename T>
ll powmod(T a,T b,ll m){ ll ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
ll power(T a, T b){ ll ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}
template <typename T>
T gcd(T a,T b){ return (b?__gcd(a,b):a); }
template <typename T>
T lcm(T a, T b){ return (a*(b/gcd(a,b))); }
template <typename T>
T cl(T a, T b){ return (a+b-1)/b; }
template <typename T>
T set_bits(T a)
{ return __builtin_popcount(a); }
template <typename T>
T add_self(T& a, T b, T mod){ a+=b; if(a>=mod){ a-=mod; } }
template <typename T>
T to_upper(T s){ transform(s.begin(), s.end(), s.begin(), ::toupper); return s; }
template <typename T>
T to_lower(T s){ transform(s.begin(), s.end(), s.begin(), ::tolower); return s; }



int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    auto startTime = curTime();

    int n,w;
    cin>>n>>w;

    vi u(n), v(n);
    for(int i=0;i<n;i++)
    {
        cin>>u[i]>>v[i];
    }

    // dp[i][j] is the max value we get by taking weight j until the ith element
    vvi dp(n+1, vi(w+1,0));

    ll mx=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(u[i-1]<=j) dp[i][j] = max(dp[i-1][j], dp[i-1][j-u[i-1]] + v[i-1]);
            else dp[i][j] = dp[i-1][j];
            mx = max(mx, dp[i][j]);
        }
    }

    cout<<mx<<endl;

    auto stopTime = curTime();
    auto duration = duration_cast<microseconds>(stopTime - startTime);
    //cout<<"Program ran for "<<(ld)duration.count()/1e6<<" "<<"seconds"<<endl;
}


Measured memory_bytes: 83068
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
long long CN[400005];
long long mod = 998244353;
long long fstp(long long base, long long p) {
    long long rt = 1;
    while (p) {
        if (p & 1) {
            rt *= base;
            rt %= mod;
        }
        base *= base;
        base %= mod;
        p >>= 1;
    }
    return rt;
}
long long ny(long long x) {
    return fstp(x, mod - 2);
}

long long gcd(long long a, long long b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    long long n, a, b, k;
    cin >> n >> a >> b >> k;
    if (b < a) swap(a, b);
    CN[0] = 1;
    for (long long i = 1; i <= n; ++i) {
        CN[i] = CN[i - 1] * (n - i + 1) % mod * ny(i) % mod;
    }
    long long bs = n + 1;
    for (long long i = 0; i < b; ++i) {
        if ((k - i * a) % b == 0) {
            bs = i;
            break;
        }
    }
    if (bs > n) {
        puts("0");
        return 0;
    }
    long long bb = b / gcd(a, b);
    long long rs = 0;
    for (long long i = bs; i <= n; i += bb) {
        long long usb = (k - i * a) / b;
        if (i < 0 || usb < 0) break;
        if (i > n || usb > n) continue;
        rs += CN[i] * CN[usb] % mod;
        rs %= mod;
    }
    cout << rs << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define MOD = 1e9+7
#define rep(i,n) for(int i=0;i<(n);++i)
const double PI=3.14159265358979323846; 
const int INF = 1001001001;
using namespace std;

int main(){
  ll n;
  cin >> n;
  vector<int> ans(4,0);

  rep(i,n){
    string s;
    cin >> s;
    if(s=="AC") ans[0]++;
    else if(s=="WA") ans[1]++;
    else if(s=="TLE") ans[2]++;
    else if(s=="RE") ans[3]++;
  }

  rep(i, ans.size()){
    if(i==0) cout << "AC" << " " << "x" << " " << ans[i] << endl;
    else if(i==1) cout << "WA" << " " << "x" << " " << ans[i] << endl;
    else if(i==2) cout << "TLE" << " " << "x" << " " << ans[i] << endl;
    else if(i==3) cout << "RE" << " " << "x" << " " << ans[i] << endl;
  }
}

Measured memory_bytes: 3628
s = input()
k = int(input())
ans = 0
cnt = 0
ans_fin = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        cnt = cnt +1
        if i == len(s)-2:
            if cnt%2 == 1:
                ans = ans + int((cnt+1)/2)
            else:
                ans = ans + int(cnt/2)
    else:
        if cnt%2 == 1:
            ans = ans + int((cnt+1)/2)
            cnt = 0
        elif (cnt%2 == 0 and not(cnt == 0)):
            ans = ans + int(cnt/2)
            cnt = 0
        else:
            pass
ans_fin = ans*k
#print(ans_fin)
if not(s[0] == s[len(s)-1]):
    pass
elif len(s) == 1:
    if k%2 ==0:
        ans_fin = int(k/2)
    else:
        ans_fin = int((k-1)/2)
elif len(set(s)) == 1:
    if (len(s)*k)%2 == 0:
        ans_fin = int((len(s)*k)/2)
    else:
        ans_fin = int((len(s)*k-1)/2)
else:
    cnt2 = 0
    cnt3 = 0
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            cnt2 = cnt2 + 1
        else:
            break
    for i in range(len(s)-1):
        if s[len(s)-1-i] == s[len(s)-i-2]:
            cnt3 = cnt3 + 1
        else:
            break
#    print(cnt2,cnt3)
    if (cnt2%2 ==0 and cnt2 >0) and(cnt3%2 == 0 and cnt3>0):
        ans_fin = ans_fin + (k-1)
    if cnt2 == 0 and cnt3 == 0:
        ans_fin = ans_fin + (k-1)
print(ans_fin)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  int N,C[500],S[500],F[500];
  cin>>N;
  int now=0;
  FOR(i,0,N-1){
    cin>>C[i]>>S[i]>>F[i];
  }
  FOR(i,0,N){
    int now=0;
    FOR(j,i,N-1){
      if(S[j]<now){
        int X=S[j];
        while(X<now){
          X+=F[j];
        }
        now=X;
      }else{
        now=S[j];
      }
      now+=C[j];
    }
    cout<<now<<endl;
  }
  return 0;
}


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

double PI=3.141592653589793;

int main()
{
    double a,b;
    int h,m;
    cin >> a >> b >> h >> m;

    int abstime = h * 60 + m;

    double hs = (double)abstime * 0.5 * PI / 180;
    double ms = (double)m * 6 * PI / 180;

    double hx = cos(hs) * a, hy = sin(hs) * a;
    double mx = cos(ms) * b, my = sin(ms) * b;

    double ans = sqrt((hx - mx) * (hx - mx) + (hy - my) * (hy - my));
     cout << fixed << setprecision(15) << ans << endl;
}


Measured memory_bytes: 4160
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

btc = 380000
n = getN()
ans = 0
for i in range(n):
    x,u = input().split()
    x = float(x)
    if u == "JPY":
        ans += x
    else:
        ans += x * btc

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<vector>
#define MAX 104800
#define REP(i,s,n) for(int i=s;i<=n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
bool prime[MAX];
vector<int> p;
int mMAX = MAX-10;

void eratos(){
  rep(i,mMAX)prime[i] = false;
  for(int i=3;i<=mMAX;i+=2)prime[i] = true;
  prime[2] = true;
  int lim = sqrt((double)mMAX)+1;
  for(int i=3;i<=lim;i+=2){
    if(!prime[i])continue;
    for(int j=i+i;j<=mMAX;j+=i)prime[j] = false;
  }
  p.push_back(2);
  for(int i=3;i<=mMAX;i+=2){
    if(prime[i])p.push_back(i);
  }
}


int main(){
  int n;
  eratos();

  while(cin >> n && n){
    long long sam=0;
    rep(i,n-1){
      sam+=p[i];
    }
    cout << sam << endl;
  }
  return 0;
}

Measured memory_bytes: 1420
use std::cmp;

fn main(){
  let n: usize = read();
  let mut plan: Vec<Vec<u32>> = vec![vec![0; 3]; n];
  
  for i in 0 .. n {
    plan[i] = read_vec();
  }

  let mut hp: Vec<Vec<u32>> = vec![vec![0; 3]; n];
  
  hp[0][0] = plan[0][0];
  hp[0][1] = plan[0][1];
  hp[0][2] = plan[0][2];

  for i in 1 .. n {
    hp[i][0] = plan[i][0] + cmp::max(hp[i-1][1], hp[i-1][2]);
    hp[i][1] = plan[i][1] + cmp::max(hp[i-1][0], hp[i-1][2]);
    hp[i][2] = plan[i][2] + cmp::max(hp[i-1][0], hp[i-1][1]);
  }
  
  println!("{}", cmp::max(cmp::max(hp[n-1][0], hp[n-1][1]), hp[n-1][2]));
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


Measured memory_bytes: 14588
fun main(args: Array<String>) {
    abc073b()
}

fun abc073b() {
    val n = readLine()!!.toInt()
    val lrList = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }
        .map { Pair(it[0], it[1]) }

    val answer = lrList.sumBy { it.second - it.first + 1 }

    println(answer)
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
vector<ll> a;

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

  cin>>n;
  a.resize(n);
  multiset<ll> st;
  rep(i,n){
    cin>>a[i];
    st.insert(-a[i]);
  }

  ll res=0;
  while(st.size()){
    ll c=-(*st.begin()); st.erase(st.find(-c));
    for(ll i=2;i<=2e9;i*=2LL){
      if(i-c<=0)continue;
      if(st.lower_bound(-(i-c))==st.end())continue;
      ll d=-(*st.lower_bound(-(i-c)));
      if(c+d==i){
        st.erase(st.find(-d));
        res++;
        break;
      }
    }
  }

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


Measured memory_bytes: 11264
import sys
str = ""
for line in sys.stdin:
	str = line

numbers = str.split()

answer = 0
stackList = []

for number in numbers :

    if number == '+' :
        answer = int(stackList.pop()) + int(stackList.pop())
        stackList.append(answer)
    elif number == '-' :
        x = int(stackList.pop())
        y = int(stackList.pop())
        answer = y - x
        stackList.append(answer)
    elif number == '*' :
        answer = int(stackList.pop()) * int(stackList.pop())
        stackList.append(answer)
    else :
        stackList.append(number)

print(answer)


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

int main(){
  int N;
  cin >> N;
  for(int X=0;X<N+1;X++){
    int a=X*1.08;
    if(N==a){
	  cout << X << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  int x, y, z, xx;
  int f_n = 0;
  int cnt = 0;
  
  for (int i = 1; i < n+1; i++) {
    // 1～Nまでforループし、計算式とNが一致する数をcntでカウント
    cnt = 0;
    
    for (x = 1; x < i; x++) {
      if((x*x) > i) break; // 計算量削減
      
      for (y = 1; y < i; y++) {
        if((x*x+y*y+x*y) > i) break; // 計算量削減
        
        for (z = 1; z < i; z++) {
          if((x*x+y*y+z*z+x*y+y*z+z*x) > i) break; // 計算量削減
          
          f_n = x*x + y*y + z*z + x*y + y*z + z*x;
          //cout << "debug n:" << i << ", f_n:" << f_n << endl;
          if(f_n == i) {
            cnt = cnt + 1;
            //cout << "debug x:y:z - " << x << ":" << y << ":" << z << endl;
            //cout << "debug f_n - " << f_n << endl;
          }
        }
      }
    } // for x
    
    cout << cnt << endl;
  } // for i
}

Measured memory_bytes: 3548
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a, b, c, l[10], gl[10], buf[4];

int main(){
	cin >> n >> a >> b >> c;
	for(ll i = 1; i <= n; i++){cin >> l[i];}
	
	ll ans = a+b+c;
	for(ll bit = 0; bit < (1<<2*n); bit++){
		for(ll i = 1; i <= n; i++){
			if(bit&(1<<2*i-2) && bit&(1<<2*i-1)){gl[i] = 3;}
			if(bit&(1<<2*i-2) && !(bit&(1<<2*i-1))){gl[i] = 1;}
			if(!(bit&(1<<2*i-2)) && bit&(1<<2*i-1)){gl[i] = 2;}
			if(!(bit&(1<<2*i-2)) && !(bit&(1<<2*i-1))){gl[i] = 0;}
		}
		
		ll mp = -30;
		ll check = 0;
		memset(buf, 0, sizeof(buf));
		for(ll i = 1; i <= n; i++){
			buf[gl[i]] += l[i];
			if(gl[i] <= 2){
				mp += 10;
				check |= (1<<gl[i]);
			}
		
		}
		sort(buf, buf+3);
		
		mp += abs(c-buf[0]);
		mp += abs(b-buf[1]);
		mp += abs(a-buf[2]);
		
		if(check == (1<<3)-1){ans = min(mp, ans);}
		//cout << gl[1] << gl[2] << gl[3] << " " << bit << endl;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int,input().split()))

a.sort()
for i in range(1,n,2):
    if a[i] + a[i-1] < 0:
        a[i]*=(-1)
        a[i-1]*=(-1)
    else:
        break
    #print((a[i],a[i-1]))
print(sum(a))

Measured memory_bytes: 14284
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int H, W;
    scanf("%d %d",&H,&W);
    
    int i,j;
    while (1)
    {
        if (H == 0 && W == 0) {
            break;
        }
        else {
            for (i=0; i<H; i++) {
                for (j=0; j<W; j++) {
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
            scanf("%d %d",&H,&W);
        }
    }
     return 0;
}

Measured memory_bytes: 572
s = input()
size = len(s)

for i in range(size):
    if s[i] == 'A':
        aa = i
        break

for i in range(size):
    if s[size - 1 - i] == 'Z':
        zz = size - 1 - i
        break

print(zz - aa + 1)


Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
   int r,g,b;
   cin>>r>>g>>b;
   int cnt=r*100+g*10+b;
   if(cnt%4==0) cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>
#define pi acos(-1.0)
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=i;
	}
	printf("%d\n",sum);
	return 0;
}

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

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

	int H,N,A,sum=0;

	cin >> H >> N;

	for(int i=0;i<N;i++)
	{
		cin >> A;
		sum+=A;
	}

	if(sum>=H)
	{
		cout << "Yes" << '\n';
	}
	else
	{
		cout << "No" << '\n';
	}

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,l,ans,flag,ok;
int deli[206];
bool cmp(int a,int b){
	return a<b;
}
bool cnp(int a,int b){
	return a>b;
}
int main(){
	cin>>n>>l;
	for(int i=1;i<=n;i++){
		deli[i]=i+l-1;
		if(deli[i]==0){
			flag++;
		}
		if(deli[i]<0){
			ok++;
		}
	}
		if(flag==1){
			for(int i=1;i<=n;i++){
				ans+=deli[i];
			}
			cout<<ans;
			return 0;
		}
		
		if(l>0){
			sort(deli+1,deli+n+1,cmp);
			for(int i=2;i<=n;i++){
			ans+=deli[i];
			}
			cout<<ans;
			return 0;
		}
		
		if(ok==n){
			sort(deli+1,deli+n+1,cnp);
			for(int i=2;i<=n;i++){
			ans+=deli[i];
			}
			cout<<ans;
			return 0;
		}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main(){
	int n, m; cin >> n >> m;
	n--;m--;
  	cout << n * m << endl;
  	return 0;
}


Measured memory_bytes: 256
li=  list(map(int,input().split()))	       
X, K, D=li[0], li[1], li[2]
if abs(X)>K*D:
    print(min(abs(X-K*D), abs(X+K*D)))
else:
    X=abs(X)
    N=X//D
    Min=10**16
    n=0
    for i in range(N-1, N+2):
        M=abs(X-i*D)
        if M<Min:
            Min=M
            n=i
    if (K-n)%2==0:
        print (Min)
    else:
        print(min(abs(Min+D), abs(Min-D)))

Measured memory_bytes: 9216
# 094b

def atc_094b(NMX: str, Ai_input: str) -> int:
    N, M, X = map(int, NMX.split(" "))
    Ai = [int(ai) for ai in Ai_input.split(" ")]

    up_cost = 0
    down_cost = 0

    for i in range(X + 1, N + 1):
        if i in Ai:
            up_cost += 1
    for i in range(X - 1, 0, -1):
        if i in Ai:
            down_cost += 1
    return min(up_cost, down_cost)


NMX_input_value = input()
Ai_input_value = input()
print(atc_094b(NMX_input_value, Ai_input_value))


Measured memory_bytes: 9128
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)                \
    cerr << #v << ": ";             \
    REP(__i, (v).size())            \
        cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main()
{
    ios::sync_with_stdio(false);
    int N, X;
    cin >> N >> X;
    vi L(N);
    REP(i, N) cin >> L[i];
    partial_sum(L.begin(), L.end(), L.begin());

    int res = 1;
    for (auto l: L) {
        if (l <= X) res++;
        else break;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    double n,k,ans=0;
    cin>>n>>k;
    for(int i=1; i<=n; ++i){
        if(i>=k){
            ans+=(double)1/n;
            continue;
        }
        int c=0;
        int a=i;
        while(a<k){
            a*=2;
            c++;
        }
        double b=1;
        rep(j,c){
            b*=(double) 1/2;
        }
        ans+=b/n;
    }
    cout<<ketasuu(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
k = int(input())
import math
from functools import reduce

l = []
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

for i in range(1, k+1):
    for j in range(1, k+1):
        for m in range(1, k+1):
            n = gcd(i, j, m)
            l.append(n)
print(sum(l))

Measured memory_bytes: 189316
def f(x):
  a=x; c=0
  while 1:
    b=[a.count(e) for e in a]
    if a==b: return c," ".join(map(str,a))
    else: a=b; c+=1

while 1:
  if input()==0: break
  c,s=f(map(int,raw_input().split()))
  print c; print s

Measured memory_bytes: 4220
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define maxn	500005
#define mod		int(1e9+7)
#define db		double
#define ll		long long
#define si 		stack<int>
#define qi 		queue<int>
#define vi 		vector<int>
#define pi 		pair<int, int>
ll powmod(ll a, ll b) {
	ll res = 1; a %= mod;
	for (; b; b >>= 1)
		res = (res * ((b & 1) ? a : 1)) % mod,
		a = a * a % mod;
	return res;
}
ll gcd(ll a, ll b) {
	return b ? gcd(a, b) : a;
}
/** GRAPH
int edgenum, head[maxn], vet[2 * maxn], nxt[2 * maxn], wt[2 * maxn];
void addedge(int u, int v) {
	edgenum ++;
	vet[edgenum] = v;
	nxt[edgenum] = head[u];
	head[u] = edgenum;
}
void addedge(int u, int v, int w) {
	edgenum ++;
	vet[edgenum] = v;
	nxt[edgenum] = head[u];
	head[u] = edgenum;
	wt[edgenum] = w;

}
GRAPH **/

using namespace std;
int main() {
	ll x;
	cin >> x;
	for(ll i = 0, m = 100; ; i ++, m = m * 1.01) {
		// cout << m << endl;
		if(m >= x) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
var
 i,n,l,r:longint;
 a,s:array[0..100001] of longint;
function sushu(x:longint):boolean;
var
 i:longint;
begin
 for i:=2 to trunc(sqrt(x)) do
  if x mod i=0 then exit(false);
 exit(true);
end; 
begin
 for i:=3 to 100000 do
  begin
   if sushu(i) and sushu((i+1) div 2) then
    inc(s[i]);
   s[i]:=s[i]+s[i-1];
  end;
 readln(n);
 for i:=1 to n do
  begin
   readln(l,r);
   a[i]:=s[r]-s[l-1];
  end;
 for i:=1 to n do writeln(a[i]);
end.

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

using namespace std;
#define PI              3.1415926536

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define REP(i,n) for(i=0;i<n;i++)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

bool f(int x, int y)
{
	return x > y;
}
void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int n, m;
int a[100][100];
int vis[100][100];
int x;
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
bool safe(int x, int y)
{
	return (x >= 0 && y >= 0 && x < n && y < m && vis[x][y] == 0 && a[x][y] == 1);
}
void dfs(int i, int j)
{
	x++;

	vis[i][j] = 1;
	int k;
	for (k = 0; k < 8; k++)
	{
		int p = i + dx[k];
		int q = j + dy[k];
		if (safe(p, q) )
			dfs(p, q);
	}


}

int32_t main()
{
	
	string s;
	cin >> s;
	int c = 0;
	int i;
	int maxi = INT_MIN;
	for (i = 0; i < 3; i++)
	{
		c = 0;
		while (s[i] == 'R' && i < 3)
		{
			i++;
			c++;
		}
		maxi = max(maxi, c);
	}
	cout << maxi;

}





Measured memory_bytes: 3640
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {



	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);


String[] S=sc.nextLine().split(" ");
int X=Integer.parseInt(S[0]);
int Y=Integer.parseInt(S[1]);
boolean[] goodx=new boolean[110];
boolean[] goody=new boolean[110];

String[] board=new String[110];

for(int i=0;i<X;i++){
board[i]=sc.nextLine();
}
for(int i=0;i<X;i++){
for(int j=0;j<Y;j++){
String[] temp=board[i].split("");
if(temp[j].equals("#")){
goodx[i]=true;
goody[j]=true;
}
}
}
for(int i=0;i<X;i++){
if(goodx[i]){
for(int j=0;j<Y;j++){
if(goody[j]){
String[] tem=board[i].split("");
System.out.print(tem[j]);
}
}
System.out.println();
}



}

}




}





Measured memory_bytes: 65508
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int cnt=0,n;
	scanf("%d",&n);
	for(int i=0,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		if(x==y) ++cnt;
		else cnt=0;
		if(cnt==3) break;
	}
	if(cnt==3) printf("Yes");
	else printf("No");
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int sx, sy, tx, ty; scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
  int dx = tx - sx, dy = ty - sy;
  string ans;
  ans += string(dx, 'R') + string(dy, 'U') + string(dx, 'L') + string(dy, 'D');
  ans += string(1, 'D') + string(dx + 1, 'R') + string(dy + 1, 'U') + string(1, 'L');
  ans += string(1, 'U') + string(dx + 1, 'L') + string(dy + 1, 'D') + string(1, 'R');

  printf("%s\n", ans.c_str());
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        int v;
        cin >> v;
        vec.at(i) = v;
    }
    sort(vec.begin(), vec.end());
    double answer = vec.at(0);
    for (int i = 1; i < N; i++) {
        answer = (answer + vec.at(i)) / 2;
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n,m=MI()
brs=[]
for i in range(m):
    brs.append(int(input()))
brs.append(0)
dp=[0 for i in range(n+2)]
dp[0]=0
dp[1]=1
i=2
while i<n+2:
    if i==brs[0]+1:
        dp[i]==0
        brs.remove(brs[0])
        #print(brs[0])
        i=i+1
    else:
        dp[i]=dp[i-1]+dp[i-2]
        i=i+1
print(dp[-1]%(10**9+7))


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

void solve() {
    double x; cin >> x;
    double y = 100;

    long long ans = 0;
    while (y < x) {
        y = floor(y *  1.01);
        ans++;
    }
    cout << ans << '\n';
}

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

    solve();
    return 0;
}


Measured memory_bytes: 3736
def floor(x)
  x |= x >> 1
  x |= x >> 2
  x |= x >> 4
  x |= x >> 8
  x |= x >> 16
  (x + 1) >> 1
end

def f(a, b)
  t = floor(b - a)

  a, b = -b, -a if b % t == 0
  c = (b / t) * t
    
  b == c ? 1 : f(a, c) + f(c, b)
end

n = STDIN.gets.to_i
n.times do
  s, d = STDIN.gets.split.map(&:to_i)
  puts f(s, d)
end

Measured memory_bytes: 8636
#include <stdio.h>

int main(void)
{
	int n;
	int i, j;
	int flag[5];
	int f;
	
	f = 0;
	while (scanf("%d", &n) != EOF){
		if (f != 0){
			printf("\n");
		}
		else {
			f = 1;
		}
		
		for (i = 0; i < 5; i++){
			flag[i] = 0;
		}
		
		if (n / 10000 >= 5){
			flag[0] = 1;
		}
		if (n / 1000 % 10 >= 5){
			flag[1] = 1;
		}
		if (n / 100 % 10 >= 5){
			flag[2] = 1;
		}
		if (n / 10 % 10 >= 5){
			flag[3] = 1;
		}
		if (n % 10 >= 5){
			flag[4] = 1;
		}
		
		for (i = 0; i < 5; i++){
			if (flag[i] == 0){
				printf("*");
			}
			else {
				printf(" ");
			}
		}
		printf("\n");
		for (i = 0; i < 5; i++){
			if (flag[i] == 1){
				printf("*");
			}
			else {
				printf(" ");
			}
		}
		printf("\n");
		printf("=====\n");
		
		
		flag[0] = n / 10000 % 5;
		flag[1] = n / 1000 % 5;
		flag[2] = n / 100 % 5;
		flag[3] = n / 10 % 5;
		flag[4] = n % 5;
		
		for (i = 0; i < 5; i++){
			for (j = 0; j < 5; j++){
				switch (flag[j]){
				  case 0:
				  	if (i == 0){
						printf(" ");
				  	}
					else {
						printf("*");
					}
					break;
					
				  case 1:
				  	if (i == 1){
						printf(" ");
				  	}
					else {
						printf("*");
					}
					break;
					
				  case 2:
				  	if (i == 2){
						printf(" ");
				  	}
					else {
						printf("*");
					}
					break;
					
				  case 3:
				  	if (i == 3){
						printf(" ");
				  	}
					else {
						printf("*");
					}
					break;
					
				  case 4:
				  	if (i == 4){
						printf(" ");
				  	}
					else {
						printf("*");
					}
					break;
				}
			}
			printf("\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
	ll n;
	cin>>n;
	if(n%1000==0)
	{
		cout<<"0\n";
		return ;
	}
	else
	{
		cout<<(n/1000+1)*1000-n<<"\n";
	}
}
int main()
{

   // int t;
   // cin>>t;
   // while(t--)
   // {
    	solve();
   // }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
ll get(ll n) {
    ll cnt = 0;
    while(n) {
        n/=5;
        cnt += n;
    }
    return cnt;
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    ll n; cin >> n;
    if(n&1) cout << 0 << endl;
    else
    cout << get(n/10) + n/10 << endl;
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
typedef long long ll;

const ll Inf = 1L << 61;

int main(int argc, char *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int V, E;
  cin >> V >> E;
  ll d[V][V];
  REP(i,V) REP(j,V) {
    if (i == j) d[i][j] = 0;
    else d[i][j] = Inf;
  }
  REP(i,E) {
    ll s, t, c;
    cin >> s >> t >> c;
    d[s][t] = c;
  }
  REP(k,V) REP(i,V) REP(j,V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  REP(i,V) if (d[i][i] < 0) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }
  REP(i,V) REP(j,V) {
    if (d[i][j] >= Inf >> 10) cout << "INF";
    else cout << d[i][j];
    if (j < V-1) cout << ' ';
    else cout << '\n';
  }
  cout << flush;

  return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    pair<ll,ll> b = {0,0};
    ll time = 0;
    rep(i,n){
        ll t;
        pair<ll,ll> p;
        cin >> t >> p.first >> p.second;
        t -= time;
        ll dist = abs(b.first - p.first) + abs(b.second - p.second);
        if(dist > t || !(t%2 == dist%2)){
            cout << "No\n";
            return 0;
        }
        b = p;
        time += t;
    }
    cout << "Yes\n" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


char c;

int main(){
	cin >> c;
	
	if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
		cout << "vowel" << endl;
	else cout << "consonant" << endl;
	
	return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

ll gcd(ll a, ll b){
	if(b ==0) return a;

	gcd(b, a%b);
}

ll lcm(ll a, ll b){

	return a*b/gcd(a,b);
}

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

	int A,B;cin>>A>>B;

	writeln(lcm(A,B));


}




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

using namespace std;

int N, A, B, C;
vector<int> L;


int rec(int i, int a, int b, int c){
    if(i == N){
        if(a == 0 || b == 0 || c == 0){
            return 1e9;
        }else{
            return abs(a - A) + abs(b - B) + abs(c - C);
        }
    }

    int res;
    res = min({ rec(i+1, a, b, c),
                rec(i+1, a + L[i], b, c) + (a ? 10 : 0),
                rec(i+1, a, b + L[i], c) + (b ? 10 : 0),
                rec(i+1, a, b, c + L[i]) + (c ? 10 : 0)
                });
    
    return res;
}


int main() {
    cin >> N >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i< N; ++i){
        cin >> L[i];
    }
    
    cout << rec(0, 0, 0, 0) << endl;


    return 0;
}

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

# A内の整数値を用いて作られる最小の整数を求めよ、という問題


def gcd(a, b):
    """
    自然数a, b の最大公約数を求める
    """
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


ans = gcd(A[0], A[1])
for i in range(1, N):
    ans = min(ans, gcd(ans, A[i]))


print(ans)

Measured memory_bytes: 62704
(N,K),A = $<.map{ _1.split.map &:to_i}
A.unshift 0

n = 1
s = 0
Step = [nil] * (N+1)
Route = []
until Step[n] 
    Route << n
    Step[n] = s
    s += 1
    n = A[n]
end

k = K<Route.size ? K : (K - Step[n]) % (s-Step[n]) + Step[n]
p Route[k]

Measured memory_bytes: 31148
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;                       // to be set
    vector<Abel> dat;
    
    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }
    
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

template<class T> long long inversion_number(const vector<T> &a) {
    int n = (int)a.size();
    vector<T> b = a;
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    
    long long res = 0;
    BIT<int> bit(n);
    for (int i = 0; i < n; ++i) {
        int order = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
        ++order;
        res += bit.sum(1,order);
        bit.add(order, 1);
    }
    return res;
}

int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  ll lb = 0, ub= INF;
  while (ub-lb > 1){
    ll mb = (ub + lb)/2;
    vector<ll> sum(n+1);
    for(int i = 0; i < n; ++i){
      int v = -1;
      if(a[i]<=mb)v = 1;
      sum[i+ 1]= sum[i]+ v;
    }
    ll num = inversion_number(sum);
    if(num>n * (n+ 1 )/2/2)ub = mb;
    else lb = mb;
  }
  cout << ub << endl;
}


Measured memory_bytes: 3040
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

int H,A;

int ans;
 
void solve(){
	ans = (H-H%A)/A+(H%A!=0);
}
 
int main(){
	cin>>H>>A;

	solve();

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
 
/*Coding Space*/
int main(){
  string s; cin >> s;
  if(s == "A") cout << "T";
  if(s == "T") cout << "A";
  if(s == "C") cout << "G";
  if(s == "G") cout << "C";
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static final int like = 753;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		HashSet<Integer> set = new HashSet<>();
		for(int i = 0; i < n; i++) {
			set.add(sc.nextInt());
		}
		out.println(set.size());
		
		out.close();
	}
	


static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

ll B[1007],D[1007];

int main() {
    ll N,h=1,day=0;cin >> N;
    ll A[1007][1007];
    ll a;
    rep(i,N){
        rep(j,N-1){
            cin >> A[i][j];
        }       
    }
    while(h>0){
        h=0;
        rep(i,N){
            if( A[A[i][D[i]]-1][D[A[i][D[i]]-1]]==i+1 && i<=A[i][D[i]]-1){
                B[A[i][D[i]]-1]++;
                D[i]++;
                h++;
            }
            else if(B[i]>0){
                D[i]++;
                h++;
            }
        }
        rep(i,N){
            B[i]=0;
        }
        day++;
    }  
    int k=0;
    rep(i,N){
        if(D[i]!=N-1){
            k++;
        }
    }
    cout << (k==0 ? day-1 : -1) << endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
 
/* short */
#define pb push_back
#define print(x) cout << x << '\n'
 
/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = INT_MAX;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}


signed main()
{
  //ios::sync_with_stdio(false);
  int n;

  cin >> n;
  while (n--){
    int h, m;
    scanf("%d:%d", &h, &m);
    double  diff = fabs((h % 12 + m / 60.0) * (360 / 12.0) -  m * 360 / 60.0);

    if (180.0 < diff) diff = 360 - diff;
    if (diff < 30.0){
      print("alert");
    } else if (90.0 <= diff && diff <= 180.0){
      print("safe");
    } else {
      print("warning");
    }
    //cout << "diff: " << diff << endl;
  }

  return (0);
}

Measured memory_bytes: 1208
N, X, M = list(map(int, input().split()))
loop = []
A_set = set()
# find loop
while not X in A_set:
    loop.append(X)
    A_set.add(X)
    X = (X*X)%M

if loop[-1] == 0:
    print(sum(loop))
else:
    ans = 0

    # ループになる前の部分
    loop_L = loop.index(X)
    ans += sum(loop[0:loop_L])
    N -= loop_L

    # ループ部
    loop = loop[loop_L:]
    loop_size = len(loop)
    loop_S = sum(loop)
    ans += loop_S*(N//loop_size)

    # 端数
    ans += sum(loop[:N%loop_size])

    print(ans)

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

int main() {
    int n, m;
    map<string, int> cnt;
    string x;
    cin >> n;
    set<string> all;
    for (int i=0; i<n; i++) {
        cin >> x;
        all.insert(x);
        cnt[x]++;
    }
    cin >> m;
    for (int i=0; i<m; i++) {
        cin >> x;
        all.insert(x);
        cnt[x]--;
    }
    int ans=0;
    for (auto y : all) {
        if (cnt[y] > ans) ans = cnt[y];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next()), count = 0, i = 2, sum = 0;
            
            while(count<n-1){
            	if(i%2 == 0 || i%3 == 0){
            		System.out.print(i + " ");
            		sum += i;
            		count++;
            	}
            	i++;
            }
            
            for(int j = 6 - sum%6; ; j += 6){
            	if((j>=i || (j%2 != 0 && j%3 != 0)) && gcd(j, sum) != 1){
                    System.out.println(j);
                    sc.close();
                    return;
            	}
            }
        }
        
        public static int gcd(int a, int b) {
            return b == 0 ? a : gcd(b, a % b);
         }
    }
	

Measured memory_bytes: 31292
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();

		if (x - a >= 0 && b - (x - a) >= 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

		sc.close();

	}

}


Measured memory_bytes: 35576
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
b.reverse()
c = 0
d = 0
for i in range(0,len(a),2):
    c += b[i]
for j in range(1,len(a),2):
    d += b[j]
    
print(c-d)

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

#define int long long

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

int N, A, B;

signed main() {
    cin >> N >> A >> B;
    cout << ((((N - 1) * B + A) - ((N - 1) * A + B) >= 0) ? ((N - 1) * B + A) - ((N - 1) * A + B) + 1 : 0) << endl;
    return 0;
}


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

lst = []

for i in range(n):
    s, p = input().split()
    lst.append([s, 100 - int(p), i + 1])
    # ([])でも(())でもいい(?)
# print(lst)

# 番号はただのおまけ
# 最初の順番の並びが,入れ替えた後に何番目だったかわかるだけ
lst.sort()
# lstの前の要素から優先的に昇順(1,2,3...a,b,c...)にsortされる

# print(lst)
for i in lst:
    print(i[2])

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, K, ans = 1e18;

int Solve(ll num, ll turn){
  if (turn == N){
    ans = min(ans, num);
    return 0;
  }

  Solve(num * 2, turn + 1);
  Solve(num + K, turn + 1);
  return 0;
}

int main(){
  cin >> N >> K;
  Solve(1, 0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
map<int,bool> MAP;

int main(){

	scanf("%d",&N);

	int tmp;
	bool FLG = true;

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

		scanf("%d",&tmp);
		if(!FLG)continue;

		auto at = MAP.find(tmp);
		if(at != MAP.end()){

			FLG = false;
		}else{

			MAP[tmp] = true;
		}
	}

	if(FLG){

		printf("YES\n");
	}else{

		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 9600
#include<iostream>
using namespace std;
long long gcd(long long a, long long b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
    int t;
    long long a,ret=1;
    cin >> t;
    while(t--){
        cin >> a;
        ret=ret/gcd(ret,a)*a;
    }
    cout << ret<< endl;
    return 0;
}

Measured memory_bytes: 256