akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN = 200000;

int want;
char a[MAXLEN + 1]; int alen;
char b[MAXLEN + 1]; int blen;


char ret1[MAXLEN + 1];
char ret2[MAXLEN + 1];

// x*a+y*b=g
int egcd(int a, int b, int &x, int &y) {
	if (b == 0) { x = 1, y = 0; return a; }
	int g = egcd(b, a%b, y, x); y -= x*(a / b); return g;
}

void build(char *res, ll na, char *a, int alen, ll nb, char *b, int blen,int cmp) {
	if (cmp > 0) { swap(na, nb); swap(a, b); swap(alen, blen); cmp = -cmp; }
	REP(i, na) REP(j, alen) res[i*alen + j] = a[j];
	REP(i, nb) REP(j, blen) res[na*alen + i*blen + j] = b[j];
	res[na*alen + nb*blen] = '\0';
}

void run() {
	scanf("%d%s%s", &want, a, b); alen = strlen(a), blen = strlen(b);
	int gx, gy, g = egcd(alen, blen, gx, gy); // gx*alen+gy*blen=g
	assert(want%g == 0);
	ll x = (ll)gx*(want / g), y = (ll)gy*(want / g); // x*alen+y*blen=want
	ll period = (ll)alen*blen / g;
	if (x < 0) { int tmp = blen / g; ll t = (-x + tmp - 1) / tmp; x += t*tmp; y -= t*(alen / g); } // make x>=0
	if (y < 0) { int tmp = alen / g; ll t = (-y + tmp - 1) / tmp; y += t*tmp; x -= t*(blen / g); } // make y>=0
	assert(x >= 0 && y >= 0);

	int cmp = 0; // -1 -> ab<ba, +1 -> ab>ba
	REP(i, alen + blen) { char p = i < alen ? a[i] : b[i - alen], q = i < blen ? b[i] : a[i - blen]; if (p != q) { cmp = p < q ? -1 : +1; break; } }

	{ int tmp = blen / g; ll t = x / tmp; x -= t*tmp; y += t*(alen / g); } // minimize x (s.t. x>=0)
	build(ret1, x, a, alen, y, b, blen, cmp);
	{ int tmp = alen / g; ll t = y / tmp; y -= t*tmp; x += t*(blen / g); } // minimize y (s.t. y>=0)
	build(ret2, x, a, alen, y, b, blen, cmp);

	int retcmp = 0;
	REP(i, want) if (ret1[i] != ret2[i]) { retcmp = ret1[i] < ret2[i] ? -1 : +1; break; }
	printf("%s\n", retcmp <= 0 ? ret1 : ret2);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
template <typename X>
struct DST
{
  int n;
  vector<X> dat,delay;
  X init;

  DST(int _n)
  {
    n = 1;
    while(n < _n) n *= 2;
    dat.assign(2*n-1,0);
    delay.assign(2*n-1,0);
  }

  void eval(int k,int l,int r)
  {
    if(delay[k] != 0){
      dat[k] += delay[k];
      if(k < n-1){
	delay[2*k+1] += delay[k]/2;
	delay[2*k+2] += delay[k]/2;
      }
      delay[k] = 0;
    }
  }
  
  void update(int a,int b,X x,int k,int l,int r)
  {
    eval(k,l,r);
    
    if(r<=a||b<=l) return ;
    
    if(a<=l&&r<=b){
      delay[k] += (r-l)*x;
      eval(k,l,r);
    }
    else{
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      dat[k] = dat[2*k+1] + dat[2*k+2];
    }
  }

  X query(int a,int b,int k,int l,int r)
  {
    eval(k,l,r);
    
    if(r<=a||b<=l) return 0;

    if(a<=l&&r<=b) return dat[k];    
    else{
      X vl = query(a,b,2*k+1,l,(l+r)/2);
      X vr = query(a,b,2*k+2,(l+r)/2,r);
      return vl + vr;
    }
  }
};
int _n,q;
vector<int> com,s,t;
vector<ll> x;
int main()
{
  cin >> _n >> q;
  s.resize(q);
  t.resize(q);
  x.resize(q);
  com.resize(q);  
  rep(i,q){
    cin >> com[i] >> s[i] >> t[i];
    if(com[i]==0) cin >> x[i]; 
  }

  DST<ll> dst(_n);
  
  rep(i,q){
    if(com[i]==1){
      cout << dst.query(s[i]-1,t[i],0,0,dst.n) << "\n";
    }
    else{
      dst.update(s[i]-1,t[i],x[i],0,0,dst.n);
    }    
  }
  
  return 0;
}



Measured memory_bytes: 8932
#include <iostream>

int main() {
    int a, b;   std::cin >> a >> b;
    int ret = 0;
    for (int i = a; i <= b; i++) {
        int l = i / 1000;
        int r = i % 100;

        int ll = l / 10;
        int lr = l % 10;
        
        int rl = r / 10;
        int rr = r % 10;

        if (lr == rl && ll == rr)   ret++;
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = []
for i in range(n):
	a, b = map(int, input().split())
	l.append((a,b))
l.sort(key = lambda x: x[1])
accm = 0
f = 1
for i in range(n):
    accm += l[i][0]
    if accm > l[i][1]:
        f=0
        break
if f: print("Yes")
else: print("No")

Measured memory_bytes: 75096
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >>N>>M;
  vector<vector<int>>data(M,vector<int>(2));
  for(int i=0;i<M;i++){
    for(int j=0;j<2;j++){
      cin>> data.at(i).at(j);
    }
  }
  
  int count=0;
  int big=data.at(0).at(0) ,small=data.at(0).at(1);
  for(int k=0;k<M;k++){
    if(big<data.at(k).at(0)){
      big=data.at(k).at(0);
    }
    if(small>data.at(k).at(1)){
      small=data.at(k).at(1);
    }
    if(k==M-1){
      if(big>small){
        cout<<0<<endl;
      }
      else{
        count=small-big+1;
        cout<<count<<endl;
      }
    }
  }
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<"\n";
#define lli long long int
long long int mod= 1000000007,modd=998244353;
int32_t main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);  cout.tie(0);
   lli len,i,c=0;
   string s,t;
   cin>>s>>t;
   len=s.length();
   for(i=0;i<len;i++)
   {
       if(s[i]!=t[i])c++;
   }
   cout<<c<<"\n";
   return 0;
}//main


Measured memory_bytes: 3792
#include<stdbool.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<set>
typedef long long ll;
using namespace std;

int main(void) {
	int n;
	cin >> n;
	cout << 800 * n - 200 * (n / 15) << endl;
	/*ll n, m, ans = 0;
	cin >> n >> m;
	if (n == m) {
		if (n == 1) {
			cout << ans << endl;
		}
		else {
			while (m >= 2) {
				ans++;
				m -= 2;
			}
			cout << ans << endl;
		}
	}
	else {
		if (n > m) {
			if (m == 1) {
				cout << ans << endl;
			}
			else {
				while (m >= 2) {
					ans++;
					m -= 2;
				}
				cout << ans << endl;
			}
		}
		else {
			while (true) {
				n--;
				m -= 2;
				ans++;
				if (m < 2) {
					cout << ans << endl;
					return 0;
				}
				if (n == 0)break;
			}
			while (m >= 4) {
				m -= 4;
				ans++;
			}
			cout << ans << endl;
		}
	}*/
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<string.h>
using namespace std;
char str[100];int a[100],N,len;
int main(){
	scanf("%s",str);
	N=strlen(str);
	for(int i=0;i<N;i++){
		if(str[i]=='0'){
			len++;
			a[len]=0;
		}
		if(str[i]=='1'){
			len++;
			a[len]=1;
		}
		if(str[i]=='B'){
			if(len>0) len--;
		}
	}
	for(int i=1;i<=len;i++){
		printf("%d",a[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ll n;cin>>n;
    ll ans=1e12;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0)ans=min(ans,i-1+n/i-1);
    }
    cout<<ans;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

const long long MAXN = (1e5+10);
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

int a_place[MAXN];

constexpr int power(int b, int i){
  if (i == 1) return b % MOD;
  if (i % 2 == 0) {
    return power(b*b % MOD, i/2) ;
  } else {
    return power(b*b % MOD, i/2)*b % MOD ;
  }
}

constexpr int fact(int n){
  if (n == 0 ) return 1;
  return (n * (fact(n-1))) % MOD;
}

constexpr int invMod(int n){
  return power(n,MOD - 2);
}


template<int N>
struct Facts {
    constexpr Facts() : arr() {
        for (auto i = 0; i != N; ++i){
            arr[i] = fact(i); 
        }
    }
    int arr[N];
};

constexpr auto facts = Facts<MAXN>();

template<int N>
struct InvMods {
    constexpr InvMods() : arr() {
        for (auto i = 0; i != N; ++i){
            arr[i] = invMod(facts.arr[i]); 
        }
    }
    int arr[N];
};

//constexpr auto invmods = InvMods<100>();

int combination(int m, int n){
  if(m<0 || n < 0 || m < n) return 0;
  return ((((facts.arr[m])*invMod(facts.arr[n])) % MOD) * invMod(facts.arr[m-n])) % MOD;
}

signed main(){
    int n;

    cin >> n;
    int same_smaller;
    int same_bigger;

    for(int i=1;i<=n+1;i++) a_place[i]=-1;
    for (int i = 1; i <= n+1; i++){
      int a;
      cin >> a;
      if(a_place[a]!=-1){
        same_smaller=min(a_place[a],i);
        same_bigger=max(a_place[a],i);
        break;
      }else{
        a_place[a]=i;
      }
    }

    int n1 = same_smaller - 1;
    int n2 = n - same_bigger + 1;

  for(int k=1;k<=n+1;k++){
    auto ans = combination(n+1,k) - combination(n1+n2,k-1);
    cout << (ans < 0 ? ans + MOD : ans) << endl;
  }
   return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#define ll long long
using namespace std;

int main(){
 //cout<<123<<endl;
  int N,M;cin>>N>>M;
  
  vector <int> X(0);
  for(int i=0;i<M;i++){
    int a;cin>>a;
    X.push_back(a);
  }
  if(N>=M) {cout<<0<<endl; return 0;}
  sort(X.begin(), X.end());
  reverse(X.begin(), X.end());
  
  vector <int> Y(0);
  ll sum=0;
  ll cutsum=0;
  for(int i=0;i<M-1;i++){
    int d = abs(X[i+1]-X[i]);
    Y.push_back(d);
    sum+=d;
  }
  
  sort(Y.begin(), Y.end());
  reverse(Y.begin(), Y.end());
  for(int i=0;i<N-1;i++){
    cutsum+=Y[i];
  }
  
  cout<<sum-cutsum<<endl;
  return 0;
}


Measured memory_bytes: 1400
import java.util.*
import kotlin.math.*

fun main() {
    val mod = 998244353L

    val (n, k) = readIntList()
    val range = List(k) { readIntList() }

    val dp = LongArray(n + 1)
    val dpSum = LongArray(n + 1)
    dp[1] = 1L
    dpSum[1] = 1L

    for (i in 2..n) {
        for ((l, r) in range) {
            val li = max(i - r, 1)
            val ri = i - l
            if (ri < 0) continue
            dp[i] = (dp[i] + dpSum[ri] - dpSum[li - 1] + mod) % mod
        }
        dpSum[i] = (dpSum[i - 1] + dp[i]) % mod
    }
    println(dp[n])
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 48372
#include <iostream>
#include <numeric>
#include <vector>

using lint = long long;

void solve() {
    int k, q;
    std::cin >> k >> q;

    std::vector<lint> ds(k);
    for (auto& d : ds) std::cin >> d;

    while (q--) {
        lint n, x, m;
        std::cin >> n >> x >> m;
        int nn = n;
        --nn;

        x %= m;
        auto xs = ds;
        for (auto& y : xs) {
            y %= m;
            if (y == 0) y = m;
        }

        lint sum = std::accumulate(xs.begin(), xs.end(), 0LL);
        x += sum * (nn / k);
        nn %= k;
        for (int i = 0; i < nn; ++i) x += xs[i];

        std::cout << n - 1 - x / m << std::endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 384
<?php
# 入力部
fscanf(STDIN, "%s", $n);
// fscanf(STDIN, "%d %d", $s, $w);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $n);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%s", $s2);

# 処理部
// $arr1 = str_split($s1);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// for ($i = $a; $i <= $b; $i++) {
//   if ($i % $k == 0) {
//     $r = "OK";
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }
$r = "No";
if (strpos($n, "7") !== false) {
  $r = "Yes";
}

# 出力部
echo $r . "\n";
// echo ($i * 1000) - $n . "\n";

Measured memory_bytes: 15928
#include <bits/stdc++.h>
#define int long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MAX 1e15+1
const int N = 1e9+7;
#define pi  pair<int,int>

int dp[1001][1001];
 
signed main(){
	fast;

	int n,m;
	cin>>n>>m;
	string s[1001];
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	//cout<<s[0][2];
	dp[0][1]=1;

	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1][j-1]!='#'){
				
				dp[i][j]=(dp[i-1][j]%N+dp[i][j-1]%N)%N;
			}
			
		}
	}
	cout<<dp[n][m];
}

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

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    int N;
    cin>>N;
    V<int> A(N);
    map<int, ll>cnt;
    for (int i = 0; i < N; ++i) {
        cin>>A[i];
        cnt[A[i]]++;
    }
    ll sum = 0LL;
    for(auto c : cnt){
        ll cnum = c.second;
        sum += cnum*(cnum-1)/2;
    }

    for(int i=0;i<N;i++){
        cout<<sum-(cnt[A[i]]-1)<<endl;
    }

    return 0;
}

Measured memory_bytes: 11008
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;


ll N;
ll k;
ll start[100010];
int main() {
    cin>>N;
    ll po=0;
    bool f=false;
    ll cnt=0;
    REP(i,1,N+1){
        po+=i;
        if(po==N){
            f=true;
            k=i;
            break;
        }
    }
    if(N==1){
        p("Yes");
        cout<<2<<endl;
        cout<<"1 1"<<endl;
        cout<<"1 1"<<endl;
    }else if(f){
        p("Yes");
        cout<<k+1<<endl;
        start[0]=1;
        REP(i,1,k+2){
            start[i]=start[i-1]+k-i+1;
        }
        REP(i,0,k+1){
            cout<<k;
            REP(j,0,i){
                cout<<" "<<start[j]+(i-j)-1;
            }
            REP(j,0,k-i){
                cout<<" "<<start[i]+j;
            }
            cout<<endl;
        }


    }else{
        p("No");
    }
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, x[555], ans[255555];
    memset(ans, 0, sizeof(ans));
    
    cin >> n;
    rep(i, 1, n){
    	cin >> x[i];
    	ans[x[i]] = i;
    }
    
    vector<P> arg;
    rep(i, 1, n){
    	arg.push_back(P(x[i], i));
    }
    sort(arg.begin(), arg.end());
    
    queue<ll> q;
    zep(i, 0, n){
    	rep(j, 1, arg[i].second-1){
    		q.push(arg[i].second);
    	}
    }
    ll z = q.size();
    //printa(ans, 1, n*n)
    
    bool use[n+1]; memset(use, 0, sizeof(use));
    bool ok = true;
    rep(i, 1, n*n){
    	if(ans[i]){
    		use[ans[i]] = true;
    		rep(j, 1, n-ans[i]){
    			q.push(ans[i]);
    		}
    	}
    	else{
    		if(q.empty()){
    			ok = false;
    		}
    		else{
	    		ll x = q.front(); q.pop();
	    		z--;
	    		if(z > 0 && use[x]){
	    			ok = false;
	    		}
	    		ans[i] = x;
    		}
    	}
    }
    
    if(ok){
    	print("Yes")
    	printa(ans, 1, n*n)
    }
    else{
    	print("No")
    }
    return 0;
}

Measured memory_bytes: 4736
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    ll n; cin >> n;
    ll ans = 0;
    for(ll i=1;i<=n;i++) {
        ans += i*(i+1)/2;
    }
    for(ll i=1; i<=n-1; i++) {
        ll u,v; cin >> u >> v;
        ans -= min(u,v) * (n-max(u,v)+1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

s = STR()
if len(s) < 26:
    for i in range(26):
        tmp = chr(i + ord('a'))
        if not tmp in s:
            print(s + tmp)
            exit()
else:
    for i in reversed(range(26)):
        for j in range(ord(s[i]) + 1, ord('z') + 1):
            if not chr(j) in s[:i]:
                print(s[:i] + chr(j))
                exit()
    print(-1)
    exit()

Measured memory_bytes: 59628
#include<iostream>
#include<vector>
#include<set>
using namespace std;
int main(){
	int n,p,nn[1001]={0},m=0;
	long long res=1;
	cin>>n;
	for(int i=2;i<=n;i++){
		p=1;
		for(int j=2;j<i;j++){
			if(i%j==0){
//				cout<<"qq"<<endl;
				p=0;
				break;
			}
		}
		if(p==1){
//			cout<<"pp"<<i<<endl;
			for(int k=1;k<=n;k++){
				int l=k;
//				cout<<"#"<<l<<endl;
				while(l%i==0){
					l/=i;
					nn[i]++;
				}
			}
		}
	}
	for(int i=0;i<1000;i++){
		if(nn[i]!=0){
//			cout<<i<<"! !"<<nn[i]<<"! !"<<res<<endl;
		}
		nn[i]++;
		res*=nn[i];
		res=res%1000000007;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         long N=gl();
         

         System.out.println(((N-1) * N)/2);
     }

     public static class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> implements Comparable<Pair<K, V>> {
    		/** serialVersionUID. */
    	    private static final long serialVersionUID = 6411527075103472113L;

    	    public Pair(final K key, final V value) {
    	        super(key, value);
    	    }

    		@Override
    		public int compareTo(Pair<K, V> o) {

    			Comparable key = (Comparable)this.getKey();
    			Comparable key2 = (Comparable)o.getKey();

    			return key.compareTo(key2);
    		}

    	}

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 35664
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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 d = sc.nextInt();
        int e = sc.nextInt();
        int f = sc.nextInt();
        Set<Integer> wSet = new HashSet<>();
        Set<Integer> sSet = new HashSet<>();
        for (int i = 0 ; i <= 30/a ; i++) {
            for (int j = 0; j <= 30/b; j++) {
                int w = 100 * a * i + 100 * b * j;
                wSet.add(w);
            }
        }
        for (int i = 0 ; i <= f / c ; i++) {
            for (int j = 0 ; j <= f / d ; j++) {
                int s = c * i + d * j;
                sSet.add(s);
            }
        }
        double maxConcentration = 0;
        int suger = 0;
        int water = 0;
        for (Integer w : wSet) {
            for (Integer s : sSet) {
                if (w + s <= f && w * e / 100 - s >= 0) {
                    double concentration = (double) s / (double) (w + s);
                    if (concentration >= maxConcentration) {
                        maxConcentration = concentration;
                        suger = s;
                        water = w;

                    }
                }
            }
        }
        System.out.println(water + suger + " " + suger);

    }

}

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

#define PI 3.14159265
int main()
{
 double  a,b,alpha,area,poridhi,h,c;
    scanf("%lf %lf %lf",&a,&b,&alpha);
    area=0.5*a*b*sin(alpha*PI/180);
    h=b*sin(alpha*PI/180);
    c=sqrt(a*a+b*b-2*a*b*cos(alpha*PI/180));
    poridhi=a+b+c;
    printf("%lf %lf %lf\n",area,poridhi,h);
    return 0;

}



Measured memory_bytes: 2088
#include <iostream>
#include <vector>

using namespace std;

class Solution {
private:
    int N, M, X;
    vector<int> costs;
    vector<vector<int>> arr;
public:
    void load() {
        cin >> N >> M >> X;
        costs.assign(N, 0);
        arr.resize(N);
        for (int i = 0; i < N; ++i) {
            arr[i].resize(M);
            cin >> costs[i];
            for (int j = 0; j < M; ++j) {
                cin >> arr[i][j];
            }
        }
    }

    void helper(int cur, vector<int> sofar, int cost, int *output) {
        int min_val = numeric_limits<int>::max();
        for (int i = 0; i < M; ++i) {
            min_val = min(min_val, sofar[i]);
        }
        if (min_val >= X) {
            *output = min(*output, cost);
            return;
        }
        if (cur >= N) {
            return;
        }
        helper(cur + 1, sofar, cost, output); // don't choose cur
        for (int i = 0; i < M; ++i) {
            sofar[i] += arr[cur][i];
        }
        helper(cur + 1, sofar, cost + costs[cur], output); // choose cur
    }

    void solve() {
        vector<int> sofar(M, 0);
        int output = numeric_limits<int>::max();
        helper(0, sofar, 0, &output);

        if (output ==  numeric_limits<int>::max()) {
            cout << -1 << endl;
        } else {
            cout << output << endl;
        }
    }
};

int main() {
    Solution sol;
    sol.load();
    sol.solve();
}


Measured memory_bytes: 3196
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int N=scanner.nextInt();
        for(int i=0;i<20;i++){
            if(N-(i*4)<0){
                break;
            }
            if((N-(i*4))%7==0){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");

    }
}


Measured memory_bytes: 23892
H,W,K=map(int,input().split())
G=[list(input()) for i in range(H)]
ans=0
cnt_bl=0
for i in range(H):
  for j in range(W):
    if G[i][j]=="#":
      cnt_bl+=1
cnt_bl-=K
if cnt_bl<0:
  print(0);exit()


for i in range(2**W):
  for j in range(2**H):
    res=0
    for x,k in enumerate(bin(i)[2:][::-1]):
      for y,l in enumerate(bin(j)[2:][::-1]):
        #print(G[y][x],k,l,y,x)
        if k=="1" and l=="1":
          if G[y][x]=="#":
            res-=1
    for x,k in enumerate(bin(i)[2:][::-1]):
      for y in range(H):
        #print(k)
        if k=="1" and G[y][x]=="#":
          #print(y,x,k)
          res+=1
    for y,l in enumerate(bin(j)[2:][::-1]):
      for x in range(W):
        if l=="1" and G[y][x]=="#":
          res+=1
    #print(bin(i)[2:],bin(j)[2:],res)
    if res==cnt_bl:
      ans+=1
print(ans)
        
    
  


Measured memory_bytes: 74904
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
const double Pi = acos(-1);
int n, l, T[3000];
int main()
{
	scanf("%d%d", &n, &l);
	for (int i = 0; i < n; i++)
		scanf("%d", &T[i]);
    double ansX = 0, ansY = 0;
    for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			int inter = j - i - 1;
			int outer = n - inter - 2;
			double theta = Pi * (T[i] + T[j]) / l;
			ansX += (outer - inter) * cos(theta);
			ansY += (outer - inter) * sin(theta);
		}
	}
	ll all = (ll)n * (n - 1) * (n - 2) / 6;
	ansX /= all, ansY /= all;
	printf("%.15lf %.15lf\n", ansX, ansY);
}


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

class Cake{
public:	
	int w,h;
	Cake(int a,int b):w(a),h(b){}
	Cake(){}

	bool operator < (const Cake& opp)const{
		return w*h<opp.w*opp.h;
	}
};

vector <Cake> c;

main(){
	int i,n,p,s,w,h;
	Cake t;
	while(cin>>n>>w>>h,w){
		c.clear();
		c.push_back(Cake(w,h));
		for(i=0;i<n;i++){
			cin >> p >> s;
			t = c[--p];
			c.erase(c.begin()+p);
			s %= t.w+t.h;
			if(s<t.w){
				if(t.w-s<s) s=t.w-s;
				c.push_back(Cake(s,t.h));
				c.push_back(Cake(t.w-s,t.h));
			}else{
				s -= t.w;
				if(t.h-s<s) s=t.h-s;
				c.push_back(Cake(t.w,s));
				c.push_back(Cake(t.w,t.h-s));
			}
		}
		sort(c.begin(), c.end());
		for(i=0;i<n;i++) cout << c[i].w*c[i].h << ' ';
		cout << c[i].w*c[i].h << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
	char room[4][3][10] = {};				//4棟*3階*10部屋の多次元配列
	int num = 0;							//処理回数
	int i = 0, j, k;
	int b, f, r, v;
	scanf("%d", &num);						//処理回数の確定
	getchar();								//改行コードの読み飛ばし
	do{
		scanf("%d%d%d%d", &b,&f,&r,&v);
		getchar();							//改行コードの読み飛ばし
		room[b - 1][f - 1][r - 1] += v;
		if (room[b - 1][f - 1][r - 1] > 9) { room[b - 1][f - 1][r - 1] = 9; }
		if (room[b - 1][f - 1][r - 1] < 0) { room[b - 1][f - 1][r - 1] = 0; }
		i++;
	} while (i != num);
	for (i = 0; i < 4; i++) {				//棟の回数ループ
		for (j = 0; j < 3; j++) {			//階の回数ループ
			for (k = 0; k < 10; k++) {		//部屋の回数ループ
				printf(" %d", room[i][j][k]);
			}
			printf("\n");
		}
		if (i < 3) { printf("####################\n"); }
	}
	return 0;
}


Measured memory_bytes: 2044
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);

            var menseki = a * b;
            var nagasa = 2 * (a + b);
            
            Console.WriteLine("{0} {1}", menseki, nagasa);
        }
    }
}



Measured memory_bytes: 15980
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null){
boolean[] cards=new boolean[11];
int count=0;
String[] values=line.split(" ");
int c1=Integer.parseInt(values[0]);
int c2=Integer.parseInt(values[1]);
int c3=Integer.parseInt(values[2]);
cards[c1]=cards[c2]=cards[c3]=true;
for(int i=1;i<=10;i++){
if(!cards[i]&&20-c1-c2>=i){
count++;
}
}
if(count>=4){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}
}
}

Measured memory_bytes: 16908
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


ll calc(ll x){
  if(x<0)return 0;
  x++;
  ll res = 0;
  rep(i,50){
    ll loop = 1LL<<(i+1);
    ll num = loop/2;
    ll cnt = num*(x/loop);
    cnt+=max(0LL,(x%loop)-(loop/2));
    if(cnt%2)res+=(1LL<<i);
  }
  return res;
}
int main() {
  ll a,b;
  cin>>a>>b;
  ll ans = calc(b)^calc(a-1);
  print(ans);
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  ll L[n];
  rep(i,n) cin >> L[i];
  int cnt = 0;
  rep(i,n-2){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]){
          ll x = L[i]+L[j];
          ll y = L[j]+L[k];
          ll z = L[k]+L[i];
          if(L[i]<y&&L[j]<z&&L[k]<x)cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MIN=1<<30;
int main(void){
    ll n,k,ans;
    cin>>n>>k;
    vector<ll> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    for(int i=0;i<n-k+1;i++){
        ans=s[i+k-1]-s[i];
        MIN=min(ans,MIN);
    }
    cout<<MIN<<endl;
    //cout<<(1<<30)<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;

ll MOD=1000000007;

int main(){
  ll N,K;
  cin >> N >> K;

  ll res=0;
  for(ll k=K;k<=N+1;k++){
    res+=k*(2*N-k+1)/2+1;
    res%=MOD;
    res-=k*(k-1)/2;
    res%=MOD;
  }

  cout << (res+MOD)%MOD << endl;
  
  return 0;
}


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

void Main() {
  int n;
  cin >> n;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int minimum = 1000000;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] <= minimum) {
      ans++;
      minimum = min(p[i], minimum);
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
//#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 1000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
itn main(){
    int n;
    std::cin >> n;
    if(n>=1000){
        n%=999;
        std::cout << "ABD"<< std::endl;
    }
    else{
        std::cout << "ABC" << std::endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int N=1000010;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
void print(int x) {if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int n,k,a[N];
signed main()
{
	k=read(), n=read(); int x=-1;
	for(ri int i=1;i<=n;i++)
	{
		a[i]=read();
		if(i>=2) x=max(x,a[i]-a[i-1]);
	}
	x=max(x,k-a[n]+a[1]);
	printf("%lld\n",k-x);
	return 0;
}

Measured memory_bytes: 1792
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define clr clear()
#define ins insert
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define cusmem(x,val) for(auto &i:x) i=val;
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);\
            cin.tie(NULL);\
            cout.tie(NULL);
using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int>pli;
typedef vector<ll> vl;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpii;
string impossible;

mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
// const int N=6;
const int N=3e5+5;
const int L=41;
int MOD=1e9+7;
ll n,m,k,i,j;
bool f0,f1,f2;
const int MAXN=2e3;
int row[N],col[N];
vector<pii>tars;
int h,w;
vector<pii>dir{{0,1},{1,0},{0,-1},{-1,0}};
int main(){
    #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin); 
            freopen("output.txt","w",stdout);
    #endif
    fastio
    cout<<fixed<<setprecision(11);
    int tests=1;    
    // cin>>tests;
    for(int te=1;te<=tests;te++){
        cin>>h>>w>>m;
        tars=vector<pii>(m);
        map<pii,int>um;
        for(int i=0;i<m;i++){
            int u,v;    cin>>u>>v;
            u--;v--;
            tars.pb({u,v});
            um[{u,v}]=1;
            row[u]++;
            col[v]++;
        }
        int rm=0,cm=0;
        for(int i=0;i<h;i++)    rm=max(rm,row[i]);
        for(int i=0;i<w;i++)    cm=max(cm,col[i]);
        vector<int>rs,cs;
        ll rcnt=0,ccnt=0;
        for(int i=0;i<h;i++)    if(row[i]==rm)    rs.pb(i),rcnt++;
        for(int i=0;i<w;i++)    if(col[i]==cm)  cs.pb(i),ccnt++;
        ll tot=rcnt*ccnt;
        if(tot>m) cout<<rm+cm<<"\n";
        else{
            for(auto i:rs){
                for(auto j:cs){
                    pii t={i,j};
                    if(um.find(t)==um.end()){
                        cout<<rm+cm<<"\n";
                        return 0;
                    }
                }
            }
            cout<<rm+cm-1<<"\n";
        }
    }
    return 0;
}





Measured memory_bytes: 33360
import itertools
import math
import numpy as np

n=int(input())
l=[]
for i in range(n):
    array=list(map(int,input().split()))
    l.append(array)

ll=[]
for v in itertools.permutations(range(n)):
    ll.append(list(v))
a=0
for j in ll:
    for k in range(len(j)-1):
        x=j[k]
        y=j[k+1]
        dis=math.sqrt((l[x][0]-l[y][0])**2+(l[x][1]-l[y][1])**2)
        a+=dis

print(a/len(ll))

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

ll v[200005], pref[200005], suff[200005];

int main(){

    int n; cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    for(int i = 1; i <= n; i++)
        pref[i] = pref[i-1] + v[i];
    for(int i = n; i >= 1; i--)
        suff[i] = suff[i+1] + v[i];

    ll res = 1e18;
    for(int i = 1; i < n; i++){
        ll x = pref[i], y = suff[i+1];
        res = min(res, abs(x-y));
    }
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main() {

    int a, b, c, min, mid, max;

    scanf("%d %d %d\n", &a, &b, &c);

    if (a >= b && b >= c) {
    	min = c, mid = b, max = a;
    	printf("%d %d %d\n", min, mid, max);
    } else if (a >= c && c >= b) {
    	min = b, mid = c, max = a;
    	printf("%d %d %d\n", min, mid, max);
    } else if (b >= c && c >= a) {
    	min = a, mid = c, max = b;
    	printf("%d %d %d\n", min, mid, max);
    } else if (c <= a && a <= b) {
    	min = c, mid = a, max = b;
    	printf("%d %d %d\n", min, mid, max);
    } else if (a <= b && b <= c) {
    	min = a, mid = b, max = c;
    	printf("%d %d %d\n", min, mid, max);
    } else if (b <= a && a <= c) {
    	min = b, mid = a, max = c;
    	printf("%d %d %d\n", min, mid, max);
    }

    return 0;
}



Measured memory_bytes: 2088
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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


/* きょむ〜 */


Measured memory_bytes: 3624
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{

    static int n;
    static int c;
    static int k;
    static String s;
    static int[] times;
    static int m;
    static long ans;
    static int[] w;
    static int[] ww;
    static boolean[] visit;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        n = sc.nextInt();
        c = sc.nextInt();
        k = sc.nextInt();
        m = 0;
        ans = 1;
        times = new int[n];
        
        for (int i = 0; i < n; i++) {
            times[i] = sc.nextInt();
        }
        Arrays.sort(times);
        for (int i = 0; i < n; i++) {
            if (times[i]-times[m] > k || i-m == c) {
                m = i;
                ans++;
            }
        }

        System.out.println(ans);

        sc.close();
    }

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

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

    public static void dfs(int placenow) {
        // if went all -> success! 
        // if not went all -> fail...
        
        /*
         dfs
         Go All Place that there is way to and not having been yet. 

         if island 1 is start point, dfs(1);
         if there is way to island 2 and island 3,
         - island 2 changes non-visited -> visited, and dfs(2).
         - island 3 changes non-visited -> visited, and dfs(3).
         

        */

        visit[placenow] = true;
        boolean success = true;
        for (int i = 0; i < n; i++) {
            if (visit[i] == false) { // not go all place
                success = false;
                break;
            }
        }
        if (success) {
            ans++;
            visit[placenow] = false;
            return;
        }

        for (int i = 0; i < m; i++) {
            if (w[i] == placenow && visit[ww[i]] == false ) {
                dfs(ww[i]);
            }else if(ww[i] == placenow && visit[w[i]] == false){
                dfs(w[i]);
            }else{
                continue;
            }
        }
        visit[placenow] = false;
        return;
    }

}



Measured memory_bytes: 49344
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
#include<vector> 
using namespace std;
int main()
{string s;
 cin>>s;
 if(s=="abc" || s=="acb" || s=="bac" || s=="bca" || s=="cab" ||s=="cba")
 cout<<"Yes"<<endl;
 else
 cout<<"No"<<endl; 
 system("pause");
 return 0;
}

Measured memory_bytes: 504
#include<stdio.h>

int main(void)
{
	int n,N,S[15]={0},H[15]={0},C[15]={0},D[15]={0},i;
	
	char m;
	
	for(i=0;i<13;i++){
		
		S[i]=i+1;
		H[i]=i+1;
		C[i]=i+1;
		D[i]=i+1;
	}
	//printf("%d",S[12]);
	
	scanf("%d",&n);
	
	for(i=0;i<n*2;i++){
		
		scanf("%c",&m);
		scanf("%d",&N);
		if(m=='S'){
			
			S[N-1]=0;
		}
		else if(m=='H'){
			
			H[N-1]=0;
		}
		else if(m=='C'){
			
			C[N-1]=0;
		}
		else if(m=='D'){
			
			D[N-1]=0;
		}
		//printf("%d\n",i);
	}
	for(i=0;i<15;i++){
		
		if(S[i]!=0){
			
			printf("S %d\n",S[i]);
		}
	}
	for(i=0;i<15;i++){
		
		if(H[i]!=0){
			
			printf("H %d\n",H[i]);
		}
	}
	for(i=0;i<15;i++){
		
		if(C[i]!=0){
			
			printf("C %d\n",C[i]);
		}
	}
	for(i=0;i<15;i++){
		
		if(D[i]!=0){
			
			printf("D %d\n",D[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 2756
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
N = int(input())
AB = [ inpl() for i in range(N) ]
AB.sort(key=lambda x: x[1])
totaltime = 0
for time, deadline in AB:
    totaltime += time
    if totaltime > deadline:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 83932
S = gets.chomp
f_yymm = false
f_mmyy = false
case S[0..1]
when '01','02','03','04','05','06','07','08','09','10','11','12'
    f_mmyy = true
end
case S[2..3]
when '01','02','03','04','05','06','07','08','09','10','11','12'
    f_yymm = true
end
if f_yymm && f_mmyy then
    puts 'AMBIGUOUS'
elsif f_yymm then
    puts 'YYMM'
elsif f_mmyy then
    puts 'MMYY'
else
    puts 'NA'
end

Measured memory_bytes: 1788
using System;
 
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            int count;
            while((count = int.Parse(Console.ReadLine())) != 0) {
                var value = new int[7];
                for(int i = 0; i < count; ++i) {
                    int age = int.Parse(Console.ReadLine());
                    ++value[(age >= 70 ? 60 : age) / 10];
                }
                Array.ForEach(value, Console.WriteLine);
            }
        }
    }
}

Measured memory_bytes: 5840
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

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

    int n, t, a, h[1005];
    cin >> n >> t >> a;
    for (int i = 0; i < n; i++)cin >> h[i];
    int ans = 1;
    for (int i = 1; i < n; i++) {
        if (abs(a - (t - h[ans-1] * 0.006)) > abs(a - (t - h[i] * 0.006)))ans = i+1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
ll a[maxn];
int main(){
	ll n,m;
	cin>>n>>m;
	ll lcm=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(lcm>1e9) continue;
		lcm=lcm*a[i]/2 / __gcd(lcm,a[i]/2);
	}
	bool flag=0;
	for(int i=0;i<n;i++){
		ll t=lcm*2/a[i];
		if(t%2==0){
			flag=1;
			break;
		}
	}
	ll ans=m/lcm;
	if(ans&1) ans=ans/2+1;
	else ans/=2;
	if(flag) cout<<"0"<<"\n";
	else cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4344
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,i,j,p=1000000007,temp=0,count=0,flag=0,a,b;
string s;
cin>>s;
 n=s.length();
if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
else cout<<"No"<<endl;

            
return 0; 
 
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int count1 = 0;
	int count2 = 0;
	int count4 = 0;
	for (int i = 0; i < N; ++i)
	{
		int tmp = 0;
		cin >> tmp;
		if(tmp % 4 == 0) {
			count4++;
		}else if(tmp % 2 == 0){
			count2++;
		}else{
			count1++;
		}
	}
	if(count1 <= count4 || (count1 <= count4 + 1 && count2 == 0)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	} 

}

Measured memory_bytes: 256