akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		map<int, int> s;
		for (int i = 0; i < n; ++i)
		{
			int t;
			scanf("%d", &t);
			++s[t];
		}
		int ans = -1;
		for (map<int, int>::iterator it = s.begin(); ans == -1 && it != s.end(); ++it)
		{
			if (it->second > n/2)
				ans = it->first;
		}
		if (ans != -1)
			printf("%d\n", ans);
		else
			printf("NO COLOR\n");
	}

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i = 0; i<N; ++i) cin >> h.at(i);
  
  vector<int> dp(N,1001001000);
  
  dp.at(0) = 0;
  
  for(int i = 0; i<N-1; ++i){
    dp.at(i+1) = min(dp.at(i+1),
                     dp.at(i)+abs(h.at(i)-h.at(i+1))
                    );
    if(i+2<N){
      dp.at(i+2) = min(dp.at(i+2),
                     dp.at(i)+abs(h.at(i)-h.at(i+2))
                    );
    }
  }
  
  cout << dp.at(N-1) << endl;
}

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

using namespace std;

int main()
{
    int a, b , c , d , p , h;
    cin>>a>>b>>c>>d;
    h = ceil((float)a/d);
    p = ceil((float)c/b);
   // cout<<h<<endl;
    if(h<p)cout<<"No"<<endl;
    else 
    {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>

using namespace std;

int n, k;

int main(){
  cin >> n >> k;
  if(n % 2 != 0){
    if(((n - 1) / 2) + 1 >= k){
      cout << "YES" << endl;
    }else
    {
      cout << "NO" << endl;
    }
  }else{
    if((n / 2) >= k){
      cout << "YES" << endl;
    }else
    {
      cout << "NO" << endl;
    }
  }
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b and b==c){
        if(a%2==0) cout<<-1<<en;
        else cout<<0<<en;
        return;
    }
    
    auto count = [](ll x)->ll{
        ll con=0;
        while(x%2==0){
            x/=2;
            con++;
        }
        return con;
    };

    ll cona=count(a);
    ll conb=count(b);
    ll conc=count(c);
    ll mi=min({cona,conb,conc});
    ll ma=max({cona,conb,conc});
    if(ma==mi && mi>0) cout<<mi+1<<en;
    else cout<<mi<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long  div1[10000001];
int main()
{
        for( int i =2;i<10000001;i++){
                for(int j = i;j<10000001;j+=i){
                        div1[j]++ ; 
                }
        }
        
        int n ; 
        cin>>n;
      //  div1[10000000]++ ; 
        
        long long sum =0 ; 
        for(int i =1;i<=n;i++){
                sum+=i*(div1[i]+1);
        }cout<<sum ; 
}

Measured memory_bytes: 81756
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n;
    
 
   cin >> n;
   string strArr[n];
  
  // cout << n << endl;
   for(int i = 0;i<n;i++){
     
     cin >> strArr[i];
     
   }
  
   int flag = 0;
  
   for(int i = 0;i<n;i++){
     
     int jyufuku = 0;
     
     for(int j = 0;j<n;j++){
       
         if(strArr[i]==strArr[j]){
        
           jyufuku++;
         }
       
     }
     
     if(jyufuku!=1){
       
       flag = 1;
       break;
     }
     
   }
  
   int num = 0;
  
   for(int i = 1;i<n;i++){
     
    // cout << strArr[i] << strArr[i-1] <<endl;
     string a = strArr[i];
   //  cout << a[0] <<endl;
     
     string b = strArr[i-1];
     
    // cout << b[b.size()-1] <<endl;
     
     if(a[0]==b[b.size()-1]){
       
       num++;
     }
     
   //  if()

   }
  
  if(flag==0){
    
     if(num==n-1){
     
      cout << "Yes" <<endl;
     
      }else{
     
        cout << "No" <<endl;
     }
    
  }else{
    cout << "No" <<endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main(){

	int n;
	cin >> n;
	int a[n];
	for(int i = 0;i<n;i++) cin >> a[i];
	for(int i = n-1;i >= 0;i--) {
		if(i != 0) cout << a[i] << " ";
		else cout << a[i] << "\n";
	}

	return 0;
}



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

vector<bool> visited;
vector<set<int>> tree;
vector<int> point;

void dfs(int parent) {

  visited[parent] = true;

  for (int i_ : tree[parent]) {
    if (!visited[i_]) {
      point[i_] += point[parent];
      dfs(i_);
    }
  }
 
}

int main() {

  int N, Q;
  cin >> N >> Q;

  tree.resize(N);
  visited.resize(N);
  point.resize(N);

  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    tree[a - 1].insert(b - 1);
    tree[b - 1].insert(a - 1);
  }
  
  for (int i = 0; i < Q; i++) {
    int p, x;
    cin >> p >> x;
    point[p - 1] += x;
  }

  dfs(0);

  for (int i = 0; i < N; i++) {
    cout << point[i] << " ";
  }

  cout << endl;

}

Measured memory_bytes: 40704
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		if(n == 1){
			System.out.println(1);
			return;
		}
		int i = 1;
		ArrayDeque<Long> queue = new ArrayDeque<>();
		queue.addFirst((long)2);
		queue.addFirst((long)1);
		Long sum;
		while(i < n){
			sum = (long)0;
			sum += queue.getFirst() + queue.getLast();
			queue.addFirst(sum);
			queue.removeLast();
			i++;
		}
		System.out.println(queue.getFirst());
	}

}


Measured memory_bytes: 21844
n,m,x,y=map(int,input().split())
xl=list(map(int,input().split()))
yl=list(map(int,input().split()))
ans='War'
if x<y:
    for i in range(x+1,y+1):
        if max(xl)<i and min(yl)>=i:
            ans='No War'
print(ans)

Measured memory_bytes: 3060
N = int(input())
A = [int(_)for _ in input().split()]
sumA = sum(A)
halfsumA = sumA / 2
pos = 0
for n, a in enumerate(A):
    pos += a
    if pos > halfsumA:
        l = pos - a
        r = pos
        # 小さい方が差が小さい
        if abs(l - halfsumA) < abs(r - halfsumA):
            ans = abs((sumA - l) - l)
        else:
            ans = abs((sumA - r) - r)

        break

print(ans)

Measured memory_bytes: 26220
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int N = Int ();
        int[] B = new int[N + 1];

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

        B[0] = B[1];
        B[N] = B[N - 1];

        int ret = 0;
        for (int i = 0; i < N; i++) {
            ret += Math.Min (B[i], B[i + 1]);
        }

        Console.WriteLine (ret);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

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

int main()
{
	int n, lt;
	cin >> n >> lt;
	int aws = 1001;

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

		if (t <= lt)
		{
			aws = min(aws, c);
		}
	}

	if (aws == 1001)
	{
		cout << "TLE" << endl;
	}
	else
	{
		cout << aws << endl;
	}
}


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


int main(void)
{
    char a[100], b[100];
    int len;

    scanf("%s", &a);
    len = strlen(a);

    for (int i = 0; i < len; i++) {
        b[i] = a[len - i-1];
    }
    b[len] = '\0';
    
    if (strcmp(a, b) != 0) {
        puts("No");
        return 0;
    }
    
    char c[50];
    char d[50];
    for (int i = 0; i < len / 2; i++) {
        c[i] = a[i];
    }
    c[len / 2] = '\0';
    for (int i = 0; i < len/2; i++) {
        d[i] = c[len/2 - i - 1];
    }
    d[len/2] = '\0';

    if (strcmp(c, d) != 0) {
        puts("No");
        return 0;
    }


    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int t[100][100];
int u[100],v[100];

void solve(){
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(u[i]!=v[j])continue;
      cout<<t[i][j]<<endl;
      return;
    }
  }
  cout<<0<<endl;
}

int main(){
  while(cin>>n&&n){
    for(int i=0;i<n;i++){
      u[i]=1e8;v[i]=-1;
      for(int j=0;j<n;j++){
	cin>>t[i][j];
      }
    }
    
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	u[i]=min(u[i],t[i][j]);
	v[j]=max(v[j],t[i][j]);
      }
    }
    
    solve();

  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  ll a,b,n;
  cin>>a>>b>>n;
  if(b-1<=n){
    cout<<a*(b-1)/b<<endl;
    return 0;
  }
  cout<<a*n/b<<endl;
}

Measured memory_bytes: 3492
# -*- coding: utf-8 -*-
import numpy as np

iMod = 1000000007
lModPow = [iP for iP, s in enumerate(bin(iMod-2)[:1:-1]) if s == "1"]

def fnModInv(iDivN):
  lNp  = [iDivN % iMod]
  for _ in range(max(lModPow)):
    lNp.append(lNp[-1]**2 % iMod)
  iRet = 1
  for iP in lModPow:
    iRet *= lNp[iP]
    iRet %= iMod
  return iRet

def fnSolv():
  iNum, iK = map(int, input().split())
  naU = [0]*iNum
  naA = np.array(list(map(int, input().split())), dtype = np.int64)
  naA = np.sort(naA)
  iRet =0
  if iK >= 2:
    naU[-iK] = 1
    for iK0 in range(iNum - iK):
      naU[-iK -iK0 - 1]= ( (naU[- iK - iK0] * (iK + iK0))%iMod * fnModInv(iK0 + 1) )%iMod
  for iL, iA in enumerate(naA):
    iRet += ((naU[-iL-1] - naU[iL])%iMod * iA)%iMod
    iRet %=iMod
  print(iRet)

if __name__ == '__main__':
  fnSolv()


Measured memory_bytes: 24292
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;
long long MOD;
using namespace std;


int main(int argc, char* argv[])
{
    int a,b,x;
    scanf("%d%d%d", &a, &b, &x);
    const double PI=3.14159265358979;
    double L=(double)x/a/a;
    if(L>=(double)b/2) {
        double tmp=2*(double)(b-L)/a;
        
        double ans=atan(tmp)/PI*180;
        printf("%.10lf\n", ans);
    }
    else {
        double tmp=(double)x/a*2/b;
        tmp=(double)b/tmp;
        double ans=atan(tmp)/PI*180;
        printf("%.10lf\n", ans);
    }

    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>     
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define rev(i,n) for(ll i=n-1;i>=0;--i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
//cout << fixed << setprecision(10) << num << endl;
signed main() {
	string s;
	cin >> s;
	rep(i,s.size()) {
		if (s[i] != 'h' && i % 2 == 0) {
			cout << "No" << endl; return 0;
		}
		if (s[i] != 'i' && i % 2 == 1) {
			cout << "No" << endl; return 0;
		}
	}
	if (s.size() % 2 != 0) {
		cout << "No" << endl; return 0;
	}
	cout << "Yes" << endl; return 0;
}


Measured memory_bytes: 256
def B_BiteEating():
    N, L = map(int,input().split())
    eat = 0
    if L >= 0:
        eat = L
    elif L + N <= 0:
        eat = L + N - 1
    else:
        eat = 0
    print(sum([i for i in range(L, L + N)]) - eat)
    
if __name__ =="__main__":
    B_BiteEating()

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>

using namespace std;
int a[100];

int main() {

	int n; 
	cin >> n;

	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());

	int sum1 = 0;
	int	sum2 = 0;

	for (int i = 1; i <= n; ++i) {
		if (i % 2 == 1) {
			sum1 = sum1 + a[i - 1];
		}
		else {
			sum2 = sum2 + a[i - 1];
		}

	}

	cout << sum1 - sum2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <cstring>
#include <stdio.h>

using namespace std;

typedef long long int lli;

int main() {
	int n, x, y;
	cin >> n >> x >> y;

	int ans[2005] = {};
	for (int i = 1; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			int dis = std::min(j - i, std::abs(x - i) + std::abs(y - j) + 1);
			ans[dis]++;
		}
	}

	for (int i = 1; i <= n - 1; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc172/abc172_d.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  ll ans = 0;
  rep(i, N) {
    ll X = (i + 1);
    ll Y = N / X;
    ans += Y * (Y + 1) * X / 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

double x = 0;
double y = 0;

int main() {
	double dir = M_PI/2;
	double d, t;
	// dump(sin(M_PI));
	// dump(cos(dir));
	// dump(sin(dir));
	while (scanf("%lf,%lf",&d,&t) != EOF) {
		// cout << d << " " << t << endl;
		if (d == 0) break;
		x += d*cos(dir);
		y += d*sin(dir);
		dir += -t/180*M_PI;
	}
	cout << (ll)(x+1e-8) << endl;
	cout << (ll)(y+1e-8) << endl;
	return 0;
}

Measured memory_bytes: 3556
import java.util.Scanner;
import java.util.ArrayList;

class RMQ {
	ArrayList<Integer> node;
	int defval;
	int N;
	int n;

	public int func(int a, int b) {
		return Math.min(a, b);
	}
	public void init(int n, int defval) {
		node = new ArrayList<>();
		N = 1;
		while (N < n)N *= 2;
		this.n = n;
		this.defval = defval;
		for (int i = 0; i < N * 2 - 1; i++)
			node.add(defval);
	}
	public int query(int a, int b, int l, int r, int i) {
		if (r == -1) r = N;
		if (b <= l || r <= a) return defval;
		if (a <= l && r <= b) return node.get(i);
		return func(query(a, b, l, (l + r) / 2, i * 2 + 1), query(a, b, (l + r) / 2, r, i * 2 + 2));
	}
	public void update(int p, int v) {
		int q = p + N - 1;
		node.set(q, v);
		while (q != 0) {
			q = (q - 1) / 2;
			node.set(q, func(node.get(q * 2 + 1), node.get(q * 2 + 2)));
		}
	}
	public int get(int p) { return node.get(p + N - 1); }
};


public class Main{
	public static void main(String[] args){
		RMQ t; t = new RMQ();
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		ArrayList<Integer> ans = new ArrayList<>();
		t.init(n, 0x7fffffff);
		for(int i = 0; i < q; i ++){
			int c = Integer.parseInt(sc.next());
			int x = Integer.parseInt(sc.next());
			int y = Integer.parseInt(sc.next());
			if (c == 0) {
				t.update(x, y);
			}
			 else {
				ans.add(t.query(x, y + 1, 0, -1, 0));
			}
		}
		for (int i = 0; i < ans.size(); i++)
		    System.out.println(ans.get(i));
	}
}



Measured memory_bytes: 98808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int[] prime = new int[100001];
		prime[0] = 0;
		prime[1] = 0;
		prime[2] = 0;
		prime[3] = 1;
		prime[4] = 1;
		for (int i = 5; i < 100000; i = i + 2) {
			boolean b = true;
			for (int j = 2; j * j <= i; j++) {
				if (i % j == 0) {
					b = false;
					break;
				}
			}
			for (int j = 2; j * j <= (i + 1) / 2; j++) {
				if ((i + 1) / 2 % j == 0) {
					b = false;
					break;
				}
			}
			if (b) {
				prime[i] = prime[i - 1] + 1;
				prime[i + 1] = prime[i];
			} else {
				prime[i] = prime[i - 1];
				prime[i + 1] = prime[i - 1];
			}
		}

		int n = sc.nextInt();
		int l, r, cnt;
		for (int i = 0; i < n; i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			sb.append(prime[r] - prime[l-1] + "\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 72296
// F.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <map>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL k = -1, q = -1, n, x, m;
		cin >> k >> q;
		if (k < 0) return 0;
		vector<LL> d(k);
		for (int i = 0; i < k; ++i) {
			cin >> d[i];
		}
		for (int qi = 0; qi < q; ++qi) {
			cin >> n >> x >> m;
			LL sum = x;
			LL zc = 0;
			for (int i = 0; i < k; ++i) {
				LL e = d[i] % m;
				LL c = (n - 1) / k + (((n - 1) % k) >= i + 1);
				sum += e * c;
				if (e == 0) {
					zc += c;
				}
			}
			LL ans = n - 1 - (sum / m - x / m + zc);
			cout << ans << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 384
class RollingHash:

    def __init__(self, string, root, mod):
        self.root = root
        self.mod = mod
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            self.hs[i + 1] = self.hs[i] * self.root + ord(string[i]) % self.mod
            self.pw[i + 1] = self.pw[i] * self.root % self.mod

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        return (self.hs[r] - self.hs[l] * self.pw[r - l]) % self.mod

    def __getitem__(self, index):
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0


RHMOD = 1 << 61 - 1
POSITIVIZER = RHMOD << 20
class RollingHashMOD61:
    """
    MOD == 2 ** 61 - 1
    参考: https://qiita.com/keymoon/items/11fac5627672a6d6a9f6
    """


    def __init__(self, string, root):
        self.root = root
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            tmp = self.hs[i] * self.root + ord(string[i])
            self.hs[i + 1] = tmp >> 61 + (tmp & RHMOD)
            tmp = self.pw[i] * self.root
            self.pw[i + 1] = tmp >> 61 + (tmp & RHMOD)

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        ret = (self.hs[r] - self.hs[l] * self.pw[r - l] + POSITIVIZER)
        ret = ret >> 61 + (ret & RHMOD)
        return ret

    def __getitem__(self, index):
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0
        
if __name__ == "__main__":
    N = int(input())
    S = input()

    MOD = 2 ** 61 - 1
    root = 10000

    rh = RollingHash(S, root, MOD)

    ok = 0
    ng = N
    while ng - ok > 1:
        mid = (ok + ng) // 2
        hashes = dict()
        flg = False
        for i in range(N - mid + 1):
            hashofsub = rh[i:i+mid]
            if hashofsub in hashes:
                if i >= hashes[hashofsub] + mid:
                    flg = True
                    break
            else:
                hashes[hashofsub] = i
        
        if flg:
            ok = mid
        else:
            ng = mid

    print(ok)


Measured memory_bytes: 97884
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

bool solve(int N, int K, vector<int>& A) {
    sort(A.begin(), A.end());
    int GCD = A[0];
    rep(i,N) GCD = gcd(GCD, A[i]);
    return (K % GCD == 0);
}

int main() {
    int N, K; cin >> N >> K;
    vector<int> A(N);
    int ma = 0;
    rep(i,N) {
        cin >> A.at(i);
        if (ma < A[i]) ma = A[i];
        if (K == A[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    if (K > ma) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    bool possible = solve(N, K, A);
    if (possible) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


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

#define int long long int
#define vi vector<int>
#define pb push_back
#define vvi vector<vi>

signed main() {
    int n;
    cin >> n;
    if(n % 2) {
        cout << 0 << endl;
        return 0;
    }
    int cnt = 0;
    for(int i = 10; i <= n; i *= 5) {
        cnt += (n / i);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int A[3][3];
    bool isOK[3][3];
    for (int yi = 0; yi < 3; ++yi) {
        for (int xi = 0; xi < 3; ++xi) {
            cin >> A[yi][xi];
            isOK[yi][xi] = false;
        }
    }
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        for (int yi = 0; yi < 3; ++yi) {
            for (int xi = 0; xi < 3; ++xi) {
                if(tmp == A[yi][xi]){
                    isOK[yi][xi] = true;
                }
            }
        }
    }
    for (int yi = 0; yi < 3; ++yi) {
        if(isOK[yi][0] && isOK[yi][1] && isOK[yi][2]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    for (int xi = 0; xi < 3; ++xi) {
        if(isOK[0][xi] && isOK[1][xi] && isOK[2][xi]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(isOK[0][0] && isOK[1][1] && isOK[2][2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(isOK[0][2] && isOK[1][1] && isOK[0][2]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,z,w = na()
a = na()

if n == 1:
    print(abs(a[-1]-w))
    exit()

print(max(abs(a[-1]-w),abs(a[-2]-a[-1])))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=300005,INF=1<<30;
int p[MAX],v[MAX],w[MAX];

vector<pair<int,int>> C[MAX];

vector<int> use[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    
    p[0]=-1;
    for(int i=2;i<=N;i++){
        p[i-1]=i/2-1;
    }
    
    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i];
    }
    
    for(int i=0;i<(1<<11);i++){
        for(int j=0;j<11;j++){
            if(i&(1<<j)) use[i].push_back(j);
        }
    }
    
    int Q;cin>>Q;
    
    for(int u=0;u<min(N,2047);u++){
        vector<int> A,B;
        int save=u;
        while(u!=-1){
            A.push_back(v[u]);
            B.push_back(w[u]);
            u=p[u];
        }
        u=save;
        int M=si(A);
        C[u].push_back(mp(0,0));
        
        for(int bit=0;bit<(1<<M);bit++){
            int vsum=0,wsum=0;
            for(int i:use[bit]){
                vsum+=A[i];
                wsum+=B[i];
            }
            C[u].push_back(mp(wsum,vsum));
        }
        
        sort(all(C[u]));
    }
    
    vector<int> A,B;
    
    while(Q--){
        int u,L;cin>>u>>L;
        u--;
        
        if(u<min(N,2047)){
            int ans=0;
            for(int i=0;i<si(C[u]);i++){
                if(C[u][i].fi<=L) chmax(ans,C[u][i].se);
            }
            cout<<ans<<"\n";
            continue;
        }
        
        while(u>=2047){
            A.push_back(v[u]);
            B.push_back(w[u]);
            u=p[u];
        }
        
        int M=si(A);
        
        vector<pair<int,int>> D(1<<M);
        
        for(int bit=0;bit<(1<<M);bit++){
            int vsum=0,wsum=0;
            for(int i:use[bit]){
                vsum+=A[i];
                wsum+=B[i];
            }
            D[bit]=(mp(L-wsum,vsum));
        }
        
        D.push_back(mp(0,0));
        D.push_back(mp(L,0));
        
        sort(all(D));
        
        for(int i=si(D)-2;i>=0;i--) chmax(D[i].se,D[i+1].se);
        
        int ans=0;
        
        int id=0;
        
        for(int i=0;i<si(C[u]);i++){
            if(C[u][i].fi>L) break;
            while(id<si(D)&&C[u][i].fi>D[id].fi) id++;
            chmax(ans,C[u][i].se+D[id].se);
        }
        
        cout<<ans<<"\n";
        
        A.clear();
        B.clear();
    }
    
}



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

int main() {
	int i = 0, a, b, temp;
	while(i != 3000) {
		cin >> a >> b;
		if(a > b) {
			temp = a;
			a = b;
			b = temp;
		}
		if(a == 0 && b == 0) {
			break;
		}
		i++;
		cout << a << " " << b << endl;
	}
}


Measured memory_bytes: 3084
import sys

class Rect():
    def __init__(self,w,h):
        self.w = w
        self.h = h

    def draw(self):
        for i in range(self.w):
            for j in range(self.h):
                sys.stdout.write("#")
            sys.stdout.write("\n")
        sys.stdout.write("\n")

def main():
    data = []
    while 1:
        n = input().split()
        w = int(n[0])
        h = int(n[1])

        if w == 0 and h == 0:
            break

        data.append(Rect(w,h))

    for num in data:
        num.draw()

if __name__ == "__main__":
    main()

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

int a[200005];

int main()
{
    int n;
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    int maxv=-2000000000;
    int minv=a[0];
    for(i=1;i<n;i++)
    {
        if(maxv<(a[i]-minv))
            maxv=a[i]-minv;
        if(minv>a[i])
            minv=a[i];
    }
    printf("%d\n",maxv);
    return 0;
}

Measured memory_bytes: 3528
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(br.readLine());
        String s;
        Set<String> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            s = br.readLine();
            set.add(s);
        }

        br.close();

        bw.write(String.valueOf(set.size()));

        bw.flush();

    }
}

Measured memory_bytes: 66852
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
const long long Maxn=1e5+5;
typedef long long ll;

char s[4];

int main(){
	int a=0,b=0,c=0;
	scanf("%s",s);
	for(int i=0;i<strlen(s);i++){
		if(s[i]=='a') a++;
		if(s[i]=='b') b++;
		if(s[i]=='c') c++;
	}
	if(a==1&&b==1&&c==1) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
a=[]
b=1001
n,t=map(int,input().split(" "))
for _ in range(n):
    a.append(tuple(map(int,input().split(" "))))
for i in range(n):
    if t>=a[i][1]:
        if b>a[i][0]:
            b=a[i][0]
if b !=1001:
    print(b)
else:
    print("TLE")

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

vector<int> to[200005];
vector<int> ans;

void dfs(int u, int p = -1) {
    for (int i = 0; i < to[u].size(); i++) {
        int v = to[u][i];
        if (v == p) {
            continue;
        }
        ans[v] += ans[u];
        dfs(v, u);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);//resizeは0を格納する
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);

    for (int i = 0; i < n; i++) {
        if (i) {
            cout << " ";
        }
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	string s;
	int ans = 0;
	
	cin >> s;
	for(int i = 0; i < 3; i++){
		if(s[i] == 'R'){
			ans = 1;
			i++;
			while(i < 3 && s[i] == 'R') ans++, i++;
		} 
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    ll a ;
    double b ;
    cin >> a >> b ;
    //a = 100 ;
    //b = 0.53 ;
    double eps = 0.001 ;
    ll llb = 100*b + eps ;

    //cout << (ll) (a*b) << endl ;

    cout << (a*llb/100) << endl ;




        return 0; 
}

Measured memory_bytes: 3716
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.exception;

  int n; rd(n);
  auto a=readln.split.to!(long[]);
  auto b=readln.split.to!(long[]);

  auto d=new long[](n);
  foreach(i; 0..n) d[i]=b[i]-a[i];
  sort(d);
  for(int i=0, j=n-1; i<n; i++){
    if(d[i]>=0){writeln("Yes"); return;}
    if(d[j]>=d[i]*(-1)*2) d[j]+=d[i]*2;
    else{
      auto r=d[i]*(-1)-(d[j--]/2);
      while(j>=0 && r>0){
        if(d[j]<=1){writeln("No"); return;}
        if(d[j]>=r*2){d[j]-=r*2; break;}
        else r-=d[j--]/2;
      }
      if(j<0){writeln("No"); return;}
    }
  }

  enforce(false);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <string>
#include <cfenv>
#include <cmath>
#include <string>
#include <algorithm>
#include <cassert>
#include <functional>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main(){
  double a,b;
  int rec;
  cin >> a >> b;
  int Min = ceil(max(a/0.08,b*10));
  int Max = ceil(min((a+1)/0.08,(b+1)*10)-1);
  if(Min > Max) rec = -1;
  else rec = Min;
  cout << rec << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static final int MAX = 100;
	static final int INF = 1 << 21;
	static final int WHITE = 0;
	static final int GRAY = 1;
	static final int BLACK = 2;
	static int n;
	static int[][]M = new int[MAX][MAX];
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				M[i][j] = INF;
			}
		}
		for(int i = 0; i < n; i++) {
			int u = scan.nextInt();
			int k = scan.nextInt();
			for(int j = 0; j < k; j++) {
				int v = scan.nextInt();
				int c = scan.nextInt();
				M[u][v] = c;
			}
		}
		scan.close();
		dijkstra();
	}
	static void dijkstra() {
		int minV;
		int[]d = new int [MAX];
		int[]color = new int [MAX];
		for(int i = 0; i < n; i++) {
			d[i] = INF;
			color[i] = WHITE;
		}
		d[0] = 0;
		color[0] = GRAY;
		while(true) {
			minV = INF;
			int u = -1;
			for(int i = 0; i < n; i++) {
				if(minV > d[i] && color[i] != BLACK) {
					u = i;
					minV = d[i];
				}
			}
			if(u == -1) break;
			color[u] = BLACK;
			for(int v = 0; v < n; v++) {
				if(d[v] > d[u] + M[u][v]) {
					d[v] = d[u] + M[u][v];
					color[v] = GRAY;
				}
			}
		}
		for(int i = 0; i < n; i++) {
			if(d[i] == INF) {
				System.out.println(i + " " + -1);
			}else {
				System.out.println(i + " " + d[i]);
			}
		}
	}
}


Measured memory_bytes: 40224
N=int(input())
A=list(map(int,input().split()))
four,two,one = 0,0,0

for i in A:
    if i%4==0:
        four+=1
    elif i%2==0:
        two+=1
    else:
        one+=1

s=''
import sys
if one==0:
    print('Yes')
    sys.exit()
else:
    s+='1'
    one-=1

while four!=0 or two!=0 or one!=0:
    if s[-1]=='1':
        if four!=0:
            s+='4'
            four-=1
        else:
            print('No')
            sys.exit()
    elif s[-1]=='2':
        if two!=0:
            s+='2'
            two-=1
        elif four!=0:
            s+='4'
            four-=1
        else:
            print('No')
            sys.exit()
    else:
        if one!=0:
            s+='1'
            one-=1
        elif two!=0:
            s+='2'
            two-=1
        else:
            s+='4'
            four-=1

print('Yes')

Measured memory_bytes: 14480
#include <iostream>

 int main() {

	 int x;
	 int a = 1;
	 std::cin >> x;
	 
	 while (x > 0) {
		 x -= a;
		 a += 1;
	 }
	 std::cout << a - 1 << std::endl;

	 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h,n;
    cin>>h>>n;
    ll sum=0;
    for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        sum+=x;
    }
    if(sum>=h)
    cout<<"Yes";
    else
    cout<<"No";
} 


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

int n, a[2005], d[2005][2005][2];
int f(int p, int q, int w) {
	if(d[p][q][w] != -1) return d[p][q][w];
	int k = max(p, q);
	if(k == n+1) return abs(a[p] - a[q]);
	if(p == 0) return d[p][q][w] = f(k+1, q, 0);
	if(w == 0) return d[p][q][w] = max(f(k+1, q, 0), f(p, k+1, 1));
	else return d[p][q][w] = min(f(k+1, q, 0), f(p, k+1, 1));
}

int main() {
	cin>>n>>a[0]>>a[1];
	for(int i=2; i<n+2; i++) scanf("%d", &a[i]);
	memset(d, -1, sizeof(d));
	cout<<f(0, 1, 0);
	return 0;
}


Measured memory_bytes: 31744
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numOfTest = sc.nextInt(); 
		int[] time = new int[numOfTest];
		int sum = 0;
		for(int i = 0; i < numOfTest; i++) {
			time[i] = sc.nextInt();
			sum += time[i];
		}
		int numOfDrink = sc.nextInt();
		int[] totalTime = new int [numOfDrink];
		for(int j = 0; j < numOfDrink; j++) {
			int i = sc.nextInt();
			totalTime[j] = sum - time[i - 1] + sc.nextInt();
		}
		for(int j : totalTime) {
			System.out.println(j);
		}
	}
}

Measured memory_bytes: 22740
#include "bits/stdc++.h"
#include <unordered_set>

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979323846

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================
struct Point { double x, y; };

void print(Point a) {
	printf("%.8f %.8f\n", a.x, a.y);
}

void koch(int n, Point a, Point b) {
	if (n == 0) return;
	Point s, t, u;

	double th = PI * 60.0 / 180.0;

	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;

	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;

	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n - 1, a, s); print(s);
	koch(n - 1, s, u); print(u);
	koch(n - 1, u, t); print(t);

	koch(n - 1, t, b);
}

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

	int n;
	cin >> n;
	Point a = { 0, 0 }, b = { 100, 0 };

	print(a);
	koch(n, a, b);
	print(b);

	return 0;
}

Measured memory_bytes: 3252
#include<iostream>
#include<vector>
#include<deque>
using namespace std;

int main() {
  int H,W,Ch,Cw,Dh,Dw,i;
  cin>>H>>W>>Ch>>Cw>>Dh>>Dw;
  vector<string> S(H);
  for (i=0;i<H;i++) cin>>S[i];
  deque<pair<int,int>> Q;
  // 最低ワープ回数
  vector<vector<int> > A(H, vector<int>(W, 1e9));
  // 未到達か
  vector<vector<bool> > B(H, vector<bool>(W, true));

  A[Ch-1][Cw-1] = 0;
  Q.push_front(make_pair(Ch-1, Cw-1));
  while(!Q.empty()) {
    // 到達済み座標
    int y = Q.front().first;
    int x = Q.front().second;
    Q.pop_front();
    B[y][x] = false;

    // 徒歩で移動
    vector<pair<int,int> > P = {
      make_pair(y-1, x),
      make_pair(y+1, x),
      make_pair(y, x-1),
      make_pair(y, x+1)
    };
    for (pair<int,int> p: P) {
      int Y = p.first;
      int X = p.second;
      if (0<=Y && Y<H && 0<=X && X<W && B[Y][X] && S[Y][X] != '#') {
        A[Y][X] = min(A[Y][X], A[y][x]);
        Q.push_front(make_pair(Y,X));
      }
    }

    // ワープで移動
    for (int Y=y-2;Y<=y+2;Y++) {
      for (int X=x-2;X<=x+2;X++) {
        if (0<=Y && Y<H && 0<=X && X<W && B[Y][X] && S[Y][X] != '#') {
          A[Y][X] = min(A[Y][X], A[y][x]+1);
          Q.push_back(make_pair(Y,X));
        }
      }
    }
  }

  cout<<(B[Dh-1][Dw-1] ? -1 : A[Dh-1][Dw-1])<<endl;
  return 0;
}


Measured memory_bytes: 9632
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

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

    string s;
    cin >> s;
    int k;
    cin >> k;
    for( int i = 0; i < s.size(); ++i ) {
        if( i == s.size() - 1 ) {
            k %= 26;
            if( s[i] + k > 'z' ) {
                k -= 'z' - s[i] + 1;
                s[i] = 'a' + k;

            } else {
                s[i] += k;

            }
            continue;

        }

        if( s[i] == 'a' ) continue;
        if( s[i] + k > 'z' ) {
            k -= 'z' - s[i] + 1;
            s[i] = 'a';

        }
    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 592
#include<iostream>
#include<cmath>
using namespace std;
int x[100][100];

float distance(int a[100], int b[100], int length){
	int sum = 0;
	for(int i=0; i<length; i++){
		sum += pow(a[i]- b[i],2);
	}

	return sum;
}
int main(){
    int n, d, count=0;
    cin>>n>>d;
    for(int i=0; i<n;i++){
    	for(int j=0; j<d;j++){
    		cin>>x[i][j];
    	}
    }
    for(int i=0; i<n; i++){
    	for(int j=i+1; j<n; j++){
    		float f = distance(x[i], x[j], d);
    		f = sqrt(f);
    		if(abs(f-int(f))<=0) count++;
    	}
    }
    cout<<count<<endl;
    return 0;
}


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

int main(void){
    int N, K;
    cin >> N >> K;
    vector<int> v;
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.rbegin(), v.rend());
    int  a=0;
    for(int i=0;i<K;i++){
        a += v[i];
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256