akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define MOD 1000000007
#define N 10000007
#define INF 1000000000000000000
#define fastio ios_base::sync_with_stdio(false); cin.tie(NUint);
#define randright srand(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;

int fact[N];

int power(int a, int b, int p){
    int ans = 1;
    while (b > 0) 
    {
        if (b & 1) 
            ans = (ans*a)%p;
        
        b = b>>1;
        a = (a*a)%p;
    }
    return ans;
}

int inv(int a, int p){
    return power(a,p-2,p);
}

int preComp(int p){
    fact[0] = 1;
    for(int i=1;i<N;i++){
        fact[i] = (fact[i-1] * i)%p;
    }
}

int nCr(int n, int r, int p){
    return ( (fact[n]*inv(fact[r], MOD)%p * inv(fact[n-r], MOD) ) ) % p;
}

void solve(){
    int x,y,n,m,i,j;
    cin>>x>>y;
    n=max(x,y);
    m=min(x,y);
    if((x+y)%3!=0){
        cout<<"0\n";
        return;
    }
    pair<int,int> ans;
    int maxx=0;
    for(i=0;i<=m;i++){
        j=(m-i);
        if(j%2==0){
            j/=2;
            if(j+(2*i) == n){
                ans = {i,j};
                maxx = max(maxx, ((fact[ans.first+ans.second] * inv(fact[ans.first], MOD))%MOD * inv(fact[ans.second], MOD))%MOD);
            }
        }
    }
    cout<<maxx<<'\n';
}

signed main(){
    preComp(MOD);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

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

map<int, int> d;

int main() {
	int n;
	cin >> n;
	for(int i=0;i<n;++i){
		int a;
		cin >> a;
		d[a]++;
	}
	int m;
	cin >> m;
	bool flag = true;
	for(int i=0;i<m;++i){
		int t;
		cin >> t;
		if(flag){
			d[t]--;
			if(d[t] < 0)flag = false;
		}
	}
	if(flag)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int A, B, C;
    cin >> A >> B >> C;
    bool flag = false;
    if (A == B && B != C){flag = true;}
    if (B == C && C != A){flag = true;}
    if (C == A && A != B){flag = true;}
    if (flag){cout << "Yes" << endl;} else {cout << "No" << endl;}
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

bool rev(int n) {
    string S = to_string(n);
    string RS;
    for (int i = S.length() - 1; i >= 0; i--) {
        RS += S[i];
    }
    return S == RS;
 }

int main() {
    int A, B;
    cin >> A >>B;

    int cnt = 0; 
    for (int i = A; i <= B; i++) {
        if (rev(i))
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3580
#define ll				long long
#define MOD				1000000007

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct data {
	int s;
	int t;
	int x;
} data;

int i, j, k;

FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outd(double d) {
	char s[128];
	sprintf(s, "%.10lf\n", d);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int fnc() {

	i = geti() - 2;
	outi(i * 180);

	return 0;
}

int main() {

#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>

int H,W;
char **bitmap;
bool inRange(int i,int j)
{
    if(i>=0 && i<H && j>=0 && j<W)
        return true;
    return false;
}

int solve(int i,int j)
{
    int dx,dy,counter=0;
    for(dx=-1;dx<=1;dx++)
        for(dy=-1;dy<=1;dy++)
        {
            if(inRange(i+dx,j+dy) 
                    && bitmap[i+dx][j+dy]=='#')
                counter++;
        }
    return counter;
}


int main(void)
{
    int i,j;

    scanf("%d%d",&H,&W);
    bitmap=new char* [H];
    for(i=0;i<H;i++)
        bitmap[i]=new char [W];

    
    for(i=0;i<H;i++)
    {
        getchar();
        for(j=0;j<W;j++)
            scanf("%c",&bitmap[i][j]);
    }
    for(i=0;i<H;i++)
    {
        getchar();
        for(j=0;j<W;j++)
        {
            if(bitmap[i][j]=='.')
                printf("%d",solve(i,j));
            else
                printf("#"); 

        }
        printf("\n");
    }

    for(i=0;i<H;i++)
        delete [] bitmap[i];
    delete [] bitmap;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;

    cout << Z << ' ' << X << ' ' << Y;

}


Measured memory_bytes: 888
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(ALL(a));
  cout << a[0] + a[1] << endl;
}

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

int main(){
    int D;
    std::cin >> D;
    std::vector< int > C(26);
    std::vector< int > cur_bad(26);
    for(int i=0; i<26; i++){
        std::cin >> C[i];
        cur_bad[i] = C[i];
    }
    std::vector< std::vector< int > > S(D, std::vector< int >(26));
    for(int i=0; i<D; i++){
        for(int j=0; j<26; j++){
            std::cin >> S[i][j];
        }
    }
    std::vector< int > T(D);
    
    for(int i=0; i<D; i++){
        int max = 0;
        int max_index = 0;
        for(int j=0; j<26; j++){
            int score = S[i][j] + cur_bad[j];
            if(max < score){
                max = score;
                max_index = j;
            }
        }
        T[i] = max_index + 1;
        cur_bad[max_index] = 0;
        for(int j=0; j<26; j++){
            cur_bad[j] += C[j];
        }
    }
    
    long long score = 0;
    std::vector< int > lasta(26, 0);
    for(int i=0; i<D; i++){
        score += S[i][T[i] - 1];
        lasta[T[i] - 1] = i + 1;
        for(int j=0; j<26; j++){
            score -= (i + 1 - lasta[j]) * C[j];
        }
    }
        
    for(int q=0; q<100000; q++){
        int qD = std::rand() % D;
        int Q = std::rand() % 26 + 1;
        //std::cout << qD << " " << Q << std::endl;
        int pre = T[qD];
        
        T[qD] = Q;
        long long ans = 0;
        std::vector< int > last(26, 0);
        for(int i=0; i<D; i++){
            ans += S[i][T[i] - 1];
            last[T[i] - 1] = i + 1;
            for(int j=0; j<26; j++){
                ans -= (i + 1 - last[j]) * C[j];
            }
        }
        if(score < ans){
            score = ans;
        }else{
            T[qD] = pre;
        }
    }
    
    
    
    
    for(int i=0; i<D; i++){
        std::cout << T[i] << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=100005;
int n,m;
char s[N],t[N];
int main(){
	cin>>n>>m>>s>>t;
	int g=__gcd(n,m);
	// L = n * m / g 
	// L / n = m / g 
	// L / m = n / g
	// LCM(m / g, n / g) = n * m / g^2
	LL L=(LL)n*m/g;
	for (LL a=0;a<L;a+=L/g)
		if (s[a*g/m]!=t[a*g/n])
			return puts("-1"),0;
	cout<<L<<endl;
	return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b)
{
    if (a < b)
        euclid(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b;
    string s;
    cin >> a >> b;
    cin >> s;

    bool f = true;
    if (s[a] == '-')
    {
        s[a] = '0';
    }
    else
    {
        f = false;
    }

    for (int i = 0; i < s.size(); i++)
        if (s[i] < '0' || s[i] > '9')
            f = false;

    if (f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
N=int(input())
L=list(map(int,input().split()))
list.sort(L,reverse=True)
count=0
if N>2:
    for x in range(N):
        for y in range(x+1,N):
            for z in range(y+1,N):
                if L[x]==L[y]:
                    break
                elif (L[z]!=L[y])and(L[x]<(L[y]+L[z])):
                    count+=1
print(count)

Measured memory_bytes: 9032
#include <iostream>
#include <string>
#include <string_view>
using namespace std;
const int INF = 1e9;
template<typename T> bool chmin(T &a, T b) { return a > b && (a = b, true); }

int main() {
	int n; cin >> n;
	string s, t; cin >> s >> t;

	string tmp;
	int ans = INF;
	for (int i = 0; i <= t.length(); i++) {
		tmp = s;
		tmp = s + t.substr(t.length() - i);
		if (tmp.substr(0, n) == s &&
		    tmp.substr(i, n) == t)
                chmin(ans, (int)tmp.length());
	}

	cout << ans << endl;
}


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

int main() 
{   
  

 
long long int n,k;
scanf("%lld %lld",&n,&k);
long long int a[n];
    for(long long int i = 0; i <n; i++){
   
   
   scanf("%lld",&a[i]);
}

long long int dp[k+1];
memset(dp,0,sizeof(dp));

for(long long int i=1;i<=k;i++)
{
for(long long int j=0;j<n;j++)
{
if(i-a[j]>=0)
{

if(dp[i-a[j]]==0)
  dp[i]=1;

}


}


}


if(dp[k]==1)
  printf("First\n");
else
  printf("Second\n");




}

  
 

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

int main(){
int a,b,x;
cin >> a >> b >> x;
if(a<=x){
    if(x-a<b){
        cout << "YES" <<endl;
    }
    else if(x-a>b){
        cout << "NO" << endl;}
}
else{cout << "NO" <<endl;}
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%lld%lld", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    ll x[1000] = {},y[1000];
    ll leng[1000];

    Scd(n);

    Rep(i,n){
        Scd2(x[i],y[i]);
        leng[i] = abs(x[i]) + abs(y[i]);
    }
  
  	

    int odd = leng[0] % 2;

    Rep(i,n){
        if(leng[i] % 2 != odd){
            printf ("%d\n", -1);
            return 0;
        }
    }

  
    int ans = 31;
    ans += !odd;
    printf ("%d\n", ans);
  	ans -= !odd;

    if(!odd) printf ("%d ", 1);
    ll longer[32] = {1};
  
  	
    Rep(i,ans){
        printf("%lld", longer[i]);
              
        if( i+1 != ans) {
            printf (" ");
            longer[i+1] = longer[i];  
            longer[i+1] *= 2;
        }
    }
    printf ("\n");
  
    ans += !odd;
  
    ll pow31 = 1;
    Rep(i,31) pow31*=2;

    ll u[1000],v[1000];
    Rep(i,n){
        if(!odd) x[i]--;
        u[i] = x[i] + y[i];
        v[i] = x[i] - y[i];
        u[i] = (u[i] + (pow31 - 1)) / 2;
        v[i] = (v[i] + (pow31 - 1)) / 2;
        ll xx = 0;
        ll yy = 0;
        Rep(j,ans){
            if( !odd && j == 0) {printf ("R"); xx++ ;continue;}
            if( u[i] % 2 && v[i] % 2){
                printf ("R");
                xx += longer[j-!odd];
            }else if( u[i] % 2 == 0 && v[i] % 2){
                printf ("D");
                yy -= longer[j-!odd];
            }else if( u[i] % 2 && v[i] % 2 == 0 ){
                printf ("U");
                yy += longer[j-!odd];
            }else{
                printf ("L");
                xx -= longer[j-!odd];
            }
            u[i] /= 2;
            v[i] /= 2;
        }
        //p//rintf ("%lld,%lld", xx,yy);
        printf ("\n");
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long int
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define N 300009
#define mod 1000000007
#define med 998244353
#define dbg cout<<"There There\n";
#define dbg1(x) cout<<"\nValue is "<<x<<endl
#define dbg2(x,y) cout<<"\nValue is "<<x<<" "<<y<<endl
#define dbg3(x,y,z) cout<<"\nValue is "<<x<<" "<<y<<" "<<z<<endl  
#define pq priority_queue<int>
#define mpq priority_queue<int,vector<int>,greater<int>>
#define pr pair<int,int>
#define mx INT_MAX
#define lmx LLONG_MAX
#define err return 0
#define cn continue 
#define bre break
   
int n;

int32_t main()
{
     IOS;
     cin>>n;
     cout<<180*(n-2)<<endl;
}


Measured memory_bytes: 256
#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 a[100000];

int main() {
  int N;
  cin >> N;
  for (int i=0;i<N;i++)
    cin >> a[i];
  
  //辞書を作る
  map<int,int>mp;
  for (int i=0;i<N;i++)
  	mp[a[i]]++;
  
  int ans=0;
  for (auto p:mp){
  	int x=p.first;
    int n=p.second;
    if (n>=x){
    	ans+=(n-x);
    }
    else{
    	ans+=n;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S, T;
	cin >> S >> T;
	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3860
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scanf("%d %d", &N, &M)

    holeIndices := make([]int, M)
	for i := 0; i < M; i++ {
        fmt.Scanf("%d", &holeIndices[i])
	}

	isHole := make([]bool, N+10)
    for _, holeIndex := range holeIndices {
        isHole[holeIndex - 1] = true
    }

    if isHole[0] && isHole[1] {
        fmt.Println(0)
        return
    }
	dp := make([]int, N+10)
    dp[0] = 1
    if !isHole[0] {
        dp[1] = 2
    } else {
        dp[1] = 1
    }


	for i := 2; i < N; i++ {
        if isHole[i] {
            if isHole[i-1] {
                fmt.Println(0)
                return
            }
            dp[i] = dp[i-1]
        } else {
            if !isHole[i-1] && !isHole[i-2] {
                dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
            } else {
                dp[i] = dp[i-1]
            }
        }
    }
    fmt.Println(dp[N-1])
}



Measured memory_bytes: 5504
import java.util.Scanner;

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 >= 22) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}
	}

}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     int ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/












int r[100005],s[100005];
char st[100005];
int main(){
     int n;
     cin>>n;
     cin>>(st+1);
     for(int i=1;i<=n;i++){
          if(st[i]=='o')s[i]=0;
          else s[i]=1;
     }
     for(int v1=0;v1<2;v1++){
          for(int v2=0;v2<2;v2++){
               r[1]=v1,r[2]=v2;
               for(int i=3;i<=n;i++)r[i]=s[i-1]^r[i-1]^r[i-2];
               if((r[1]==(s[n]^r[n-1]^r[n]))&&(r[n]==(s[1]^r[1]^r[2]))){
                    for(int i=1;i<=n;i++){
                         if(r[i]==1)cout<<"W";
                         else cout<<"S";
                    }
                    return 0;
               }
          }
     }
     cout<<-1;

}



















































Measured memory_bytes: 4380
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N;
int A[100010];
int dp[100010][2];

void _main() {
    cin >> N;
    REP(i, N) cin >> A[i];
    dp[0][0] = 0;
    dp[0][1] = -INF;
    REP(i, N) {
        dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i]);
        dp[i + 1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i]);
    }
    cout << dp[N][0] << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i'))
            freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o'))
            freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 2560
a,$,=:+,' '
puts [6484,a,0,1,3,:<,2,3,3]+[0,1].map{|x|[a,x,3,x]+(0..29).map{|t|v=x+4;u=x*60+9+t;[a,v,v,v,a,v,3,6,*[a,6,6,6]*(29-t),:<,6,x,u,a,v,u,v]}}+(0..59).map{|t|[a,2,2,2]+(0...t).map{[a,8+t-_1,69+_1,5,:<,3,5,6,a,2,6,2]}}

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

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

	int data[10];
	data[0] = 1;
	for(int i = 1; i < 10; ++i){
		data[i] = data[i - 1] * 2;
	}

	int n;
	while(cin >> n){

		bool check[10];
		for(int i = 0; i < 10; ++i){
			check[i] = false;
		}

		for(int i = 9; i >= 0; --i){
			if(n >= data[i]){
				n -= data[i];
				check[i] = true;
			}
		}

		bool check2 = false;
		for(int i = 0; i < 10; ++i){
			if(check[i]){
				if(check2) cout << " ";
				else check2 = true;
				cout << data[i];
			}
		}

		cout << endl;

	}

	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

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

    int N;
    cin >> N;

    vector<int> H(N);
    rep (i, N) {
        cin >> H[i];
    }

    int ans = 0;
    for (int i = N; i > 0; i--) {
        for (int j = 0; j < i; j++) {
            if (H[i-1] < H[j]) {
                break;
            }
            if (j == i-1) {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    int k, x; cin >> k >> x;

    int vmin = x - k + 1;
    int vmax = x + k - 1;

    reps(i, vmin, vmax+1){
        cout << i << " ";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int unused __attribute__((unused));
    int a, b;
    char op;

    unused = scanf("%d %c %d", &a, &op, &b);

    if (op == '+')
        printf("%d", a + b);
    else
        printf("%d", a - b);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main() {
  ll n; cin >> n;
  ll tmp = n;
  ll dsum = 0;
  while(tmp > 0){
    dsum += tmp%10;
    tmp /= 10;
  }
  if(n%dsum==0) yes();
  else no();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool pal(string s)
{
    string r;
    r=s;
    reverse(s.begin(),s.end());
    return s==r;
}
int main()
{
    string s,a,d;
    int i,n;
    cin>>s;
    n=s.size();
    if(pal(s))
    {
        a=s.substr(0,(n-1)/2);
        d=s.substr(((n+3)/2)-1,n-((n+3)/2)+1);
        if(pal(a)&&pal(d))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3624
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

int a[100005];
int used[100005];
int cnt[65];
bool good[65];
int basis[65];
void solve(){  
	int n;
	cin>>n;
	int ans=0;
	rep(i,0,n){
		cin>>a[i];
		ans^=a[i];
		repd(j,60,0){
			if((a[i]>>j)&1){
				cnt[j]++;
			}
		}
	}  
	int max_and = 0;
	rep(i,0,61){
		if(cnt[i] && cnt[i]%2==0){
			good[i]=1;
		}
	}
	//compute max_and
	rep(i,0,n){
		int cur=a[i];
		repd(j,60,0){
			if(!good[j])
				continue;
			if((cur>>j)&1){
				if(basis[j]==0){
					basis[j]=cur;
					break;
				}
				else cur^=basis[j];
			}
		}
	}
	int cur=0;
	repd(j,60,0){
		if(good[j]){
			if((cur>>j)&1){
				max_and+=(1LL<<j);
			}
			else{
				if(basis[j]){
					cur^=basis[j];
					max_and+=(1LL<<j);
				}
			}
		}
	}
	cout << ans + 2*max_and<<endl;

}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
struct hoge
{
    int a, b;
};
struct hoge arr[100000];
int compare_int(const void *a, const void *b){
	struct hoge *A = (struct hoge *)a;
	struct hoge *B = (struct hoge *)b;
    return (A->b) - (B->b);
}
int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 0;i < m;i++){
        int aa, bb;
        scanf("%d %d", &aa, &bb);
        aa--;
        bb--;
        arr[i].a = aa;
        arr[i].b = bb;
    }
    qsort(arr, m, sizeof(struct hoge), compare_int);
    int j = 0;
    int count = 0;
    while(j < m){
        count++;
        int k = j;
        while(k < m && arr[k].a < arr[j].b)k++;
        j = k;
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  int ans = 0;
  for(int i = 1; i*i <= N; i++){
    if(N%i == 0) ans = i+N/i-2;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner console = new Scanner(System.in);
		
		int number = console.nextInt();
		ArrayList<Integer> a = new ArrayList<Integer>();

		for(int i = 0; i < number; i ++)
		{
			a.add(console.nextInt());
		}
		
		Collections.sort(a);
		
		
		long answer = 0;
		answer += a.get(number - 1);

		for(int i = 0; i < number - 2; i ++)
		{
			answer += (a.get(number - 2 - (i / 2)));
		}
		System.out.print(answer);
	}
}


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

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  string r=s;
  reverse(all(r));
  if(r==s){
    string tmp=s.substr(0,((n-1)/2));
    // cout<<tmp<<endl;
    string rtmp=tmp;
    reverse(all(rtmp));
    if(tmp==rtmp){
      tmp=s.substr((n+3)/2-1,n+1-(n+3)/2);
      // cout<<tmp<<endl;
      rtmp=tmp;
      reverse(all(rtmp));
      if(tmp==rtmp){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

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

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N;
  cin >> N;
  int h[N];
  for (int i = 0; i < N; i++) cin >> h[i];

  int tmp = h[0];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (tmp <= h[i]) {
      ans++;
      tmp = h[i];
    }
  }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

    public void solove() {

        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();


        if (x == 1) {
            System.out.println(x);
            return;
        }

        int result = 2;
        
        for (int i = 2; i <= x; i++) {
            for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            }
        }
        System.out.println(result);
    }
}


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

using namespace std;

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

void solve() {
    int n,m,k;
    cin >> n >> m >> k;
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    --sx;--sy;--tx;--ty;
    vector<string> s(n);
    for (auto& x: s) cin >> x;
    vector<vector<int>> d(n, vector<int>(m, -1));
    d[sx][sy] = 0;
    queue<pair<int,int>> q;
    q.emplace(sx, sy);
    while (!q.empty()) {
        int x,y;
        tie(x,y) = q.front(); q.pop();
        for (int _ = 0; _ < 4; _++) {
            for (int i = 1; i <= k; i++) {
                int u = x + i*dx[_];
                int v = y + i*dy[_];
                if (u<0||u>=n || v<0||v>=m) break;
                if (s[u][v] == '@') break;
                if (d[u][v] != -1 && d[u][v] < d[x][y]+1) break;
                if (d[u][v] == -1) {
                    d[u][v] = d[x][y] + 1;
                    q.emplace(u, v);
                }
            }
        }
    }
    cout << d[tx][ty];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 12144
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  long long k;
  cin>>s;
  cin>>k;
  k--;
  int cur=0;
  while(cur<s.length()&&s[cur]=='1')cur++;
  if(cur==s.length()){
    cout<<1;
    return 0;
  }
  if(k>=cur){
    cout<<s[cur];
    return 0;
  }
  else cout<<1;
  return 0;
}

Measured memory_bytes: 384
import math
a = input()
a_half = math.floor(len(a)/2)
count= 0
ans_list_R = ['R', 'U','D']
ans_list_L = ['L', 'U','D']
for i in range(len(a)):
    if i % 2==0:
        if a[i] in ans_list_R:
            count += 1
    else:
        if a[i] in ans_list_L:
            count += 1
if count == len(a) :
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int A, B;
    int X = 0;
    cin >> A >> B;
    for (int i = 1; i < B;) {
        X++;
        i = i + (A - 1);
    }
    cout << X << endl;
}


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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
       _l: usize,
       s: [chars; n]
    }

    //test
    //
    /*
    let n: usize = 3;
    let _l: usize = 3;
    let mut s: Vec<Vec<char>> = vec![
        vec!['a', 'z', 'x'],
        vec!['d', 'y', 'x'],
        vec!['d', 'y', 'a'],
    ];
    */

    s.sort();

    for v in s {
        print!("{}", v.into_iter().collect::<String>());
    }
    println!();
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
    int n,x,i,j,k,count=0;

    scanf("%d%d",&n,&x);
    while((n!=0)||(x!=0)) { 
        for(i=1;i<=n-2;i++) {
            for(j=i+1;j<=n-1;j++) { 
                for(k=j+1;k<=n;k++) {
                    if(i+j+k==x)
                        count+=1;
                }
            }
        }
    printf("%d\n", count);
    count = 0;
    scanf("%d%d",&n,&x);
    }
    return 0;
}   

Measured memory_bytes: 2680
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		boolean[] a=new boolean[4];
		for(int i=0;i<s.length();i++) {
			if(s.substring(i, i+1).equals("N"))a[0]=true;
			if(s.substring(i, i+1).equals("W"))a[1]=true;
			if(s.substring(i, i+1).equals("S"))a[2]=true;
			if(s.substring(i, i+1).equals("E"))a[3]=true;
		}
		if(a[0]==a[2] && a[1]==a[3])System.out.println("Yes");
		else System.out.println("No");
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <cmath>
#define LOG10_101 0.00432137378
using namespace std;
int main(void){
    long long now=100,x;
    int counter=0;
    cin >> x;
    while(now<x){
        now=(long long)((double)now*1.01);
        counter++;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3596
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
// set<int>st{ 3,1,4,1,5,9,2,6,5,3,5 };
//     for (auto itr = st.begin(); itr != st.end(); ++itr) {
//         cout << *itr;
//     }
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
    string s;
    cin>>s;
    string t="";
    rep(i,s.size()/2){
        t+=s.at(i*2);
    }
    if(s.size()%2){
        t+=s.at(s.size()-1);
    }
    cout<<t<<endl;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,m,k=0,x,f,t,a,b;
    cin>>m;
    string s;
    set<string>g;
    for(int i = 0;i < m;i++)
    {
        cin>>s;
        g.insert(s);
    }
    cout<<g.size()<<endl;



}


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

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

    int N;
    cin >> N;
    int i = 1;
    while (pow(i, 2) <= N) {
        i++;
    }
    ll ans = pow(i-1, 2);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	cout << (N + 999) / 1000 * 1000 - N << "\n";

	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

signed main()
{
    int N;
    cin >> N;
    int A[MAX_N];
    REP(i, N) {
        cin >> A[i];
    }

    int ans = LLINF;
    for(int i = -100; i <= 100; ++i) {
        int cand = 0;
        REP(j, N) {
            cand += abs(A[j] - i) * abs(A[j] - i);
        }
        ans = min(ans, cand);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    ll N, X;
    cin >> N >> X;
    if (X > N-X) X = N-X;
    ll Tmp = X+N;
    ll L = N-2*X;
    while (L != 0) {
        if (X >= L) {
            if (X%L == 0) {
                Tmp += X+L*(2*X/L-1);
                break;
            } else {
                Tmp += X+2*L*(X/L)+X%L;
                ll nextX = X%L;
                ll nextL = L-X%L;
                X = nextX;
                L = nextL;
            }
        } else {
            if (L%X == 0) {
                Tmp += 2*L;
                break;
            } else {
                Tmp += 2*X*(L/X);
                L = L%X;
            }
        }
    }
    cout << Tmp << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  int A=(a-b), B=(a-c), C=(a-d), D=(a-e), E=(b-c), F=(b-d), G=(b-e),
  H=(c-d), I=(c-e), J=(d-e);
  
  if(A>k || -A>k || B>k || -B>k || C>k || -C>k || D>k || -D>k ||
     E>k || -E>k || F>k || -F>k || G>k || -G>k || H>k || -H>k ||
     I>k || -I>k || J>k || -J>k){
    cout << ":(" << endl;
  }
  
  else{
    cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
//==========================================
// ABC142d
//
// 2019/09/28
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
using ull=unsigned long long;

ull gcd(ull a, ull b)
{
  if(a<b) return gcd(b,a);  
  ull r;
  while(r=a%b)
  {
    a = b;
    b = r;
  }

  return b;
}

int main(int argc, char* argv[])
{
  ull a, b;
  cin >> a >> b;
  
  ull g;
  g=gcd(a, b);
  ull cnt=1;

  for(ull i=2; i*i<g; ++i)
  {
    if(g%i==0)
    {
      cnt++;
      while(g%i==0) g/= i;
    }
  }
  if(g>1) cnt++;
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int[] A = new int[N];
    int max1 = 0;
    int max1Ind = -1;
    int max2 = 0;
    int max2Ind = -1;
    for (int i = 0; i < N; i++) {
      A[i] = scanner.nextInt();
      if (A[i] > max1) {
        max1 = A[i];
        max1Ind = i;
      } else if (A[i] > max2) {
        max2 = A[i];
        max2Ind = i;
      }
    }

    for (int i = 0; i < N; i++) {
      if (i == max1Ind) {
        System.out.println(max2);
      } else {
        System.out.println(max1);
      }
    }

  }
}

Measured memory_bytes: 88840
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n);
    for(auto& v:a){
        cin >> v;
    }
    // pattern num of sharing 1 to n-th people, k candy
    vector<vector<ll>> dp(n, vector<ll>(k+1, 0));
    for(int i=0; i<n; i++){
        dp[i][0] = 1;
    }
    for(int i=0; i<a[0]+1; i++){
        dp[0][i] = 1;
    }
    int limit = a[0];
    for(int i=1; i<n; i++){
        limit += a[i];
        for(int j=1; j<k+1; j++){
            if(j > min(limit, k)){break;}
            dp[i][j] += dp[i][j-1];
            dp[i][j] += dp[i-1][j];
            if(j - a[i] - 1 >= 0){
                dp[i][j] -= dp[i-1][j - a[i] - 1];
            }
            dp[i][j] %= MOD;
        }
    }
    cout << (dp[n-1][k] + MOD) % MOD << "\n";
    return 0;
}

Measured memory_bytes: 79488
#define _crt_secure_no_warnings

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#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 <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main()
{
	long long int x,i;
	vector<int>data;
	while (1)
	{
		data.clear();
		i = 7;
		cin >> x;
		if (x == 1)break;
		cout << x << ":";
		while (i<= x+1)
		{
			if (!(x % (i - 1)))
			{
				data.push_back(i - 1);
				
			}
			if (!(x % (i + 1)))
			{
				data.push_back(i + 1);
				
			}
			i += 7;
		}
		int f;
		for (auto x : data)
		{
			f = 1;
			for (auto ite = data.begin(); *ite != x; ite++)
			{
				if (!(x%*ite))
				{
					f = 0;
				}
			}
			if (f)cout << " " << x;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1216