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

int main(){
  int N;
  int A,AA;
  long long ans=0;
  cin>>N;
  int times=N-1;
  int s;
  cin>>A;
  for(int i=0;i<times;i++){
    cin>>AA;
    if(A>AA){
      s=A-AA;
      ans+=s;
      AA+=s;
      A=AA;
    }else{
      A=AA;
    }
  }
  cout<<ans<<endl;
}


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

const long long maxa=10002;
long long ans[maxa];
int n;

long long g(long long x, long long y, long long z){
	return x*x+y*y+z*z+x*y+x*z+y*z;
}

int main(){
	memset(ans,0,sizeof ans);
	for (long long x=1;x*x<maxa;x++){
		for (long long y=1;y*y<maxa;y++){
			long long tmp;
			for (long long z=1;z*z<maxa;z++){
				tmp=g(x,y,z);
				if (tmp>=maxa) break;
				ans[tmp]++;
			}
		}
	}
	cin >> n;
	for (int i=1;i<=n;i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 3708
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int main(void){
    int N,M;
    GI(N);GI(M);
    vector<pair<int,int> > ab(M);
    REP(i,M){
        GI(ab[i].first);
        GI(ab[i].second);
    }
    sort(ALL(ab));
    priority_queue<int, vector<int>, greater<int> > que;
    int ans = 0;
    for(auto p:ab){
        if(!que.empty() && que.top() <= p.first){
            ans++;
            que = priority_queue<int, vector<int>, greater<int> >();
        }
        que.push(p.second);
    }
    if(!que.empty())
        ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1448
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, K int

func main() {
	sc.Split(bufio.ScanWords)
	N, K = nextInt(), nextInt()

	ans := 0
	var tmp int
	for i := 0; i < N; i++ {
		tmp = nextInt()
		ans += 2 * minInt(K-tmp, tmp)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int c[n];
    int a[m][n];
    for(int i=0;i<n;i++){
        cin >> c[i];
        for(int j=0;j<m;j++){
            cin >> a[j][i];
        }
    }
    bool exist=false;
    long long ans=1000000000000000;
    for(int bit=0;bit<(1<<n);bit++){
        long long sum=0;
        int vol[m]={0};
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                sum+=c[i];
                for(int j=0;j<m;j++){
                    vol[j]+=a[j][i];
                }
            }
        }
        for(int i=0;i<m;i++){
            if(vol[i]>=x){
                if(i==m-1){
                    exist=true;
                    if(ans>sum)ans=sum;
                }
            }
            else break;
        }
        
    }
    if(exist)cout << ans;
    else cout << -1;
}

Measured memory_bytes: 3628
n = int(input())
ls = []
for i in range(n):
    a = int(input())
    p = []
    for i in range(a):
        x,y = map(int,input().split())
        p.append([x-1,y])
    ls.append(p)

ans = 0

for i in range(2**n):
    flag = 0
    for j in range(n):
        if (i >> j) & 1:#もし正直者だったら
            for k in ls[j]:#証言の確認
                if (i >> k[0])&1 != k[1]:#もし証言がおかしかったら
                    flag = 1
                    break
    if flag == 0:
        ans = max(ans, bin(i)[2:].count('1'))
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
using namespace std;
const int N = 110;

char a[N],b[N];
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s%s",a,b);
    int i,j;
    for(i = 0; i < n; i++)
    {
        for(j = i; j < n; j++)
        {
            if(a[j] != b[j-i])
                break;
        }
        if(j == n)
        {
            printf("%d\n",n*2-(n-i));
            break;
        }
    }
    if(i == n)
        printf("%d\n",n*2);
}


Measured memory_bytes: 256
def factorial(n):
    ans = 1
    for i in range(2, n + 1):
        ans = ans * i % 1000000007
    return ans


N, M = map(int, input().split())

MAD = 10**9+7
if abs(N-M) >= 2:
    print(0)

elif N == M:
    print((2*factorial(N)*factorial(M)) % MAD)

else:
    print((factorial(N)*factorial(M)) % MAD)


Measured memory_bytes: 3060
#include<stdio.h>
int main(void) {
	int a = 0, b = 0;
	scanf("%d%d", &a, &b);
	if (a % 3 == 0)printf("Possible");
	else if (b % 3 == 0)printf("Possible");
	else if ((a + b) % 3 == 0)printf("Possible");
	else printf("Impossible");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  int count=3;
  if(a==b){
    count--;
  }
  if(a==c){
    count--;
  }
  if(b==c){
    count--;
  }
  if(count==0){
    count++;
  }
  cout<<count<<"\n";
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define vi vector<int>

using ll = long long;
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
inline ll inv(ll x, ll div){return pow(x, div - 2, div);}
#define chmax(a,b) a=max(a,b)
int gcj_out_cnt = 1;
#define gcj_put cout<<"Case #"<<gcj_out_cnt++<<": ";

/*Coding Space*/
int cnt = 0;
int main(){
  int n; cin >> n;
  rep(i,n){
    int input; cin >> input;
    if(input%2) cnt++;
  }
  if(cnt == 0){
    cout << "second" << endl;
  }else{
    cout << "first" << endl;
  }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll a[20];
ll p[20];

void solve(){

    ll n,k;
    cin >> n >> k;
    
    
    rep(i,n){
        cin >> a[i];
        if(i!=0) p[i]=max(a[i],p[i-1]);
        else p[0]=a[0];
    }
    /*
    rep(i,n){
        cout << p[i] << " ";
    }
    cout << endl;
    */

    ll ans = 10000000000000;

    for(ll bit=0; bit<(1<<n); bit++){

        ll tmp=bit;
        vector<ll> c;
        for(ll i=0; i<n; i++){
            if(tmp%2==1) {
                c.emplace_back(i);
            }
            tmp = tmp/2;
        }

        /*
        rep(i,c.size()){
            cout << a[c[i]] << " ";
        }
        cout << endl;
        */

        if(c.size()<k) continue;
        ll count=0;
        count += p[c[0]]-a[c[0]];
        //cout << c[0] << ": " << count << " ";
        rep(i,c.size()-1){
            ll x = c[i];
            if(p[x]>=p[c[i+1]]){
                p[c[i+1]]=p[x]+1;
                count += p[x]+1-a[c[i+1]];
                //cout << x+1 << ": " << p[x]+1-a[c[i+1]] << " ";
            }
        }
        //cout << endl;

        /*
        rep(i,c.size()){
            cout << "result: " << p[c[i]] << " ";
        }
        cout << count << endl;
        */

        //cout << count << endl;

        ans = min(ans, count);

        rep(i,n){
        if(i!=0) p[i]=max(a[i],p[i-1]);
        else p[0]=a[0];
    }

    }

    cout << ans << endl;

    

    

}

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


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

int dp[2][111][11111],t;
int main() {
  int n,m;
  cin >> n >> m;
  for(int i=0; i<=m; i++) {
    for(int j=0; j<11111; j++) dp[0][i][j]=dp[1][i][j]=-(1<<30);
  }
  dp[0][0][0]=0;
  for(int i=0; i<n; i++) {
    int a,b,c;
    cin >> a >> b >> c;
    for(int j=m; j>=0; j--) {
      for(int k=10001; k>=0; k--) {
        if(j+c<=m) {
          dp[t^1][j+c][k+a]=max(dp[t^1][j+c][k+a],dp[t][j][k]+b);
          dp[t^1][j+c][k+b]=max(dp[t^1][j+c][k+b],dp[t][j][k]+a);
        }
        dp[t^1][j][k]=max(dp[t^1][j][k],dp[t][j][k]);
      }
    }
    t^=1;
  }
  int ans=0;
  for(int i=0; i<=m; i++) {
    for(int j=0; j<11111; j++) ans=max(ans,min(j,dp[t][i][j]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11872
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C = readline().decode('utf8').split()
ans=A[0]+B[0]+C[0]

print(ans.upper())


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

/*
10S = 77777770
 9S = 70000000 - 7
  S =  7777777 = (10^9 * 7 - 7) / 9

mod kで考える
取りうる値は0 <= x < k
mod kは同じ値が現れるとループに入る -> k回回すまでに必ずループ開始
*/

int		main(void)
{
	int k;
	cin >> k;

	int x = 7 % k;
	for (int i = 0; i < k; ++i)
	{
		if (x == 0)
		{
			cout << i + 1 << endl;
			return 0;
		}
		x = (x*10 + 7) % k;
	}
	cout << -1 << endl;
}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  
  scanf("%d", &n);

  switch (n % 10) {
    case 0:
    case 1:
    case 6:
    case 8:
      puts("pon");
      break;

    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      puts("hon");
      
      break;

    case 3:
      puts("bon");

      break;
  }
  return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
 #define mod 1000000007
 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
    cin>>n;
    int v[n];
    double ans=0;
    for(int x=0;x<n;x++){
        cin>>v[x];
      
    }
    sort(v,v+n);
    ans=v[0];
    for(int x=1;x<n;x++){
        ans=(ans+v[x])/2.0;
    }
    cout<<fixed<<setprecision(10)<<ans;









	
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int time;
	int minu=0;
	int min_1=10;
	for (int i = 0; i < 5; ++i) {
		cin >> time;
		if (time % 10 != 0 && time % 10 < min_1) {
			min_1 = time % 10;
		}
		if (time % 10 != 0) {
			time = (time / 10) * 10 + 10;
		}
		minu += time;
	}
	if (min_1 != 10) {
		minu = minu - 10 + min_1;
	}
	cout << minu << endl;
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> pixel(H);
  string buf = "";
  for (int i = 0; i < H; i++) {
    cin >> pixel.at(i);
  }
  for (int i = 0; i < W; i++) {
    buf += '#';
  }
  string line = '#' + buf + '#';
  cout << line << endl;
  for (int i = 0; i < H; i++) {
    cout << '#' + pixel.at(i) + '#' << endl;
  }
  cout << line << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int modInverse(int a, int m) 
{ 
    int m0 = m; 
    int y = 0, x = 1; 
    if (m == 1) 
      return 0;   
    while (a > 1) 
    { 
        int q = a / m; 
        int t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 

int fac[100005];
int mod=1e9+7;
int cal(int n,int r)
{
   if(n<r)
      return 0;
   int z=fac[n];
   z=(z*modInverse(fac[r],mod))%mod;
   z=(z*modInverse(fac[n-r],mod))%mod;
   return z;
}
int pr1[100005],pr2[100005],pr3[100005];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   cin>>n;
   int x[n+1];
   for(int i=1;i<=n;i++)
   {
      cin>>x[i];
      x[i]%=mod;
   }
   fac[0]=1;
   for(int i=1;i<=n;i++)
      fac[i]=(fac[i-1]*i)%mod;
   int pre[n+1]={0};
   for(int i=1;i<=n-1;i++)
   {
      pre[i]=(x[i+1]-x[i]+pre[i-1]+5*mod)%mod;
      // cout<<pre[i]<<" ";
   }
   // cout<<'\n';
   int l=0,r=n-2;
   int zz=0;
   for(int i=1;l<=r;i++)
   {
      zz++;
      pr1[i]=(pre[r]-pre[l]+mod)%mod+pr1[i-1];
      pr1[i]%=mod;
      pr2[i]=pr1[i];
      pr2[i]%=mod;
      l++;
      r--;
   }
   if(l-r==1)
   {
      l=2;
   }
   else
   {
      l=3;
   }
   
   for(int i=zz+1;i<=n-2;i++)
   {
      pr2[i]=pr1[i-l];
      pr2[i]%=mod;
      l+=2;
   }
   // for(int i=1;i<=n;i++)
   // {
   //    cout<<pr2[i]<<" ";
   // }
   // cout<<"\n";
   int sum=0;
   int ans=0;
   int ind=2;
   for(int i=1;i<=n-2;i++)
   {
      sum=pr2[i];
      int z=(sum*cal(n-1,ind))%mod;
      z=(z*fac[ind-2])%mod;
      z=(z*fac[n-1-ind])%mod;
      ans=(ans+z)%mod;
      // cout<<ans<<"\n";
      ind++;
   }
   // cout<<ans<<"\n";
   for(int i=1;i<=n-1;i++)
   {
      int z=(pre[n-1]-pre[n-1-i]+mod)%mod;
      z=(z*cal(n-1,i))%mod;
      z=(z*fac[i-1])%mod;
      z=(z*fac[n-1-i])%mod;
      ans=(ans+z)%mod;
   }
   cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 3840
N = int(input())
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
C = list(map(int, input().strip().split()))

satisfaction = 0
for i in range(N):
    satisfaction += B[A[i]-1]
    if i != 0 and A[i] == A[i-1] + 1:
        satisfaction += C[A[i-1]-1]


print(satisfaction)


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

using namespace std;

int main(){
	
	string d;
	cin>>d;
	int countA = 0;
	int countB =0;
	for(auto s : d){
		if(s== 'B') countB++;
		else countA++;
		}
	if(countB==3 or countA==3) cout<<"No";
	else cout<<"Yes";	
	
	return 0;
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LOCAL 0
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int INF=0x3f3f3f3f;
#define Pa pair<int,int>
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define ld long double
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main() {
    int a,b;
    cin>>a>>b;
    
    int p=a*b;
    if(p%2==1) cout<<"Odd\n";
    else cout<<"Even\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

char Trump;
string cards[4][13];
bool awin(char a,char b)
{
  int pa = (isdigit(a)?a-'0':(a=='T'?10:(a=='J'?11:(a=='Q'?12:(a=='K'?13:(a=='A'?14:inf))))));
  int pb = (isdigit(b)?b-'0':(b=='T'?10:(b=='J'?11:(b=='Q'?12:(b=='K'?13:(b=='A'?14:inf))))));
  return pa > pb;
}

void compute()
{
  int points[2];
  points[0] = points[1] = 0;
  int winner = 0;
  rep(i,13)
    {
      bool trump = (cards[0][i][1] == Trump);
      char suit = cards[winner][i][1];
      int mex = 0;
      REP(j,1,4)
	{
	  if(trump)
	    {
	      if(Trump != cards[j][i][1])continue;
	      if(awin(cards[j][i][0],cards[mex][i][0]))mex = j;
	    }
	  else
	    {
	      if(Trump == cards[j][i][1])
		{
		  trump = true;
		  mex = j;
		  continue;
		}
	      if(cards[mex][i][1] != suit)mex = j;
	      if(suit == cards[j][i][1])
		{
		  if(awin(cards[j][i][0],cards[mex][i][0]))mex = j;
		}
	    }
	}

      points[(mex==1||mex==3)?0:1]++;
      winner = mex;
      //cout << "winner : " << mex << " suit : " << suit << endl;
    }
  //cout << "posint " << points[0] << " " << points[1] << endl;
  cout << ( points[0] > points[1] ? "EW" : "NS") << " " << (points[0] < points[1]?points[1]:points[0])-6 << endl;
}

int main()
{
  while(cin >> Trump,Trump!='#')
    {
      rep(i,4)rep(j,13)cin >> cards[i][j];
      compute();
    }
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    int r=0, b=0;
    for (int i = 0; i < S.size(); ++i) {
        if(S[i] == '0'){
            r++;
        }else{
            b++;
        }
    }
    cout << min(r,b)*2;
    return 0;
}

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

typedef double db;
typedef long long ll;
const int maxn = 2e5 + 10;
int n, q[maxn]; ll C, a[maxn], f[maxn];

db get(int x, int y) {
	return db((f[x] + a[x] * a[x]) - (f[y] + a[y] * a[y])) / db(a[x] - a[y]);
}

int main() {
	scanf("%d %lld", &n, &C);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", a + i);
	}
	int l = 1, r = 1; q[1] = 1;
	for (int i = 2; i <= n; i++) {
		while (l < r && get(q[l], q[l + 1]) < (db)2 * a[i]) l++;
		f[i] = f[q[l]] + (a[i] - a[q[l]]) * (a[i] - a[q[l]]) + C;
		while (l < r && get(q[r - 1], q[r]) > get(q[r], i)) r--;
		q[++r] = i;
	}
	printf("%lld", f[n]);
	return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    int M = -1;
    REP(i, N) {
        M = max(M, A[i]);
    }
    vector<int> E(M + 1, -1);
    FOR(i, 2, M + 1) {
        if(E[i] == -1) {
            E[i] = i;
        }
        for(int j = i*2;j < M + 1;j += i) {
            if(E[j] == -1) {
                E[j] = i;
            }
        }
    }
    vector<bool> primes(M + 1, false);
    bool pairwise = true;
    for(int i = N - 1;0 <= i;i--) {
        int j = A[i];
        set<int> s;
        for(;1 < j;) {
            s.insert(E[j]);
            j /= E[j];
        }
        for(auto i : s) {
            pairwise = pairwise && !primes[i];
            primes[i] = true;
        }
    }
    int g = A[0];
    FOR(i, 1, N) {
        g = gcd(g, A[i]);
    }
    bool setwise = g == 1;
    if(pairwise) {
        cout << "pairwise coprime" << endl;
    }else if(setwise) {
        cout << "setwise coprime" << endl;
    }else{
        cout << "not coprime" << endl;
    }
    return 0;
}


Measured memory_bytes: 11100
#include<iostream>
#include<string>

using namespace std;

int main(){
	string o,e;
	cin >> o >> e;
	for(int i = 0; i < o.size(); i++){
		cout << o[i];
		if(i == o.size()-1 && o.size() != e.size())
			break;
		cout << e[i];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int K[300];

int main(){
  int i;
  int n;

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



Measured memory_bytes: 2112
N = int(input())
t, x, y = [0], [0], [0]

for i in range(N):
    t_tmp = 0
    x_tmp = 0
    y_tmp = 0

    t_tmp, x_tmp, y_tmp = map(int, input().split())

    t.append(t_tmp)
    x.append(x_tmp)
    y.append(y_tmp)

flag = 0

for i in range(N):
    judge = (t[i+1] - t[i]) - abs(x[i+1] - x[i]) - abs(y[i+1] - y[i])
    if judge % 2 == 1 or judge < 0:
        flag = 1
        break

if flag == 0:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 11764
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();
		int x=sc.nextInt();
		int y=sc.nextInt();
		
		if(x>y){
			int tmp=a; a=b; b=tmp;
			tmp=x; x=y; y=tmp;
		}

		if(a+b<=2*c){
			System.out.println(a*x+b*y);
		}else{
			System.out.println(2*c*x + Math.min(b,2*c)*(y-x));
		}
	}
}


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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        long t=fsc.nextLong();
        long last=0;
        long ans=0;
        for(int i=0;i<n;i++){
            long ti=fsc.nextLong();
            if(ti>=last){
                ans+=t;
            }
            else{
                ans+=ti+t-last;
            }
            last=ti+t;
        }
        fsc.close();
        System.out.println(ans);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 23848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n;
  cin >> n;
  bool ans = true;
  vi a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(all(a));
  rep(i,n){
    if(a[i]==a[i+1]){
      ans = false;
    }
  }
  if(ans){
    print("YES");
  }
  else{
    print("NO");
  }
}

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

int to_int(string s){
    int number = 0;
    for(int i=0;i<s.size();i++){
        number *= 10;
        number += s[i] - '0';
    }
    return number;
}

string to_str(int n){
    string s;
    while(n!=0){
        s += n % 10 + 48;
        n /= 10;
    }
    reverse(s.begin(),s.end());
    return s;
}

bool isLeapYear(int year)
{
    if(((year % 4 == 0 ) && (year % 100 != 0)) || (year % 400 == 0))
        return true;
    else
        return false;
}

bool isPrime(int n)
{
    if (n == 2)
        return true;
    if ((n & 1)==0)
        return false;
    for (int i = 3; i*i <= n;i+=2) {
        if (n%i == 0)
            return false;
    }

    return true;
}

/*#define row 5001
#define col 10000

int arr[row][col];

void fib()
{
    arr[0][0] = 0;
    arr[1][0] = 1;
    for(int i=2;i<row;i++){
        for(int j=0;j<col;j++){
            if(arr[i-1][j] + arr[i-2][j] == 0)
                continue;
            arr[i][j] += arr[i-1][j] + arr[i-2][j];
            if(arr[i][j] > 9){
                arr[i][j+1] = arr[i][j]/10;
                arr[i][j] %= 10;
            }
        }
    }
}*/

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

    return 0;
}


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

int main()
{

    ll d, g;
    cin >> d >> g;
    vector<int> p(d);
    vector<int> c(d);
    vector<bool> isComp(d);
    ll ans = 1000000000000;

    for (auto i = 0; i < d; i++)
    {
        int pi, ci;
        cin >> pi >> ci;
        p[i] = pi;
        c[i] = ci;
    }

    for (auto i = 0; i < (1 << d); i++)
    {
        for (auto j = 0; j < d; j++)
        {
            if ((i & (1 << j)))
            {
                isComp[j] = true;
            }
            else
            {
                isComp[j] = false;
            }
        }

        ll score = 0, num = 0;
        int max_index = -1;
        for (auto j = d - 1; j >= 0; j--)
        {
            if (!isComp[j])
            {
                max_index = j;
                break;
            }
        }

        for (auto j = 0; j < d; j++)
        {
            if (isComp[j])
            {
                score += p[j] * (j + 1) * 100 + c[j];
                num += p[j];
            }
        }

        if (max_index != -1)
        {
            int tmp = 0;
            while (score < g && tmp <= p[max_index] - 1)
            {
                score += 100*(max_index+1);
                num += 1;
                tmp += 1;
            }
        }

        if (score >= g)
        {
            if (num < ans)
            {
                ans = num;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] c = s.toCharArray();
		int count = 0;
		long ans = 0;
		for(int i = 0; i < s.length(); i++) {
			if(c[i]=='W') {
				ans += i-count;
				count++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 41036
S = int(input())

after = S % 100
before = S //100

if after >31 and before > 31:
  print("NA")
else:
  if before <= 12 and before >0:
    if after <= 12 and after >0:
      print("AMBIGUOUS")
    else:
      print("MMYY")
  else:
    if after <= 12 and after > 0:
      print("YYMM")
    else:
      print("NA")


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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int notprime[345678]={};
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    notprime[0]=1;
    notprime[1]=1;
    REP(i,500){
      if(notprime[i]) continue;
      for(int j=i*i;j<250000;j+=i)
	notprime[j]=1;
    }
    int answer=0;
    FOR(i,n+1,n*2+1)
      if(!notprime[i]) answer++;
    cout << answer << endl;
  }
}

Measured memory_bytes: 2136
[n,k] = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

ls_posi = []#0を含む
ls_nega = []

for i in range(n):
    if x[i] < 0:
        ls_nega.append(-x[i])
    else:
        ls_posi.append(x[i])

ls_nega.reverse()
ans = 10 ** 9

for i in range(k+1):
    #posiから0〜k個, negaからk-posi個
    if i == 0:
        if len(ls_nega) >= k:
            ans = min(ans,ls_nega[k-1])
    elif i == k:
        if len(ls_posi) >= k:
            ans = min(ans,ls_posi[k-1])
    else:
        if len(ls_posi) >= i and len(ls_nega) >= k - i:
            ans = min(ans,ls_posi[i-1] * 2 + ls_nega[k-i-1])
            ans = min(ans,ls_posi[i-1] + ls_nega[k-i-1] * 2)
print(ans)


Measured memory_bytes: 90720
#include<bits/stdc++.h>
using namespace std;
int a,b,k,tmp,tmp2,c;
int main(){
  cin>>a>>b>>k;
  c=1;
  while(k>0){
    if((c%2)==1){tmp=a;tmp2=b;}
    else{tmp=b;tmp2=a;}
    if((tmp%2)==1){
      tmp=(tmp-1)/2;
      tmp2+=tmp;
    }
    else{
      tmp/=2;
      tmp2+=tmp;
    }
    if((c%2)==1){a=tmp;b=tmp2;}
    else{b=tmp;a=tmp2;}
    k--;
    c++;
  }
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;
const ll INF = 1LL<<50;

int main(){

int N,W;
cin>>N>>W;
ll w[N+1],v[N+1];
rep3(i,N){
    cin>>w[i]>>v[i];
}
ll dp[W+1][N+1];
rep(i,N+1){
    dp[0][i]=0;
}
rep(i,W+1){
    dp[i][0]=0;
}
rep3(i,W){
    rep3(j,N){
        if(i>=w[j]){
            dp[i][j]=max(dp[i][j-1],dp[i-w[j]][j-1]+v[j]);
        }
        else{
            dp[i][j]=dp[i][j-1];
        }
    }
}
cout<<dp[W][N]<<endl;
return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    set<string> q;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        q.insert(s);
    }
    cout << q.size();

    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c, cnt = 0, x, y, z;
    cin >> a >> b >> c;
    if(a%2 || b%2 || c%2) {
        cout << 0 << endl;
        return 0;
    }
    if(a == b && b == c) {
        cout << -1 << endl;
        return 0;
    }
    while(!(a%2) && !(b%2) && !(c%2)) {
        x = b/2 + c/2;
        y = a/2 + c/2;
        z = a/2 + b/2;
        a = x;
        b = y;
        c = z;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli k,n;
    string s;
    cin>>n>>k>>s;
    vi st;
    lli res=0;
    lli now=0;
    lli ans=0;
    char prev='1';
    rep(i,n){
        if(prev==s[i]){
                now+=1;
        }
        else{
            st.push_back(now);
            prev=s[i];
            now=1;
        }
        if(i==n-1){
            st.push_back(now);
        }
    }
    if(st.size()%2==0) st.push_back(0);
    lli add=2*k+1;
    vi sum;
    sum.push_back(0);
    rep(i,st.size()){
        sum.push_back(sum.at(sum.size()-1)+st.at(i));
    }
    for(int i=0;i<sum.size();i+=2){
        int left=i;
        int right=min(i+add,(lli)sum.size()-1);
        res=sum[right]-sum[left];
        ans=max(res,ans);
    }
    out(ans);
    
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1L<<61);

int H, W, K, mxH = 0;
vector<string> s;
vvl ans;

void dfs(int y, int x, int c, int mnX, int mxX, bool fix) {
  if (ans[y][x] != -1) return;
  ans[y][x] = c;
  rep(i,W) {
    int nx = x - i - 1;
    if (fix && nx < mnX) break;
    if (nx == -1 || ans[y][nx] != -1 || s[y][nx] == '#') break;
    ans[y][nx] = c;
    if (!fix) {
      mnX = min(mnX, nx);
    }
  }
  rep(i,W) {
    int nx = x + i + 1;
    if (fix && nx > mxX) break;
    if (nx == W || ans[y][nx] != -1 || s[y][nx] == '#') break;
    ans[y][nx] = c;
    if (!fix) {
      mxX = max(mxX, nx);
    }
  }
  if (y != 0) {
    dfs(y-1, x, c, mnX, mxX, true);
  }
  if (y >= mxH && y < H-1) {
    dfs(y+1, x, c, mnX, mxX, true); 
  }
}

int main() {
  cin >> H >> W >> K;
  ans.assign(H, vl(W, -1));
  s.resize(H);
  rep(i,H) {
    cin >> s[i];
    bool exist = false;
    rep(j,W) {
      if (s[i][j] == '#') exist = true;
    }
    if (exist) mxH = i;
  }
  int c = 1;
  rep(i,H) {
    rep(j,W) {
      if (s[i][j] == '#') {
        dfs(i, j, c, j, j, false);
        c++;
      }
    }
  }
  rep(i,H) {
    rep(j,W) {
      cout << ans[i][j] << " \n"[j==W-1];
    }
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
 
  int count = 0;
 
  for (int i = 0; i < 3; i++){
    for (int j = i + 1; j < 4; j++){
      if (s.at(i) == s.at(j)){
        count++;
      }
    }
  }
 
  if (count == 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    while (cin >> n, n) {
        vector<ll> v(n); cin >> v;
        ll ans = linf;
        rep(i, n) rep(j, i+1, n) chmin(ans, abs(v[i]-v[j]));
        cout << ans << endl;
    }
}

Measured memory_bytes: 3120
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

	private static Map<String, Integer> map = new HashMap<String, Integer>() {
		{
			put("a", 0);
			put("b", 0);
			put("c", 0);
			put("d", 0);
			put("e", 0);
			put("f", 0);
			put("g", 0);
			put("h", 0);
			put("i", 0);
			put("j", 0);
			put("k", 0);
			put("l", 0);
			put("m", 0);
			put("n", 0);
			put("o", 0);
			put("p", 0);
			put("q", 0);
			put("r", 0);
			put("s", 0);
			put("t", 0);
			put("u", 0);
			put("v", 0);
			put("w", 0);
			put("x", 0);
			put("y", 0);
			put("z", 0);
		}
	};

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String[] S = sc.next().split("");
		Set<String> alph = new HashSet<>();
		for (int i = 0; i < S.length; i++)
			alph.add(S[i]);
		for (String string : alph) {
			map.put(string, 1);
		}
		String ans = "None";
		for (Map.Entry<String, Integer> entry : map.entrySet()) {
			if (entry.getValue() == 0) {
				ans = entry.getKey();
				break;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 32652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>

using namespace std;

int main()
{
    stack <int> S;
    int a , b , x;
    string s;

    while (cin >> s){
        if (s[0] == '+'){
            a = S.top() ; S.pop();
            b = S.top() ; S.pop();
            S.push(a + b);
        }
        else if (s[0] == '-'){
            b = S.top() ; S.pop();
            a = S.top() ; S.pop();
            S.push(a - b);
        }
        else if (s[0] == '*'){
            a = S.top() ; S.pop();
            b = S.top() ; S.pop();
            S.push(a * b);
        }
        else {
            S.push(atoi(s.c_str()));
        }
    }

    cout << S.top() << endl;
    return 0;
}



Measured memory_bytes: 3172
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


MOD = 10 ** 9 + 7


def calc_cumsum(l):
    cumsum = [l[0]]
    for i in l[1:]:
        cumsum.append(cumsum[-1] + i)
    return cumsum


n, k = LI()
nums = list(range(n + 1))
ans = 0
ruiseki_min = calc_cumsum(nums)
ruiseki_max = calc_cumsum(nums[::-1])
for i in range(k, n + 2):
    min_sum = ruiseki_min[i - 1]
    max_sum = ruiseki_max[i - 1]
    ans += max_sum - min_sum + 1
    ans %= MOD
print(ans)


Measured memory_bytes: 41296
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <map>
#include <cmath>
#include <math.h>

#define FOR(i,x,y,z)   for(int i = x ; i < y ; i+=z)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

using namespace std;

int train[501][501] = {0}; 
int CSum[501][501] ={0};
int train_num[100000] = {0};

int main()
{
	
	int N,M,Q;

	cin >> N >> M >> Q;


	FOR(i,0,M,1){
		 int L,R = 0;

		 cin >> L >> R ;

		 train[L][R] ++;
	
	}
	
	FOR(i,1,N+1,1){
		FOR(j,1,N+1,1){
			CSum[i][j] = CSum[i][j-1] + train[i][j] ;
		}
	
	}

	FOR(i,0,Q,1){
		int p,q = 0;

		cin >>p >>q;
	
		FOR(j,p,q+1,1){
			
			train_num[i] += (CSum[j][q] -CSum[j][p-1]);
		}

	}

	FOR(i,0,Q,1){
	
		cout << train_num[i] <<endl;
	
	}
	
	return 0;
}



Measured memory_bytes: 3328
#include<stdio.h>
int main() {
	int cnt=0,n, x, a[101], i, j, e;
	scanf("%d%d", &n, &x);
	for (i = 0; i < n; i++)scanf("%d", &a[i]);

	for (i = 0; i < n; i++) {
		for (j = n - 1; j > i; j--) {
			if (a[j] < a[j - 1]) {
				e = a[j];
				a[j] = a[j - 1];
				a[j - 1] = e;
			}
		}
	}
	
		for (i = 0; i < n-1; i++) {
		
			if ((x-a[i]) >= 0) {
				
				cnt++;
				x = x - a[i];
			}	
	  }
		if (a[n-1] ==x)cnt++;
	

	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

signed main(){
  int a,b;
  cin >> a >> b;
  vector<vector<char>> mass(100,vector<char>(100));
  rep(i,0,50){
    rep(j,0,100){
      mass[i][j] = '#';
    }
  }
  rep(i,50,100){
    rep(j,0,100){
      mass[i][j] = '.';
    }
  }
  int cnt = a-1;
  for(int i = 0;i < 50;i += 2){
    for(int j = 0;j < 100;j += 2){
      if(cnt == 0) break;
      mass[i][j] = '.';
      cnt--;
    }
    if(cnt == 0) break;
  }
  cnt = b-1;
  for(int i = 51;i < 100;i += 2){
    for(int j = 0;j < 100;j += 2){
      if(cnt == 0) break;
      mass[i][j] = '#';
      cnt--;
    }
    if(cnt == 0) break;
  }
  cout << 100 << ' ' << 100 << endl;
  rep(i,0,100){
    rep(j,0,100){
      cout << mass[i][j];
    }
    cout << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	int sum = 0;
  	cin >> N;
	int tmp = N;
	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}
	if (N % sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,d,r,z;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f= 1.0*a/b;
    printf("%d %d %.5f\n",d,r,f);

    return 0;
}

Measured memory_bytes: 640
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	string s, t;
	cin >> s >> t;

	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		ans += s[i] != t[i];
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3780
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var aa = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
    var a=aa[0]
    var b=aa[1]

    /*if(a<b)
    {
        for(i in 1..b)
            print(a)
    }
    else
    {
        for(i in 1..a)
            print(b)
    }
*/
    var ast=""
    var bst=""
    for(i in 1..b)
        ast+="$a"
    for(i in 1..a)
        bst+="$b"

    if(ast<bst)
        print(ast)
    else
        print(bst)
}


Measured memory_bytes: 34172