akhauriyash/Code-Regression huggingface dataset:
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(a,b);
  REP(i,a){
    REP(j,b){
      IN(s);
      if(s == "snuke"){
        char ch = (char)('A'+j);
        cout << ch << i+1 << endl;
      }
    }
  }
}

Measured memory_bytes: 256
n = gets.to_i
t = gets.split.map(&:to_i).unshift(0)
v = gets.split.map(&:to_i).unshift(0)

for i in 0..n-1
  t[i+1] += t[i]
end

b = Array.new(2*t[n]+1){|i|[i,2*t[n]-i].min*0.5}

for i in 1..n
  for j in t[i-1]*2..t[i]*2
    b[j] = [b[j],v[i]].min
  end
  temp = 0.0
  (t[i-1]*2).downto(0) do |j|
    b[j] = v[i]+temp if b[j] > v[i]+temp
    temp += 0.5
  end
  temp = 0.0
  for j in t[i]*2..2*t[n]
    b[j] = v[i]+temp if b[j] > v[i]+temp
    temp += 0.5
  end
end

p b.inject(:+)/2

Measured memory_bytes: 2044
#include <iostream>
using namespace std;
#define abs(v) ((v>0)?(v):(-(v)))

int main() {
  int h, w, d, q;
  int x[90000];
  int y[90000];
  int mp[90000];
  cin >> h >> w >> d;
  int tmp;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> tmp;
      x[tmp-1] = j; y[tmp-1] = i;
    }
  }
  for (int i = d; i < h*w; ++i)
    mp[i] = mp[i-d] + abs(x[i] - x[i-d]) + abs(y[i] - y[i-d]);
  cin >> q;
  int l, r;
  while(q--) {
    cin >> l >> r;
    cout << mp[r-1] - mp[l-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a = [int(input()) for _ in range(5)]
    k = int(readline())

    if a[4] - a[0] <= k:
        print("Yay!")
    else:
        print(":(")

if __name__ == '__main__':
    main()


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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

using namespace std;

int main() {
	SINT32 N;
	UINT64 K;
	UINT64 ANS = 0;
	UINT64 ANS2 = 0;
	cin >> N >> K;

	vector<UINT64> DATA(N);

	vector<int> ZERO(64);
	vector<int> ICHI(64);

	for (SINT32 i = 0; i < N; i++) {
		cin >> DATA[i];
	}

	for (SINT32 i = 0; i < N; i++) {
		for (SINT32 j = 0; j < 64; j++) {
			if (((DATA[i] >> j) % 2) == 1) {
				ICHI[j] = ICHI[j] + 1;
			} else {
				ZERO[j] = ZERO[j] + 1;
			}
		}
	}

	for (SINT32 i = 63; i >= 0; i--) {
		if ( ZERO[i] > ICHI[i]) {
			if ((ANS + pow(2,i)) <= K) {
				ANS = ANS + pow(2,i);
			}
		}
	}

	for (SINT32 i = 0; i < N; i++) {
		ANS2 = ANS2 + (ANS^DATA[i]);
	}

	
	cout << ANS2 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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(){
    int n,k,r,s,p;cin >> n >> k >> r >> s >> p;
    string t;cin >> t;
    int ans=0;
    map<char,char> win;
    win['r']='p';
    win['s']='r';
    win['p']='s';
    map<char,int> reward;
    reward['r']=r;
    reward['s']=s;
    reward['p']=p;
    vector<char> what(n);
    vector<char> next={'r','s','p'};
    rep(i,n){
        if(i<k){
            what[i]=win[t[i]];
            ans+=reward[win[t[i]]];
        }
        else{
            bool ok=false;
            set<char> ng;
            rep(j,3){
                if(next[j]==what[i-k]){
                    ng.insert(next[j]);
                    continue;
                }
                if(i+k<n&&next[j]==win[t[i+k]]&&win[t[i]]!=win[t[i+k]]){
                    ng.insert(next[j]);
                    continue;
                }
                if(next[j]==win[t[i]]){
                    ans+=reward[win[t[i]]];
                    what[i]=next[j];
                    ok=true;
                }
            }
            if(!ok){
                rep(j,3){
                    if(!ng.count(next[j])){
                        what[i]=next[j];
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
	int N = 0;
	int sum = 0, max = 0;
	scanf("%d", &N);
	int H[100000];
	for (int i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}
	for(int j=0;j<N-1;j++){
		if (H[j] >= H[j + 1]) {
			sum++;
		}
		else {
			if (max < sum) {
				max = sum;
			}
			sum = 0;
		}
	}
	if (max < sum) {
		max = sum;
	}
	printf("%d\n", max);
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
    int a[3];
    int k;
    int max=0;
    int sum=0;
    for(int i=0;i<3;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&k);
    for(int i=0;i<3;i++){
        sum=sum+a[i];
        if(max<=a[i]){
            max=a[i];
        }else{

        }
    }
    int x=sum-max;
    for(int i=1;i<=k;i++){
        max=max*2;
    }
    printf("%d\n",x+max);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
  
#define mp make_pair
#define s second 
#define f first
#define ll long long
#define pb push_back
  
using namespace std;
/*
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  */
const int inf = 2e9+7;
const int N = 2e6;

int ans=0;

int used[N], d[N];
 
int xx[8]={1, 1, -1, -1, 2, 2, -2, -2};
int yy[8]={2, -2, 2, -2, 1, -1, 1, -1};

vector <int> g1[N], g2[N];

void dfs(int v){
	used[v]=1;
	for(auto to : g2[v]){
		if(!used[to]){
			dfs(to);	
		}
		d[v]=max(d[to]+1, d[v]);
	}
		
}

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		g1[b].pb(a);
		g2[a].pb(b);
	}	
	for(int i=1; i<=n; i++){
			dfs(i);

	}
	for(int i=1; i<=n; i++){
//		cout << d[i] << " " ;
		ans=max(ans, d[i]);
	}
//	cout << endl;
	cout << ans;
	return 0;
}



Measured memory_bytes: 105088
def solve(k, a, b):
    if b - a > 2:
        t = k - a + 1
        if t % 2 == 0:
            c = (b-a) * (t // 2)
            c += a
        else:
            c = (b-a) * (t // 2)
            c += a + 1
        return max(k+1, c)
    else:
        return k+1

assert solve(4,2,6) == 7
assert solve(7,3,4) == 8
assert solve(314159265, 35897932, 384626433) == 48518828981938099

k, a, b = map(int, input().split())
print(solve(k, a, b))

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

vector<pair<int, int>> A;
vector<int> F[100001];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N, M;
	cin >> N >> M;
	A.resize(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i].first >> A[i].second;
		F[A[i].first].push_back(A[i].second);
	}
	for (int i = 1; i <= N; i++) {
		sort(F[i].begin(), F[i].end());
	}
	for (int i = 0; i < M; i++) {
		cout << setw(6) << setfill('0') << A[i].first << setw(6) << setfill('0') << upper_bound(F[A[i].first].begin(), F[A[i].first].end(), A[i].second) - F[A[i].first].begin() << '\n';
	}
	return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-5
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

int main() 
{
    fastio
    string s, t;
    cin>>s>>t;
    if(s == t.substr(0, s.length())) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3656
use std::io::{self, Read};
use std::str::FromStr;
pub struct Scanner<R: Read> {
    reader: R,
}
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let s = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok().expect("failed to parse token")
    }
}

fn main() {
    let sin = io::stdin();
    let sin = sin.lock();
    let mut sc = Scanner::new(sin);

    let q: usize = sc.read();
    let mut vals: Vec<i64> = vec![0; q];
    let mut idx: Option<usize> = None; 

    for _ in 0..q {
        let c: u32 = sc.read();
        match c {
            0 => {  // pushBack
                let x: i64 = sc.read();
                if let Some(i) = idx {
                    vals[i+1] = x;
                    idx = Some(i+1);
                } else {
                    vals[0] = x;
                    idx = Some(0);
                }
            },
            1 => {  //randomAccess
                let p: usize = sc.read();
                println!("{}", vals[p]);
            },
            2 => {  // popBack
                if let Some(i) = idx {
                    idx = Some(i-1);
                }
            },
            _ => {
                panic!("irregular query");
            }
        }
    }
}



Measured memory_bytes: 7096
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, string>
const int INF = INT_MAX / 2;
const int N = 100;


P split(string str){
    stringstream ss(str);
    string tmp;
    P ret;
    getline(ss, tmp, ',');
    ret.first = atoi(tmp.c_str());
    getline(ss, ret.second, ',') ;
    return ret;
}

int main(){
    string str;
    map<int, pair<int, int> > m;
    while(getline(cin, str) && str != ""){
        P tmp = split(str);
        m[tmp.first].first++;
    }
    while(getline(cin, str)){
        P tmp = split(str);
        m[tmp.first].second++;
    }
    vector< pair<int, int> > ans;
    for(map<int, pair<int, int> >::iterator it = m.begin(); it != m.end(); it++){
        int No = (*it).first, a = (*it).second.first, b = (*it).second.second;
        if(a != 0 && b != 0) ans.push_back( pair<int, int>(No, a + b) );
    }
    sort(ans.begin(), ans.end());
    REP(i, ans.size()) cout <<ans[i].first <<" " <<ans[i].second <<endl;
    return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <string.h>

static int
check (
  int * h
  )
{
  int i;

  for ( i = 2; ; ++i )
  {
    if ( h[ i - 1 ] != h[ i ] )   break ;
    if ( i == 9 && h[ i ] == 0 )  return ( 1 );
  }

  for ( i = 1; i <= 9; ++i )
  {
    if ( h[ i ] < 3 ) continue;

    h[ i ] -= 3;
    if ( check ( h ) ) return ( 1 );
    h[ i ] += 3;
  }

  for ( i = 3; i <= 9; ++i )
  {
    if ( h[ i - 2 ] < 1
      || h[ i - 1 ] < 1
      || h[ i ] < 1 ) continue ;

    --h[ i - 2 ];
    --h[ i - 1 ];
    --h[ i ];
    if ( check ( h ) ) return ( 1 );
    ++h[ i ];
    ++h[ i - 1 ];
    ++h[ i - 2 ];
  }

  return ( 0 );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  char puzzle[ 16 ];
  int i, j;

  while ( fgets ( puzzle, 16, stdin ) != NULL )
  {
    int disabled[ 10 ] = { 0 };
    int flg = 0;

    for ( i = 0; i < 13; ++i )
    {
      ++disabled[ puzzle[ i ] - '0' ];
    }

    for ( i = 1; i <= 9; ++i )
    {
      int test[ 10 ];

      if ( disabled[ i ] >= 4 ) continue ;

      ++disabled[ i ];
      for ( j = 1; j <= 9; ++j )
      {
        if ( disabled[ j ] < 2 )  continue;

        memcpy ( test, disabled, sizeof ( test ) );
        test[ j ] -= 2;
        if ( check ( test ) )
        {
          if ( flg++ ) putchar ( ' ' );
          printf ( "%d", i );
          break ;
        }
      }
      --disabled[ i ];
    }
    puts ( !( flg ) ? "0" : "" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>

int main(void){
    int count=0;
    char w[11], tmp[100], *eot="END_OF_TEXT";
    scanf("%s", w);
    while(1){
        scanf("%s", tmp);
        if(!strcmp(tmp, eot)) break;
        for(int i=0; tmp[i]!='\0'; i++){
            if(tmp[i]<='Z' && tmp[i]>='A') tmp[i]=tmp[i]-'A'+'a';
        }
        if(!strcmp(tmp, w)) count++;
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2040
N = int(input())
all_pattern = 10**N

not_using_nine_and_zero_pattern = 8**N
using_zero_pattern = all_pattern - 9**N
using_nine_pattern = all_pattern - 9**N

ans = -(all_pattern - not_using_nine_and_zero_pattern -
        using_nine_pattern - using_zero_pattern)

print(ans % (10**9+7))


Measured memory_bytes: 11964
#include<stdio.h>

int gcd(long long a ,long long b){
  if(b == 0){
    return a;
  }
  gcd(b,a%b);
}

int main(void){
  long long a , b;
  scanf("%lld %lld",&a,&b);
  if(a < b){
    long long  temp = a;
    a = b;
    b = temp;
  }
  int g = gcd(a,b);
  long long ans = b * a/g;

  printf("%lld\n",ans);

  return 0;   
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pii>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vi a(n,-1);
    rep(i,0,n)cin>>a[i];
    sort(a.begin(),a.end());
    vpii V;
    int cnt=0,key=-1;
    int p=0;
    while(p<n){
        if(cnt==0){
            key=a[p];
        }
        while(p<n&&key==a[p]){
            cnt++;
            p++;
        }
        pii t=make_pair(cnt,key);
        V.push_back(t);
        cnt=0;
    }
    sort(V.rbegin(),V.rend());
    int res=0;
    p=0;
    int c=0;

    while(p<V.size()){
        c+=V[p].first-1;
        c%=2;
        res++;
        p++;
    }
    cout<<res-c<<endl;
    return 0;
}




Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define int long long 
using namespace std;
 
int32_t main()
{
	int n,a,b;
	cin>>n>>a>>b;

	int ans=0;
	ans+=(min(n%(a+b),a));

	int k = n/(a+b);

	ans+=(k*a);	
	cout<<ans;
}


Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    N = int(input())
    ArareList = list(input())

    if "Y" in ArareList:
        print("Four")
    else:
        print("Three")

main()


Measured memory_bytes: 5120
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n, m;
    cin >> n >> m;

    vector<pair<int,int>> S;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        S.emplace_back(x, y);
    }

    vector<pair<int,int>> C;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        C.emplace_back(x, y);
    }

    auto dis = [&](long long x1, long long y1, long long x2, long long y2) {
        return abs(x1 - x2) + abs(y1 - y2);
    };

    for (int i = 0; i < n; ++i) {
        pair<long long, int> best{1LL << 60, 0};
        for (int j = 0; j < m; ++j) {
            auto d = dis(S[i].first, S[i].second, C[j].first, C[j].second);
            best = min(best, make_pair(d, j));
        }

        cout << best.second + 1 << '\n';
    }


    return 0;
}

Measured memory_bytes: 3540
import java.util.*;
	
	
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int A= sc.nextInt();
			int B = sc.nextInt();
			int res = 0;
			
			for (int i=1;i<=N;i++) {
				int sum = 0;
				for (int n =i;n>0;n/=10) {
					sum += n%10;
				}
			
				if(A<=sum && sum<=B){
					res = res + i;
					}
			}
			System.out.println(res);
			
			sc.close();
		}
		
	}


Measured memory_bytes: 21588
A,B,C,D,E,F = map(int,input().split())

xy = []
# 水
for Ai in range(0,F+1,100*A):
    for Bj in range(0,F-Ai+1,100*B):
        # x <= F
        x = Ai + Bj

        # 塩
        for Ci in range(0,(F-x)+1,C):
            Dj = 0
            y = Ci + Dj
            while x + y <= F:
                xy.append((x,y))
                Dj += D
                y += D

ans = (100*A,0)
node = 0
for x,y in xy:
    if x == y == 0:
        continue
    # 完全に溶けるか
    if (x//100) * E >= y:
        tmp = 100*y/(x+y)
        # 濃度の最大をとる
        if node < tmp:
            ans = (x+y, y)
            node = tmp

print(*ans)

Measured memory_bytes: 175956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=1000;
ll ans,t,a,w,tn,an=1,wn;

void keisan(){
	ll i,j;
	i=an/a;
	j=tn/t;
	if(an>a*i)i++;
	if(tn>t*j)j++;
	i=max(i,j);
	tn=i*t;
	an=i*a;
}
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	double ta,tnan;
	cin >> n;
	FOR(i,0,n){
		cin >> t >> a;
		if(i==0){
			tn=t;
			an=a;
		}else{
			keisan();
		}
	}
	cout << tn+an << endl;

	return 0;
}

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

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

  bool rev = false;
  string left = "";
  string right = "";

  while ( q-- > 0 ) {
    int t;
    cin >> t;
    if ( t == 1 ) {
      rev = !rev;
    }
    if ( t == 2 ) {
      int f;
      string c;
      cin >> f >> c;
      if ( f == 1 ) {
        if ( rev ) {
          right += c;
        } else {
          left += c;
        }
      }
      if ( f == 2 ) {
        if ( rev ) {
          left += c;
        } else {
          right += c;
        }
      }
    }
  }

  if ( !rev ) {
    reverse(left.begin(), left.end());
    s = left + s + right;
  } else {
    reverse(s.begin(), s.end());
    reverse(right.begin(), right.end());
    s = right + s + left;
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 4288
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

#define int long long

using namespace std;

long long r, c, n;
struct ff{
    int x1, y1, x2, y2;
};
ff a[500000];

int check_x(int x)
{
    return (x == 0 || x == r);
}

int check_y(int y)
{
    return (y == 0 || y == c);
}

const int KEK = 1e8 + 8;

int ss(int x, int y)
{
    if (y == 0)
        return x;
    if (x == r)
        return KEK + y;
    if (y == c)
        return 2 * KEK + r - x;
    if (x == 0)
        return 3 * KEK + c - y;
}

pair<int, int> on_border(ff A)
{
    if (check_x(A.x1) || check_y(A.y1))
    if (check_x(A.x2) || check_y(A.y2))
    {
        pair<int, int> aa = {ss(A.x1, A.y1), ss(A.x2, A.y2)};
        if (aa.first > aa.second)
            swap(aa.first, aa.second);
        return aa;
    }
    return {-1, -1};
}

signed main()
{
    cin >> r >> c >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i].x1 >> a[i].y1 >> a[i].x2 >> a[i].y2;
    vector<pair<int, int> > v;
    pair<int, int> NO = {-1, -1};
    for (int i = 0; i < n; i++)
    {
        //if (check_x(a[i].x1) || check_y(a[i].y1)) cout << ss(a[i].x1, a[i].y1) << endl;
        //if (check_x(a[i].x2) || check_y(a[i].y2)) cout << ss(a[i].x2, a[i].y2) << endl;
        if (on_border(a[i]) != NO)
        {
            v.push_back(on_border(a[i]));
        }
    }
    vector<pair<int, int> > check;
    for (int i = 0; i < v.size(); i++)
    {
        check.push_back({v[i].first, i});
        check.push_back({v[i].second, i});
    }
    sort(check.begin(), check.end());
    vector<int> st;
    for (int i = 0; i < check.size(); i++)
    {
        if (st.size() && check[i].second == st[st.size() - 1])
            st.pop_back();
        else
            st.push_back(check[i].second);
    }
    if (st.size() == 0)
    {
        cout << "YES";
        return 0;
    }
    st = {check[check.size() - 1].second};
    for (int i = 0; i < check.size() - 1; i++)
    {
        if (st.size() && check[i].second == st[st.size() - 1])
            st.pop_back();
        else
            st.push_back(check[i].second);
    }
    if (st.size() == 0)
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}


Measured memory_bytes: 12016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {

			// 入力
			int first = sc.nextInt();
			int mid = sc.nextInt();
			int re = sc.nextInt();

			String ach;

			if(first == -1 && mid == -1 && re == -1) break;

			// 成績判断
			int sumPoint = first + mid;
			if(first == -1 || mid == -1 || (sumPoint) < 30) {
				ach = "F";
			} else if((sumPoint) >= 80) {
				ach = "A";
			} else if((sumPoint) >= 65) {
				ach = "B";
			} else if((sumPoint) >= 50) {
				ach = "C";
			} else {
				if(re >= 50) {
					ach = "C";
				} else {
					ach = "D";
				}
			}

			System.out.println(ach);

		}

	}

}



Measured memory_bytes: 26268
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s, p;
  cin >> s;
  cin >> p;
  string sub;
  string ss = s + s;
  bool c = false;
  for (int i = 0; i < s.size(); i++) {
    sub = ss.substr(i, p.size());
    if (sub == p) {
      c = true;
      break;
    }
  }
  if (c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define INFLL 0x3fffffffffffffffLL
#define INF 0x3fffffff
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define exist(s,e) (s.find(e)!=s.end())
#define ff first
#define ss second
#define EPS 1e7
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
const ll MOD=1e9+7;
/////////////////// DEBUG MODE ///////////////////////////////////
#define D(x) cerr<<"DEBUG: "<<#x<<" is: "<<x<<'\n'
#define error(args...) {string _s=#args; replace(all(_s),',',' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string>) { cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
/////////////////// GLOBAL VARIABLES /////////////////////////////
vector<vector<int>> adj; vector<bool> vis; vector<int> color;
/////////////////// FUNCTIONS ////////////////////////////////////
template<class T>
T maxx(T a, T b) {return a>b?a:b;}
template<typename T, typename... Args>
T maxx(T a, T b, Args... args){return maxx(a>b?a:b, args...);}
ll mexp(ll x, ll n, ull m){
  ll res=1;  while(n){if(n&1) res=(res*x)%m;n>>=1; x=((x%m)*(x%m))%m;}
  return res;
}
template<class T>
T minn(T a, T b) {return a<b?a:b;}
template<typename T, typename... Args>
T minn(T a, T b, Args... args){return minn(a>b?a:b, args...);}
bool ispow2(ll x){ return x && (!(x&(x-1))); }
ld pow(ld a, int n) {
  if(n == 0) return 1;if(n == 1) return a;
  double t = pow(a, n/2);return t * t * pow(a, n%2);
}

/////////////////// MAIN STARTS //////////////////////////////////
int main(){
  ios::sync_with_stdio(0);  cin.tie(0);   cout<<fixed; cerr<<fixed;
  cout<<setprecision(10); cerr<<setprecision(3);
  #ifdef DEBUG
  freopen("ip.txt","r",stdin); //freopen("op.txt","w",stdout);
  clock_t tStart = clock();
  #endif

	int a,b,c,x; cin>>a>>b>>c>>x;
	int ans=0;
	for(int i=0;i<=x && i/500<=a;i+=500){
		for(int j=0;j+i<=x && j/100<=b;j+=100){
			int t=(x-i-j)/50; if(t<=c) ++ans;
		}
	}
	cout<<ans<<'\n';


	#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1000<<"ms.\n";
	#endif
  return 0;
}


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

int main() {
    long long n , a , b, c , d;
    cin >> n >> a >> b >> c >> d;
    if(abs(b - a) > (n - 1) * d){
        cout << "NO";
        return 0;
    }
    for(int i = 1; i <= n; i++){
        long long x = n - i - 1;
        if(a + d * i - c * x >= b && a + c * i - d * x <= b){
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int group[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
int main(){
    int x,y;
    cin>>x>>y;
    if(group[x]==group[y])cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";

    return 0;
}



Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

 a = inp
 puts (sum(a) <= 21)? "win" : "bust"

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

#define MAX 200000

template<typename T>
class Stack
{
private:
    int index;
    T a[MAX];
public:
    Stack() { index = 0; }
    T pop(void) { return a[--index]; }
    void push(T t) { a[index++] = t; }
    bool isEmpty(void) { return (index == 0); }
    T top(void) { return a[index-1]; }
    void initial(void) { index = 0; }
};

enum LandType {
    NONE,
    FLAT,
    SLOPE,
    BACKSLOPE,
    WATER,
};

class LandScape {
public:
    LandType type;
    int len;
    int area; // 水のある領域面積
    LandScape() { this->type = NONE; this->len = 0; this->area = 0; }
    LandScape(LandType type) {
        this->type = type;
        this->len = 0;
        this->area = 0;
    }
    LandScape(LandType type, int len, int area) {
        this->type = type;
        this->len = len;
        this->area = area;
    }
    LandScape operator+ (const LandScape l) {
        // typeはとりあえず左の項のものに合わせる
        return LandScape(this->type, this->len + l.len, this->area + l.area);
    }
    LandScape& operator+= (const LandScape& l) {
        // typeはとりあえず元の項のものに合わせる
        this->len += l.len;
        this->area += l.area;
        return *this;
    }
};

int main(int, char**)
{
    Stack<LandScape> stack;
    int slope_count = 0;

    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        switch (s[i]) {
            case '\\':
                stack.push(LandScape(SLOPE));
                slope_count++;
                break;
            case '_' :
                if ((stack.top()).type != FLAT) {
                    stack.push(LandScape(FLAT, 1, 0));
                } else {
                    stack.push(stack.pop() + LandScape(FLAT, 1, 0));                    
                }
                break;
            case '/' :
                if (slope_count == 0) { stack.push(BACKSLOPE); continue; }  // 左端か丘の上
                {
                    LandScape tmp = LandScape(WATER);
                    while (stack.top().type != SLOPE) {
                        tmp += stack.pop();
                    }
                    tmp += LandScape(WATER, 2, tmp.len + 1);
                    stack.pop();
                    stack.push(tmp);
                    slope_count--;
                }
                break;
            default : break;
        }
    }

    int l[MAX];
    int count = 0;
    int sum = 0;
    while (!stack.isEmpty()) {
        LandScape tmp = stack.pop();
        if (tmp.type == WATER) {
            sum += tmp.area;
            l[count++] = tmp.area;
        }
    }

    cout << sum << endl;
    cout << count;
    for (int i = count - 1; i >= 0; i--) cout << " " << l[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 5596
import java.math.BigDecimal

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var zero = false
    val a = readLine()!!.split(' ').map {
        val aa = it.toLong()
        if (aa == 0L) zero = true
        BigDecimal(aa)
    }
    val max = BigDecimal("1000000000000000000")
    if (!zero) {
        var ans = BigDecimal.ONE
        var i = 0
        while (i < n && ans <= max) {
            ans *= a[i]
            i++
        }
        if (ans > max) println(-1)
        else println(ans)
    } else {
        println(0)
    }
}


Measured memory_bytes: 61848
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef long double ldouble;
int compare(const void *a, const void *b){return *(llint *)a - *(llint *)b;}



int main(void){
    llint n,i,k;
    scanf("%lld%lld",&n,&k);
    llint h[n],sa[n-(k-1)];
    for(i=0;i<n;i++){
        scanf("%lld",&h[i]);
    }
    qsort(h,n,sizeof(llint),compare);
    for(i=0;i<n-(k-1);i++){
        sa[i] = h[i+k-1] - h[i];
    }
    qsort(sa,n-k+1,sizeof(llint),compare);


    printf("%lld\n",sa[0]);
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

const int MAX_ROW = 110000; // to be set appropriately
const int MAX_COL = 60; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};
int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}
int main(){
   int t; cin>>t;
   while(t--){
      int n; cin>>n;
      vector<ll> a(n);
      rep(i,0,n)cin>>a[i];
      string s; cin>>s;
      vector<ll> b;
      for(int i=n-1;i>=0;i--){
         if(s[i]=='0')b.push_back(a[i]);
         else{
            BitMatrix mat(b.size(),60);
            rep(j,0,b.size())rep(d,0,60)mat[j][d]=(b[j]>>d&1);
            GaussJordan(mat);
            ll cur=a[i];
            for(int d=59;d>=0;d--)if(cur>>d&1){
               int idx=-1;
               rep(j,0,b.size())if(mat[j][d])idx=j;
               if(idx==-1){
                  puts("1"); goto fail;
               }
               ll add=0;
               rep(j,0,60)if(mat[idx][j])add|=(1LL<<j);
               cur^=add;
            }
            if(cur!=0){
               puts("1"); goto fail;
            }
         }
      }
      puts("0");
      fail:;
   }
   return 0;
}

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

string str = "6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9";
string getstr(char s, char d){
	int i,j;
	for(i=0;str[i]!=s;i++);
	for(j=i;str[j]!=d;j++) if(str[j]==s) i=j;
	return str.substr(i, j-i+1);
}
main(){
	int n,a,b;
	cin >> n;
	while(n--){
		cin >> a >> b;
		cout << getstr(a+'0', b+'0') << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
using namespace std;
int N;
vector<int> v;
int main(){
  int num;
  int counter=0,flag=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>num;
    v.push_back(num);
  }
  while (flag==0) {
    for(auto itr=v.begin();itr!=v.end();itr++){
      if(*itr%2==0) *itr=*itr/2;
      else{
        flag=1;
        counter--;
        break;
      }
    }
    counter++;
  }
  cout<<counter<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
#define pii pair<int,int>
int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> ans(n);
    ll sumx = 0;
    rep(i,n){
        sumx = (sumx^a[i]);
    }
    rep(i,n) ans[i] = (sumx^a[i]);
    rep(i,n) cout << ans[i] << " ";
    cout  << endl;
}

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

#define pb push_back
#define pop_b pop_back
#define pf push_front
#define pop_f pop_front

typedef long long int ll;
typedef pair<int, int> ii; // are aligned to the right like this
typedef vector<ii> vii;  //vector pair
typedef vector<int> vi;   //vector integer
typedef vector<string> vs; //vector string


int main() 
{
    string s;
    cin>>s;
    int l=s.length();
    if(s[l-1]=='s')
        cout<<s+"es";
    else
        cout<<s+"s";
}
 

/*
0
0
2
2
3
*/

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

using ll = long long;
using pii = pair<int, int>;

template <typename T> T inf;
template <> int inf<int> = 1e9;
template <> ll inf<ll> = 1e18;

int main() {
    string s;
    cin >> s;
    vector<int> cnt(3);
    for(int i = 0; i < s.size(); ++i) {
        cnt[s[i] - 'a']++;
    }
    if(s.size() == 1) {
        cout << "YES" << endl;
        return 0;
    }
    sort(cnt.begin(), cnt.end());
    bool ok = true;
    int t = 0;
    for(int i = 0; i < 3; ++i) {
        ok &= s.size() / 2 >= cnt[i];
        t += cnt[i] > 0;
    }
    ok &= t == 3 || t == 2 && s.size() == 2 || t == 1 && s.size() == 1;
    if(t == 3) {
        ok &= cnt.back() - cnt[0] <= 1;
    }

    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll n;
	cin >> n;
	string s;
	cin >> s;


	vector<ll> cumsumR(n+1);
	rep(i,n){
		if(s[i] == 'R') cumsumR[i+1] = cumsumR[i] + 1;
		else cumsumR[i+1] = cumsumR[i];
	}

	ll res = MOD;
	rep(i,n+1){
		assert(i - cumsumR[i] >= 0);
		ll tmp = max(i - cumsumR[i], cumsumR[n] - cumsumR[i]);
		assert(tmp >= 0);
		res = min(res, tmp);
	}

	cout << res << endl;
	
	return 0;
}
int main(){

	return mainsolve();
}

Measured memory_bytes: 5220
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

const ll INF = 1LL << 50;

const ll mod = 1000000007;

int main() {
  ll n;
  cin >> n;

  ll ans = 0;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll r = i;
    ll m = n / i - 1;
    if (r < m) ans += m;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  int N, c = 0;
  cin >> N;
  
  for(int i = 1; i <= N; i = i + 2) {
    int cnt = 0;
    for(int j = 1; j <= i; j = j + 2) if(i % j == 0) cnt++;
    if(cnt == 8) c++;
  }
  cout << c;
  
  return 0;
}

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

using namespace std;

const long long inf = (long long) 1e18 + 10;

map<long long, long long> dist;

long long A, B, C, D;

long long go(long long n) {
  if (dist.count(n)) return dist[n];
  long long cur = inf / D > n ? n * D : inf;
  dist[n] = cur;
  for (int t : {2, 3, 5}) {
    long long m = n % t, prev = n - m, next = prev + t;
    long long p = (t == 2 ? A : (t == 3 ? B : C));
    cur = min(cur, go(prev / t) + m * D + p);
    cur = min(cur, go(next / t) + (t - m) * D + p);
  }
  return dist[n] = cur;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    dist.clear();
    long long N;
    cin >> N >> A >> B >> C >> D;
    dist[0] = 0;
    dist[1] = D;
    dist[2] = min(dist[1] + A, dist[1] + D);
    dist[3] = min(dist[1] + B, dist[2] + D);
    dist[4] = min(dist[2] + A, dist[3] + D);
    dist[5] = min(dist[1] + C, dist[4] + D);
    cout << go(N) << '\n';
  }
  return 0;
}


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

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int s;
	cin >> s;
	int cur = s;
	int mi = cur;
	set<int> st;
	st.insert(cur);
	for (int i = 0; i < 1000001; i++) {
		int tmp;
		if(cur % 2 == 0) {
			tmp = cur / 2;
		} else {
			tmp = 3 * cur + 1;
		}
		if(st.count(tmp)) {
			cout << i + 2 << endl;
			return 0;
		}
		st.insert(tmp);
		cur = tmp;
	}
	return 0;	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S = sc.next();

    sc.close();

    String r = S.substring(0,1) + (S.length() - 2) + S.substring(S.length() - 1);

    System.out.println(r);

  }

}

Measured memory_bytes: 21844
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      n: usize,
      vs: [i64; n],
      cs: [i64; n],
    }
    let mut ans = 0;
    for i in 0..n {
        ans += max(vs[i] - cs[i], 0);
    }
    println!("{}", ans);
}


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

typedef long long int ll; 
#define MOD 1000000007
#define ON 200000
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define FF first
#define SS second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define MK make_pair
#define PB push_back
#define PO pop_back
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
///// This part below is only for debug, not used /////
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
///// END /////

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  rll(a);
  rll(b);
  ll n = __gcd(a,b);
  ll count  = 1;
  
  	if(n%2==0)
  		count++;
    while (n % 2 == 0)  
    {  
          
        n = n/2;  
    }  
  
    
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        if(n%i==0)
        	count++;  
        while (n % i == 0)  
        {    
            n = n/i;  
        }  
    }  
  
   
    if (n > 2) 
    	count++; 

    cout << count << endl;
  
  return 0;
  
}

Measured memory_bytes: 256