akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mn(a, b) (a < b ? a : b)
#define mx(a, b) (a > b ? a : b)
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
#define base 331
#define db(a) cout<<(a)<<"\n";

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;

struct mat{
    ll matriz[52][52];
    mat(){
        for(int i = 1; i <= 50; i++){
            for(int j = 1; j <= 50; j++)
                matriz[i][j] = 0;
        }
    }
    friend mat operator *(const mat &a, const mat &b){
        mat c;
        for(int i = 1; i <= 50; i++)
            fill(c.matriz[i] + 1, c.matriz[i] + 51, 0);
        for(int i = 1; i <= 50; i++){
            for(int j = 1; j <= 50; j++){
                for(int k = 1; k <= 50; k++)
                    c.matriz[i][j] = (c.matriz[i][j] + (a.matriz[i][k] * b.matriz[k][j] % MOD)) % MOD;
            }
        }
        return c;
    }
};

mat ident(){
    mat c;
    for(int i = 1; i <= 50; i++)
        c.matriz[i][i] = 1;
    return c;
}

mat qp(ll e, mat b){
    mat a = b, aux = ident();
    if(e == 1)
        return a;
    while(e > 1){
        if(e % 2)
            aux = aux * a;
        a = a * a;
        e /= 2;
    }
    return a * aux;
}


int main(){

    //freopen(".in","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    ll k;
    cin>>k;
    mat xz;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin>>xz.matriz[i][j];
        }
    }
    mat x = qp(k, xz);
    ll sum = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            sum = (sum + x.matriz[i][j]) % MOD;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    /*
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    */
    
    /*
    int a, b, c;
    cin >> a >> b >> c;
    */
    
    /*
    int n;
    cin >> n;
    string s;
    cin >> s;
    */
    
    int n;
    cin >> n;
    double ans = 0;
    ans = (double)(n % 2 == 0 ? n / 2 : n / 2 + 1) / n;
    cout << fixed << setprecision(7) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
const double pi=3.141592653589793;

int main(){
    int n;cin>>n;
    vi v(n),x(n);
    ll ans=0;
    rep(i,n)cin>>x[i];
    rep(i,n)v[i]=x[i]+x[n-i-1];
    REP(i,1,n/2){
        ll sum=0;
      vector<bool> b(n,false);
      if(n%2==1)b[n/2]=true;
        for(int j=i;j<n;j+=i){
          if(b[j]||b[n-j-1])break;
          if(n-j-1<i)break;
            sum+=v[j];
            if(ans<sum){
              ans=sum;
            }
          b[j]=true;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;
 
int main(){
    int n, m;
    bool open = false;
    map<string, int> door;
    cin >> n;
    while(n--){
        string input;
        cin >> input;
        door[input] = 1;
    }
    cin >> m;
    while(m--){
        string input;
        cin >> input;
        if(door.find(input) == door.end()){
            cout << "Unknown " << input << endl;
        }else{
            if(door[input] == 1 && open == false){
                cout << "Opened by " << input << endl;
                open = true;
            }else if(door[input] == 1 && open == true){
                cout << "Closed by " << input << endl;
                open = false;
            }
        }
 
    }
}

Measured memory_bytes: 3248
INF = 1 << 60

n = gets.to_i
hs = gets.split.map(&:to_i)

# minimize
dp = Array.new(n, INF)
# init
dp[0] = 0
# change min
n.times do |i|
  [1, 2].each do |d|
    j = i + d
    next unless j < n
    dp[j] = [dp[j], dp[i] + (hs[i] - hs[j]).abs].min
  end
end

p dp[n - 1]


Measured memory_bytes: 13444
def solve_e(n, m, a_list, k_list):
    dp = [[10 ** 9] * (2 ** n) for _ in range(m + 1)]
    dp[0][0] = 0

    # update
    for i in range(m):
        k = k_list[i]
        for j in range(2 ** n):
            ll = (k ^ j) + ((k + j - (k ^ j)) // 2) - k
            dp[i + 1][j] = min(dp[i][j], dp[i][ll] + a_list[i])

    # print(dp)
    if dp[m][2 ** n - 1] == 10 ** 9:
        return -1
    else:
        return dp[m][2 ** n - 1]


def main():
    n, m = map(int, (input().split()))
    a_list = [0] * m
    k_list = [0] * m
    for i in range(m):
        a, b = map(int, (input().split()))
        a_list[i] = a
        c_list = list(map(int, (input().split())))
        k_list[i] = sum([2 ** (c - 1) for c in c_list])

    res = solve_e(n, m, a_list, k_list)
    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 75244
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<memory.h>
using namespace std;
typedef long long ll;
const int Max = 4e5 + 5;
const int Mod = 1e9 + 7;
int lst[Max];

int main()
{
	ll n;
	cin >> n;
	ll res = n / 11 * 2;
	if (n % 11 != 0 && n % 11 <= 6)res++;
	else if (n % 11 != 0 && n % 11 > 6)res += 2;
	cout << res;
}

Measured memory_bytes: 3156
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <iostream>
#include <sstream>
#include <vector>
#include <iterator>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define    ll          long long
#define    mp          make_pair
#define    pb          push_back
#define    vi          vector <int>
#define    vs          vector <string>
#define    maxx(a,b,c) max(a,max(b,c))
#define    minn(a,b,c) min(a,min(b,c))
#define    SORT(x)     sort(x.begin(),x.end())
#define    fill(x,y)   memset(x, y, sizeof(x))

using namespace std;

int main(){
	//freopen("in.txt","r", stdin);
	//freopen("out.txt","w", stdout);

	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s; cin >> s;
	for(int i=0;i<s.size();i++) cout << "x";
	cout << endl;	
 
	return 0;	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{
   int a,b,c,d,i;
   while(scanf("%d %d",&a,&b) != EOF )
   {
      c=a+b;
      for(i=1;i<8;i++)
      {
            d=pow(10,i);/*d=pow(a,b)でaのb乗*/
            if(c<d)
            {
                  printf("%d\n",i);
                  break;
            }
      }

   }
   return 0;
}

Measured memory_bytes: 644
#include<iostream>

using namespace std;

int main(){
  string S, T;
  int count=0;
  
  cin >> S >> T;
  
  for(int i=0; i<3; i++){
    if(S[i] == T[i]){
      count++;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
int N,M;
int R,RR[202];
 
ll mat[202][202];
 
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>R;
	FOR(i,R) cin>>RR[i], RR[i]--;
	FOR(x,N) FOR(y,N) mat[x][y]=(x==y)?0:(1LL<<40);
	FOR(i,M) {
		cin>>x>>y>>r;
		x--,y--;
		mat[x][y]=min(mat[x][y],(ll)r);
		mat[y][x]=min(mat[y][x],(ll)r);
	}
	
	int z;
	FOR(z,N) FOR(x,N) FOR(y,N) mat[x][y]=min(mat[x][y],mat[x][z]+mat[z][y]);
	sort(RR,RR+R);
	
	ll ret=1LL<<40;
	do {
		ll tot=0;
		FOR(i,R-1) tot += mat[RR[i]][RR[i+1]];
		ret=min(tot,ret);
	} while(next_permutation(RR,RR+R));
	
	
	cout<<ret<<endl;
	
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 640
from collections import defaultdict

def get_renzokuomote(goal, now_num):
    count = 0
    while now_num < goal:
        now_num *= 2
        count += 1
    return count



def main():
    num = int(input())
    a = num // 100
    b = num % 100

    if a == 0:
        if b == 0:
            print('NA')
        elif b <= 12:
            print('YYMM')
        else:
            print('NA')
    elif a <= 12:
        if b == 0:
            print('MMYY')
        elif b <= 12:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    else:
        if b == 0:
            print('NA')
        elif b <= 12:
            print('YYMM')
        else:
            print('NA')






if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
/* Educational DP Contest 2019/1/6
 * B Frog-2
 * 2020.3.29 練習
 *  Aの変化系．ジャンプ先が最大100から選ぶことになる．
 */
#include<iostream>
#include<vector>
#include<algorithm> // max
//#include<cmath>
using namespace std;

int abs(int x){
  return (x>=0)?x:-x;
}

// 最長増加部分列(LIS)
int n;  // 2~10^5
int k;  // 1~100 ジャンプ先可能数
vector<int> h; // 数字列 1~10^4
vector<int> cost; // コストのメモ

//入力
void init(){
  cin >> n;
  cin >> k;
  h.assign(n+1,0);
  cost.assign(n+1,0);
  for(int i=1; i<n+1; i++){
    cin >> h[i];
  }
  return;
}

/* 再帰関数で実装した場合(Aの場合)
int recur(int k){
  // メモがある場合
  if(cost[k]) return cost[k];  //メモあり
  // 境界条件
  if(k==n) return 0;
  if(k==n-1) return abs(h[n-1]-h[n]);
  // 再帰
  // メモ化
  cost[k] = min( recur(k+1)+abs(h[k]-h[k+1]), recur(k+2)+abs(h[k]-h[k+2]) );
  cout << "mem: k=" << k << ", cost=" << cost[k] << endl;
  return cost[k];
}
//*/

//* DPで実装した場合
void dodp(){
  // 境界条件
  cost[n] = 0;
  int temp;
  // k未満しか飛べない位置
  for(int i=n-1; i>n-k; i--){
    //cout << i << " ";
    temp = cost[i+1]+abs(h[i]-h[i+1]); // k>=1なので
    for(int j=2; i+j<n+1; j++){
      temp = min(temp, cost[i+j]+abs(h[i]-h[i+j]));
    }
    cost[i] = temp;
    if(i==1){
      break;
    }
    //cout << "db1: i " << i << " cost: " << temp << endl;
  }
  for(int i=n-k; i>0; i--){
    temp = cost[i+1]+abs(h[i]-h[i+1]); // k>=1なので
    for(int j=2; j<k+1; j++){
      temp = min(temp, cost[i+j]+abs(h[i]-h[i+j]));
    }
    cost[i] = temp;
    //cout << "db2: i " << i << " cost: " << temp << endl;
  }
}
//*/

int main(void){
  init();
  //cout << "test" << endl;
  dodp();
  cout << cost[1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main()
{
    ll d,n;
    cin >> d >> n;
    ll ans=0;
    ll v=1;
    rep(i,d){
        v*=100;
    }
    ll w=v*100;
    ll cnt=0;
    while(cnt<n){
        ans+=v;
        if(ans%w==0){
            continue;
        }
        else{
            cnt++;
        }
    }
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 256
N=int(input())
T=list(map(int,input().split()))
M=int(input())
PX=[list(map(int,input().split())) for i in range(M)]
import copy
for i in range(len(PX)):
    TC=copy.deepcopy(T)
    TC[PX[i][0]-1]=PX[i][1]
    print(sum(TC))

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
  	ci(n>>m);
  vpll A(m);
  
  FOR(i,0,m){
    ci(A[i].fi>>A[i].se)
  }
  
  vll B(m);
  vll C(m);
  
  FOR(i,0,m){
    if(A[i].fi==1){
      B[i]=A[i].se;
    }
    if(A[i].se==n){
      C[i]=A[i].fi;
    }
  }
  
  SORT(B);
  SORT(C);

  ll nowB=0;
  ll nowC=0;
  bl b=true;
  
  FOR(i,0,2*m){
    if(B[nowB]==0){
      nowB++;
    }
    else if(C[nowC]==0){
      nowC++;
    }
    else if(B[nowB]<C[nowC]){
      nowB++;
    }
    else if(B[nowB]>C[nowC]){
      nowC++;
    }
    else {
      co("POSSIBLE")
      b=false;
      break;
    }
  }
  
  if(b){
    co("IMPOSSIBLE")
  }
}

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

int top, S[1000];

void push(int x){
   S[++top] = x;
}

int pop(){
   top--;
   return S[top+1];
}

int main(){
   int a, b;
   top = 0;
   char s[100];
   while(scanf("%s", s) != EOF){
      if(s[0] == '+'){
         a = pop();
         b = pop();
         push(a+b);
      }
      else if(s[0] == '-'){
         b = pop();
         a = pop();
         push(a-b);
      }
      else if(s[0] == '*'){
         a = pop();
         b = pop();
         push(a*b);
      }
      else push(atoi(s));
   }
   printf("%d\n", pop());
   
   return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
vector<long long>v;
void dfs(long long a,long long b)
{
	v.push_back(b);
	if(a>=9)
		return;
	long long ok=b%10;
	if(ok)
		dfs(a+1,b*10+ok-1);
	dfs(a+1,b*10+ok);
	if(ok<9)
		dfs(a+1,b*10+ok+1);
}
int main()
{
	for(long long i=1;i<=9;i++)
		dfs(0,i);
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	long long n;
	cin>>n;
	cout<<v[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 2420
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    int N, M;
    cin >> N >> M;
    double DP[300] = {};
    for(int loop = 0; loop < N; loop++){
        int K;
        cin >> K;
        double PS[300] = {};
        int pos = 0;
        for(int i = 0; i < K; i++){
            int S, H;
            cin >> S >> H;
            for(int j = 1; j <= S * H; j++){
                if(pos + j > M){
                    break;
                }
                PS[pos + j] = PS[pos] + j / (double)S;
            }
            pos += S * H;
        }
        for(int i = M; i >= 0; i--){
            for(int j = 0; i + j <= M; j++){
                DP[i + j] = max(DP[i + j], DP[i] + PS[j]);
            }
        }
    }
    printf("%.10f\n", DP[M]);
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N;
    reps(i,2, 1000){
        if(i * (i - 1) / 2 == N){
            cout<<"Yes"<<endl;
            cout<<i<<endl;
            mat ans(i, vec(0));
            ll num = 1;
            rep(j,i){
                reps(k,j + 1,i){
                    ans[j].push_back(num);
                    ans[k].push_back(num++);
                }
            }
            rep(j,i){
                cout<<i - 1;
                for(ll a : ans[j]) cout<<' '<<a;
                cout<<endl;
            }
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3200
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#include <cstdint>
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
int main(){
    int a,b;
	cin >>a >> b;
    a--;b--;
if (a == 0) a = 1000;
	if (b== 0) b = 1000;
   if (a > b) cout << "Alice"<< endl;
	else if (a < b) cout << "Bob"<< endl;
else cout << "Draw" << endl;
}

Measured memory_bytes: 256
import math
n=int(input())
XY=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    disx=XY[i][0]-XY[j][0]
    disy=XY[i][1]-XY[j][1]
    dis=math.sqrt(disx**2+disy**2)

    ans+=dis

print(2*ans/n)

Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

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


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
    int n, m, x, i;
    scanf("%d%d", &n, &m);
    for (i = 0; i < m; i++) {
        scanf("%d", &x);
        n -= x;
    }
    if (n < 0) n = -1;
    printf("%d\n", n);
    return 0;
}


Measured memory_bytes: 1732
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long
	iostream::sync_with_stdio(false);
	while (true) {
		int n, k;
		cin >> n >> k;
		if (n == k&&k == 0) {
			return 0;
		}
		vector<int> a;
		REP(i, n) {
			int b;
			cin >> b;
			a.push_back(b);
		}
		long long ans = -1000000000000;
		long long tmp = 0;
		for (int i = 0;i < k;++i) {
			tmp += a[i];
		}
		ans = tmp;
		for (int i = k;i < n;++i) {
			tmp += a[i];
			tmp -= a[i - k];
			ans = max(ans, tmp);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3888
n = int(input())

def is_p(n):
    i = 2
    while i**2 <= n:
        if n % i == 0:
            return False
        i += 1
    return True

l = []
for i in range(2, 55555 + 1):
    if i % 5 == 2 and is_p(i):
        l.append(i)
        if len(l) == n:
            break
            
print(" ".join(map(str, l)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll N,M;
	cin>>N>>M;
	vector<ll> A(N);
	FDS(i,N){
		cin>>A[i];
	}
	vector<pair<ll, ll> > pairs(M);

    FDS(i,M){
        ll a, b;
        cin >> a >> b;
        pairs[i] = make_pair(b, a);
    }
	VSORT(A);
	VREV(A);
    VSORT(pairs);
    VREV(pairs);
	ll ans=0;
	ll j=0;
	ll b=0;
	ll a=0;
	FDS(i,N){
		if(pairs[b].first>A[a]){
			ans+=pairs[b].first;
			j++;
		}
		else{
			ans+=A[a];
			a++;
		}
		if(j==pairs[b].second){
			b++;
			j=0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

if x < a[0]:
	print(0)
	exit()

if sum(a) < x:
	print(n - 1)
	exit()

cnt = 0
for i in range(n):
	if a[i] <= x:
		cnt += 1
		x -= a[i]

print(cnt)


Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();

		String s = sc.next();
		if(a >= 3200) {
			System.out.println(s);
		}else {
			System.out.println("red");
		}

	}
}


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

using namespace std;

int main(){
	int H,W,N;
	cin >> H >> W >> N;
	int a;
	int data[10000];
	int count=0;
	for(int i=1;i<N+1;i++){
		cin >> a;
		for(int j=0;j<a;j++){
			data[count]=i;
			count++;
		}
	}
	// //debug
	// for(int i=0;i<(H*W);i++){
	// 	cout << data[i] << " ";
	// }
	// cout << endl;
	// //debug end

	// 並べ替える
	int ans=0;
	int  buf[100];
	for(int i=1;i<H;i+=2){
		for(int j=0;j<W;j++){
			buf[j]=data[(i*W)+j];
			// //debug
			// cout << (i*W) + j << ":" << buf[j] << ":" << j;
			// cout << endl;
			// //debug end
		}
		// //debug
		// for(int j=0;j<W;j++){
		// 	cout << buf[j] << ":" << j << " ";
		// }
		// cout << endl;
		// //debug end
		for(int j=0;j<W;j++){
			data[(i*W)+(W-j)-1]=buf[j];
		}
	}
	// //debug
	// for(int i=0;i<(H*W);i++){
	// 	cout << data[i] << " ";
	// }
	// cout << endl;
	// //debug end
	//出力
	//debug
	
	//debug end
	for(int i=0;i<H;i++){
		cout << data[i*W];
		for(int j=1;j<W;j++){
			cout << " " << data[i*W+j];
		}
		cout << endl;
	}
}


/*
偶数 1 0 1 0 > N/2
奇数 0 1 0 > (N-1)/2
*/


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong d, c;
	cin >> d >> c;

	cout << d*c << endl;

	return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ve vector
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())
//using namespace __gnu_pbds;
using namespace std;

// // // functions: find_by_order  & order_of_key
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

const int inf=(int)2e9;
const long long mod=1000000007; //1E9+7
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

ll powmod(ll a,ll p){
	ll ans=1;
	while(p){
		if(p&1) ans*=a;
		p/=2;a*=a; ans%=mod;a%=mod;
	}
	return ans;
}
ll modinv(ll a){return powmod(a,mod-2); }

const int N=3e5+10;
int f[N];
int ifac[N];

signed main(){
	IOS
	f[0]=f[1]=1;
	ifac[0]=ifac[1]=1;
	for(int i=2;i<N;i++) f[i]=f[i-1]*i%mod;
	for(int i=2;i<N;i++){
		ifac[i]=modinv(f[i]);
	}
	int h,w;cin>>h>>w;
	int n;cin>>n;
	function<int(int,int,int,int)> give=[&](int a,int b,int c,int d){
		a=c-a,b=d-b;
		return f[a+b]*ifac[a]%mod*ifac[b]%mod;
	};

	vii d(n);
	forn(i,n){
		int a,b;cin>>a>>b;
		d[i]={a,b};
	}
	d.push_back({1,1});
	n++;
	sort(all(d));
	vi dp(n);
	for(int i=n-1;i>=0;i--){
		dp[i]=give(d[i].x,d[i].y,h,w);
		for(int j=i+1;j<n;j++){
			if(d[j].x >= d[i].x && d[j].y >= d[i].y){
				dp[i]-=give(d[i].x,d[i].y,d[j].x,d[j].y)*dp[j]%mod;
				if(dp[i]<0) dp[i]+=mod;
			}
		}
	}
	cout<<dp[0];
}


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

int main() {
  int L,R;
  cin>>L>>R;
  
 
  int l=L%2019;
  R=l+R-L;
  while(R>l+4038){
    R-=2019;
  }
  if(R<l){
    swap(R,l);
  }
  int a=10000000;
  if(R==l){
    a=R*l%2019;
  }
  else{
  for (int i = l; i <= R; i++) {
    for (int j = i+1; j <= R; j++) {
      a=min(a,i*j%2019);
    }
  }
  }
  cout<<a<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int(i)=int (a);i<=int (b);i++)
#define ff(i,a,b) for(int(i)=int (a);i<int (b);i++)
#define F(i,a,b) for(int(i)=int (a);i>=int (b);i--)
#define foreach(i,x) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vt vector
#define ll long long
#define lower(p,x) lower_bound(all(p),x)
#define upper(p,x) upper_bound(all(p),x)
#define ms(a,x) memset(a,x,sizeof a)
#define minn(a,b,c,d) min(a,min(b,min(c,d))) 
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const double pi=acos(-1.0);//NOTE:PI
const double eps=1e-5;
const int INF=1e9,mod=1e9+7,N=1e6+6;
ll a[N];
ll dp[55][55][2500];
ll n,k;
ll back(ll pos,ll take,ll sum){
	if(pos==n) {
		if(sum==k*take&&take!=0) return 1;
		return 0;	
	}
	if(dp[pos][take][sum]!=-1) return dp[pos][take][sum];
	return dp[pos][take][sum]=back(pos+1,take+1,sum+a[pos])+back(pos+1,take,sum);

}
int main(){
	cin>>n>>k;ms(dp,-1);
	ff(i,0,n) cin>>a[i];
	cout<<back(0,0,0);
}


Measured memory_bytes: 59648
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
 int n, m;
 while(cin>>n>>m){
   int temp;
   priority_queue<int>que;
   for(int i=0;i<n;i++){
     cin>>temp;
     que.push(temp);
   }
   for(int i=0;i<m;i++){
     int t=que.top();
     que.pop();
     que.push(t/2);
   }
   long long ans=0;
   while(!que.empty()){
     ans+=que.top();
     que.pop();
   }
   cout<<ans<<endl;
 }
 return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
typedef long long int ll;
const int MOD=1e9+7;
const int N=2e3+10;
ll fac[N],ans[N][N];
ll pow(ll a,ll t){
    if(t==0)return 1;
    ll temp=pow(a,t/2);
    temp*=temp;
    temp%=MOD;
    if(t&1){
        temp*=a;
        temp%=MOD;
    }
    return temp;
}
ll rev(ll n){return pow(n,MOD-2);}
ll C(int n,int k){return (fac[n]*((rev(fac[k])*rev(fac[n-k]))%MOD))%MOD;}
ll H(int n,int k){return C(n+k-1,k);}
void init(){
    fac[0]=fac[1]=1;
    for(int i=2;i<N;i++)fac[i]=(fac[i-1]*i)%MOD;
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)ans[i][j]=-1;
    ans[0][0]=1;
    return ;
}
ll dp(int n,int k){
    if(n<0||k<0)return 0;
    if(ans[n][k]>=0)return ans[n][k];
    if(n==k)return ans[n][k]=dp(n-1,k-1);
    return ans[n][k]=(dp(n-1,k-1)+k*dp(n-1,k))%MOD;
}
int main(){
    int n,k,now=1;
    ll ans=0;
    scanf("%d%d",&n,&k);
    init();
    for(int i=1;i<=k;i++){
        ans+=dp(n,i);
        ans%=MOD;
    }
    printf("%lld\n",ans);
}


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

int main()
{
   int n;
   cin>>n;
   string s;
   cin>>s;
   int red=0,white=0,left=0;
   for(auto x:s)
   {
       if(x=='R')
       red++;
       else
       white++;
   }
       for(int i=0;i<(red);i++)
         if(s[i]=='W')
           left++;
   cout<<min(red,min(white,left))<<endl;
}

Measured memory_bytes: 3704
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')

#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a=ii()
print(a+a**2+a**3)





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

int main() {
  ll A;
  ld B;
  cin >> A >> B;

  ll ans = floor(A * B);
  cout << ans << endl;
  return 0;
}


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

int main(void){
    vector<int> num(3);
    for(int i = 0; i < 3; i++){
        cin >> num[i];
    }
    sort(num.begin(),num.end());
    printf("%d %d %d\n",num[0],num[1],num[2]);
}


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

int main(){
  long n; cin >> n;
  vector<long> a(n);
  int amin =1000000000;
  
  for(int i=0;i<n;i++){
    int count =0;
    cin >> a.at(i);
    while(a.at(i)%2==0){
      a.at(i) /= 2;
      count++;
    }
    amin = min(amin,count);
  }
  cout << amin << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
        int a,b,c;
        cin >> a >> b >> c;
        for(int i=0 ; i<2 ; i++ ){
                if(a>b){
                        int tmp=a;
                        a=b;
                        b=tmp;
                }
                if(b>c){
                        int tmp=b;
                        b=c;
                        c=tmp;
                }
        }
        cout << a << " " << b << " " << c <<endl;
        return 0;
}

Measured memory_bytes: 3068
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
using namespace std;

int N;
long long X;
vector<long long> x;
vector<long long> imos;

long long calc(int n)
{
	long long ret = (N + n) * X;
	long long sum;
	for(int i=N, w=1; i>0; i-=n, w++){
		long long d = imos[i] - imos[max(0, i-n)];

		if(w == 1)
			sum= 5 * d;
		else{
			if(d <= (LLONG_MAX/(w*2+1)))
				sum = (w*2 + 1) * d;
			else
				return LLONG_MAX;
		}

		if(ret <= LLONG_MAX-sum)
			ret += sum;
		else
			return LLONG_MAX;
	}

	return ret;
}

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

	x = vector<long long>(N);
	for(int i=0; i<N; i++)
		cin >> x[i];
	
	imos = vector<long long>(N+1, 0);
	for(int i=0; i<N; i++)
		imos[i+1] = imos[i] + x[i];

	long long ret = LLONG_MAX;
	for(int i=1; i<=N; i++){
		ret = min(ret, calc(i));
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>

#define M 3500000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return 0;
}

/* convert a string into an integer value */
int getKey(char str[]){
  int sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+key%(M-1); }

int find(char str[]){
 int key;
 int H1,H2,i,j,HS;
  key=getKey(str);
  H1=h1(key);
  H2=h2(key);
  for(i=0;;i++){
    HS=(H1+i*H2)%M;
    if(H[HS][0]=='\0'){
      return 0;

    }
    else if(!strcmp(H[HS],str)){
      return 1;
 
    }
  }
    /* your task */

}

int insert(char str[]){
int  key;
  int H1,H2,i,HS;
   key=getKey(str);
  H1=h1(key);
  H2=h2(key);
  
  for(i=0;;i++){
    HS=(H1+i*H2)%M;
  
    if(H[HS][0]=='\0'){
      strcpy(H[HS],str);
      break;
    }
      
    }
  
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s%s", com, str);

	if ( com[0] == 'i' ){
	  insert(str);
	} else {
	    if (find(str)){
	      printf("yes\n");
	      fflush(stdout);
	    } else {
	      printf("no\n");
	      fflush(stdout);
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 49568
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i, j, k;
		int floor1[][];
		int floor2[][];
		int floor3[][];
		int floor4[][];
		floor1 = new int[3][10];
		floor2 = new int[3][10];
		floor3 = new int[3][10];
		floor4 = new int[3][10];
		
		int n = scan.nextInt();
		int v;
		int w;
		
	
	
		for (k = 1; k <= n; k++) {
			
			int b = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			v = scan.nextInt();
			w = v;
		
if(b == 1 && v <= 9){
	floor1[f-1][r-1] += v;
}else if(b == 2 &&  v <= 9){
	floor2[f-1][r-1] += v;
}else if(b == 3 &&  v <= 9){
	floor3[f-1][r-1] += v;
}else if(b == 4 &&  v <= 9){
	floor4[f-1][r-1] += v;
}


		}
		for (j = 0; j < 3; j++) {
			for (i = 0; i < 10; i++) {
			if(floor1[j][i] < 0){
				floor1[j][i] = 0;
			}
			if(floor2[j][i] < 0){
				floor2[j][i] = 0;
			}
			if(floor3[j][i] < 0){
				floor3[j][i] = 0;
			}
			if(floor4[j][i] < 0){
				floor4[j][i] = 0;
			}
		for (j = 0; j < 3; j++) {
			for (i = 0; i < 10; i++) {
				
				System.out.print(" "+floor1[j][i]);
				if(i >= 9){
					System.out.println();
				}
				
			}
		}
		System.out.println("####################");
		for (j = 0; j < 3; j++) {
			for (i = 0; i < 10; i++) {
				System.out.print(" "+floor2[j][i]);
				if(i >= 9){
					System.out.println();
				}
				
			}
		}
		System.out.println("####################");
		for (j = 0; j < 3; j++) {
			for (i = 0; i < 10; i++) {
				System.out.print(" "+floor3[j][i]);
				if(i >= 9){
					System.out.println();
				}
				
			}
		}
		System.out.println("####################");
		for (j = 0; j < 3; j++) {
			for (i = 0; i < 10; i++) {
				System.out.print(" "+floor4[j][i]);
				if(i >= 9){
					System.out.println();
				}
				
			}
		}
	}
		}	
	}
}

Measured memory_bytes: 29920
from functools import reduce


class Solver(object):
    def __init__(self):
        self.n, self.x = list(map(int, input().split(" ")))
        self.x_s = list(map(int, input().split(" ")))

    def solve(self):
        self.shifted = [abs(self.x - i) for i in self.x_s]
        print(Solver.gcd(self.shifted))

    @staticmethod
    def gcd(numbers):
        if len(numbers) < 1:
            raise ValueError
        if len(numbers) == 1:
            return numbers[0]
        return reduce(Solver.pair_gcd, numbers)

    @staticmethod
    def pair_gcd(a, b):
        """a = bq + r"""
        a, b = (max(a, b), min(a, b))
        if b == 0:
            return a
        else:
            r = a % b
            return Solver.pair_gcd(b, r)


if __name__ == "__main__":
    s = Solver()
    s.solve()

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

int main(){
	string s;cin>>s;
  	vector<int> a(26,0);
  	char temp='z';
  	for(int i=0;i<s.size();i++){
    	a[s[i]-'a']++;
    }
  if(s.size()!=26){
  	for(int i=0;i<26;i++){
    	if(a[i]==0){
          	s+=i+'a';
            cout<<s<<endl;
      		return 0;
        }
    }
  }else{
  	for(int i=s.size()-1;i>0;i--){
    	if(s[i]>s[i-1]){
          for(int j=i;j<s.size();j++){
          	if(s[i-1]<s[j] && temp>s[j]) temp=s[j];
          }
        		s[i-1]=temp;
          		cout<<s.substr(0,i)<<endl;
          		return 0;
        }
    }
  }
           cout<<-1<<endl;
}    

Measured memory_bytes: 256
package main

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

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := bufio.NewScanner(stdin)

	/* 単語ごとに入力するならこれ */
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var sum float64

	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sum += 1.0 / float64(a)
	}

	/* 出力用 */
	_, _ = fmt.Fprintf(stdout, "%v\n", 1 / sum)
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;
constexpr int64_t mod = 1000000000 + 7;

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

    bool ok = true;
    vector<int> A(N);
    vector<int> data(N);
    for(auto& c : A){
        cin >> c;
        if(N % 2 == c % 2){
            ok = false;
        }
        data[c]++;
        if(data[c] > 2){
            ok = false;
        }
        if(N % 2 == 1 && c == 0 && data[c] > 1){
            ok = false;
        }
    }
    int64_t ans = 1;
    for(int i = 0; i < N / 2; ++i){
        ans *= 2;
        ans %= mod;
    }
    cout << (ok ? ans : 0) << endl;
}

Measured memory_bytes: 1024
N = gets.to_i
A = gets.chomp.split.map(&:to_i)

natural = []
minus = []
A.each do |a|
  if a < 0
    minus << a
  elsif
    natural << a
  end
end
natural.sort!
minus.sort!

if minus.length % 2 == 0
  ans = 0
  ans += natural.inject(:+) if natural.length > 0
  ans -= minus.inject(:+) if minus.length > 0
  puts ans
else
  ans = 0
  if natural.length > 1
    natural[1..-1].each do |n|
      ans += n
    end
  end
  if minus.length > 1
    minus[0..-2].each do |m|
      ans -= m
    end
  end
  if natural.length > 0 and minus.length > 0 and natural[0] < -minus[-1]
    ans -= natural[0]
    ans -= minus[-1]
  else
    ans += natural[0] if natural.length > 0
    ans += minus[-1] if minus.length > 0
  end
  puts ans
end

Measured memory_bytes: 11536
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,i;
  cin>>n;
  vector<int> v(n);
  for(i=0;i<n;i++) cin>>v.at(i);
  sort(v.begin(),v.end());
  double d=0.5*(v.at(0)+v.at(1));
  for(i=2;i<n;i++) d=0.5*(d+v.at(i));
  cout<<fixed<<setprecision(10)<<d<<endl;
}

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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int xya[n][3];
  rep(i, n) cin >> xya[i][0] >> xya[i][1] >> xya[i][2];
  int x[] = {0, w}, y[] = {0, h};
  rep(i, n) {
    if (xya[i][2] == 1) {
      if (x[0] < xya[i][0]) x[0] = xya[i][0];
    } else if (xya[i][2] == 2) {
      if (x[1] > xya[i][0]) x[1] = xya[i][0];
    } else if (xya[i][2] == 3) {
      if (y[0] < xya[i][1]) y[0] = xya[i][1];
    } else {
      if (y[1] > xya[i][1]) y[1] = xya[i][1];
    }
  }
  if ((x[1] - x[0]) <= 0 || (y[1] - y[0]) <= 0)
    cout << 0 << endl;
  else
    cout << (x[1] - x[0]) * (y[1] - y[0]) << endl;
  return 0;
}


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

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
using namespace std;
typedef long long ll;

int main(){
    int nmin = 1;
    ll n;
    cin >> n;
    ll custom[n];
    ll sell = 0;
    REP(i,n) cin >> custom[i];
    REP(i,n){
        if(nmin > custom[i]) continue;
        else if(nmin == custom[i]){
            nmin++;
            continue;
        }
        sell = sell + floor((custom[i] - 1)/double(nmin));
        if(nmin == 1) nmin++;
    }
    cout << sell << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) ((int)(x).size())
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int inf = 1 << 30;
const ll INF = 1LL << 60;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<P>> g(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(1, b);
        g[b].emplace_back(1, a);
    }

    priority_queue<P, VP, greater<P>> pq;
    VI dist(n, inf), visited(n, -1);
    pq.push(P(0, 0));
    dist[0] = 0;
    while(!pq.empty()){
        P p = pq.top(); pq.pop();
        int u = p.second;

        if (dist[u] < p.first) continue;
        visited[u] = 1;

        for(P pp: g[u]){
            int v = pp.second, dis = pp.first;
            if (visited[v] == 1) continue;

            if (chmin(dist[v], dist[u] + dis)){
                pq.push(P(dist[v], v));
            }
        }
    }

    if (dist[n-1] == 2) {
        view("POSSIBLE");
    }else{
        view("IMPOSSIBLE");
    }
    return 0;
}

Measured memory_bytes: 18628
import java.util.*;
/*
NOTES:
-more than 10 digits (10^10), use long
-prefix sum of 1's and -1's to control flow of highlighting a region
-log(a)/log(b) = log base b of a
-create a position array if trying to see if elements show up next to each other sequentially
 i.e. elements 1,2,3 are within 3 spots of each other in an array
      arr[scannedInt - 1] = i; (position of i at p[i] in original)
- use a freq array when counting instances of an element occurring
- increment the counter first before simulating anything turn-based (two player game)

 */

public class Main {
    static long mod = (long)(Math.pow(10, 9) + 7);
    public static String alpha = "zabcdefghijklmnopqrstuvwxy";
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t =1;
        while (t-- > 0) {
            int a = scan.nextInt();
            long ans = a+a*a+a*a*a;
            System.out.println(ans);

        }
        scan.close();
    }

    static ArrayList factors(int n ){
        ArrayList<Integer> facts = new ArrayList<>();
        for(int i = 1; i<=(int)Math.sqrt(n); i++){
            if(n%i == 0){
                if( i == Math.sqrt(n)) facts.add(i);
                else{
                    facts.add(i);
                    facts.add(n/i);
                }
            }
        }
        Collections.sort(facts);
        return facts;
    }

    static boolean isPrime (int n){
        if(factors(n).size() ==2) return true;
        else return false;
    }





    static int GCD(int a, int b) {
        // Everything divides 0
        if (a == 0) return b;
        if (b == 0) return a;

        // base case
        if (a == b) return a;

        // a is greater
        if (a > b) return GCD(a-b, b);
        return GCD(a, b-a);
    }
    static int LCM(int a, int b){
        return (a*b)/(GCD(a,b));
    }
    static String rev(String s){
        char[] arr = s.toCharArray();
        for(int i = 0; i<(s.length()+1)/2; i++){
            char temp = arr[i];
            arr[i] = arr[s.length()-i-1];
            arr[s.length()-i-1] = temp;
        }
        String fin = new String(arr);
        return fin;
    }
    static long pow(long a, long N) {
        if (N == 0) return 1;
        else if (N == 1) return a;
        else {
            long R = pow(a,N/2);
            if (N % 2 == 0) {
                return R*R;
            }
            else {
                return R*R*a;
            }
        }
    }

    static long powMod(long a, long N) {
        if (N == 0) return 1;
        else if (N == 1) return a % mod;
        else {
            long R = powMod(a,N/2) % mod;
            R *= R;
            R %= mod;
            if (N % 2 == 1) {
                R *= a;
                R %= mod;
            }
            return R % mod;
        }
    }

}

Measured memory_bytes: 35988
#include<stdio.h>
#include<string.h>

int main(){
	char s[1000000];
	char ans[10000];
	int i,len,k;

	
	scanf("%s", s);
	ans[0] = s[0];
	k = 1;
	len = strlen(s);
	for (i = 2; i < len; i++){
		if (i % 2 == 0){
			ans[k]= s[i];
			k++;
		}
	}
	ans[k] = '\0';
	/*len = strlen(ans);
	for (i = 0; i < len; i++){
		printf()
	}*/
	printf("%s", ans);
	return 0;
}

Measured memory_bytes: 384