akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

class dice{
    public:
    int t[7][6];

    dice(){ //??????????????????????????????
    	
    }

    void ready(){
        t[1][1]=t[5][0], t[1][2]=t[4][0], t[1][3]=t[2][0], t[1][4]=t[3][0], t[1][5]=t[5][0];
        t[2][1]=t[1][0], t[2][2]=t[4][0], t[2][3]=t[6][0], t[2][4]=t[3][0], t[2][5]=t[1][0];
        t[3][1]=t[1][0], t[3][2]=t[2][0], t[3][3]=t[6][0], t[3][4]=t[5][0], t[3][5]=t[1][0];
        t[4][1]=t[1][0], t[4][2]=t[5][0], t[4][3]=t[6][0], t[4][4]=t[2][0], t[4][5]=t[1][0];
        t[5][1]=t[1][0], t[5][2]=t[3][0], t[5][3]=t[6][0], t[5][4]=t[4][0], t[5][5]=t[1][0];
        t[6][1]=t[2][0], t[6][2]=t[4][0], t[6][3]=t[5][0], t[6][4]=t[3][0], t[6][5]=t[2][0];
    }
    
};

int main(){
    dice D2;
    for(int i=1; i<7; i++){
        cin >> D2.t[i][0];
    }
    D2.ready();
    
    int n,top,front,table,cher;
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> top >> front;

        for(int i=1; i<7; i++){
            if(D2.t[i][0]==top)table=i;     
        }

        for(int i=1; i<5; i++){
            if(D2.t[table][i]==front)cher=i+1;
        }

        cout << D2.t[table][cher] << endl;
    }

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),().end()
#define SZ(x) ((int)(x).size())
typedef long long ll;



int main()
{
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(15);

        ll a;
        ll b;
        ll k;

        cin>>a>>b>>k;
        if(a+b<=k) {cout<<0<<" "<<0<<endl; return 0;}
        if(a>=k) {cout<<a-k<<" "<<b<<endl;}
        else{cout<<0<<" "<<b-k+a<<endl;}


        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    if(a[0]!=0){
        cout<<-1<<endl;
        return 0;
    }

    ll ans=0;
    rep(i,n-1){
        if(a[i+1]-a[i]>1){
            cout<<-1<<endl;
            return 0;
        }

        if(a[i+1]==a[i]) ans+=a[i+1];
        else if(a[i]>a[i+1]) ans+=a[i+1];
        else ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4776
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void){
    char InputA[10],InputB[100];
    int count=0;
    int i;
    
    scanf("%s",InputA);
    
    while(scanf("%s",InputB)!=EOF){
        
        if(strcmp(InputB,"END_OF_TEXT")==0) break;
        //大文字の処理
        for(i=0;i<strlen(InputB);i++){
            if(isupper(InputB[i])) InputB[i] += 'a' - 'A';
        }
        
        if(strcmp(InputA,InputB)==0) count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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

//ax + by = gcd(a,b) となるような (x,y) を求める
long long ext_gcd(long long a,long long b,long long &x,long long &y){
  if(b==0){
    x=1;
    y=0;
    return a;
  }
  long long d=ext_gcd(b,a%b,y,x);
  y-=a/b*x;
  return d;
}

vector<ll> prime_pow;

ll calc(int bit){
  ll A = 1;
  ll B = 1;
  rep(i,sz(prime_pow)){
    if(bit & (1 << i))  A*=prime_pow.at(i);
    else  B*=prime_pow.at(i);
  }
  debug(A);
  debug(B);

  ll X,Y;
  ext_gcd(A,B,X,Y);
  X = -X;
  debug(X);
  debug(Y);
  if(X<=0){
    ll tmp = (1-X + B-1)/B;
    X += tmp*B;
    Y += tmp*A;
  }
  if(Y<=0){
    ll tmp = (1-Y + A-1)/A;
    X += tmp*B;
    Y += tmp*A;
  }
  debug(X);
  debug(Y);
  debug(A*X);
  debug("");
  return A*X;
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll N;
  cin >> N;

  if(N==1){
    cout << 1 << endl;
    return 0;
  }

  N*=2;
  for(ll i=2; i*i<=N; i++){
    if(N%i!=0)  continue;
    ll now=1;
    while(N%i==0){
      N/=i;
      now*=i;
    }
    prime_pow.p_b(now);
  }
  if(N!=1)  prime_pow.p_b(N);

  ll ans = 1e18;
  for(int bit=0; bit < (1 << sz(prime_pow)); bit++){
    chmin(ans,calc(bit));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3656
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	l := nextLine()
	total := 0
	max := 0
	for _, h := range strings.Split(l, " ") {
		i, _ := strconv.Atoi(h)
		if i >= max {
			total++
			max = i
		}
	}

	fmt.Printf("%d", total)
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    // 整数の入力
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    // 条件分岐と出力
    if (a+b==c) {
      System.out.println("Yes");
    } else if (a==b+c) {
      System.out.println("Yes");
    } else if (a+c==b) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

long long dp[100000][3];
long long a[100000];
long long b[100000];
long long c[100000];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    cin >> a[0] >> b[0] >> c[0];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define dd double
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int N;
	cin>>N;
	int i,j,k;
	ll A[N];
	for(i=0;i<N;i++)
	cin>>A[i];
	ll count=0;
		for(i=0;i<N;i++)
		{
			for(j=i+1;j<N;j++)
			{
				if(A[j]==A[i])
				continue;
				for(k=j+1;k<N;k++)
				{
					if((A[k]==A[i])||(A[k]==A[j]))
					continue;
					if((A[i]+A[j]>A[k])&&(A[j]+A[k]>A[i])&&(A[k]+A[i]>A[j]))
					count++;
				}
			}
		}
		cout<<count;
		return 0;
}

Measured memory_bytes: 3632
using System.Collections.Generic;
using System;

public class Hiryo
{
    public int x { get; set; }
    public int y { get; set; }
}
public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var w = int.Parse(line[0]);
        var h = int.Parse(line[1]);
        var p = int.Parse(Console.ReadLine().Trim());
        var hiryos = new List<Hiryo>();
        for (int i = 0; i < p; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            hiryos.Add(new Hiryo { x = int.Parse(line2[0]), y = int.Parse(line2[1])});
        }
        var plant = new int[w,h];
        for (int i = 0; i < h; i++)
        {
            string[] line3 = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < w; j++)
                if (line3[j] == "1") plant[j, i] = 0;
                else plant[j, i] = -1;
        }
        foreach (var a in hiryos)
            if (plant[a.x, a.y] != -1) plant[a.x, a.y]++;
        var count = 0;
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                if (plant[j, i] != -1) count += plant[j, i];
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 9316
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int N;
  cin >> N;

  cout << N / 3 << endl;
}


Measured memory_bytes: 256
import java.io.*;

class Main {

    public static void main( String[] args ) {
        try {
	      	BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
			String[] str = kb.readLine( ).split( " " );
        	int n = Integer.parseInt( str[0] );
        	int k = Integer.parseInt( str[1] );
        	int[] w = new int[n];
        	int i;
        	int maxW = 0, sumW = 0;
        	for( i=0; i<n; i++ ) {
        		w[i] = Integer.parseInt( kb.readLine( ) );
        		sumW += w[i];
        		maxW = Math.max( maxW, w[i] );
        	}
        	
        	int left, right, middle;
        	int loadings, P;
        	int truckCnt;
        	
        	P = 0;
        	if( n == k ) {
        		P = maxW;
        	} else if( 1 == k ) {
        		P = sumW;
        	} else {
        		left = Math.max( maxW, sumW/k );
	        	right = 10000*100000;
	        	loadings = 0;
	    		while( left <= right ) {
		        	middle = ( left+right )/2;
					truckCnt = 0;
					loadings = 0;
					for( i=0; i<n; i++ ) {
						loadings += w[i];
						if( middle < loadings ) {
							truckCnt++;
							if( k < truckCnt+1 ) { break; }
							i--;
							loadings = 0;
						}
					}
					if( truckCnt+1<= k ) { 
						P = middle;
					}
					if( k < truckCnt+1 ) {
						left = middle + 1;
					} else {
						right = middle - 1;
					}
	    		}
    		}
    		
			System.out.println( P );
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}

Measured memory_bytes: 29396
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
maxa = a[-1]
m = maxa / 2
d = bisect.bisect_left(a, m)
if a[d] == maxa:
  print(maxa, a[-2])
elif d == 0:
  print(maxa, a[0])
else:
  if abs(a[d] - m) <= abs(a[d-1] - m):
    print(maxa, a[d])
  else:
    print(maxa, a[d-1])

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

int main() {
  while (1) {
    int m = -1;
    int mi = -1;
    for (int i = 0; i < 5; ++i) {
      int a, b, c;
      cin >> a >> b;
      if (!a && !b) {
        return 0;
      }
      c = a + b;
      if (m < c) {
        m = c;
        mi = i;
      }
    }
    cout << (char)('A' + mi) << " " << m << endl;
  }
}

Measured memory_bytes: 3000
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	long N;
	cin >>N;

	vector<string> S;
	S.resize(N);

	for (int i = 0; i < N; i++)
		cin >> S[i];
	
	sort(S.begin(), S.end());
	S.erase(unique(S.begin(), S.end()), S.end());

	cout << S.size();
	

	return 0;
}

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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  const long double pi = 3.14159265358979323846;
  long double longX = sin(M * pi / 30);
  long double longY = cos(M * pi / 30);
  long double shortX = sin((H * pi / 6) + (M * pi / 360));
  long double shortY = cos((H * pi / 6) + (M * pi / 360));

  long double ans = sqrt((B * longX - A * shortX) * (B * longX - A * shortX) + (B * longY - A * shortY) * (B * longY - A * shortY));
  cout << fixed << setprecision(20);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4164
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

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

	int N;
	int X[102] = {0};
	
	cin >> N;
	int min = 1, max = 100;
	for(int i = 1; i <= N; i++){
		cin >> X[i];
		if(min > X[i]){ min = X[i]; }
		if(max < X[i]){ max = X[i]; }
	}
	long long ans = 100000000000LL;
	for(int p = min; p <= max; p++){
		long long v = 0;
		for(int i = 1; i <= N; i++){
			v += ( (X[i] - p) * (X[i] - p) );
		}
		if(ans > v){ ans = v;}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int N, X, T;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);

 cin>>N>>X>>T;
 int ans = N/X;
 if(N%X != 0) ans++;
 cout << ans*T<<endl;



 return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#define llint long long
#define inf 1e18
#define mod 1000000007

using namespace std;

llint n, t;
llint a[3005], b[3005];
llint dp[3005][3005], dp2[3005][3005];
llint sum[3005];

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

	cin >> n >> t;
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];

	llint suma = 0, sumb = 0;
	for(int i = 1; i <= n; i++) suma += a[i], sumb += b[i];
	if(suma <= t){
		cout << sumb << endl;
		return 0;
	}

	for(int i = 0; i <= n+1; i++){
		for(int j = 0; j <= t; j++){
			dp[i][j] = -inf;
		}
	}
	dp[0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= t; j++){
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
			if(j+a[i+1] <= t) dp[i+1][j+a[i+1]] = max(dp[i+1][j+a[i+1]], dp[i][j] + b[i+1]);
		}
	}


	for(int i = 0; i <= n+1; i++){
		for(int j = 0; j <= t; j++){
			dp2[i][j] = -inf;
		}
	}
	dp2[n+1][0] = 0;
	for(int i = n+1; i >= 1; i--){
		for(int j = 0; j <= t; j++){
			dp2[i-1][j] = max(dp2[i-1][j], dp2[i][j]);
			if(j+a[i-1] <= t) dp2[i-1][j+a[i-1]] = max(dp2[i-1][j+a[i-1]], dp2[i][j] + b[i-1]);
		}
	}

	llint ans = 0;
	for(int i = 1; i <= n; i++){
		sum[0] = dp2[i+1][0];
		for(int j = 1; j <= t; j++) sum[j] = max(sum[j-1], dp2[i+1][j]);
		for(int j = 0; j < t; j++){
			//cout << j << " " << t-1-j << endl;
			//cout << dp[i-1][j] << endl;
			ans = max(ans, dp[i-1][j] + sum[(t-1)-j] + b[i]);
		}
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 141312
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        StringBuilder s = new StringBuilder(sc.nextLine());
        s.deleteCharAt(5);
        s.deleteCharAt(12);
        s.insert(5," ");
        s.insert(13," ");

        System.out.println(s);

    }
}

Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000009
#define MAX 100001
#define INF LLONG_MAX
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,tmp;
    cin>>n;
    vector<ll> v;
    ll sum = 0;
    for(int i=0;i<n;i++){
        cin>>tmp;
        sum+=tmp;
        v.pb(tmp);
    }
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
    for(int k=0;k<n;k++){
        for(int i=0,j=k;j<n;i++,j++){
            ll a = (i<n && j>0)?dp[i+1][j-1]:0;
            ll b = (i<n-1)?dp[i+2][j]:0;
            ll c = (j>1)?dp[i][j-2]:0;
            dp[i][j]=max(v[i]+min(a,b),v[j]+min(a,c));
        }
    }
    cout<<dp[0][n-1]-(sum-dp[0][n-1])<<endl;
    return 0;
}


Measured memory_bytes: 73628
#include <stdio.h>

int main() {
  int h, w, y, x, matrix[100][100], vector[100], a;
  scanf("%d%d", &h, &w);
  for(y = 0; y < h; ++y) for(x = 0; x < w; ++x) scanf("%d", &matrix[y][x]);
  for(x = 0; x < w; ++x) scanf("%d", &vector[x]);
  for(y = 0; y < h; ++y) {
    a = 0;
    for(x = 0; x < w; ++x) a += matrix[y][x] * vector[x];
    printf("%d\n", a);
  }
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
	int visit[4]={0};
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		char c;
		cin>>c;
		if(c=='P')visit[0]=1;
		else if(c=='W')visit[1]=1;
		else if(c=='G')visit[2]=1;
		else if(c=='Y')visit[3]=1;
	}
	int count=0;
	for(int i=0;i<=3;i++)
	{
		if(visit[i])count++;
	}
	if(count==4)cout<<"Four"<<endl;
	else cout<<"Three"<<endl; 
	return 0;
}

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

int main(void){
   
    string str;
    cin>>str;
    
    int len=0;
    int x1, x2;
    
    for(int i=0; i<str.size(); i++){
        if(str[i]=='A'){
            x1=i;
            break;
        }
    }
    
    for(int i=str.size()-1; i>=0; i--){
        if(str[i]=='Z'){
            x2=i;
            break;
        }
    }
    
    cout<<x2-x1+1<<endl;
    
}


Measured memory_bytes: 640
S = input()
buff = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(4):
    buff[i] = buff[i][::-1]
S = S[::-1]
while len(S) > 0:
    if S[:7] == buff[1]:
        S = S[7:]
    elif S[:6] == buff[3]:
        S = S[6:]
    elif S[:5] == buff[0] or S[:5] == buff[2]:
        S = S[5:]
    else:
        break
if S: print('NO')
else: print('YES')

Measured memory_bytes: 3236
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(IntStream.rangeClosed(1, (n + 1) / 2).map(i -> 2 * i - 1)
					.filter(i -> 8 == getDivisorNumber(i)).count());
		}
	}

	/**
	 * nの約数の数を計算する
	 * 
	 * @param n
	 * @return nの約数の数
	 */
	private static int getDivisorNumber(int n) {
		int count = 0;
		for (int i = 1; i <= (int) Math.sqrt(n); i++) {
			if (0 == n % i) {
				count += (i == n / i) ? 1 : 2;
			}
		}
		return count;
	}
}


Measured memory_bytes: 36124
function Main(input) {
	const setting = input.trim().split('\n')
  const process_sum = setting[0] - 0
  const up = setting[1].split(' ')
  const down = setting[2].split(' ')

  let answer = 0

  for (let process_up = 0; process_up < process_sum; process_up++) {
    let process_down = process_sum - process_up - 1
    let candies = 0
    for (let i = 0; i <= process_up; i++) {
      candies += parseInt(up[i])
    }

    for (let i = 0; i <= process_down; i++) {
      candies += parseInt(down[process_up + i])
    }
    if (answer < candies) {
      answer = candies
    }
  }

  console.log(answer)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29560
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N,K;
	cin >> N >> K;
	int max = (N-1)*(N-2)/2; //スター型
	if (max < K){
		cout << -1 << endl;
		return 0;
	}
	vector<pair<int,int>> graph;
	rep(i,2,N+1){
		graph.emplace_back(1,i);
	}
	rep(i,2,N){
		rep(j,i+1,N+1){
			if(max == K) break;
			graph.emplace_back(i,j); // 1本増やすと最短が1つへる
			max--;
		}
	}
	cout << graph.size() << endl;
	
	rep(i,0,graph.size()){
		cout << graph[i].first << " " << graph[i].second << endl;
	}
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC100.B
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            var d = sc.Nextint ();
            var n = sc.Nextint ();
            if (n != 100) Console.WriteLine ((int) Math.Pow (100, d) * n);
            else Console.WriteLine ((int) Math.Pow (100, d) * (n + 1));
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int Nextint ()
        {
            return int.Parse (Next ());
        }
        public int[] Arrayint (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13140
n,k = map(int,input().split())
a = list(map(int,input().split()))
tf = ["" for _ in range(k+1)]
tf[0] = False
for i in range(1,k+1):
  j = 0
  flag = 0
  while j < n and i - a[j] >= 0:
    if tf[i-a[j]] == False:
      tf[i] = True
      flag = 1
      break
    j += 1
  if flag ==0:
    tf[i] = False
if tf[k]:
  print("First")
else:
  print("Second")
      
    
  


Measured memory_bytes: 3864
#include<iostream>
#include<stdio.h>
#include<vector>
#include<string>

using namespace std;
int main(void)
{
    int N;
    int buffer;
    string S;
    scanf("%d",&N);
    cin>>S;
    for(int i=0;i<S.length();i++)
    {
        
        buffer=S[i];
        buffer-=65;
        buffer+=N;
        buffer%=26;
        S[i]=65+buffer;
    }
    cout<<S;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;


int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a>b)swap(a,b);
  if(a<c&&c<b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        long a[]=new long[scanner.nextInt()+1];
        System.out.println(IntStream.range(0,a.length).mapToLong(i->a[i]=(i==0?0:a[i-1]+scanner.nextInt())).boxed().collect(Collectors.groupingBy(i->i,Collectors.counting())).values().stream().mapToLong(i->i*(i-1)/2).sum());
    }
}

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

d=[[-1,-1],[-1,0],[0,-1],[1,0],[-1,1],[0,1],[1,1],[1,-1]]
for i in range(H):
    for j in range(W):
        if S[i][j]=='.':
            cnt=0
            for k in d:
                nx,ny=i-k[0],j-k[1]
                if 0<=nx<H and 0<=ny<W and S[nx][ny]=='#':
                    cnt+=1
            S[i][j]=str(cnt)
for s in S:
    print(''.join(s))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int cmp(int x,int y)
{
    return x>y;
}
int main()
{
    int n,a[100005],i;
    long long ansc=0,ansk=0;
    bool use[100005]={0};
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+1+n,cmp);
    for(i=1;i<=n;i++)
    {
        if(a[i]==a[i-1]&&use[i-1]==0)
        {
            if(ansc!=0)
            {
                ansk=a[i];
                cout<<ansc*ansk;
                return 0;
            }
            else
            {
                use[i-1]=1;
                use[i]=1;
                ansc=a[i];
            }
        }
    }
    cout<<ansc*ansk;
    return 0;
}

Measured memory_bytes: 768
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n):
    for j in range(i+1, n):
        k = j + (j - i)
        if j < k < n and s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
            ans -= 1

print(ans)


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n%2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  string a = s.substr(0,n/2);
  string b = s.substr(n/2);
  if (a == b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c;
    cin>>a>>b>>c;
    if(c<=a||c<=b)
    {
        cout<<"No"<<endl;
    }
    else
    {
        long long int val=c-a+b;
        long long int op=4*b*c;
        if(val>0&&val*val>op)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations

n = int(input())
Ps = list(map(int, input().split()))
Qs = list(map(int, input().split()))

a = 0
b = 0

Rs = list(range(1,n+1))

for v in permutations(Rs, n):
    v_s = ''.join(list(map(str, v)))
    p_s = ''.join(list(map(str, Ps)))
    
    if v_s == p_s:
        break
    else:
        a += 1

for v in permutations(Rs, n):
    v_s = ''.join(list(map(str, v)))
    q_s = ''.join(list(map(str, Qs)))
    
    if v_s == q_s:
        break
    else:
        b += 1

print(abs(a-b))

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if (s.charAt(2) == s.charAt(3)) {
      if (s.charAt(4) == s.charAt(5)) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    } else {
      System.out.println("No");
    }
    sc.close();
  }
}

Measured memory_bytes: 23764
#include<stdio.h>

int main(void){
	int a, b, c;
	int tmp;
	scanf("%d %d %d", &a, &b, &c);
	if(a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	
	if(a > c){
		tmp = c;
		c = a;
		a = tmp;
	}
	
	if(b > c){
		tmp = b;
		b = c;
		c = tmp;
	}
	
	
	
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 2696
#include<iostream>
using namespace std;
int main(){
    int x;
    cin>>x;
    int ans=1;
    for(int i=2;i<=32;i++){
        for(int j=1;j<=32;j++){
            int tmp=1;
            for(int k=1;k<=i;k++){
                tmp=tmp*j;
            }
            if(tmp<=x){
                if(ans<tmp){
                    ans=tmp;
                }
            }
            else{continue;}
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 3e3+5;

double a[N], dp[N][N];

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    	cin >> a[i];
    dp[1][1] = a[1];
    dp[1][0] = 1-a[1];
    for (int i = 2; i <= n; i++) {
    	dp[i][0] = dp[i-1][0] * (1-a[i]);
    }
    for (int i = 1; i <= n; i++) {
    	for (int j = 1; j <= n; j++) {
    		if (i == 1 && j == 1) continue;
    		if (j > i) {dp[i][j] = 0; continue;}
    		dp[i][j] = dp[i-1][j]*(1-a[i]) + dp[i-1][j-1]*a[i];
    	}
    }
    double ans = 0;
    for (int i = (n+1)/2; i <= n; i++)
    	ans += dp[n][i];
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 70656
#include <set>
#include <iostream>
#include <functional>

int main() {
    int n;
    std::cin >> n;
    long long first;
    std::cin >> first;
    int ans = 1;
    std::multiset<long long, std::greater<long long>> set;
    set.insert(first);

    for (int i = 1; i < n; ++i) {
        long long next;
        std::cin >> next;
        auto it = set.upper_bound(next);
        if (it == set.end()) {
            ans++;
        } else {
            set.erase(it);
        }
        set.insert(next);
    }

    std::cout << set.size();
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    int mass_sugar_max = 0, mass_water_max = 0;
    float ans = 0;
    rep(i, 0, 100)
        rep(j, 0, 100)
            rep(k, 0, 100)
                rep(l, 0, 100)
                {
                    float mass_water = i*100*a + j*100*b;
                    float mass_sugar = k*c + l*d;
                    if (mass_water == 0) continue;
                    float density = mass_sugar / (float)(mass_sugar + mass_water);
                    if (mass_sugar + mass_water <= f && mass_sugar / mass_water <= (float)e/100 && density > ans)
                    {
                        ans = density;
                        mass_sugar_max = mass_sugar;
                        mass_water_max = mass_water;
                    }
                }
    if (ans == 0)
        return cout << a*100 << " " << 0, 0;
    cout << mass_water_max + mass_sugar_max << " " << mass_sugar_max; 
    return 0;
}

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

int main(void)
{
  int n, m;
  cin >> n >> m;
  int box[n + 5];
  bool a[n + 5];
  fill(box, box + n, 1);
  fill(a, a + n, false);
  a[0] = true;

  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;

    box[x]--; box[y]++;
    if (a[x]) {
      a[y] = true;
    }
    if (box[x] == 0) {
      a[x] = false;
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i]) {
      ans++;
    }
  }

  cout << ans << endl;
}



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

bool check(string a,string b,int d){
  if(a.size()<b.size())swap(a,b);
  if(a==b) return 1;
  if(d==0||a.empty())return 0;


  //erase
  for(int i=0;i<a.size();i++){
    string t = a;
    t.erase(t.begin()+i);
    if(check(t,b,d-1))return 1;
  }

  if(a.size()!=b.size()) return 0;

  //swap
  for(int i=0;i<(int)a.size()-1;i++){
    swap(a[i],a[i+1]);
    if(check(a,b,d-1))return 1;
    swap(a[i],a[i+1]);
  }

  
  //change
  for(int i=0;i<b.size();i++){
    char ch = a[i];
    if(a[i]!=b[i]) a[i] = b[i];
    if(check(a,b,d-1))return 1;
    a[i] = ch;
  }
  return 0;
}

int main(){
  int n,d;
  while(cin>>n,n){
    cin>>d;
    string str[201];
    for(int i=0;i<n;i++)cin>>str[i];
    sort(str,str+n);

    int cnt=0;    
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
	if(check(str[i],str[j],d)) cout<<str[i]<<","<<str[j]<<endl,cnt++;
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 3092
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0008&lang=jp

#include <iostream>
using namespace std;

int main() {
  int n ;
  while (cin >> n) {
    int count = 0;
    for (auto i=0; i<10; i++) {
      for (auto j=0; j<10; j++) {
	for (auto k=0; k<10; k++) {
	  for (auto l=0; l<10; l++) {
	    if (i+j+k+l == n) count++;
	  }
	}
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 1156
#include <stdio.h>



int main(){

  int i,n,H[251];
  scanf("%d",&n);

  for(i=1;i<=n;i++)scanf("%d",&H[i]);

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,H[i]);
    if(i/2>=1)printf("parent key = %d, ",H[i/2]);
    if(i*2<=n)printf("left key = %d, ",H[i*2]);
    if(i*2+1<=n)printf("right key = %d, ",H[i*2+1]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2040
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt(), h = sc.nextInt(), w = sc.nextInt();
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int hh = sc.nextInt(), ww = sc.nextInt();
			if (h <= hh && w <= ww) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
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; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vvint a(2, vint(4, 1));
    rep(i,2)rep(j,3) cin>>a[i][j];

    auto f = [&](ll N, vint &w, vint &v){
        vint dp1(N+1, -1);
        dp1[0] = 0;
        rep(i,4){
            vint dp2(N+1, -1);
            rep(j,N+1){
                chmax(dp2[j], dp1[j]);
                if(j+w[i] > N) continue;
                if(dp1[j] != -1){
                    chmax(dp2[j+w[i]], dp1[j] + v[i]);
                }
                if(dp2[j] != -1){
                    chmax(dp2[j+w[i]], dp2[j] + v[i]);
                }
            }
            swap(dp1, dp2);
        }

        return *max_element(ALL(dp1));
    };


    ll N_new = f(n, a[0], a[1]);
    cout<<f(N_new, a[1], a[0])<<endl;


    return 0;

}


Measured memory_bytes: 390948
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector< vector<int> > a(n,vector<int> (n));
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      a[i][j]=0;
    }
  }
  for(int i=0; i<n; i++){
    int u,k;
    cin>>u;
    cin>>k;
    vector<int> v(k);
    for(int j=0; j<k; j++){
      cin>>v[j];
    }
    for(int s=0; s<n; s++){
      for(int t=0; t<k; t++){
	if(s==v[t]-1){
	  a[u-1][v[t]-1]=1;
	}
      }
    }
  }

  for(int i=0;i<n; i++){
    for(int j=0; j<n; j++){
      cout<<a[i][j];
      if(j!=n-1){
	cout<<" ";
      }
    }
    cout<<endl;
  }
  return 0;
}


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

using namespace std;


#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)
     
#define ll long long int
#define ld long double


#define fr first
#define se second



#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)v.size()
#define sunq(v) sort(all(v));v.resize(distance(v.begin(),unique(all(v))))


#define pb push_back
#define mp make_pair

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define emla(a, val) memset(a, val, sizeof(a))

#define easm(a, b) (a + b - 1)/b 


#define PI 3.141592653589793238
#define E  2.718281828459045235


ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a*b/gcd(a,b);}


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

const int N = 1e5 + 10;

ll dp[N];
int n, a[N], k;



int main(){
  IOS;
  //freopen("input.in", "r", stdin);
  //freopen("output.txt", "w", stdout);
  clock_t z = clock();
  cin >> n >> k;
  for(int i = 0; i < n; i++)cin >> a[i];
  dp[0] = 0;
  for(int i = 1; i < n; i++)dp[i] = 1e18;
  for(int i = 1; i < n; i++)
    for(int j = 1; j <= k; j++)
      if(i - j >= 0)
        dp[i] = min(dp[i-j]+abs(a[i] - a[i - j]), dp[i]);
  cout << dp[n-1] << endl;
  debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
  /*
  *try tricky test cases:
    -bounds
    -integer overflow
    -small input (0, 1)
    -big input
    -random tests
  */
  return 0;
}

Measured memory_bytes: 1408
import itertools
import bisect
n,K=map(int, input().split(" "))
A=list(map(int, input().split(" ")))

A2=[0]
sum=0
for i in A:
    A2.append(i+sum)
    sum+=i

#print(A2)
A3=[]
for i in range(len(A2)):
    for k in range(len(A2)-i-1):
        A3.append(A2[k+1+i]-A2[i])
A3.sort()
#print(A3)
#print(len(A3))

tmparr=[]
for i in range(50):
    if 2**i-1>A3[-1]:
        break
    tmparr.append(2**i-1)
#print(tmparr)


"""
for i in tmparr[::-1]:
    rem=len(A3)-bisect.bisect_right(A3,i)
    if rem>K:
        A4=A3[-rem:]
        break
"""
arr=A3
result=0
for i in tmparr[::-1]:
    count=0
    tmparr=[]
    for k in arr:
        if k & i+1 > 0:
            count+=1
            tmparr.append(k)
    if count>=K:
        arr=tmparr
        result+=i+1
print(result)

Measured memory_bytes: 24984
//
// Created by yamunaku on 2020/06/27.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    ll n;
    cin >> n;
    ll ans = 0;
    repl(i, 1, n + 1){
        ll k = n / i;
        ans += k * (k + 1) / 2 * i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

int gcd(int a, int b) 
{
    if (a > b) {
        if (a%b==0) {
            return b;
        } else {
            return gcd(b, a%b);
        }
    } else {
        if (b%a==0) {
            return a;
        } else {
            return gcd(a, b%a);
        }
    }
}
 
int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    
    int min = INF;
    int index = 0;
    for (int i = 0; i < N; i++) {
        if (min > A[i]) {
            min = A[i];
            index = i;
        }
    }

    A.erase(A.begin() + index);

    int ans = INF; 
    for (int i = 0; i < A.size(); i++) {
        if (ans > gcd(min, A[i])) {
            ans = gcd(min, A[i]);
        }
    }

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


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

public class Main {

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

  private void solve() {
    try(InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {

      final int A = in.nextInt();
      final int B = in.nextInt();
      final int Q = in.nextInt();

      long[] s = new long[A+1];
      for (int i = 0; i < A; i++) {
        s[i] = in.nextLong();
      }
      s[A] = 1L << 40;

      long[] t = new long[B+1];
      for (int i = 0; i < B; i++) {
        t[i] = in.nextLong();
      }
      t[B] = 1L << 40;

      for (int q = 0; q < Q; q++) {
        long x = in.nextLong();
        long dist = 1L << 50;

        for (int c = 0; c < 2; c++) {
          long[] af = c == 0 ? s : t;
          long[] as = c == 0 ? t : s;

          for (int i = 0; i < 2; i++) {
            int posF = binarySearch(af, x) + i;
            long df = af[posF];

            for (int j = 0; j < 2; j++) {
              int posS = binarySearch(as, x) + j;
              long ds = as[posS];
              
              long d = Math.abs(x - df);
              d += Math.abs(df - ds);
              dist = Math.min(dist, d);
            }
          }
        }

        out.println(dist);
      }
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private int binarySearch(long[] arr, long x) {
    int left = 0;
    int right = arr.length;

    return loop(arr, x, left, right);
  }

  private int loop(long[] arr, long x, int left, int right) {
    if(right - left < 2) return left;
    else {
      int mid = (left + right) / 2;
      if(arr[mid] <= x) return loop(arr, x, mid, right);
      else return loop(arr, x, left, mid);
    }
  }

  static class InputReader implements AutoCloseable {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new UncheckedIOException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    @Override
    public void close() throws IOException {
      reader.close();
    }
  }
}

Measured memory_bytes: 49360
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
 
using namespace std;

using t = unsigned long long;

int main() {
    t n,m;
    cin>>n>>m;
    vector<t> a;
    t sum=0;
    for (t i=0;i<n;++i){
        t x;
        cin>>x;
        a.push_back(x);
        sum+=x;
    }
    sort(a.rbegin(),a.rend());
    if (4*m*a[m-1] >= sum) {
        cout<<"Yes";
    }
    else cout << "No";
}

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

int main(){
  string s,t;
  cin >> s >> t;
  int ss, tt, c, mi = 1000;
  ss = s.size();
  tt = t.size();
  for(int i = 0; i < ss - tt + 1; i++){
    c = 0;
    for(int v = 0; v < tt; v++){
      if(s.at(i + v) != t.at(v)){
        c++;
      }
    }
    mi = min(mi,c);
  }
  cout << mi << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

static const ll mod  = 1e9 + 7;
static const ll inf  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;



void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}


bool compare_by_b(pair<string, pair<int, int> >a, pair<string, pair<int,int> > b){
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return (a.second).first > (b.second).first;
    }
} 

int main(){
    int n;
    cin >> n;
    vector<pair <string, pair<int, int> > > pairs;
    string s;
    int p;
    REP(i,n){
        cin >> s >> p;
        auto pair1 = make_pair(p, i+1);
        pairs.push_back(make_pair(s, pair1));
    }
    sort(ALL(pairs), compare_by_b);

    REP(i,n){
        p(pairs[i].second.second);
    }

    /*for(int i = 0; i < n-1; i++){
        if(pair[i].first == pair[i+1].first){
            if(p[pair[i].second] > p[pair[i+1].second]){
                p(pair[i].second + 1);
            }else{
                p(pair[i+1].second + 1);
            }
        }else{
            p(pair[i].second + 1);
        }
    }*/

}

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

using namespace std;

#define int long long
const int DIM = 2e5 + 7;


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


    int n;
    cin >> n;

    int rez = 0;
    int last;

    for(int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;

        if(i == 1)
            last = x;
        else
        {
            if(x < last)
            {
                rez+= last - x;


            }
            else
                last = x;
        }
    }

    cout << rez;


    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<iosfwd>
using namespace std;
int main(){
    string c;
    cin >> c;
    int cnt=0;
    int max=0;
    for(int i=0; i<c.length(); i++){
        string t=c.substr(i,1);
        // cout << t;
        if(t=="A"||t=="T"||t=="C"||t=="G"){
            cnt++;
        } else{
            if(max<cnt){
                max=cnt;
                cnt=0;
            }
        }
    }
    if(max<cnt){
        max=cnt;
        cnt=0;
    }
    cout <<max<<endl;
    
}

Measured memory_bytes: 888