akhauriyash/Code-Regression huggingface dataset:
//0015
#include <bits/stdc++.h>
using namespace std;

int main(){
	long n;
	cin>>n;
	while(n--){
		string a,b,ans;
		long tmp = 0,i;
		cin>>a>>b;
		while(a.size() != b.size()){
		if(a.size() > b.size()){
			while(a.size() != b.size()){
				b = '0' + b;
			}
		}

		else if(a.size() < b.size()){
			while(a.size() != b.size()){
				a = '0' + a;
			}
		}
		}

		reverse(a.begin(),a.end());
		reverse(b.begin(),b.end());

		for(i = 0;i < a.size()||i < b.size();i++){
			tmp = (int)(a[i] - '0') + (int)(b[i] - '0') + (int)tmp;
			ans = ((char)((tmp % 10)+'0')) + ans;

			tmp /= 10;
		}

		if(tmp != 0)
			ans = '1' + ans;

		if(ans.size() > 80)
			cout<<"overflow"<<endl;
		else
			cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,t,a;
  cin>>n>>t>>a;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  vector<int> w(n);
  for(int i=0;i<n;i++){
    w[i]=a*1000-1000*t+h[i]*6;
    if(w[i]<0){
      w[i]=-w[i];
    }
  }
  int min=w[0];
  int ans=1;
  for(int i=0;i<n;i++){
    if(w[i]<min){
      min=w[i];
      ans=i+1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
int n;
pair<int,int>p[100005];
map<int,int>mp;
int val[200005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x,y;cin>>x>>y;
		p[i]=make_pair(x-y,x+y);
	}
	for(int i=1;i<=n;i++)mp[p[i].first],mp[p[i].second];
	int tot=0;
	for(auto &p:mp)p.second=++tot;
	for(int i=1;i<=n;i++){
		p[i].first=mp[p[i].first];
		p[i].second=mp[p[i].second];
	}
	memset(val,inf,sizeof val);
	for(int i=1;i<=n;i++){
//		cerr<<i<<" "<<p[i].first<<" "<<p[i].second<<endl;
		val[p[i].first]=min(val[p[i].first],p[i].second);
	}
	for(int i=2e5;i>=0;i--)val[i]=min(val[i],val[i+1]);
	int ans=0,now=0;
	while(1){
		ans++;now=val[now];
		if(val[now]==inf)break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11136
### constant

LLEN = 72

### subroutines

def posdel(ary, key)
  i0 = 0
  i1 = ary.length - 1
  loop do
    i = (i0 + i1) / 2
    ai = ary[i]
    if ai == key
      ary.delete_at(i)
      return
    elsif ai > key
      i1 = i - 1
    else
      i0 = i + 1
    end
  end
end

### main

loop do
  line = gets.strip
  break if line == ''

  str = ''
  while line != ''
    str += line
    line = gets.strip
  end
  strlen = str.length
  
  kchs = gets.strip.split('')
  gets

  khash = {}
  kchs.each{|ch| khash[ch] = true}

  kpos = {}
  #p str
  #p khash

  minpos = nil
  minlen = strlen + 1
  minstr = nil
  minc = 0
  rem = kchs.length
  poss = []
  
  for pos in (0...strlen)
    ch = str[pos]
    next if ! khash.key?(ch)

    chpos = kpos[ch]

    if chpos.nil?
      poss << pos
      kpos[ch] = pos
      rem -= 1
    else
      kpos[ch] = pos
      posdel(poss, chpos)
      poss << pos
    end
    #p [pos, ch, minpos]
    
    if rem == 0
      minpos = poss.first
      len = pos - minpos + 1
      if minlen > len
        minlen = len
        minc = 1
        minstr = str[minpos, len]
      elsif minlen == len
        minc += 1
      end
    end
  end

  puts minc
  puts

  if minc > 0
    k = 0
    mslen = minstr.length
    while k < mslen
      puts minstr[k, LLEN]
      k += LLEN
    end
    puts
  end
end

Measured memory_bytes: 14824
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        xv: [isize; n]
    };

    let mut res = std::isize::MAX;
    for p in 1_isize..=100 {
        let mut sum = 0;
        for &x in &xv {
            sum += (x - p).pow(2);
        }
        if sum < res {
            res = sum;
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2212
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int k,q;
vi d;
int di,n,x,m;

signed main(){
    I(k); I(q);
    REP(i,k){
        I(di);
        d.pb(di);
    }
    
    REP(_,q){
        I(n); I(x); I(m);
        // m-進法でみたとき、いわゆる繰り上がりが起こらない回数に等しい
        // あと m-進で 0 もアウト
        vi dmod;
        REP(i,k) dmod.pb(d[i] % m);
        int sumd = accumulate(all(dmod), 0LL);
        x %= m;
        n--;
        
        int a_n = x + sumd * (n/k);
        REP(i,n%k) a_n += dmod[i];
        int subst = a_n / m;
        
        int zeros = 0;
        REP(i,k) zeros += dmod[i] == 0;
        zeros *= (n/k);
        REP(i,n%k) zeros += dmod[i] == 0;

        cout << (n - subst - zeros) << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

int dp[3010][3010];

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

	int N, T; cin >> N >> T;
	VP A(N);
	REP(i, N)cin >> A[i].first >> A[i].second;
	SORT(A);

	REP(i, N) {
		int t = A[i].first, v = A[i].second;
		eREP(j, T) {
			int nj = j + t;
			chmin(nj, T);
			if (j != 0)chmax(dp[i + 1][j], dp[i + 1][j - 1]);

			chmax(dp[i + 1][j], dp[i][j]);
			if(j!=T)chmax(dp[i + 1][nj], dp[i][j] + v);
		}
	}
	cout << dp[N][T] << endl;

	return 0;
}



Measured memory_bytes: 74144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b); for(ll i=(a); i<=ll(b); i++) 
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
const ll MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
//int:~2e9   小数:double



int main(){
  int h,a;
  cin >>h>>a;
  int ans=0;
  while(h>0){
    h -= a;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int INF   = (1 << 21);
static const int WHITE = 0;
static const int GRAY  = 1;
static const int BLACK = 2;
static const int NIL   = -1;

int n;

void prim(vector<vector<int>> &A) {
  vector<int> color(n, WHITE);
  vector<int> d(n, INF);
  vector<int> p(n, 0);
  d[0] = 0;
  p[0] = -1;

  while (true) {
    int mincost = INF;
    int u       = -1;

    for (int i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < mincost) {
        mincost = d[i];
        u       = i;
      }
    }
    if (mincost == INF) { break; }
    color[u] = BLACK;

    for (int v = 0; v < n; v++) {
      if (color[v] != BLACK && A[u][v] != -1) {
        if (A[u][v] < d[v]) {
          d[v]     = A[u][v];
          p[v]     = u;
          color[v] = GRAY;
        }
      }
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    res += d[i];
  }
  cout << res << endl;
}

int main() {
  cin >> n;
  vector<vector<int>> A(n, vector<int>(n));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> A[i][j];
    }
  }
  prim(A);
}


Measured memory_bytes: 3156
row, col = map(int,input().split())

mat = [[0 for i2 in range(col)] for i1 in range(row)]
for i in range(row):
    mat[i] = list(map(float,input().split()))
vec = [0 for i in range(col)]
for i in range(col):
       vec[i] = float(input())

result = [0 for i in range(row)]
for i in range(row):
    for j in range(col):
        result[i] += mat[i][j]*vec[j]

for i in range(len(result)):
    print(int(result[i]))

Measured memory_bytes: 7960
#include <bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define MOD  (int)(1e9+7)
 
#define float long double
 
 
int ADD(int &a,int &b)
{
  return (a%MOD + b%MOD )%MOD;
}
 
 
 
int ADD(int &a,int &b,int &c)
{
  return ( ADD(a,b) + c%MOD )%MOD;
}
 
 

 
 
 
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
 
 
bool  isPalindrome(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.size() - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            
            return false; 
        } 
    } 
	return true;
	
} 
int32_t main()
{
  FAST;
 
  
	string s;
	cin >> s;
	string ss,tt;
	int n=s.size();
	
	ss=s.substr(0,n/2);
	tt=s.substr((n/2)+1,n/2);
	reverse(tt.begin(),tt.end());
	if(ss!=tt) cout<<"No\n";	
	else if(isPalindrome(ss)==false) cout<<"No\n";
	else cout<<"Yes\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int m,n;
int book[101];
bool check(int width){
  int j=0;
  int sum=0;
  
  for(int i=0;i<n;i++){
    if(book[i] > width){
      return false;
    }
    
    sum += book[i];
    
    if(sum > width){
      j++;
      i--;
      sum = 0;
    }
    if(j == m){
      return false;
    }
  }
  return true;
}
int main(){
  while(1){
    cin>>m>>n;
    if(m == 0 && n == 0) break;
    
    for(int i=0;i<n;i++){
      cin>>book[i];
    }
    
    int left=0,right=1500000;
    while(right - left > 0) {
      int mid = (left + right) / 2;
      if(check(mid)) right = mid;
      else left = mid + 1;
    }
    
    cout<<right<<endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
using ll = long long;

int n;
bool flag = 0;

int main(){
	cin >> n;
	for (int i = 0; i < n; ++i){
		int a; cin >> a;
		if (a % 2 == 1)flag = 1;
	}
	cout << (flag ? "first" : "second") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <random>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;


const int maxn = 2e5;
char s[maxn];

struct str
{
    int a[30];
    bool operator < (const str &x) const {
        for(int i = 0; i < 26; ++i) {
            if(a[i] != x.a[i]) {
                return a[i] < x.a[i];
            }
        }
        return 0;
    }
};

signed main()
{
#ifndef ONLINE_JUDGE
    // freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    map<str, int> mp;
    for(int i = 0; i < n; ++i) {
        cin >> s;
        str t;
        memset(t.a, 0, sizeof(t.a));
        for(int j = 0; s[j]; ++j) {
            t.a[s[j] - 'a']++;
        }
        mp[t]++;
    }
    long long res = 0;
    for(auto i : mp) {
        res += (long long) i.se * (i.se - 1) / 2;
    }
    cout << res << endl;




    
    return 0;
}

Measured memory_bytes: 17408
N, H = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
	a[i], b[i] = map(int, input().split())
a_max = max(a)
ans = dmg = 0
for dmg_i in sorted([bi for bi in b if bi > a_max], reverse=True):
	dmg += dmg_i
	ans += 1
	if dmg >= H:
		print(ans)
		break
else:
	print(ans + (H - dmg + a_max - 1) // a_max)


Measured memory_bytes: 12844
if __name__ == '__main__':
	n = int(input())
	res = ""
	for i in range(1,n+1):
		x = i
		if i % 3 == 0:
			res=res+" "+str(i)
			x = 0
		elif i % 10 == 3:
			res=res+" "+str(i)
			x = 0
		while x != 0:
			x = x // 10
			if x % 10 == 3:
				res=res+" "+str(i)
				x = 0
				
	print(res)



Measured memory_bytes: 5628
#include <stdio.h>
int main(void)
{
        int a,b=0,c,i=0,j,p[100],ans=0;

        scanf("%d%d",&a,&b);

        for(i=0; i<a; i++) scanf("%d",&p[i]);

        for (i=0; i<a; i++){
                for (j=i+1; j<a; j++){
                        if (p[i] < p[j]){
                                c=p[i];
                                p[i]=p[j];
                                p[j]=c;
                              //  printf("%d",p[j]);
      }
    }
  }

        for(i=0; i<b; i++) ans+=p[i];
        printf("%d\n",ans);
                return 0;
}

Measured memory_bytes: 128
// g++ -std=gnu++1y -O2 main.cpp

#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

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

	char c = S[0];
	for (int i = 1; i < S.size(); i++)
	{
		if (S[i] != c) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
using std::cin;
using std::cout;
using std::endl;
 
int main(void) {
    int N;
    cin >> N;
    std::vector<int> frimin(N);
    std::vector<int> frimax(N);
    for (int i = 0; i < N; i++) {
        cin >> frimin[i] >> frimax[i];
    }
 
    std::sort(frimin.begin(), frimin.end());
    std::sort(frimax.begin(), frimax.end());
 
    int ret = 0;
    int count = 1;
    int imin = -1;
    int imax = -1;
    for (int f = 2; f < N+2 && f <= frimax[N-1]; f++) {
        for (int i = imin+1; frimin[i] == f; i++) {
            count++;
            imin++;
        }
        for (int i = imax+1; frimax[i] == f-1; i++) {
            count--;
            imax++;
        }
 
        if ( count >= f) {
            ret = f-1;
        }
    }
 
    cout << ret << endl;
    return 0;
}

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

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

    string s;
    cin >> s;

    int a, b, c;
    a = 0;
    b = 0;
    c = 0;

    rep(i, 3){
        if(s[i]=='a')++a;
        if(s[i]=='b')++b;
        if(s[i]=='c')++c;
    }

    if(a==b && b==c) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 384
#include<cstdio>
const int N=2000000,mod=1000000007;
int fac[N+1],ifac[N+1];
long long inv(int a,int p=mod){return a==1?1:(1+p*(a-inv(p%a,a)))/a%p;}
long long C(int n,int m){return fac[n]*(long long)ifac[m]%mod*ifac[n-m];}
long long cal(int n,int m,int a,int b){
	int res=(C(n+m+a+b,n+a)-C(m+a+b,a)-C(n+a+b,n+a)+C(a+b,a))%mod;
	return res<0?res+mod:res;
}
int main(){
	int X1,X2,X3,X4,X5,X6,Y1,Y2,Y3,Y4,Y5,Y6;
	scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&X1,&X2,&X3,&X4,&X5,&X6,&Y1,&Y2,&Y3,&Y4,&Y5,&Y6);
	for(int i=*fac=1;i<=N;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[N]=inv(fac[N]);
	for(int i=N;i;i--)ifac[i-1]=1ll*ifac[i]*i%mod;
	int n1=X2-X1+1,m1=Y2-Y1+1,n2=X6-X5+1,m2=Y6-Y5+1,sum=0;
	for(int x=X3;x<=X4;x++)
		sum=(sum+cal(n1,m1,x-X2,Y3-Y2-1)*cal(n2,m2,X5-x,Y5-Y3)%mod*(mod-x-Y3))%mod;
	for(int y=Y3;y<=Y4;y++)
		sum=(sum+cal(n1,m1,X3-X2-1,y-Y2)*cal(n2,m2,X5-X3,Y5-y)%mod*(mod-y-X3))%mod;
	for(int x=X3;x<=X4;x++)
		sum=(sum+cal(n1,m1,x-X2,Y4-Y2)*cal(n2,m2,X5-x,Y5-Y4-1)%mod*(x+Y4+1))%mod;
	for(int y=Y3;y<=Y4;y++)
		sum=(sum+cal(n1,m1,X4-X2,y-Y2)*cal(n2,m2,X5-X4-1,Y5-y)%mod*(y+X4+1))%mod;
	printf("%d\n",sum);
}

Measured memory_bytes: 15744
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
void read(int &x)
{
    int f=1;
    x=0;
    char s=getchar();
    while(s<'0'||s>'9')
    {
        if(s=='-')
            f=-1;
        s=getchar();
    }
    while(s>='0'&&s<='9')
    {
        x=x*10+s-'0';
        s=getchar();
    }
    x*=f;
}
void print(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
int n; 
signed main()
{
	Very_fast;
	cin>>n;
	cout<<(1000-n%1000)%1000;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
#define ALL(a) a.begin(),a.end()
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int main(){
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9) {
        cout << -1 << endl;
    }else {
        cout << a * b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
main :: IO ()                                                                                                              
main = do                                                                                                                  
  a <- getLine                                                                                                             
  b <- getLine                                                                                                             
  case compare (length a) (length b) of                                                                                    
    GT -> putStrLn "GREATER"                                                                                               
    LT -> putStrLn "LESS"                                                                                                  
    EQ -> case compare a b of                                                                                              
            GT -> putStrLn "GREATER"                                                                                       
            LT -> putStrLn "LESS"                                                                                          
            EQ -> putStrLn "EQUAL"

Measured memory_bytes: 508
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,a,b;
    cin >> n >> a >> b;
    ll res = a*n < b ? a*n : b;
    cout << res << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll h, w, result = mod;
  cin >> h >> w;

  rep(i, 2) {
    FOR(j, 1, h) {
      ll n1 = j * w;
      ll n2 = (w / 2) * (h - j);
      ll n3 = ((w + 1) / 2) * (h - j);
      result = min(result, abs(max({n1, n3, n2}) - min({n1, n3, n2})));
      n2 = ((h - j) / 2) * w;
      n3 = ((h - j + 1) / 2) * w;
      result = min(result, abs(max({n1, n3, n2}) - min({n1, n3, n2})));
    }
    swap(h, w);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> g[100000+2];
int vis[100000+2];

int maxx=0;

int dfs(int node,int cnt)
{

    vis[node]=0;
   
    for(int ch : g[node])
    {
        if(vis[ch]==-1)
        {
            //cout<<node<<" "<<ch<<endl;
            vis[ch]=dfs(ch,cnt+1);
        }
        vis[node]=max(vis[node],1+vis[ch]);
    }
    maxx=max(maxx,vis[node]);
    return vis[node];
}
int main()
{
    int n,m;cin>>n>>m;
    memset(vis,-1,sizeof(vis));
   while(m--)
   {
       int u,v;
       cin>>u>>v;
       g[u].push_back(v);
   }
   for(int i=1;i<=n;i++)
   {
      if(vis[i]==-1)
      {
          vis[i]=dfs(i,0);
      }
   }
   /*cout<<endl<<endl<<endl;
   for(int i=1;i<=n;i++) cout<<vis[i]<<" ";
   cout<<endl;*/
   cout<<maxx<<endl;
}

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

int main(){
    int h,w;
    cin>>h>>w;
    char A[h+2][w+2];
    for(int i=0; i<h+2; ++i)
        for(int j=0; j<w+2; ++j) A[i][j]='#';
    for(int i=1; i<=h; ++i)
        for(int j=1; j<=w; ++j) cin>>A[i][j];
    
    vector<int> G[h*w+1];
    for(int i=1; i<=h; ++i){
        for(int j=1; j<=w; ++j){
            if(A[i][j]!='#'){
                for(int x: {1,-1}){
                    if(A[i][j+x]!='#') G[(i-1)*w+j].push_back((i-1)*w+j+x);
                }
                for(int y: {1,-1}){
                    if(A[i+y][j]!='#') G[(i-1)*w+j].push_back((i+y-1)*w+j);
                }
            }
        }
    }
    int max1=0;
    for(int i=1; i<=h*w; ++i){
        queue<int> q;
        vector<bool> visited(h*w+1);
        vector<int> distance(h*w+1,-1);//don't know why distance is initialize with -1
        visited[i]=true;
        distance[i]=0;
        q.push(i);
        while(!q.empty()){
            int s=q.front();
            q.pop();
            for(int u: G[s]){
                if(!visited[u]){
                    visited[u]=true;
                    distance[u]=distance[s]+1;
                    q.push(u);
                    max1=max(max1,distance[u]);
                }
            }
        }
    }
    cout<<max1<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int turn[4][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll mod = 3e7;
int main()
{
        ll N, K;
        cin >> N >> K;
        ll ans = 0;
        if (K == 0)
        {
                cout << N*N << endl;
                return 0;
        }
        for (ll i = K + 1; i <= N; i++)
        {
                ll time = N / i;
                if (N % i >= K)
                {
                        ans += N % i - K + 1;
                }
                ans += time * (i - K);
        }
        cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>

#define unless(c) if (!(c))
#define each(i, c) for (auto& i: c)

using namespace std;

int main(void)
{
  int N;

  while (cin >> N) {
    int i;
    for (i = 1; ; i++) {
      int cnt = 0;
      for (int j = 1; j <= i; j++) {
	if (i % j == 0) {
	  cnt++;
	}
      }
      if (cnt == N) {
	break;
      }
    }
    cout << i << endl;
  }
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;

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

int main() {
        int n, m, p;
        while (cin >> n >> m >> p) {
                if (n == 0 && m == 0 && p == 0) break;
                vector<int> x(n);
                double sum = 0;
                rep(i, n) { 
                        cin >> x[i];
                        sum += x[i];
                }
                sum *= 100;
                double s = sum * (double)p / 100.0;
                sum -= s;
                if (x[m - 1] == 0) cout << 0 << endl;
                else cout << (int)(sum / x[m - 1]) << endl;
        }
        return 0;
}

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

int main() {
    while(true) {
        int n, m;
        cin >> n >> m;
        if(n == 0 && m == 0 ) break;
        int a[1005];
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
        }
        int ans = -1;
        for(int i = 1; i <= n; i++) {
            for(int j = i + 1; j <= n; j++) {
                //cerr << i << " " << j << endl;
                if(a[i] + a[j] <= m) ans = max(ans, a[i] + a[j]);
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi dp(3);
	rep(i, n){
		vi next(3);
		rep(j, 3){
			int x; cin >> x;
			rep(k, 3) if(j != k) next[k] = max(next[k], dp[j] + x);
		}
		dp = next;
	}
	cout << *max_element(all(dp)) << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> in = new ArrayList<>();
		Integer a = sc.nextInt();
		Integer b = sc.nextInt();
		sc.close();
		in.add(1);in.add(2);in.add(3);
		if(in.contains(a)) in.remove(a);
		if(in.contains(b)) in.remove(b);
		System.out.println(in.get(0));
	}
}


Measured memory_bytes: 21844
N, M = map(int,input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
prev = [0] * N
to_list = [ [] for _ in range(N)]
for a,b in AB:
 to_list[a - 1].append(b - 1)
 to_list[b - 1].append(a - 1)
marked = {0}
que = [0]
for i in que:
   for j in to_list[i]:
       if j in marked: continue
       que.append(j)
       marked.add(j)
       prev[j] = i+1
print('Yes')
print(*prev[1:], sep='\n')

Measured memory_bytes: 79112
storeNum, target = map(int, input().split(' '))
stores = []

for i in range(storeNum):
    cost, mx = map(int, input().split(' '))
    stores.append((cost, mx))

stores.sort(key=lambda x: x[0])

totalCost = 0
totalCan = 0
for cost, cans in stores:
    totalCost += cost * cans
    totalCan += cans
    if target <= totalCan:
        totalCost -= (totalCan - target) * cost
        print(totalCost)
        break


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


const int mod = 1e+9 + 7;


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

    // dp[i][j]: i-1 番目の文字まで見終わって ABC の3文字のうち j 文字選んだ状態
    // ( ただし、i = 0 を一文字も選んでいない状態とする )
    // として、「後ろから」2次元DPをする
    int N = S.size();
    long dp[100000][4];
    for( int i = N; i >= 0; --i ){
        for( int j = 3; j >= 0; --j ){
            if( i == N ) dp[i][j] = (j == 3)? 1: 0;
            else{
                // S[i] を ABC として選ばない場合
                dp[i][j] = ( (S[i] == '?')? 3: 1 ) * dp[i+1][j];
                // S[i] を ABC として選ぶ場合
                if( j < 3 && (S[i] == '?' || S[i] == "ABC"[j]) ){
                    dp[i][j] += dp[i+1][j+1];
                }
            }
            dp[i][j] %= mod;
        }
    }

    cout << dp[0][0] << endl;

    return 0;
}

Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

template<typename T>
struct RectangeSum {
	vector<vector<T> > sum;
	template<typename U>
	void init(int h, int w, U &a) {
		sum.assign(h + 1, vector<T>(w + 1));
		rer(y, 0, h) rer(x, 0, w) sum[y][x] = (y == 0 || x == 0) ? 0 :
			sum[y - 1][x] + sum[y][x - 1] - sum[y - 1][x - 1] + a[y - 1][x - 1];
	}
	//[l, r), [t, b)
	inline T get(int t, int l, int b, int r) const {
		return sum[b][r] - sum[b][l] - sum[t][r] + sum[t][l];
	}
};

int main() {
	int H; int W;
	while (~scanf("%d%d", &H, &W)) {
		int Q;
		scanf("%d", &Q);
		vector<vector<int>> vertex(H, vector<int>(W)), edgeH = vertex, edgeV = vertex;
		string prevS(W, '0');
		rep(i, H) {
			char S[2001];
			scanf("%s", S);
			rep(j, W) {
				vertex[i][j] = S[j] - '0';
				edgeH[i][j] = S[j] == '1' && S[j + 1] == '1';
				edgeV[i][j] = S[j] == '1' && prevS[j] == '1';
			}
			prevS = S;
		}
		RectangeSum<int> sum1, sum2, sum3;
		sum1.init(H, W, vertex);
		sum2.init(H, W, edgeH);
		sum3.init(H, W, edgeV);
		rep(ii, Q) {
			int yL; int xL;
			scanf("%d%d", &yL, &xL), -- yL, -- xL;
			int yR; int xR;
			scanf("%d%d", &yR, &xR);
			int ans = 0;
			ans += sum1.get(yL, xL, yR, xR);
			ans -= sum2.get(yL, xL, yR, xR - 1);
			ans -= sum3.get(yL + 1, xL, yR, xR);
			printf("%d\n", ans);
		}
	}
	return 0;
}


Measured memory_bytes: 96000
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll x[200005];
ll check[200005];
int main() {
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		check[i] = x[i];
	}
	sort(check, check + n);
	double index = (double)(check[n / 2] + check[n / 2 - 1]) / 2;
	for (int i = 0; i < n; i++) {
		if (x[i] >= index) {
			cout << check[n / 2 - 1] << endl;
		}
		else {
			cout << check[n / 2] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define ia(n, a) rp(ia_i, 0, n) cin >> a[ia_i]
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll n;
    cin >> n;
    ll l[n];
    rp(i, 0, n) cin >> l[i];
    ll ans = 0;
    rp(i, 0, n)
    {
        rp(j, i + 1, n)
        {
            rp(k, j + 1, n)
            {
                if (llabs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j])
                {
                    if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i])
                        ans++;
                }
            }
        }
    }
    ce(ans);
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int X,K,D;
    cin >> X >> K >> D;
    int cnt = abs(X);
    if((cnt+D-1)/D >= K) {
        cout << abs(cnt-D*K) << endl;
    }
    else if(cnt%D == 0) {
        cout << (((K-cnt/D)%2 == 0)?0:D) << endl;
    }
    else {
        int Y = (D-cnt%D)%D;
        int Z = (D-Y);
        if((K-cnt/D)%2 == 0) {
            cout << Z << endl;
        }
        else {
            cout << Y << endl;
        }
    }
}


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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

long long w, h, x, y;

bool read() {
    if (!(cin >> w >> h >> x >> y))
        return false;

    return true;
}

void solve() {
    cout << setprecision(10) << fixed << 0.5 * w * h << ' ' << (2 * x == w && 2 * y == h) << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



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

int data[101];

void format(){
	int i;
	for(i=100;i--;){
		data[i]=0;
	}
}

int main(){
	format();
	int i;
	while((scanf("%d",&i))!=EOF){
		data[i]++;
		if(data[0]<data[i]){
			data[0]=data[i];
		}
	}
	
	for(i=100;i--;){
		if(data[100-i]==data[0]){
			printf("%d\n",100-i);
		}
	}
	
	
	
	return 0;
}

Measured memory_bytes: 1188
import scala.collection.mutable.ArrayBuffer

object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, K = sc.nextInt
    val S = sc.next

    val starts = ArrayBuffer[Int](0)
    val ends = new ArrayBuffer[Int]()
    var prev = ' '
    for (i <- 0 until S.length) {
      if (prev == '0' && S(i) == '1') {
        starts += i
      }
      if (prev == '1' && S(i) == '0') {
        ends += i
      }
      prev = S(i)
    }
    ends += S.length

    var result = 0
    for (i <- ends.indices) {
      val count =
        if (S(0) == '1') {
          if (i - K >= 0)
            ends(i) - starts(i - K)
          else
            0
        } else {
          if (i - K + 1 >= 0)
            ends(i) - starts(i - K + 1)
          else
            0
        }
      if (result < count) {
        result = count
      }
    }
    if (result == 0) {
      println(S.length)
    } else {
      println(result)
    }

  }
}

Measured memory_bytes: 33100
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  vector<vector<int>> c(3,vector<int>(3));
  rep(i,3){
    rep(j,3) cin>>c[i][j];
  }
  vector<int> b(3);
  rep(i,3) b[i]=c[0][i];

  bool f=1;
  if((c[1][0]-b[0]!=c[1][1]-b[1])||(c[1][0]-b[0]!=c[1][2]-b[2])||(c[1][1]-b[1]!=c[1][2]-b[2]))
  f=0;
  if((c[2][0]-b[0]!=c[2][1]-b[1])||(c[2][0]-b[0]!=c[2][2]-b[2])||(c[2][1]-b[1]!=c[2][2]-b[2]))
  f=0;

  if(f) puts("Yes");
  else puts("No");

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"sort"
)

// {{{
// source: https://github.com/raahii/algo
func MaxInts(nums ...int) int {
	var maxVal int
	for i, e := range nums {
		if i == 0 || e > maxVal {
			maxVal = e
		}
	}
	return maxVal
}

func MaxIntsWithIdx(nums ...int) (int, int) {
	var maxIdx, maxVal int
	for i, e := range nums {
		if i == 0 || e > maxVal {
			maxIdx = i
			maxVal = e
		}
	}
	return maxVal, maxIdx
}

func MinInts(nums ...int) int {
	var minVal int
	for i, e := range nums {
		if i == 0 || e < minVal {
			minVal = e
		}
	}
	return minVal
}

func MinIntsWithIdx(nums ...int) (int, int) {
	var minIdx, minVal int
	for i, e := range nums {
		if i == 0 || e < minVal {
			minIdx = i
			minVal = e
		}
	}
	return minVal, minIdx
}

func SumInts(nums []int) int {
	s := 0
	for _, v := range nums {
		s += v
	}
	return s
}

func SumInts2d(mat [][]int) int {
	s := 0
	for _, nums := range mat {
		for _, v := range nums {
			s += v
		}
	}
	return s
}

func ReverseInts(nums []int) []int {
	rnums := make([]int, len(nums))
	for i := 0; i < len(nums); i++ {
		rnums[len(nums)-1-i] = nums[i]
	}
	return rnums
}

func ExtendInts(nums1 []int, nums2 []int) []int {
	for _, v := range nums2 {
		nums1 = append(nums1, v)
	}
	return nums1
}

func Ints2d(n_rows, n_cols int) [][]int {
	ints := make([][]int, n_rows)
	for i := 0; i < n_rows; i++ {
		ints[i] = make([]int, n_cols)
	}
	return ints
}

func StrInts2d(mat [][]int) string {
	str := ""
	for i := 0; i < len(mat); i++ {
		str += fmt.Sprintf("[%d", mat[i][0])
		for j := 1; j < len(mat[0]); j++ {
			str += fmt.Sprintf(" %d", mat[i][j])
		}
		str += "]"
		if i != len(mat)-1 {
			str += "\n"
		}
	}
	return str
}

func MemsetInts1d(nums []int, val int) {
	for i := range nums {
		nums[i] = val
	}
}

func MemsetInts2d(nums [][]int, val int) {
	for i := range nums {
		for j := range nums[i] {
			nums[i][j] = val
		}
	}
}

func ContainsInt(nums []int, num int) bool {
	sort.Ints(nums)

	s, e := 0, len(nums)
	for {
		if s >= e {
			break
		}

		m := (e + s) / 2
		if nums[m] == num {
			return true
		} else if num > nums[m] {
			s = m + 1
		} else {
			e = m
		}
	}

	return false
}

func ReadInt(f *os.File) int {
	var n int
	fmt.Fscanf(f, "%d", &n)
	return n
}

func ReadInts(f *os.File, n int) []int {
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(f, "%d", &nums[i])
	}
	return nums
}

func ScanInts(f *os.File, vars ...*int) {
	for i := 0; i < len(vars); i++ {
		fmt.Fscanf(f, "%d", vars[i])
	}
}

func ReadLine(f *os.File) string {
	var str string
	fmt.Fscanf(f, "%s", &str)

	return str
}

func ReadLines(f *os.File, n int) []string {
	lines := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(f, "%s", &lines[i])
	}

	return lines
}

func ReadWords(f *os.File, n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(f, "%s", &strs[i])
	}
	return strs
}

func Pow(a, n int) int {
	c := 1
	for i := 0; i < n; i++ {
		c *= a
	}
	return c
}

func Abs(n int) int {
	if n < 0 {
		return -n
	}

	return n
}

// }}}

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	fmt.Println(x + y/2)
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0};
const int dy[] = {0, -1, 1, 0, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, K;
  cin >> N >> K;
  int a[1100], tmp[1100];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    tmp[i] = a[i];
  }

  for (int i = 1; i < N; i++) {
    tmp[i] += tmp[i - 1];
  }

  vector<int> sum[60];
  vector<int> all;
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      int t;
      if (i == 0) {
        t = tmp[j]; //[0,j]の総和
      } else {
        t = tmp[j] - tmp[i - 1]; //[i,j]の総和
      }

      all.push_back(t);

      for (int i = 0; i < 50; i++) {
        if (bitcheck(t, i)) {
          sum[i].push_back(t);
        }
      }
    }
  }

  for (int i = 0; i < 50; i++) {
    sort(ALL(sum[i]));
  }

  vector<int> v[50];
  int pre = -1;
  for (int i = 50; 0 <= i; i--) {
    if (sum[i].size() < K) {
      continue;
    } else {
      if (pre == -1) {
        for (auto x : all) {
          bool flag = binary_search(ALL(sum[i]), x);
          if (flag) {
            v[i].push_back(x);
          }
        }
        pre = i;
      } else {
        int cont = 0;
        for (auto x : v[pre]) {
          bool flag = binary_search(ALL(sum[i]), x);
          if (flag) {
            cont++;
          }
        }

        if (cont >= K) {
          for (auto x : v[pre]) {
            bool flag = binary_search(ALL(sum[i]), x);
            if (flag) {
              v[i].push_back(x);
            }
          }
          pre = i;
        }
      }
    }
  }

  sort(ALL(v[pre]), greater<int>());

  int ans = bit(60) - 1;
  for (int i = 0; i < K; i++) {
    ans &= v[pre][i];
  }

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


Measured memory_bytes: 88984
H, W = map(int, input().split())
S = [input() for _ in range(H)]

dist = [[10**7] * W for _ in range(H)]
dist[0][0] = 0

for i in range(H):
    for j in range(W):
        if j != W-1:
            if S[i][j+1] == '.' or S[i][j] == '#':
                dist[i][j+1] = min(dist[i][j], dist[i][j+1])
            else:
                dist[i][j+1] = min(dist[i][j]+1, dist[i][j+1])
        if i != H-1:
            if S[i+1][j] == '.' or S[i][j] == '#':
                dist[i+1][j] = min(dist[i][j], dist[i+1][j])
            else:
                dist[i+1][j] = min(dist[i][j]+1, dist[i+1][j])

if S[0][0] == '#':
    dist[H-1][W-1] += 1
print(dist[H-1][W-1])


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

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define FOR(i,a,b)  for(int i=(a); i< (b); ++i)
#define RFOR(i,b,a) for(int i=(b);i>=(a);i--)
#define REP(i,a,b)  for(int i=(a); i<=(b); ++i)
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
template<typename T>
void PrArr(const T a[] , int len){
	for(int i = 0;i <= len; i++)cout << a[i] << " ";
	cout << endl;
}
template<typename T>
void PrVec(const vector<T> a){
	for(auto it : a)cout << it << " ";
	cout << endl;
}
const int MAX = 0x7ffffff;
const int MIN = 0xcf;
const int N = 10000007;
int test;
bool vis[N];
void slove()
{
	int n;cin >> n;
	ll ans = 0;
	for(int x = 1;x <= n;x ++)
	{
		int y = n / x;
		ans += (ll)y * (y + 1) * x / 2;
	}
	cout << ans << endl;
}
int main()
{
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed; // 在iomanip中
#endif
	SIS;slove();
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

Measured memory_bytes: 3648