akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int main()
{
	int x;
	cin>>x;
	if(x)x=0;
	else
	{
			x=1;
	}
	cout<<x<<endl;
	

	



    int ab;
    cin>>ab;
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int H, W;
	cin >> H >> W;

	for( int i = 0; i < 2*H; ++i ) {
		string c;
		cin >> c;

		cout << c << '\n' << c << '\n';
	}
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,sys.stdin.readline().split())


n, m = intinput()
a = {int(sys.stdin.readline()) for _ in range(m)}
memo = [0 for x in range(n + 4)]
memo[0] = 1
mod = 10 ** 9 + 7
for i in range(n):
    if i + 1 not in a:
        memo[i + 1] = (memo[i + 1] + memo[i]) % mod
    if i + 2 not in a:
        memo[i + 2] = (memo[i + 2] + memo[i]) % mod
print(memo[n])

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

int main() {
    int N;
    cin >> N;
    vector<int>a(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    cout << a[N-1]-a[0] << endl;
}

Measured memory_bytes: 256
n = int(input())
ds = [list(map(int,input().split())) for i in range(n)]

judge = False
count = 0

for i in range(n):
    if ds[i][0] == ds[i][1]:
        count +=1
    else:
        count = 0
    if count >= 3:
        judge = True

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

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector< vector<int>> x(n,vector<int>(14));
    vector< vector<int>> y(n,vector<int>(14));
   
    for(int i = 0;i<n;i++){
        cin >> a[i];
        for(int j = 0;j<a[i];j++){
            cin >> x[i][j] >>y[i][j];
        }
    }
    int max = 0;
    bool ans = true;
    for(int tmp = 0;tmp<(1<<n);tmp++){
        bitset<15> bit(tmp);
        ans = true;
        for(int i = 0;i<n;i++){
            for(int j = 0;j<a[i];j++){
                if(bit.test(i)==1){ //ほんとのことを言ってると仮定
                    if(!bit.test(x[i][j]-1) == y[i][j]){
                        ans = false;
                    }
                }
            }
        }
        if(ans){
            if(bit.count()>max){
                max = bit.count();
            }
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
using namespace std;

int main(){
    int r, d, x;
    cin >> r >> d >> x;
    
    int xx = x;

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

        xx = r*xx - d;
        cout << xx << endl;
    }


}
    // for (int i = 0; i < ; i++){
        
        //         if(!(i+offset < n)) break;
        // int c = i + offset;
        // if(n/c == n%c){
        //     res += i;
        //     offset += 
        // }
    // }


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

s = raw_input()
N = S = W = E = 0
for si in s:
    if si == "N": N = 1
    if si == "S": S = 1
    if si == "W": W = 1
    if si == "E": E = 1
print "Yes" if N == S and W == E else "No"


Measured memory_bytes: 4520
using System;

class Program
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] inputArray = Console.ReadLine().Split(' ');
        int[] intArray = new int[n];

        int result = 0;

        for (int i = 0; i < n; i++)
        {
            intArray[i] = int.Parse(inputArray[i]);
        }

        for (int i = 0; i < intArray.Length - 2; i++)
        {
            int[] tempNum = new int[3];
            Array.Copy(intArray, i, tempNum, 0, 3);
            if (
                (tempNum[0] > tempNum[1] && tempNum[1] > tempNum[2])
                ||
                (tempNum[0] < tempNum[1] && tempNum[1] < tempNum[2]))
            {
                result++;
            }
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll n,x;
    cin>>n>>x;
    ll m[110];
    ll sum=0;
    rep(i,n){
        cin>>m[i];
        sum+=m[i];
    }
    sort(m,m+n);
    x-=sum;
    cout<<n+x/m[0]<<endl;

}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, r, b;
string s;

int main() {
	cin >> n >> s;
	
	inc(i, n) { if(s[i] == 'R') { r++; } else { b++; } }
	
	cout << (r > b ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main()
{
    int n,x;
    int i=0;
    while(true){
    std::cin >> n >> x;
        if(n==0 && x==0)break;
    i=0;
    for(int a=1;a<=n;a++){
        for(int b=1;b<=n;b++){
            for(int c=1;c<=n;c++){
                if(a+b+c==x){
                    if(a!=b && b!=c && c!=a){
                        i++;
                    }
                }
            }
        }
    }
    std::cout << i/6 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (abs(a-c)<=d) {
    cout << "Yes" << endl;
  }
  else if (abs(a-b)<=d && abs(b-c)<=d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, W = MAP()
wN, vN = [0]*N, [0]*N
for i in range(N):
    wN[i], vN[i] = MAP()

# dp[何個目までから選ぶか][選んだ荷物の価値] = その価値を達成するために最低限必要な重さ
V = max(vN)*N
dp = [[INF] * (V+1) for i in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for j in range(V+1):
        # 真下には常に送る
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        if j + vN[i] <= V:
            # 添字が範囲内なら右下にも送る
            dp[i+1][j+vN[i]] = min(dp[i+1][j+vN[i]], dp[i][j] + wN[i])
ans = 0
for i in range(V+1):
    if dp[N][i] <= W:
        ans = max(ans, i)
print(ans)


Measured memory_bytes: 319544
N=gets.to_i
S=gets.chomp

dot_from_back=[0]
old=0
S.reverse.each_char do |c|
    if c=="."
        old+=1
    end
    dot_from_back << old
end
dot_from_back << old
dot_from_for=dot_from_back.reverse

sharp_from_for=[0]
old=0
S.each_char do |c|
    if c=="#"
        old+=1
    end
    sharp_from_for << old
end

sharp_from_for << old


min=Float::INFINITY
(S.length+1).times do |i|
    temp=sharp_from_for[i]+dot_from_for[i+1]
    min=temp if temp<min
end


puts min

Measured memory_bytes: 7164
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	class T{
		String name;
		int score;
		int index;

		T(String name, int score, int index){
			this.name=name;
			this.score=score;
			this.index=index;
		}
	}

	void run(){
		sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(;;){
			T[] ts=new T[n];
			for(int i=0; i<n; i++){
				String name=sc.next();
				int win=sc.nextInt();
				int lose=sc.nextInt();
				int draw=sc.nextInt();
				int score=win*3+draw*1;
				ts[i]=new T(name, score, i);
			}
			sort(ts, new Comparator<T>(){
				@Override
				public int compare(T t1, T t2){
					if(t1.score!=t2.score)
						return t2.score-t1.score;
					return t1.index-t2.index;
				}
			});
			for(T t : ts)
				println(t.name+","+t.score);
			n=sc.nextInt();
			if(n==0)
				break;
			println("");
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>

const int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15,
                     2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int k;
    std::cin >> k;

    std::cout << arr[k - 1] << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long 
#define LL long long 
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
using namespace std;
const int MAXN = 1e6 + 10, mod = 1e9 + 7, INF = 1e9 + 10;
const double eps = 1e-9;
template <typename A, typename B> inline bool chmin(A &a, B b){if(a > b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline bool chmax(A &a, B b){if(a < b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline LL add(A x, B y) {if(x + y < 0) return x + y + mod; return x + y >= mod ? x + y - mod : x + y;}
template <typename A, typename B> inline void add2(A &x, B y) {if(x + y < 0) x = x + y + mod; else x = (x + y >= mod ? x + y - mod : x + y);}
template <typename A, typename B> inline LL mul(A x, B y) {return 1ll * x * y % mod;}
template <typename A, typename B> inline void mul2(A &x, B y) {x = (1ll * x * y % mod + mod) % mod;}
template <typename A> inline void debug(A a){cout << a << '\n';}
template <typename A> inline LL sqr(A x){return 1ll * x * x;}
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, c[MAXN], f[MAXN], pre[MAXN], las[MAXN];
signed main() {
	N = read();
	for(int i = 1; i <= N; i++) {
		c[i] = read();
		pre[i] = las[c[i]];
		las[c[i]] = i;
	}
	f[1] = 1;
	for(int i = 2; i <= N; i++) {
		f[i] = f[i - 1];
		if(pre[i] != i - 1) 
			add2(f[i], f[pre[i]]);
	}
	cout << f[N];
	return 0;
}
/*
3
aba
*/

Measured memory_bytes: 13312
#include <stdio.h>
#include <stdlib.h>

#define MAX_N (2999)

double dpss[MAX_N + 1][MAX_N + 1];

int main() {
  // read inputs
  int N;
  double ps[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%lf", &ps[i]);
  }

  // solve dp
  // initialize
  dpss[0][0] = 1.0;
  for (int j = 1; j <= N; j++) {
    dpss[0][j] = 0.0;
  }
  // update
  for (int i = 0; i < N; i++) {
    const double p = ps[i];
    dpss[i + 1][0] = (1 - p) * dpss[i][0];
    for (int j = 1; j <= N; j++) {
      dpss[i + 1][j] = (1 - p) * dpss[i][j] + p * dpss[i][j - 1];
    }
  }

  // print answer
  double ans = 0.0;
  for (int j = 0; j <= N; j++) {
    if (j > N - j) {
      ans += dpss[N][j];
    }
  }
  printf("%.12lf\n", ans);
}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=200005;
ll a[N];
ll n;
map<pii,ll> dp;
ll rec(ll idx,ll left){
    if(dp.find({idx,left})!=dp.end()) return dp[{idx,left}];
    if(idx>=n){
        if(left>0) {
            dp[{idx,left}]=-INF;
            return -INF;
        }
        else{
            dp[{idx,0}]=0;
            return 0;
        }
    }
    ll rem_el=n-idx;
    if(((rem_el+1)/2)<left){
        dp[{idx,left}]=-INF;
        return -INF;
    }
    ll ans;
    ans=rec(idx+1,left);
    if(left>0) ans=max(ans,rec(idx+2,left-1)+a[idx]);
    return dp[{idx,left}]=ans;
}
void solve(){
    cin>>n;
    rep(i,0,n-1) cin>>a[i];
    rec(0,n/2);
    cout<<dp[{0,n/2}]<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

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

int main(){
	int N,i=0,c=0;
  cin >> N;
	
  	string S;
  cin >> S;
  if(N==1)
    c++;
  else if(N==2){
  	if(S.at(0)==S.at(1))
      c=1;
    else
      c=2;
  }
else{    
while(i<N){

 while(i<N-1 && S.at(i)==S.at(i+1)){
   i++;
 }
  if((i==0 && S.at(0)!=S.at(1)) || i!=0)
    i++;
    
  c++;
  

}
}
  cout << c << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    int e = S.size();
    while (e > 0) {
        /* dream dreamer erase eraser */
        if (S.substr(e - 2, 2) == "er") {
            if (S.substr(e - 6, 6) == "eraser") {
                e -= 6;
                continue;
            } else if (S.substr(e - 7, 7) == "dreamer") {
                e -= 7;
                continue;
            }
        }
        if (S.substr(e - 5, 5) == "erase") {
            e -= 5;
            continue;
        } else if (S.substr(e - 5, 5) == "dream") {
            e -= 5;
            continue;
        } else {
            cout << "NO" << endl;
            exit(0);
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

inline int read() {
    int x = 0 ; char c = getchar(); bool f = 0;
    while(c < '0' || c > '9') f |= (c=='-') , c = getchar();
    while(c >= '0' && c <= '9') x = x * 10 + (c^48) , c = getchar();
    return f ? -x : x;
}

vector<int> e[5003];
void add(int f, int t) { e[f].push_back(t), e[t].push_back(f); }
int f[5003][5003], g[5003], tmp[5003];
int n, sz[5003];

void dfs(int u, int fa) {
    f[u][sz[u] = 1] = 1;
    for (int i = 0, v; i < e[u].size(); ++i) {
        if ((v = e[u][i]) == fa) continue;
        dfs(v, u);
        for (int i = 1; i <= sz[u] + sz[v]; ++i) tmp[i] = 0;
        for (int i = 1; i <= sz[u]; ++i)
            for (int j = 0; j <= sz[v]; ++j)
                (tmp[i + j] += 1ll * f[u][i] * f[v][j] % mod) %= mod;
        for (int i = 1; i <= sz[u] + sz[v]; ++i) f[u][i] = tmp[i];
        sz[u] += sz[v];
    }
    for (int i = 2; i <= sz[u]; i += 2)
        (f[u][0] += mod - 1ll * f[u][i] * g[i] % mod) %= mod;
}

int main() {
    g[0] = 1, n = read();
    for (int i = 2; i <= n; i += 2) g[i] = 1ll * g[i - 2] * (i - 1) % mod;
    for (int i = 1; i < n; ++i) add(read(), read());
    dfs(1, 0);
    printf("%d\n", mod - f[1][0]);
    return 0;
}

Measured memory_bytes: 97408
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N = 1e7;
int divs[N+1];
int n;
ll ans;
int main(){
	cin >> n;
	for (int i = 1; i <= n; ++i){
		for (int j = i; j <= n; j += i){
			divs[j]++;
		}
	}
	for (int i = 1; i <= n; ++i){
		//cout << divs[i] << endl;
		ans += (ll)divs[i]*i;
	}
	cout << ans <<endl;


}	

Measured memory_bytes: 42692
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N];
  int pos[N]; //iの位置
  for(int i = 0; i < N; i++){
    cin >> a[i];
    a[i]--;
    pos[a[i]] = i;
  }

  bool swp[N];
  fill(swp, swp + N, true);
  for(int i = 0; i < N - 1; i++){
    if(pos[i] < pos[i+1]) swp[i] = true;
    else swp[i] = false;
  }

  int ans = 0;
  int cnt = 1;
  for(int i = 0; i < N - 1; i++){
    if(swp[i]) cnt++;
    else{
      ans = max(ans, cnt);
      cnt = 1;
    }
  }

  ans = max(ans, cnt);

  /*for(int i = 0; i < N; i++){
    cout << swp[i] << " ";
  }
  cout << endl;*/

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

Measured memory_bytes: 2048
N, Y = map(int, input().split())

x=-1
y=-1
z=-1

Ten=10000
Five=5000
One=1000

count=0

max_x=int(Y//Ten)

if max_x <= N:
	for i in reversed(range(0,max_x+1)):
		if count == 1:
			break
		elif count == 0:
			max_y = int((Y - Ten*i)//Five)
			if (max_y + i) <= N:
				for j in reversed(range(0, max_y+1)):
					if (Ten*i + Five*j + One*(N-i-j))==Y:
						x=i
						y=j
						z=N - i - j
						count+=1
						break

print(x, y, z)

Measured memory_bytes: 3064
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int m=sc.nextInt();
  for(int i=0;i<m;i++)n-=sc.nextInt();
  System.out.println(n>=0?n:-1);
}
}

Measured memory_bytes: 46136
#include<stdio.h>
int main(){
    int a,b,k;
    scanf("%d %d %d",&a,&b,&k);
    int A[a];
    int n = -1;
    for(int i = 1; i <= a; i++){
        if(a % i == 0){
            n++;
            A[n] = i;
            
        }
    }
    int i = n;
    int count = 0;
    int num = 0;
    while(1){
        if(b % A[i] == 0){
            
            num = A[i];
            count++;
        }
        i--;
        if(count == k) break;
    }
    printf("%d",num);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
	double x[4];
	double y[4];
	double xp, yp;
	double temp;
	int i;
	int result;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&xp,&yp)!=EOF){
		result = 0;
		x[3] = x[0];
		y[3] = y[0];
		for(i=0;i<3;i++){
			temp = (x[i+1] - x[i])*(yp - y[i]) - (y[i+1] - y[i])*(xp - x[i]);
			if(temp>0){
				result += 1;
			}else{
				result -= 1;
			}
		}
		if(result == 3 || result == -3){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g, b, n;
    cin >> r >> g >> b >> n;

    ll ans = 0;
    for (int i = 0; i * r <= n; i++) {
        for (int j = 0; i * r + j * g <= n; j++) {
            int k = n - i * r - j * g;
            if (k % b != 0) continue;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int K, N;
	cin >> K >> N;
	int A[N];
	int maxgap = -1;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 1; i < N; i++) {
		if (A[i] - A[i - 1] > maxgap) {
			maxgap = A[i] - A[i - 1];
		}
	}
	if (K - A[N - 1] + A[0] > maxgap) {
		maxgap = K - A[N - 1] + A[0];
	}
	int walkdist = K - maxgap;
	cout << walkdist << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int max = -1000000;
		int min = 1000000;
		long sum = 0;

		for (int i = 0; i < n; i++) {
			int temp = stdIn.nextInt();
			if (temp > max) {
				max = temp;
			}
			if (temp < min) {
				min = temp;
			}
			sum += temp;
		}

		System.out.println(min + " " + max + " " + sum);

		stdIn.close();
	}
}

Measured memory_bytes: 42224
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b;
    a = 1;
    b = 1;
    while(a != 10 && b != 11){
        if(b != 10){
            printf("%dx%d=%d\n",a,b,a * b);
            b ++;
        }
        else{
            b = 1;
            a++;
        } 
    
    }
    return 0;
}



Measured memory_bytes: 2496
n = int(input())
als = list(map(int,input().split()))
ans = 'No'
sett = n//3
als.sort()
if als[0] == 0:
    if als[n-1] == 0:
        ans = 'Yes'
    else:
        cc = [0]*(n//2) + [als[n-1]]*(n//2)
        if cc == als:
            ans = 'Yes'
if n%3 == 0:
    co = [als[0]]*sett + [(als[0]^als[n-1])]*sett + [als[n-1]]*sett
    if co == als:
        ans = 'Yes'
print(ans)

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

#define PI 3.14159265358979323846264338327950L

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int peaks[100010];
    int storage[100010];
    for (int i = 0; i < n; i++) {
        cin >> peaks[i];
        storage[i] = 0;
    }
    for (int j = 0; j < m; j++) {
        int a, b;
        cin >> a >> b;
        storage[a - 1] = max(storage[a - 1], peaks[b - 1]);
        storage[b - 1] = max(storage[b - 1], peaks[a - 1]);
    }
    int answer = 0;
    for (int j = 0; j < n; j++) {
        if (peaks[j] > storage[j]) {
            answer++;
        }
    }
    cout << answer << "\n";

}


Measured memory_bytes: 4424
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	sort(A, A + N);

	rep(i, 0, N - 1) if (A[i] == A[i + 1]) {
		cout << "NO" << endl;
		return;
	}

	cout << "YES" << endl;
}







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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int A, B, C, X;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &X);

  int ans = 0;
  for (int i = 0; i <= A; ++i) {
    for (int j = 0; j <= B; ++j) {
      for (int k = 0; k <= C; ++k) {
        if (i * 500 + j * 100 + k * 50 == X) { ++ans; }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadIntArray(N).ToArray().Distinct();
            var ans = A.Count();
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int count = 0;

    while(A >= B) {
        B *= 2;
        count++;
    }
    while(B >= C) {
        C *= 2;
        count++;
    }

    if(count <= K) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0]*(n+1)
    self.el = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.data[i] += x
      i += i & -i
  def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i)


def main(n,k,a):
  b=[x-k for x in a]
  tmp=0
  cb=[tmp]
  for x in b:
    tmp+=x
    cb.append(tmp)
  from bisect import bisect_right
  cbb=cb.copy()
  cbb.sort()
  cb=[bisect_right(cbb,x) for x in cb]
  bit=BIT(n+2)
  ans=0
  for x in cb:
    ans+=bit.sum(x)
    bit.add(x,1)
  return ans

n,k=map(int,input().split())
a=[int(input()) for _ in range(n)]
print(main(n,k,a))


Measured memory_bytes: 46364
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N):
  for j in range(i+1, N-1):
    k = L[i]+L[j]
    l,r = 0,N
    while (r-l) > 1:
      m = (l+r)//2
      if L[m] >= k:
        r = m
      else:
        l = m

    ans += r-j-1

print(ans)


Measured memory_bytes: 41836
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int i,j,n,p,q,a,b,temp;
    int t=0;
    int flag=0;
    string s;
    cin>>a>>b;
    if(a>=13){cout<<b;}
    else if(a<=5){cout<<0;}
    else{cout<<b/2;}
    return 0;
}

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


int a;

int main(){
	cin >> a;
	cout << "Christmas";
	for(int i = 25; i > a; i--){
		cout << " Eve";
	}
	cout << endl;
	
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    int res = 0;
    while (1) {
        bool flag = false;
        for (int i = 0; i < N; i++) {
            if (vec.at(i)%2 != 0) {
                flag = true;
            }
        }
        if (flag) {
            break;
        }
        for (int i = 0; i < N; i++) {
            vec.at(i) /= 2;
        }
        res += 1;
    }
    cout << res << endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,k,l; cin>>n>>k>>l;
  UnionFind uf1(n), uf2(n);
  rep(i,k){
    ll a,b; cin>>a>>b; a--,b--;
    uf1.connect(a,b);
  }
  
  rep(i,l){
    ll a,b; cin>>a>>b; a--,b--;
    uf2.connect(a,b);
  }
  
  map<pll,ll> m;
  rep(i,n){
    pll p={uf1.root(i),uf2.root(i)};
    m[p]++;
  }
  rep(i,n){
    pll p={uf1.root(i),uf2.root(i)};
    cout<<m[p]<<endl;
  }
  
}


Measured memory_bytes: 15104
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N, M = I()
X = l()
X.sort()
kyori = []

if N >= M:
    print(0)
    sys.exit()

if M == 1:
    print(0)
    sys.exit()
for i in range(len(X)-1):
    s = X[i+1]-X[i]
    kyori.append(s)

kyori.sort()
kyori.reverse()

for j in range(N-1):
    kyori.pop(0)

print(sum(kyori))


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

using namespace std;

#define ll long long

int main(){
	long x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	long p[a], q[b], r[c];
	for(long i=0; i<a; i++){
		cin >> p[i];
	}
	for(long i=0; i<b; i++){
		cin >> q[i];
	}
	for(long i=0; i<c; i++){
		cin >> r[i];
	}
	long dx = (x<a) ? a-x : 0;
	long dy = (y<b) ? b-y : 0;
	sort(p, p+a);
	sort(q, q+b);
	long d = c + (a-dx) + (b-dy);
	long s[d];
	for(long i=0; i<(a-dx); i++){
		s[i] = p[dx+i];
	}
	for(long i=(a-dx); i<(b-dy)+(a-dx); i++){
		s[i] = q[i-a+dx+dy];
	}
	for(long i=(b-dy)+(a-dx); i<d; i++){
		s[i] = r[i-b+dy-a+dx];
	}
	sort(s, s+d);
	long sum=0;
	for(long i=d-1; i>=d-x-y; i--){
		sum+=s[i];
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
int main(void){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if((A>=B)&&(A>=C)){
    printf("%d",B+C);
  }else if((B>=A)&&(B>=C)){
    printf("%d",A+C);
  }else if((C>=B)&&(C>=A)){
    printf("%d",B+A);
  }

      
  return 0;
 }
      

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  for( int i=0; i < N ; i++){
    string x;
    cin >> x;
    if(x == "Y"){
      cout<<"Four"<<endl;
      break;
    }
    else if(i == N-1){
      cout<<"Three"<<endl;
    }
  }
  
}
    
    
    
    

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    ll A[N];
    ll B[N];
    rep(i,N) cin >> A[i] >> B[i];
    ll out = 0;
    rep(i,N){
        A[N-1-i] += out;
        ll C = A[N-1-i]%B[N-1-i];
        if(C==0) C = B[N-1-i];
        out += B[N-1-i]-C;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#define inf

using namespace std;

int n, k, v[100100], h[100100];

int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> h[i];
    v[2] = abs(h[1] - h[2]);
    for(int i=3; i<=n; i++)
    {
        int sol = abs(h[i] - h[i-1]) + v[i-1];
        for(int j=i-1; j>=max(1, i-k); j--)
        {
            int val = v[j] + abs(h[i] - h[j]);
            sol = min(sol, val);
        }
        v[i] = sol;
    }
    cout << v[n] << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll a,b;
  cin>>a>>b;
  ll c;
  if(a%2==0&&b%2==0){
    c=(b-a)/2;
    ll ans;
    if(c%2==0) ans=0;
    else ans=1;
    if(b%2==ans) ans=b-ans;
    else ans=b+ans;
    cout<<ans<<endl;
  }
  
  else if(a%2==0&&b%2==1){
    c=(b-a+1)/2;
    if(c%2==0) cout<<0<<endl;
    else cout<<1<<endl;
  }
  
  else if(a%2==1&&b%2==0){
    c=(b-a-1)/2;
    ll ans;
    if(c%2==0) ans=0;
    else ans=1;
    ll now=0;
    ll n=1;
    while(a>0||b>0){
      if(a%2!=b%2) now+=n;
      a/=2;
      b/=2;
      n*=2;
    }
    if(now%2==ans) ans=now-ans;
    else ans=now+ans;
    cout<<ans<<endl;
  }
  
  else if(a%2==1&&b%2==1){
    c=(b-a)/2;
    ll ans;
    if(c%2==0) ans=0;
    else ans=1;
    if(a%2==ans) ans=a-ans;
    else ans=a+ans;
    cout<<ans<<endl;
  }
}

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

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

using namespace std;

int main() {
  int64_t n, m, k;
  std::cin >> n >> m >> k;
  std::vector<int64_t> a(n), b(m);
  rep(i, n) { std::cin >> a[i]; }
  rep(i, m) { std::cin >> b[i]; }

  int64_t t = 0;
  rep(i, m) { t += b[i]; }

  int j = m, ans = 0;

  for (int i = 0; i <= n; ++i) {
    {
      while (j > 0 && t > k) {
        --j;
        t -= b[j];
      }
      if (t > k) {
        break;
      }
      ans = max(ans, i + j);
      t += a[i];
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 6368
n=input()
ans=int(n)

n_min=list(n[0]*3)
n_min=int("".join(n_min))

a=str(int(n[0])+1)

n_max=list(a*3)
n_max=int("".join(n_max))

#print(n_min)
#print(n_max)

if n_min>=ans:
    print(n_min)
else:
    print(n_max)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 1000;
int n;
int ans = 0;
int h[max_n];
int rec(int st, int en){
  int mi = h[st];
  for(int i=st ; i<=en ; i++){
    mi = min(mi, h[i]);
  }
  for(int i=st ; i<=en ; i++){
    h[i] -= mi;
  }
  ans += mi;
  int st2 = st;
  for(int i=st ; i<=en ; i++){
    st2 = i;
    while(h[i]>0&&i<=en){
      i++;
    }
    rec(st2, i-1);
  }
  return ans;
}

int main(){
  cin >> n;
  int mi = 100;
  for(int i=0 ; i<n ; i++){
    cin >> h[i];
  }
  cout << rec(0, n-1) << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
sum = 0
cnt3 = 0
cnt5 = 0
for i in range(1,n+1):
    cnt3 += 1
    cnt5 += 1
    if cnt3 != 3 and cnt5 != 5:
        sum += i
    if cnt3 == 3:
        cnt3 = 0
    if cnt5 == 5:
        cnt5 = 0
print (sum)


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

int main() {
  int S=0;
  int N;
  long int A;
  cin >> N;

  for (int i =0; i<N; i++) {
    cin >> A;
    if (A%2==1) S++;
  }
  if (S%2==1) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}



Measured memory_bytes: 256
// B.

#include <iostream>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	LL n;
	cin >> n;
	LL ans = 1;
	for (LL i = 1; i <= n; ++i) {
		ans = (ans * i) % 1000000007;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    string S; cin >> S;

    int a = -1, z = -1;
    F0R(i, sz(S)) {
        if (S[i] == 'A' && a == -1) a = i;
        if (S[i] == 'Z') z = i;
    }

    assert(a != -1 && z != -1);

    cout << z-a+1 << "\n";

}


Measured memory_bytes: 720
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int five = 0, seven = 0;

            for (var i = 0; i < 3; i++)
            {
                if (abc[i] == 5) five++;
                if (abc[i] == 7) seven++;
            }

            Console.WriteLine(five == 2 && seven == 1 ? "YES" : "NO");
        }
    }
}


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

typedef long long ll;
const int maxn = 100010, P = 1000000007;
int n, m, S, T;
ll d1[maxn], d2[maxn], f1[maxn], f2[maxn];
vector<pair<int, int>> G[maxn];
priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;

int main() {
    scanf("%d %d %d %d", &n, &m, &S, &T);
    for (int i = 1, u, v, w; i <= m; i++) {
        scanf("%d %d %d", &u, &v, &w);
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }
    memset(d1, 0x3f, sizeof(d1));
    q.push(make_pair(d1[S] = 0, S)), f1[S] = 1;
    while (!q.empty()) {
        auto p = q.top(); q.pop();
        int v = p.second;
        if (p.first ^ d1[v]) continue;
        for (auto e : G[v]) {
            if (d1[e.first] > d1[v] + e.second) {
                d1[e.first] = d1[v] + e.second, f1[e.first] = f1[v];
                q.push(make_pair(d1[e.first], e.first));
            } else if (d1[e.first] == d1[v] + e.second) {
                (f1[e.first] += f1[v]) %= P;
            }
        }
    }
    memset(d2, 0x3f, sizeof(d2));
    q.push(make_pair(d2[T] = 0, T)), f2[T] = 1;
    while (!q.empty()) {
        auto p = q.top(); q.pop();
        int v = p.second;
        if (p.first ^ d2[v]) continue;
        for (auto e : G[v]) {
            if (d2[e.first] > d2[v] + e.second) {
                d2[e.first] = d2[v] + e.second, f2[e.first] = f2[v];
                q.push(make_pair(d2[e.first], e.first));
            } else if (d2[e.first] == d2[v] + e.second) {
                (f2[e.first] += f2[v]) %= P;
            }
        }
    }
    int ans = 1LL * f1[T] * f1[T] % P;
    for (int i = 1; i <= n; i++) {
        if (d1[i] == d1[T] / 2 && d1[i] == d2[i]) {
            int t = 1LL * f1[i] * f2[i] % P;
            ans = (ans - 1LL * t * t % P + P) % P;
        }
        for (auto e : G[i]) {
            if (d1[i] < d1[T] / 2 && d2[e.first] < d1[T] / 2 && d1[i]
                + d2[e.first] + e.second == d1[T]) {
                int t = 1LL * f1[i] * f2[e.first] % P;
                ans = (ans - 1LL * t * t % P + P) % P;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int>high(N);
    for (int i=0; i<N; i++){
        cin >> high.at(i) ;

    }
    vector<vector<int>>data(M,vector<int>(2));
    for(int i=0;i<M;i++){
        cin >> data.at(i).at(0) >> data.at(i).at(1) ;
    }
    
    
    vector<int>a(N);


    for(int i=0; i<M; i++){
      if(high.at(data.at(i).at(0)-1) > high.at(data.at(i).at(1)-1)){
          //Aのほうが大きい
          a.at(data.at(i).at(1)-1)++;;
      }  
      if(high.at(data.at(i).at(1)-1) > high.at(data.at(i).at(0)-1)){
          //Bのほうが大きい
          a.at(data.at(i).at(0)-1)++;
      }  
      if(high.at(data.at(i).at(0)-1) == high.at(data.at(i).at(1)-1)){
          //同じ
            a.at(data.at(i).at(1)-1)++;
            a.at(data.at(i).at(0)-1)++;

      }  
    }
    int A=0;
    for(int x: a){
        if(x==0){
            A++;
        }
    }
    cout << A << endl;

  
}


Measured memory_bytes: 9592
#include <stdio.h>
int main()
{
	int A, B, C, D, L, R;
	
	scanf("%d%d%d%d", &A, &B, &C, &D);

	L = A + B;

	R = C + D;

	if (L > R)
		printf("Left");
	else if (R > L)
		printf("Right");
	else
		printf(" Balanced");
}

Measured memory_bytes: 1704
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


int main() {
////	ios::sync_with_stdio(false);
//	cin.tie(0);
//
	string s;
//	cin >> s;
	while(cin>>s){
	    N=M=0;
	    for (int i = 0; i < s.size() - 2; i++) {
		if (s[i + 1] == 'O'&&s[i + 2] == 'I') {
			N += s[i] == 'J';
			M += s[i] == 'I';
		}
	}
	cout << N << endl << M << endl;
//	cin>>s;
	}
	return 0;
}


Measured memory_bytes: 3196
import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).use { sc ->
        val a = sc.nextInt()
        val b = sc.nextInt()
        val c = sc.nextInt()
        val x = sc.nextInt()

        var r = 0
        for (ai in 0..a) {
            for (bi in 0..b) {
                val m = ai * 500 + bi * 100
                if (m <= x) {
                    if (m + c * 50 >= x) {
                        r++
                    }
                } else {
                    break
                }
            }
        }
        println(r)
    }
}


Measured memory_bytes: 29736