akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int n;
vector<ll> v;
ll memo[4005][6005];

ll dfs(int l, int r) {
	if(memo[l][r] != -1) return memo[l][r];

	int turn = r - l - 1;

	if(turn == n) return memo[l][r] = 0;
	else if(turn % 2 == 1) {
		if(v[l] < v[r]) {
			return memo[l][r] = dfs(l, r+1);
		} else {
			return memo[l][r] = dfs(l-1, r);
		}
	} else {
		return memo[l][r] = max(dfs(l-1, r) + v[l], dfs(l, r+1) + v[r]);
	}
}

int main() {
	cin >> n;

	v.resize(n*3);
	rep(i, n) { 
		cin >> v[i];
		v[i+n] = v[i];
		v[i+n+n] = v[i];
	}

	ll ans = 0;
	memset(memo, -1, sizeof(memo));

	rep(i, n) {
		ans = max(ans, dfs(i-1+n, i+1+n) + v[i]);
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

struct UnionFind {
  vector<int> par;
  UnionFind(int N) : par(N, -1) {}

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

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] += par[ry];
    par[ry] = rx;
  }

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

  int size(int x) { return -par[root(x)]; }
};

void solve() {
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);
  vector<int> deg(N, 0);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    deg[a]++;
    deg[b]++;
    uf.unite(a, b);
  }
  vector<vector<int>> block(N);
  for (int i = 0; i < K; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    block[a].push_back(b);
    block[b].push_back(a);
  }
  for (int i = 0; i < N; i++) {
    int ans = uf.size(i) - deg[i] - 1;
    for (int b : block[i]) {
      if (uf.same(i, b)) ans--;
    }
    cout << ans << ' ';
  }
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 7168
import bisect
n = int(input())
a=[int(input()) for i in range(n)]
b = sorted(a)
for i in range(n):
    k = bisect.bisect_left(b,a[i])
    a[i]= k

ass = 0
for i in range(n):
    if a[i]%2 != i %2:
        ass += 1

print(ass//2)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	int n, m;
	cin >> n >> m;
	ll ma, mi;
	mi = min(n,m);
	ma = max(n,m);
	if ( mi == 1 ){
		if ( ma == 1 )
			cout << 1 << "\n";
		else
			cout << ma - 2 << "\n";
	}else{
		ll res = mi * ma - 2 * ma - 2 * (mi-2);
		res = res > 0 ? res : 0;
		cout << res << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] t = new int[n];
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0 ; i < n ; i++) {
			t[i] = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		int nowT = 0;
		int X = 0;
		int Y = 0;
		for(int i = 0 ; i < n ; i++) {
			if(t[i] - nowT == Math.abs(x[i] - X) + Math.abs(y[i] - Y)) {
				nowT = t[i];
				X = x[i];
				Y = y[i];
			} else if(t[i] - nowT > Math.abs(x[i] - X) + Math.abs(y[i] - Y) && nowT % 2 == (t[i] - nowT) % 2) {
				nowT = t[i];
				X = x[i];
				Y = y[i];
			} else {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 90940
import Control.Monad
import Control.Monad.ST
import Data.List
import Data.Array.ST
import Data.Int

main = do
  [n, m] <- map read . words <$> getLine :: IO [Int]
  [x, y, z] <- transpose <$> replicateM n (map read . words <$> getLine) :: IO [[Int64]]
  print $ solve x y z m

inf :: Int64
inf = -10^18

solve :: [Int64] -> [Int64] -> [Int64] -> Int -> Int64
solve a b c m = maximum [maxsum (map (*i) a) (map (*j) b) (map (*k) c) m | i <- [-1, 1], j <- [-1, 1], k <- [-1, 1]]

maxsum :: [Int64] -> [Int64] -> [Int64] -> Int -> Int64
maxsum a b c m = runST $ do
  dp <- newArray (0, m) inf :: ST s (STUArray s Int Int64)
  writeArray dp 0 0
  forM_ (zip3 a b c) $ \(a, b, c) -> do
    forM_ [m, m - 1 .. 1] $ \i -> do
      max <$> readArray dp i <*> ((+) (a + b + c) <$> readArray dp (i - 1)) >>= writeArray dp i
  readArray dp m




Measured memory_bytes: 4092
import sys
from itertools import product


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    s = input().strip().decode()
    ans = 0
    for p in product(range(10), repeat=3):
        pointer = 0
        for c in map(str, p):
            while pointer < n:
                if s[pointer] == c:
                    pointer += 1
                    break
                pointer += 1
            else:
                break
        else:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68188
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
// cond: a>b
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll gcd2(ll a,ll b){
  return a>b ? gcd(a,b) : gcd(b,a);
}

int main()
{
  int n;
  cin>>n;
  vecint a(n);
  REP(i,n) cin>>a[i];
  vecint f(n), b(n);
  f[0] = a[0];
  FOR(i,1,n) {
    f[i] = gcd(f[i-1], a[i]);
  }
  b[n-1] = a[n-1];
  for(int i=n-2; i>=0; --i) {
    b[i] = gcd(b[i+1], a[i]);
  }
  int mx = max(b[1], f[n-2]);
  FOR(i,1,n-1) {
    int res = gcd(f[i-1], b[i+1]);
    mx = max(mx, res);
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>

int main(void){
    //input
    int A;
    scanf("%d", &A);
    int B;
    scanf("%d", &B);

    //calcu
    // int Ans=0;
    // Ans = B / A + 1;

    // if(1<=B && B<=A)
    // Ans = 1;
    int Ans=0;
    int Out=1;  //挿し込み口の数
    while(Out < B){
        Out -= 1;
        Out += A;
        Ans += 1;
    }

    //output
    printf("%d\n",Ans);
    return 0;    
}


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int MOD = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int ta = c/b+((c%b)>0);
        int tb = a/d+((a%d)>0);
        cout<<((ta>tb)?"No":"Yes")<<endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10
using namespace std;
int main(){
	string s1,s2;
	cin >> s1 >> s2;
	int ans=0;
	for(int i=0;i<s1.size();i++){
		if(s1[i]==s2[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	int coin[]={500,100,50,10,5,1};
	cin>>a;
	while(a!=0){
		a=1000-a;
		int total=0;
		int sheet=0;
		for(int i=0;i<6;i++){
			sheet=a/coin[i];
			a=a%coin[i];
			total+=sheet;
		}
		cout<<total<<endl;
		cin>>a;
	}
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int a,b;
    cin >> a >> b;
    if((a+b)%2 == 1){
        cout << (a+b)/2+1 << endl;
    }
    else{
        cout << (a+b)/2 << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1<<29;
/****** define constant end ********/
// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extGCD(b, a % b, y, x); // 再帰的に解く
  y -= a / b * x;
  return d;
}
// 負の数にも対応した % 演算
long long modmi(long long val, long long m) {
  long long res = val % m;
  if (res < 0)
    res += m;
  return res;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

/****** define variable start ******/
ll n, a, b;
/******* define variable end *******/
ll solve(){
    cin >> n >> a >> b;
    ll ans = 0;

    ans += modpow(2, n, MOD);
    ans = modmi(ans - 1, MOD);
    // cout << ans << endl;
    ll ac = 1;
    for(ll i = 0; i < a; i++){
        ac *= (n-i);
        ac %= MOD;
    }
    for(ll i = 0; i < a; i++){
        ac *= modinv(a-i, MOD);
        ac %= MOD;
    }
    ll bc = 1;
    for (ll i = 0; i < b; i++) {
      bc *= (n - i) % MOD;
      bc %= MOD;
    }
    for (ll i = 0; i < b; i++) {
      bc *= modinv(b-i, MOD);
      bc %= MOD;
    }
    ans = modmi(ans - ac - bc, MOD);
    cout << ans << endl;
    // cout << ans << endl;


    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    
    return (int)end_solve;
}


Measured memory_bytes: 384
/*
    author: Salam_35
    Created at :

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)


const ll MOD = 1e9+7;

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
  ll n,k;
  cin >> n ;
  ll ans=10000000000;
  ll arr[n+10];
  ll m=-1;
  int p=0;
  for(int i=1;i<=n;i++){
    cin >> arr[i];
    m=max(m,arr[i]);
  }
  for(int i=1;i<=m;i++){
      ll t=0;
    for(int j=1;j<=n;j++){
    t+=((arr[j]-i)*(arr[j]-i));
  }
  //cout<<"t for "<<i<<" is "<<t<<endl;
  ans=min(ans,t);
  }

  cout<<ans<<endl;


}






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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  string n;
  int k;
  cin >> n >> k;
  int leng = n.size();
  
  vector<vector<int>> dp0(101, vector<int>(101, 0));
  vector<vector<int>> dp1(101, vector<int>(101, 0));

  // initialize
  for(int j = 0; j <= k; j++){
    dp0[0][j] = 0;
    dp1[0][j] = 0;
  }
  dp0[1][0] = 1;
  dp0[1][1] = n[0] - '0' - 1;
  dp1[1][0] = 0;
  dp1[1][1] = 1;
  for(int j = 2; j <= k; j++){
    dp0[1][j] = 0;
    dp1[1][j] = 0;
  }

  for(int i = 2; i <= leng; i++){
    for(int j = 0; j <= k; j++){
      if(j == 0){
        dp0[i][j] = dp0[i-1][j] * 1;
        if(n[i-1]-'0' != 0) dp1[i][j] = 0;
        else dp1[i][j] = dp1[i][j-1];
      }else{
        dp0[i][j] = dp0[i-1][j-1]*9 + dp0[i-1][j];
        if(n[i-1]-'0' > 1) dp0[i][j] += dp1[i-1][j-1] * (n[i-1]-'0' - 1) + dp1[i-1][j];
        else if(n[i-1] - '0' == 1) dp0[i][j] += dp1[i-1][j];
        if(n[i-1]-'0' != 0) dp1[i][j] = dp1[i-1][j-1];
        else dp1[i][j] = dp1[i-1][j];
      }
    }
  }

  cout << dp0[leng][k] + dp1[leng][k] << endl;

  return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int a[5], b[5];

    int n[5] = {0};

    REP(i, 3)
    {
        cin >> a[i] >> b[i];
        n[a[i] - 1]++;
        n[b[i] - 1]++;
    }

    sort(n, n + 4);

    if (n[0] == 1 && n[1] == 1 && n[2] == 2 && n[3] == 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const int MAXN = 1e5 + 120;

int n, k;
int h[MAXN], dp[MAXN];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> k;
  fill(dp, dp + n + k, INF);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j - 1 < k; ++j) {
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}



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

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

int main() {
  ll n, m;
  cin >> n >> m;
  ll ac=0, wa=0;
  vector<ll> p(m);
  vector<string> s(m);
  rep(i, m) cin >> p[i] >> s[i];
  map<ll, int> wa_mp, ac_mp;
  rep(i, m) {
    if (s[i].compare("WA")== 0) wa_mp[p[i]]++;
    else {
      if (ac_mp[p[i]] == 0) { 
        wa += wa_mp[p[i]];
        ac++;
        ac_mp[p[i]]++;
      }
    }
  }
  cout << ac << " " << wa << endl;
  return 0;
}

Measured memory_bytes: 18944
Imports System

Module Program
	Sub Main()
		Dim msg1, msg2 As String
		Dim s As String
		s = Console.ReadLine()

		msg1 = s.Substring(0, 4)
		msg2 = s.Substring(4, 8)

		Console.WriteLine(msg1 + " " + msg2)
	End Sub
End Module


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#define INF 10e10

using namespace std;

//  #define y cout << "yes"<< endl
  #define Y cout << "YES" << endl
  #define y cout << "Yes" << endl
//  #define n cout << "no"<< endl
  #define N cout << "NO" << endl
  #define n cout << "No" << endl
void put(string z){cout << z ;}
  
  
	int a,b,c,d,e,f,g,h,ans,res;
//	char a,b,c,d,e,f,g,h,ans,res;
//	string a,b,c,d,e,f,g,h,ans,res;
//	double a,b,c,d,e,f,g,h,ans,res;
	
void take(int x);
  
int main(void){
	take(1);//数
	
	
	
	if(a==3 || a==5){
		
		
	//	y();	//Yes
		Y;	//YES
	//	n();	//No
	//	N();	//NO
	}
	
	else if(a==7){
		
		
	//	y();
		Y;
	//	n();
	//	N();
		
	}/*
	else if(){
		
		
	//	y();
	//	Y();
	//	n();
	//	N();
		
	}
	else if(){
		
		
	//	y();
	//	Y();
	//	n();
	//	N();
		
	}
	*/
	else{
		
		
	//	y();
	//	Y();
	//	n();
		N;
		
	}
//	cout << ans << endl;
	
	return 0;
}
void take(int x){
	if(x==1)
		cin >> a;
	else if(x==2)
		cin >> a >> b;
	else if(x==3)
		cin >> a >> b >> c;
	else if(x==4)
		cin >> a >> b >> c >> d;
	else if(x==5)
		cin >> a >> b >> c >> d >> e;
	else if(x==6)
		cin >> a >> b >> c >> d >> e >> f;
	else if(x==7)
		cin >> a >> b >> c >> d >> e >> f >> g;
	else if(x==8)
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
	return ;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;

LL n,m,k;
LL a[500005];

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	cout << (n - 1) / m + 1 << endl; 
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int a, b;
    cin >> a >> b;

    cout << max(a + b, max(a - b, a * b)) << endl;

    return 0;
}


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

int main() {
  int N,Y;
  cin>>N>>Y;
  int x,y,z;
  
  bool flag=false;
  int sum=0;
  for(int x=0;x<=2000;x++){
    for(int y=0;y<=2000;y++){
      z=N-x-y;
      sum=10000*x+5000*y+1000*z;
      if(sum==Y && z>=0){
        flag=true;
        printf("%d %d %d",x,y,z);
        return 0;
      }
    }
  }
  
  if(flag==false){
    x=-1;
    y=-1;
    z=-1;
    printf("%d %d %d",x,y,z);
  }

}

Measured memory_bytes: 256
def resolve():
    N, A, B = list(map(int, input().split(" ")))
    res = 0
    for i in range(1, N+1):
        val = 0
        for s in str(i):
            val += int(s)
        if A <= val and val <= B:
            res += i
    print(res)


if '__main__' == __name__:
    resolve()

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

using namespace std;

#define N 100000

int a[N + 1];

int main(){
	int n, k, two, four, i;

	scanf("%d", &n);

	two = four = 0;

	for (i = 1; i <= n; i++){
		scanf("%d", a + i);

		if (a[i] % 4 == 0){
			four++;
		}
		else if (a[i] % 2 == 0){
			two++;
		}
	}

	k = n - 1;
	k -= 2 * four;

	if (two){
		k -= two - 1;
	}

	printf("%s\n", k <= 0 ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 640
#include<iostream>

int main(void){
	int a,b,c,n,i;
	std::cin>>n;
	for(i=0;i<n;i++){
		std::cin>>a;
		std::cin>>b;
		std::cin>>c;
		if(a*a==b*b+c*c)std::cout<<"YES"<<std::endl;
		else if(b*b==a*a+c*c)std::cout<<"YES"<<std::endl;
		else if(c*c==a*a+b*b)std::cout<<"YES"<<std::endl;
		else std::cout<<"NO"<<std::endl;

		}

	return 0;
}

Measured memory_bytes: 1156
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;


int main() {

    int num;
    string word;
    cin>>num>>word;
    string pre("");

    int tt = 0;

    for(auto c : word){
        if(c == '(')
            tt++;
        else if(c == ')'){
            if(tt == 0){
                pre += '(';
            }
            else
                tt--;
        }
    }

    word = pre + word;
    while(tt--)
        word += ')';

    cout<<word<<endl;

    return 0;
}


Measured memory_bytes: 256
k, s = gets.split.map{|s|s.to_i}
ans = 0

(k+1).times do |x|
  sx = s - x
  (k+1).times do |y|
    z = sx - y
    if z > k or 0 > z
      next
    else
      ans += 1
    end
  end
end

puts ans

Measured memory_bytes: 1788
#include <stdio.h>
int main(void){
    long K = 0; long A = 0; long B = 0;
    scanf("%ld %ld %ld", &K, &A, &B);
    if(K <= A){
        printf("%ld\n", K+1);
    }else {
        if(B - A <= 2){
            printf("%ld\n", K+1);
        }else {
            long count = 0; long hit = 0;
            count = A; hit = A-1;
            K -= hit;
            if(K % 2 == 0){
                count += (K / 2) * (B - A);
            }else {
                count += (K / 2) * (B - A);
                count++;
            }
            printf("%ld\n", count);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int x, y;
  cin >> x >> y;
  for(int i = 0; i < 200; i++){
    int ii = i * 2;
    int j = x - i;
    if(j < 0) continue;
    int jj = j*4;
    if(ii + jj == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

long long gcd(long long a, long long b)
{
	if (b == 0) return a;
	else return gcd(b, a%b);
}

long long lcm(long long a, long long b)
{
	return a/gcd(a, b) * b;
}


int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll N; cin >> N;
	vector<ll> T(N); REP(i, N) cin >> T[i];

	ll res{T[0]};
	REP(i, N-1) res = lcm(res, T[i+1]);
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 3660
#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,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 25;
const ll INFL = 1223372036854775807;
const ll mod = 1000000007;





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

	VLL v(3 * n);
	REP(i, 3 * n)cin >> v[i];

	priority_queue<ll, vector<ll>, greater<ll>> a;
	priority_queue<ll> b;

	ll c = 0, d = 0;

	REP(i, n) {
		a.push(v[i]);
		c += v[i];
		b.push(v[3 * n - 1 - i]);
		d += v[3 * n - 1 - i];
	}

	VLL e(n + 1), f(n + 1);

	e[0] = c;
	f[0] = d;

	REP(i, n) {
		a.push(v[i + n]);
		c += v[i + n];
		c -= a.top();
		a.pop();
		e[i + 1] = c;
		b.push(v[2 * n - 1 - i]);
		d += v[2 * n - 1 - i];
		d -= b.top();
		b.pop();
		f[i + 1] = d;
	}

	ll ans = -INFL;

	REP(i, n + 1) {
		ans = max(ans, e[i] - f[n - i]);
	}


	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 5996
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(){
    int n,a,b;cin >> n >> a >> b;
    cout << min(a*n,b)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define fr(i,n,m) for(ll i=n;i<m;i++)
int main()
{
    ll n,k;
    scanf("%lli%lli",&n,&k);
    double p[n],sum=0,max;
    fr(i,0,n) {
        scanf("%lf",&p[i]);
        p[i] = (1+p[i])/2;
    }
    fr(i,0,k) {
        sum += p[i];
    }
    double s[n-k+1];
    s[0] = sum;
    max = s[0];
    fr (i,1,n-k+1) {
        s[i] = sum-p[i-1]+p[i+k-1];
        sum = s[i];
        if (sum > max) {
            max = sum;
        }
    }
    printf("%lf",max);
    return 0;
}

Measured memory_bytes: 4836
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))



int main(){
	lli a,b;
	scanf("%lld%lld",&a,&b);
	lli s=b*1900+(a-b)*100;
	printf("%lld\n",s << b);
	return 0;
}



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

using namespace std;


#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;debug("%s: %.5lf s\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()/1000.0), blockTime.second = false)

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

string StrCpy(string str, long long int start, long long int end){string temp = "";for(long long int i=start; i<=end; i++){temp += str[i];}return temp;}

#define ull unsigned long long int
#define ll long long int
#define gcd(a, b)  __gcd(a, b)
#define lcm(a, b)  ((a*b)/gcd(a, b))



int solve(){

    string str;

    cin >> str;

    ll sum = 0;

    for(int i=0; i<str.length(); i++){

        sum = sum + (str[i] - '0');

    }

    if(sum%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;

}

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

    //freopen("english.txt","r",stdin);

    time__("programm time"){
        solve();
	}
    return 0;

}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(),(x).end()
#define lowbit(x) x&-x
#define pb push_back
#define ls (id<<1)
#define rs (id<<1|1)
#define Rint register int
#define UNI(x) sort(ALL(x)),x.resize(unique(ALL(x))-x.begin())
#define GETPOS(c,x) (lower_bound(ALL(c),x)-c.begin())
#define LEN(x) strlen(x)
#define MS0(x) memset((x),0,sizeof((x)))
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<pii> Vpii;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(ll &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const ll &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
const int MAXN=1e6+10,MAXM=4e6+10;
const int INF=INT_MAX,SINF=0x3f3f3f3f;
const ll llINF=LLONG_MAX;
const int MOD=1e9+7,mod=998244353;
const int inv2=5e8+4;
const int Lim=1<<20;


void solve()
{
    set<string>s;
    string tmp;
    int n;
    R(n);
    while(n--)
    {
        R(tmp);
        s.insert(tmp);
    }
    W(SZ(s));
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	int t=1;
	//R(t);
	while(t--)solve();
	return 0;
}


Measured memory_bytes: 19308
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int d = 0; d < D; d++) {
            cin >> X.at(i).at(d);
        }
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            double squared_sum = 0;
            for (int d = 0; d < D; d++) {
                squared_sum += pow((X.at(i).at(d) - X.at(j).at(d)), 2);
            }
            double distance = pow(squared_sum, 0.5);
            if (fmod(distance, 1) == 0) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 640
n, k = map(int, input().split())
a = list(map(int, input().split()))

if len(list(set(a))) <= k:
    print(0)
else:
    ans = 0
    cnt = [0] *(max(a) + 1)

    for i in range(n):
        cnt[a[i]] += 1
    cnt.sort(reverse=True)
    tmp = 0
    for c in cnt:
        ans += c
        tmp += 1
        if k == tmp:
            ans = n - ans
            print(ans)
            exit()


Measured memory_bytes: 27172
n,a,b=map(int,input().split())
mod=10**9+7
ans=pow(2,n,mod)-1
cma=1
a,b=min(a,b),max(a,b)
for i in range(1,a+1):
  cma=cma*(n-i+1)*pow(i,mod-2,mod)%mod
ans-=cma
if a==b:
  print(ans);exit()
for i in range(a+1,b+1):
  cma=cma*(n-i+1)*pow(i,mod-2,mod)%mod
print((ans-cma)%mod)

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

const int M = 2010;
const int N = M * M;
const int moder = 1e9 + 7;

int powermod(int a, int exp){
	int ret = 1;
	for ( ; exp > 0; exp >>= 1){
		if (exp & 1){
			ret = 1ll * ret * a % moder;
		}
		a = 1ll * a * a % moder;
	}
	return ret;
}

int fac[N], inv[N];
int dp[M][M];

int comb(int n, int m){
	if (n < m || m < 0) return 0;
	return 1ll * fac[n] * inv[m] % moder * inv[n - m] % moder;
}

int main(){
	fac[0] = 1;
	for (int i = 1; i < N; ++ i){
		fac[i] = 1ll * fac[i - 1] * i % moder;
	}
	inv[N - 1] = powermod(fac[N - 1], moder - 2);
	for (int i = N - 1; i; -- i){
		inv[i - 1] = 1ll * inv[i] * i % moder;
	}
	int n, k;
	scanf("%d%d", &n, &k);
	if (k == 1){
		puts("1");
		return 0;
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++ i){
		dp[i][0] = 1ll * dp[i - 1][0] * comb(i * (k - 1) - 1, k - 2) % moder;
		for (int j = 1; j <= i; ++ j){
			if (j < i){
				dp[i][j] = 1ll * dp[i - 1][j] * comb(j + i * (k - 1) - 1, k - 2) % moder;
			}
			dp[i][j] += dp[i][j - 1];
			dp[i][j] -= dp[i][j] >= moder ? moder : 0;
		}
	}
	printf("%lld\n", 1ll * fac[n] * dp[n][n] % moder);
	return 0;
}

Measured memory_bytes: 46720
package main

import (
	"fmt"
)

func main() {
	var h int
	fmt.Scanf("%d", &h)
	fmt.Printf("%d\n", count(h))
}

func count(h int) int {
	if h == 1 {
		return 1
	}
	return 2*count(h/2) + 1
}


Measured memory_bytes: 512
import itertools

def test():
    a = 0
    b = 0
    c = 0
    n,k = map(int,input().split())
    if k % 2 == 0:
        for i in range(1,n+1):
            if i % k == 0:
                a += 1
            elif i % k == k//2:
                b += 1
    else:
        for i in range(1,n+1):
            if i % k == 0:
                c += 1
    print(a**3+b**3+c**3)


if __name__ == "__main__":
    test()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int M;
  cin >> N;
  M = 0;
  if(N % 2 == 0){
    M = N/2 -1;
  }
  else{
    M = (N-1) / 2;
  }
  cout << M <<'\n';
}

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

typedef long long ll;

int main(){
  ll A, B, K; cin >> A >> B >> K;
  ll x = A;
  A = max(A - K, 0LL);
  K = max(K - x, 0LL);
  B = max(B - K, 0LL);
  
  cout << A << ' ' << B << 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>;

const int INF = 1001001001;

int main() {
  int n, m, a[100];
  cin>>n>>m;

  int sum = 0;

  rep(i,n) {
    cin>>a[i];
    sum += a[i];
  }

  sort(a, a+n, greater<>());

  rep(i,m){
    if(4*m*a[i] >= sum){
    }else {
      cout<<"No"<<endl;
      exit(0);
    }
  }

  cout<<"Yes"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int LeastHeight(double v) {
  double y;
  int N;
  y = v * v / 19.6;
  N = int((y + 5) / 5 + 1);
  return N;
}

int main() {
  double v;
  while(cin >> v) {
	cout << LeastHeight(v) << endl;
  }
  //data();
  return 0;
}


/*-- check --*/
void data() {
  double v, y, t;
  int N;

  printf("t\tv\ty\tN\n");
  for(t = 1; t <=10; t += 0.5) {
	v = 9.8 * t;
	y = v * v / 19.6;
	N = int((y + 5) / 5 + 1);
	printf("%.1f\t%.2f\t%.2f\t%d\n", t, v, y, N);
  }
}

Measured memory_bytes: 3148
n, m = STDIN.gets.split(" ").map(&:to_i)

cities = Array.new(n) do [] end
pys = []
for i in 0...m
  p, y = STDIN.gets.split(" ").map(&:to_i)
  p -= 1
  pys << [p,y]
  cities[p] << y
end

cities = cities.map{|years|
  Hash[years.sort.each_with_index.to_a]
}

for p, y in pys
  puts("%06d%06d" % [p+1, cities[p][y]+1])
end


Measured memory_bytes: 52348
i=1
for i in range(9):
    i+=1
    print(f'1x{i}={1*i}')
for i in range(9):
    i+=1
    print(f'2x{i}={2*i}')
for i in range(9):
    i+=1
    print(f'3x{i}={3*i}')    
for i in range(9):
    i+=1
    print(f'4x{i}={4*i}')    
for i in range(9):
    i+=1
    print(f'5x{i}={5*i}')    
for i in range(9):
    i+=1
    print(f'6x{i}={6*i}')
for i in range(9):
    i+=1
    print(f'7x{i}={7*i}')
for i in range(9):
    i+=1
    print(f'8x{i}={8*i}')   
for i in range(9):
    i+=1
    print(f'9x{i}={9*i}')   


Measured memory_bytes: 5556
N = int(input())
pi = 0
for n in range(1, N+1):
  i = 0
  dn = n
  while dn % 2 == 0:
    i += 1
    dn = dn / 2
    if dn % 2 == 1:
      break
  
  if i >= pi:
    result = n
    pi = i
  else:
    pass
  

print(result)

Measured memory_bytes: 9176
from collections import Counter

N = int(input())
*A, = map(int, input().split())
MOD = 10**9 + 7
cnt = Counter(A)
if N % 2 == 0:
    for i in range(1, N+1, 2):
        if cnt[i] != 2:
            print(0)
            break
    else:
        print(pow(2, N//2, MOD))
else:
    if cnt[0] != 1:
        print(0)
    else:
        for i in range(2, N+1, 2):
            if cnt[i] != 2:
                print(0)
                break
        else:
            print(pow(2, N//2, MOD))

Measured memory_bytes: 14820
////**********CODED BY :- DURGESH KUMAR***************////
#include<bits/stdc++.h>
#define ff double
#define endl "\n"
#define M 1000000007
#define forever while(1)
#define ll long long
#define pb push_back
#define vi vector<int>
#define mii map<int,int>
#define pii pair<int,int>
#define test ll t;cin>>t;while(t--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
using namespace std;
int main()
{

string str;
cin>>str;
ll f=0;
for(int i=0;i<str.length();i++)
{
    if((i+1)%2==0&&str[i]=='R')
        f=1;
    if((i+1)%2!=0&&str[i]=='L')
        f=1;

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


Measured memory_bytes: 256
n=int(input())
s=input()
ans,p=0,0
for i in range(n-1):
    sets=list(set(s[:i+1]))
    if ans>p:
        p=ans
    ans=0
    for j in range(len(sets)):
        if sets[j] in s[i+1:]:
            ans+=1
        
print(p)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    int a=n;
    int b=0;
    while(n){
    b+=n%10;
    n/=10;
    }
    if(a%b==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        // 支払総額N円
        string input = Console.ReadLine();
        int payTotal = int.Parse(input);

        // 1円硬貨枚数A
        input = Console.ReadLine();
        int one = int.Parse(input);

        // 支払総額を500円で割った余りを計算
        if ( (payTotal % 500) <= one )
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            sum += a[i];
        }
        int[] dif = new int[n];
        for(int i = 0; i < n; i++){
            dif[i] = Math.abs(sum - a[i]*n);
            
        }
        int ans = 0;
        int min = dif[0];
        for(int i = 1; i < n; i++){
            if(min > dif[i]){
                ans = i;
                min = dif[i];
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

vvl dp(3010,vl(3010));
vvb seen(3010,vb(3010,false));

long dfs(vl &a, int i, int j, bool taro){
  if(seen[i][j]) return dp[i][j];
  seen[i][j] = true;
  if(i == j){
    if(taro) return dp[i][j] = a[i];
    else return dp[i][j] = -1*a[i];
  }
  if(taro){
    return dp[i][j] = max(dfs(a,i+1,j,!taro) + a[i], dfs(a,i,j-1,!taro) + a[j]);
  }else{
    return dp[i][j] = min(dfs(a,i+1,j,!taro) - a[i], dfs(a,i,j-1,!taro) - a[j]);
  }
}

int main(){
  int n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a[i];
  cout << dfs(a, 0, n-1, true) << endl;
}

Measured memory_bytes: 76024
# Your code here!

n,m = gets.chomp.split.map &:to_i
a =[]
n.times do
  a.push(gets.chomp.split.map &:to_i)
end
t = Array.new(2){Array.new(2){Array.new(2){Array.new(0)}}}
2.times do |i|
  2.times do |j|
    2.times do |k|
      a.each do |ar|
        st = (i == 0)? 1 : -1
        nd = (j == 0)? 1 : -1
        rd = (k == 0)? 1 : -1
        t[i][j][k].push(ar[0]*st+ar[1]*nd+ar[2]*rd)
      end
      t[i][j][k].sort!{|a,b|b<=>a}
    end
  end
end
ans = 0
2.times do |i|
  2.times do |j|
    2.times do |k|
      ans = [ans, t[i][j][k][0..(m-1)].inject(:+)].max
    end
  end
end

p (m==0)? 0 : ans

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

int main()
{
	string s;
	cin >> s;
	if (s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3))
		cout << "Bad" << endl;
	else
		cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)+1
k = 0
score= 0
countup = 0
countdown = 0
final = None
for i in range(N-1):
  if S[i] == "<":
    if final == ">":
      score += int(countdown*(countdown-1)/2)
      if countup <= countdown:
        score += countdown - countup
      countup = 0
    countdown = 0
    final = "<"
    countup += 1
    score += countup
  elif S[i] == ">":
    final = ">"
    countdown += 1
if final == ">":
  score += int(countdown*(countdown-1)/2)
  if countup <= countdown:
    score += countdown - countup
print(score)

Measured memory_bytes: 4120
#include <stdio.h>
#pragma warning(disable:4996)
int main(void) {
	int a[10000];
	int n;
	int i;
	long  min, max, sum;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	min = a[0];
	max = a[0];
	sum = a[0];
	for (i = 1; i < n; i++) {
		if (min > a[i]) {
			min = a[i];
	}
		if (max < a[i]) {
			max = a[i];
		}
		sum = sum + a[i];

	}
	printf("%d %d %ld\n", min, max, sum);

	return 0;

}

Measured memory_bytes: 1860
#include<bits/stdc++.h>
using namespace std;
int x;
int main()
{
    int counter=0;
    int n,k,a;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x;
    }

    while(1){
        n=n-k;
        if(n!=0)counter++;
        n++;
        if(n<k ){counter++;break;}
    }
    cout<<counter<<endl;
}


Measured memory_bytes: 256
a,b,c,d = map(int,input().split())

TH=a
TA=b
AH=c
AA=d

while(1):
  AH -= TA
  if(AH<=0):
    print("Yes")
    break
  TH -= AA
  if(TH<=0):
    print("No")
    break
  


Measured memory_bytes: 9172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        long N = GetInputLong();

        int[] B = GetInputsInt();

        long sum = 0;

        sum += B[B.Length - 1];
        for (int i = B.Length-1; i >0 ; i--)
        {
            sum += Math.Min(B[i], B[i - 1]);
        }
        sum += B[0];

        Console.WriteLine(sum);

        Console.ReadKey();
    }



    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static List<float> GetInputsFloatList()
    {
        return Console.ReadLine().Split(' ').Select(float.Parse).ToList();
    }

    public static long GetInputLong()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }

}


Measured memory_bytes: 13268
N,M=map(int,input().split())


numbers=[]

joken =[]

for _ in range(M):
    s,c = map(int,input().split())
    joken.append([s,c])

if N==1:
    start = 0
    end = 9
elif N==2:
    start =10
    end =99
else:
    start =100
    end =999

for i in range(start,end+1):
    
    i=str(i)

    flg =0
    for j in joken:
        if i[j[0]-1]!=str(j[1]):
            flg+=1

    if flg ==0:
        numbers.append(i)

if len(numbers)==0:
    print(-1)
else:
    print(min(numbers))



    


Measured memory_bytes: 3064
($a, $b) = split(' ',<>);
$max = $b + ($a - 1);
$min = $b - ($a - 1);
if($max > 1000000){$max = 1000000};
if($min < -1000000){$min = -1000000};
@array = ($min..$max);
print join(" ",@array);

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int m=0,c=0,i;
  char s[10];
  scanf("%s",s);
  for(i=0;i<3;i++){
    if(s[i]=='R')c++;
    else{
      if(m<c)m=c;
      c=0;
    }
  }
  if(m<c)m=c;
  printf("%d\n",m);
  return 0;
}


Measured memory_bytes: 1708
k=int(input())
from math import gcd
l=[0]*(k)
for i in range(1,k+1):
    for j in range(1,k+1):
        l[gcd(i,j)-1]+=1

ans=0
for i in range(1,k+1):
    for j in range(1,1+k):
        ans+=gcd(i,j)*l[i-1]
print(ans)


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

int main(){
    int n,d;
    cin>>n>>d;
    vector<vector<float>> t(n,vector<float>(d,0));
    for(int i = 0;i<n;++i){
        for(int j = 0;j<d;++j){
            cin>>t[i][j];
        }
    }
    int ans = 0,dist;
    for(int i = 0;i<n-1;++i){
        for(int j = i+1;j<n;++j){
            dist = 0;
            for(int k = 0;k<d;++k){
                dist += (t[i][k]-t[j][k])*(t[i][k]-t[j][k]);
            }
            if(dist == (int)sqrt(dist)*sqrt(dist)){
                ans++;
            }
        }   
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3736
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;

int n;
int a[111];

int main() {
	scanf("%d", &n);
	
	int s = 0;
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
		s += a[i];
	}
	
	int ans = s, cur = 0;
	for(int i=0;i<n;i++) {
		cur += a[i];
		ans = min(ans, (int)labs(s - cur*2));
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define poly vector<ll>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool d=1;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') d=0;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return d?x:-x;
}
inline void write(ll x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=3005,mo=1e9+7;
pii a[N];
int L[N],R[N],f[N][N],g[N],b[N],c[N][N];
char s[N];
int main(){
	// freopen("ssw.in","r",stdin);freopen("ssw.out","w",stdout);
	int len=read(),m=read(),n=0;
	scanf("%s",s+1);
	For(i,1,len) b[i]=b[i-1]+(s[i]=='1');
	c[0][0]=1;
	For(i,1,len){
		c[i][0]=1;
		For(j,1,i) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mo;
	}
	For(i,1,m) a[i].fi=read(),a[i].se=read();
	sort(a+1,a+m+1);int mx=0;
	For(i,1,m){
		if(i<m&&a[i].fi==a[i+1].fi&&a[i].se<a[i+1].se) continue;
		if(i&&a[i].se<=mx) continue;
		L[++n]=a[i].fi;R[n]=a[i].se;
		mx=max(mx,a[i].se);
	}
	L[n+1]=len+1;f[0][0]=1;
	int ans=1;
	For(i,1,n){
		memset(g,0,sizeof(g));
		if(L[i]>R[i-1]) g[b[R[i]]-b[L[i]-1]]=1;
		else{
			int x=b[R[i]]-b[R[i-1]];
			For(j,0,R[i-1]-L[i]+1) g[j+x]=(g[j+x]+f[i-1][j])%mo;
		}
		if(R[i]>=L[i+1]){
			For(j,0,R[i]-L[i+1]+1){
				For(k,0,L[i+1]-L[i]+1){
					int ksg=L[i+1]-L[i];
					int sana=(ll)g[j+k]*c[ksg][k]%mo;
					f[i][j]=(f[i][j]+sana)%mo;
				}
			}
		}else{
			int ssw=0,l=R[i]-L[i]+1;
			For(j,0,R[i]-L[i]+1) ssw=(ssw+(ll)c[l][j]*g[j])%mo;
			ans=(ll)ans*ssw%mo;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 36008