akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// 2項係数を求める
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};


int main(){
    int N, M;
    cin >> N >> M;
    combination c(10000001);

    auto pfs = prime_factorize(M);
    mint ans = 1;
    for (auto pf : pfs){
        int num = pf.second;
        mint tmp = c(num+N-1, N-1);
        ans *= tmp; 
    }

    cout << ans << endl;

}

Measured memory_bytes: 159556
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
const int INF = 1 << 28;

int N, M;
void a_sit(string &s) {
  for(int i=0; i<N; i++) {
    if(s[i] == '#') {
      s[i] = 'A';
      return;
    }
  }
}

void b_sit(string &s) {
  for(int i=N-1; i>=0; i--) {
    bool ok = (s[i] == '#');
    ok &= (i+1 >= N or s[i+1] != 'A');
    ok &= (i-1 <  0 or s[i-1] != 'A');

    if(ok) {
      s[i] = 'B';
      return;
    }
  }

  for(int i=0; i<N; i++) {
    if(s[i] == '#') {
      s[i] = 'B';
      return;
    }
  }
}

void c_sit(string &s) {
  for(int i=0; i<N; i++) {
    if(s[i] != '#') {
      if(i+1 < N and s[i+1] == '#') {
        s[i+1] = 'C';
        return;
      }
      if(i-1 >= 0 and s[i-1] == '#') {
        s[i-1] = 'C';
        return;
      }
    }
  }

  s[N/2] = 'C';
  return;
}

void d_sit(string &s) {
  int ma = -1, arg = -1;
  for(int i=0; i<N; i++) {
    if(s[i] != '#') continue;
    int min_dist = INF;
    for(int j=0; j<N; j++) {
      if(i == j or s[j] == '#') continue;
      int dist = (i - j > 0 ? i - j : j - i);
      if(min_dist > dist) {
        min_dist = dist;
      }
    }

    if(min_dist != INF and ma < min_dist) {
      ma = min_dist;
      arg = i;
    }
  }

  if(arg < 0) {
    s[0] = 'D';
  }
  else {
    s[arg] = 'D';
  }
}

void sit_down(char x, string &s) {
  if(x == 'A') a_sit(s);
  if(x == 'B') b_sit(s);
  if(x == 'C') c_sit(s);
  if(x == 'D') d_sit(s);
}

int solve() {
  cin >> N >> M;
  if(N == 0 and M == 0) return 1;

  vector<char> A(M);
  string ans(N, '#');
  for(int i=0; i<M; i++) cin >> A[i];
  for(int i=0; i<M; i++) {
    sit_down(A[i], ans);
  }
  cout << ans << endl;
  return 0;
}

int main() {
  while(!solve());
  return 0;
}



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

int main() {
	int N;
	cin >> N;
	int t[N];
	int x[N];
	int y[N];
	for(int i=0; i<N; ++i){
		cin >> t[i] >> x[i] >> y[i];
	}
	
	bool suc = true;
	
	for(int i=0; i<N; ++i){
		if(t[i] >= x[i]+y[i] && (t[i]-x[i]-y[i])%2 == 0){
			if(i < N-1){
				t[i+1] = t[i+1] - t[i];
				x[i+1] = x[i+1] - x[i];
				y[i+1] = y[i+1] - y[i];
			}
		}
		else{
			suc = false;
			break;
		}
	}
	if(suc){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int n, k;
  string s;
  cin >> n >> k >> s;
  s[--k] = tolower(s[k]);
  cout << s << '\n';
  return 0;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
    int n,l;
    cin >> n >> l;
    int hoge = n * l + n * (n-1)/2;
    vector<pair<int,int>> b;
    rep(i,n){
        int a = hoge - i - l;
        b.push_back(make_pair(abs(a - hoge), a));
    }
    sort(b.begin(),b.end());
    cout << b[0].second << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program{
	const int mod=1000000007;
	static void Main(){
		string s="0"+Console.ReadLine();
		string t="0"+Console.ReadLine();
		int[,] dp=new int[s.Length,t.Length];
		for(int i=1;i<s.Length;i++){
			for(int j=1;j<t.Length;j++){
				dp[i,j]=Math.Max(dp[i-1,j],dp[i,j-1]);
				if(s[i]==t[j]){dp[i,j]=Math.Max(dp[i-1,j-1]+1,dp[i,j]);}
			}
		}
		string ans="";
		int a=s.Length-1,b=t.Length-1;
		while(a>0&&b>0){
			if(dp[a,b]==dp[a-1,b]){a--;}
			else if(dp[a,b]==dp[a,b-1]){b--;}
			else{
				ans=s[a]+ans;
				a--;
				b--;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 48088
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;


int main(int argc, const char * argv[]) {
	int N;
	cin >> N;
	int h[N];
	REP(i,N) cin >> h[i];

	int cnt=0;
	FOR(hh,1,100){
		FOR(i,1,N-1){
			if(h[i-1]>= hh && h[i]< hh){
				cnt++;
			}
		}
		if(h[N-1]>= hh) cnt++;
	}
	println(cnt);
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

right = [int(i) for i in A if i > X]
left = [int(i) for i in A if i < X]

r = len(right)
l = len(left)

if r < l:
    print(r)

else:
    print(l)

Measured memory_bytes: 9164
/*
https://atcoder.jp/contests/dp/tasks/dp_h
*/
#include <iostream>
#include <vector>

using namespace std;

const int mod = 1e9 + 7;

int dfs (const vector <vector <char>> &grid, int row, int col,
         vector <vector <int>> &ways) {
    if (row == grid.size() - 1 && col == grid[0].size() - 1) {
        return 1;
    }
    if (row >= grid.size() || col >= grid[row].size() || grid[row][col] == '#') {
        return 0;
    }

    if (ways[row][col] >= 0) {
        return ways[row][col];
    }
    unsigned long count = 0;
    for (const pair <int, int> &next : initializer_list <pair <int, int>> 
                                            {{row + 1, col}, {row, col + 1}}) {
        int r = next.first, c = next.second;
        count = ((count % mod) + (dfs(grid, r, c, ways) % mod));
    }
    ways[row][col] = count % mod;
    return ways[row][col];
}

int getNumWays (const vector <vector <char>> &grid) {
    int rows = grid.size(), cols = grid[0].size();
    vector <vector <int>> ways(rows, vector <int>(cols));

    for (int r = 0; r < rows; ++r) {
        for (int c = 0; c < cols; ++c) {
            if (r == 0 && c == 0) {
                ways[r][c] = 1;
            } else {
                if (grid[r][c] == '.') {
                    int topRow = r == 0 ? 0 : ways[r - 1][c];
                    int leftCol = c == 0 ? 0 : ways[r][c - 1];
                    ways[r][c] = (topRow + leftCol) % mod;
                }
            }
        }
    }
    return ways[rows - 1][cols - 1];
}

int  main () {
    int rows, cols;
    cin >> rows >> cols;
    vector <vector <char>> grid(rows, vector <char>(cols, '.'));

    for (int r = 0; r < rows; ++r) {
        for (int c = 0; c < cols; ++c) {
            char ch;
            cin >> ch;
            grid[r][c] = ch;
        }
    }
    vector <vector <int>> ways(rows, vector <int>(cols, -1));
    // int result = dfs(grid, 0, 0, ways);
    // cout << result << "\n";
    int result = getNumWays(grid);
    cout << result << "\n";
    return 0;
}


Measured memory_bytes: 9088
N = int(input())
A = list(map(int, input().split()))

cnt_dic = {}

for i, a in enumerate(A, start=1):
    t = i + a

    if t in cnt_dic:
        cnt_dic[t] += 1
    else:
        cnt_dic[t] = 1


cnt = 0
for i, a in enumerate(A, start=1):
    if i - a <= 0:
        continue

    if i - a in cnt_dic:
        cnt += cnt_dic[i - a]

print(cnt)


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

int main() {
  int N, K; cin >> N >> K;
  long long H[N]; for (int i=0; i<N; i++) cin >> H[i];
  sort(H, H+N);
  long long ans = 0;
  for (int i=0; i<N-K; i++) {
    ans += H[i];
  }
  cout << ans << endl;

  return 0;
}


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

int main() { 
 char c[18] ; 
 scanf("%s" , &c) ; 
 for (int i =0 ; i<19 ; i++ ) {
 
 if( c[i] == ',' ) {
 
  c[i]= ' ';}
  }
 
 printf("%s" , c); 
  
  

return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 5");
            //Possible
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1 1");
            //Impossible
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();

        int A = wkArr[0];
        int B = wkArr[1];

        if ((A) % 3 == 0) Console.WriteLine("Possible");
        else if ((B) % 3 == 0) Console.WriteLine("Possible");
        else if ((A + B) % 3 == 0) Console.WriteLine("Possible");
        else Console.WriteLine("Impossible");
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int n, k;
vector<lint> a(1010, 0);
vector<vector<lint>> dp = vector<vector<lint>>(1010, vector<lint>(1010, 0));

void solve(int l, int r){
    if(dp[l][r] > 0) return;
    if(l == r){
        dp[l][r] = a[l];
        return;
    }
    solve(l+1, r);
    solve(l, r-1);
    dp[l][r] = dp[l+1][r] + a[l];
    return;
}

int main(){
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    solve(0, n-1);
    vector<lint> sum;
    rep(i, n)rep(j, n)if(i <= j){
        sum.push_back(dp[i][j]);
    }
    vector<bool> used(n*(n+1)/2, true);
    lint ans = 0;
    rrep(i, 50){
        int cnt = 0;
        rep(j, n*(n+1)/2)if(used[j] && (sum[j]>>i)&1) cnt++;
        if(cnt >= k){
            ans += 1LL<<i;
            rep(j, n*(n+1)/2)if(used[j] && !((sum[j]>>i)&1)) used[j] = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 14448
import math

class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y


def koch(n, a, b):
    if n == 0:
        return
    th = math.radians(60)
    s = Point((2*a.x+b.x)/3, (2*a.y+b.y)/3)
    t = Point((a.x+2*b.x)/3, (a.y+2*b.y)/3)
    u = Point((t.x-s.x)* math.cos(th) - (t.y-s.y)*math.sin(th)+s.x,
                (t.x-s.x)* math.sin(th) + (t.y-s.y)*math.cos(th)+s.y)

    koch(n-1, a, s)
    print(s.x, s.y)
    koch(n-1, s, u)
    print(u.x, u.y)
    koch(n-1, u, t)
    print(t.x, t.y)
    koch(n-1, t, b)

if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    n = int(input())

    a = Point(0, 0)
    b = Point(100, 0)

    print(a.x, a.y)
    koch(n, a, b)
    print(b.x, b.y)


Measured memory_bytes: 5784
N = int(input())
A = list(map(int, input().split()))
P = int(1e9+7)
max_log_2 = 60
k_zyo=[0] * max_log_2
k_2=[1]*max_log_2
for i in range(1, max_log_2):
    k_2[i] = k_2[i-1]*2
for a in A:
    for i in range(max_log_2):
        k_zyo[i] += (a // (k_2[i])) % 2

ans = 0
for a in A:
    for i in range(max_log_2):
        if (a // (k_2[i])) % 2 == 0:
            ans = (ans + k_zyo[i] * k_2[i]) % P
print(ans)


Measured memory_bytes: 124576
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    n = n % 10;
    V a = {2, 4, 5, 7, 9};
    V b = {0, 1, 6, 8};
    V c = {3};
    for(auto i:a)
        if(i == n)
            cout << "hon" << endl;
    for(auto i:b)
        if(i == n)
            cout << "pon" << endl;
    for(auto i:c)
        if(i == n)
            cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

import java.io.*;

public class Main{
	public static void main(String args[]) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
 
        char[] c1 = br.readLine().toCharArray();
        char[] c2 = br.readLine().toCharArray();
        int n1 = c1.length;
        int n2 = c2.length;
 
        int[][] dp = new int[n1+1][n2+1]; 
      
      for(int i=1;i<=n1;i++){
      
        for(int j=1;j<=n2;j++){
        
          if(c1[i-1]==c2[j-1]){         
            dp[i][j]=1+dp[i-1][j-1];
          }else{          
             dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);             
          }
                   
        }
        
      }
      
      char[] lcs = new char[dp[n1][n2]];
      
      int x=n1;
      int y=n2;
      int idx = lcs.length-1;
      
      while(x>0 && y>0){
      
      if(c1[x-1]==c2[y-1]){
      
        lcs[idx--]=c1[x-1];
        x--;
        y--;
        
      }else{
      
        if(dp[x][y]==dp[x-1][y]){        
            x--;            
        }else{      
          y--;          
        }
        
      }  
      
      }
      
      String str = new String(lcs);
      System.out.println(str);

	}
  
  
  
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);
  vector<vector<int>> vec(n+1);
  rep(i, m){
    cin >> p[i] >> y[i];
    vec[p[i]].push_back(y[i]);
  }
  rep2(i, 1, n+1){
    sort(vec[i].begin(), vec[i].end());
  }
  rep(i, m){
    auto itr = find(vec[p[i]].begin(), vec[p[i]].end(), y[i]);
    printf("%06d%06d\n", p[i], itr-vec[p[i]].begin()+1);
  }
  
  return 0;
}

Measured memory_bytes: 9496
a,b = map(int, input().split())

cont0 = False
if a <= 0 <= b:
  cont0 = True

neg = 0
if b < 0:
  neg = a-b+1
elif a < 0:
  neg = -a
  
if cont0:
  print("Zero")
else:
  if neg % 2 == 0:
    print("Positive")
  else:
    print ("Negative")

Measured memory_bytes: 3060
function main(input) {
  var rows = input.split('\n');
  var pieceCount = rows[0].split(" ").map(Number)[0];
  var coordinates = rows[1].trim().split(" ").map(Number).sort((a, b) => a - b);

  if (pieceCount >= coordinates.length){
    console.log(0);
    return;
  }

  var steps = [];
  coordinates.forEach((item, i) => {
      if (i > 0) {
      steps.push(item - coordinates[i-1])
      }
  })
  steps = steps.sort((a, b) => a - b).slice(0, steps.length - pieceCount + 1);
  console.log(steps.reduce((sum, cur) => sum+cur, 0))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 28440
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};
#define MAX 10000
int main(){
    int x,y,s;
    while(cin >> x >> y >> s,x|y|s){
        int ans = 0;
        for(int i=1; i<s; i++){
            for(int j=1; j<s; j++){
                int a = i*(100 + x)/100;
                int b = j*(100 + x)/100;
                if (a+b != s) continue;
                ans = max(ans, i*(100 + y)/100 + j*(100 + y)/100);
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3056
#include<iostream>
#include<ctype.h>
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int a[1000007];
int main(){
	int n=read(),maxn=0,x=0,y=0,minn=99999999;
	for(int i=1;i<=n;++i){
		a[i]=read();
		maxn=max(maxn,a[i]);
		minn=min(minn,a[i]);
	}
	if(maxn-minn>1){printf("No\n");return 0;}
	if(maxn==minn){
	    if(maxn==n-1 || minn+minn<=n)printf("Yes\n");
	    else printf("No\n");return 0;
	}
	for(int i=1;i<=n;++i)if(a[i]==minn)++x;else ++y;
	if(maxn>x+y/2 || maxn<=x){printf("No\n");return 0;}
	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	int a,b;
	cin>>a>>b;
	if(a==b)
	{
		cout<<"Draw"<<endl;
	}else
	{
		if(a==1)
		{
			cout<<"Alice"<<endl;
		}else if(b==1)
		{
			cout<<"Bob"<<endl;
		}else
		{
			if(a<b)
			{
				cout<<"Bob"<<endl;
			}else
			{
				cout<<"Alice"<<endl;
			}
		}
	}
	
	
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();

		System.out.println(Math.max(c - (a - b), 0));
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    string s; cin >> s;
    ll ans = 0;
    rep(i, s.size()-1){
        if(s[i+1] != s[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3760
import java.util.Scanner;

/**
 * Created by malone on 2018/3/15.
 */
public class Main{
    public static void main(String[] args) {
        int a, b,temp1,temp2;
        Scanner scanner = new Scanner(System.in);


        while (((a = scanner.nextInt()) != 0)&&((b = scanner.nextInt()) != 0)) {

            for (int i = 0; i < a; i++) {
                for (int j = 0; j < b; j++) {
                    System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.println();
        }

    }
}


Measured memory_bytes: 59836
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

int sum;

using namespace std;

int bigG, suneo;
int ans;

int main() {
	int a[200000], n;
	cin >> n;
	rep(i, n) { cin >> a[i]; }


	rep(i, n) {
		if (suneo < a[i] && a[i] <= bigG) {
			suneo = a[i];
		}
		if (bigG < a[i]) {
			bigG = a[i];
		}
	}

	rep(i, n) {
		if (bigG == a[i]) { cout << suneo << endl; }
		else { cout << bigG << endl; }
	}


	return 0;
}


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

using namespace std;

int main() {
	string str;
	cin >> str;

	long long sum1 = 0;
	long long sum2 = 0;

	int len = str.size();
	int t = 0;
	int q = 1;

	for (int i = 0; i < len; i++) {
		t = !t;
		int cur = str[i] - '0';

		if (cur != t) {
			sum1++;
		}

		q = !q;

		if (cur != q) {
			sum2++;
		}
	}

	printf("%lld", (sum1<sum2) ? sum1 : sum2);
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>

using namespace std;

long getMin(long x,int L)
{
	stringstream ss;
	ss<<x;
	string s=ss.str();
	ss.str("");
	ss.clear(stringstream::goodbit);

	while(s.size()!=L) s+='0';

	sort(s.begin(),s.end());
	ss<<s;

	long res;
	ss>>res;
//	cout<<"Min:"<<res<<endl;
	return res;
}

long getMax(long x,int L)
{
	stringstream ss;
	ss<<x;
	string s=ss.str();
	ss.str("");
	ss.clear(stringstream::goodbit);

	while(s.size()!=L) s+='0';

	sort(s.begin(),s.end());
	reverse(s.begin(),s.end());
	ss<<s;

	long res;
	ss>>res;

//	cout<<"Max:"<<res<<endl;
	return res;
}

int main()
{
	long a;
	int L;
	while(cin>>a>>L,a||L){
		map<long,int> aa;
		aa[a]=0;
//		cout<<"a0="<<a<<endl;;
		for(int i=1;;i++){
			a=getMax(a,L)-getMin(a,L);
//			cout<<"a"<<i<<"="<<a<<endl;
			auto it=aa.find(a);
			if(it!=aa.end()){
				cout<<it->second<<" "<<a<<" "<<i-it->second<<endl;
				break;
			}
			aa[a]=i;
		}
	}

	return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

bool from1[2505];
bool fromN[2505];
bool ok[2505];
vector<vl> G(2505);
vector<vl> rG(2505);



int main(){
    ll n,m; cin >> n >> m;
    vl a(n);
    rep(i,n) cin >> a[i];
    vl s(n+1,0);
    map<ll,ll> mp;
    mp[0]++;
    rep(i,n){
        s[i+1] = (s[i] + a[i]) % m;
        mp[s[i+1]]++;
    }
    ll ans = 0;
    for(auto i : mp){
        ans += i.second * (i.second-1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5888
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        long n = scan.nextLong();
        long a = scan.nextLong();
        long b = scan.nextLong();
        long c = (long) (n / (a + b));
        long d = n % (a + b);
        if(d <= a){
            long l = a * c + d;
            System.out.println(l);
        }else{
            long l = a * (c + 1);
            System.out.println(l);
        }
    }
}

Measured memory_bytes: 23764
#include<stdio.h>
int main(){

  int n,q,i,j,C=0;
  int l,r,m;
  int S[100000],T[50000];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
    for(j=0;j<q;j++){
      scanf("%d",&T[j]);
    }

    for(j=0;j<q;j++){
      l=0;
      r=n;
      while(l<r){
        m=(l+r)/2;
        if(S[m]==T[j]){
          C++;
          break;
        }
          if(T[j]<S[m]){
            r=m;
          }
          if(T[j]>S[m]){
            l=m+1;
          }

    }
}
        printf("%d\n",C);
return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int r,g;
    cin>>r>>g;
    cout<<2*g-r<<endl;
}

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

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

  vector<vector<int>> S;
  rep(i,0,M-1) {
    int k;
    cin >> k;
    vector<int> s(k);
    rep(j,0,k-1) {
      cin >> s[j];
      --s[j];
    }
    sort(s.begin(), s.end());
    S.push_back(s);
  }

  vector<int> P(M);
  rep(i,0,M-1) {
    cin >> P[i];
  }

  int ans = 0;
  for (int i = 0; i < (1 << N); ++i) {
    vector<int> switches;
    for (int j = 0; j < N; ++j) {
      if (i & (1 << j)) {
        switches.push_back(j);
      }
    }

    sort(switches.begin(), switches.end());

    bool ok = true;
    for (int j = 0; j < M; ++j) {
      vector<int> s = S[j];
      vector<int> v;
      set_intersection(switches.begin(), switches.end(), s.begin(), s.end(), back_inserter(v));
      if (v.size() % 2 != P[j])
        ok = false;
    }

    if (ok)
      ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n;
  while(cin>>n,n){
    Int dp[n+3];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(Int i=0;i<n;i++){
      dp[i+1]+=dp[i];
      dp[i+2]+=dp[i];
      dp[i+3]+=dp[i];
    }
    cout<<((dp[n]+9)/10+364)/365<<endl;
  }
  return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
typedef pair <int,int> pii;

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=1e5+50;
int n,low[N],up[N],ans[N],dep[N];
vector <int> edge[N];
inline void dfs1(int x,int f) {
	for(auto v:edge[x]) if(v^f) {
		dfs1(v,x); 
		low[x]=max(low[x],low[v]-1);
		up[x]=min(up[x],up[v]+1);
	}
} 
inline void dfs2(int x,int f) {
	if(f) low[x]=max(low[x],low[f]-1), up[x]=min(up[x],up[f]+1);
	for(auto v:edge[x]) if(v^f) dfs2(v,x);
}
inline void pre(int x,int f) {
	dep[x]=dep[f]+1;
	for(auto v:edge[x]) if(v^f) pre(v,x);
}
int main() {
	n=rd();
	for(int i=1;i<n;i++) {
		int x=rd(), y=rd();
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	pre(1,0);
	for(int i=1;i<=n;i++) low[i]=-1e9, up[i]=1e9;
	int vis[2]; vis[0]=vis[1]=-1;
	for(int i=rd();i;i--) {
		int x=rd(), y=rd();
		low[x]=up[x]=y;
		if(~vis[dep[x]&1]){
			if(vis[dep[x]&1]!=(y&1)) return puts("No"),0;
		} 
		else vis[dep[x]&1]=(y&1);
	}
	dfs1(1,0);
	dfs2(1,0);
	for(int i=1;i<=n;i++)
		if(low[i]>up[i]) return puts("No"),0;
	puts("Yes");
	for(int i=1;i<=n;i++)
		printf("%d\n",low[i]);
}

Measured memory_bytes: 11392
/* Kadai2_3
   nabe9393 */
 
#include <stdio.h>
 
int main(void) {
    int N, A, B;
 
    //入力受け取り
    scanf("%d", &N);
    scanf("%d", &A);
    B = N*N - A;
    printf("%d\n", B);
    return 0;
}


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

int main() {
  int N, C, D[30][30], c[500][500];
  cin >> N >> C;
  for (int i = 0; i < C; i++)
    for (int j = 0; j < C; j++) cin >> D[i][j];
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) cin >> c[i][j];
  int costD[30][3] = {};
  for (int goodc = 0; goodc < C; goodc++)
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++)
        costD[goodc][(i+j)%3] += D[c[i][j]-1][goodc];
  vector<int> kohoD;
  for (int c1 = 0; c1 < C; c1++) {
    for (int c2 = 0; c2 < C; c2++) {
      if (c1 == c2) continue;
      for (int c3 = 0; c3 < C; c3++) {
        if (c1 == c3 || c2 == c3) continue;
        kohoD.push_back(costD[c1][0] + costD[c2][1] + costD[c3][2]);
      }
    }
  }
  cout << *min_element(kohoD.begin(), kohoD.end());
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<string>

using namespace std;

int main(){
    string b; cin >> b;
    if(b == "SUN"){
        cout << 7;
    }
    if(b == "MON"){
        cout << 6;
    }
    if(b == "TUE"){
        cout << 5;
    }
    if(b == "WED"){
        cout << 4;
    }
    if(b == "THU"){
        cout << 3;
    }
    if(b == "FRI"){
        cout << 2;
    }
    if(b == "SAT"){
        cout << 1;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    ll n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    ll ans = 0;
    rep(i, n) {
        ll cnt1 = 0, cnt2 = 0;
        rep(j, i) if(a[j] > a[i]) cnt1++;
        rep(j, n) if(a[j] > a[i]) cnt2++;
        ans += cnt1*k%MOD + ((k*(k-1)/2)%MOD)*cnt2%MOD;
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
const ll mx=1e18;
ll a[100005];
int main()
{
    ll n,ans=1;
    cin>>n;
    rep(i,n)
    {
        cin>>a[i];
        if(a[i]==0) ans=0;
    }
    if(ans==0)
    {
        cout<<0;
        return 0;
    }
    rep(i,n)
    {
        if((mx%a[i]&&ans>=(mx+a[i]-1)/a[i])||(mx%a[i]==0&&ans>mx/a[i]))
        {
            cout<<-1;
            return 0;
        }
        ans*=a[i];
    }
    cout<<ans;
}


Measured memory_bytes: 4416
# -*- coding: utf-8 -*-
# A1=a, A2=b, A3=c
a,b,c = [int(i) for i in input().split()]

A = [a,b,c]
A.sort()

#はじめに完了すべきタスク　A[2]
#二番目に完了すべきタスク　A[1]

X = (A[2] - A[1]) + (A[1] - A[0])
print(X)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define y1 zzz
#define fi first
#define se second
#define PII pair<int2,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int n,k,x;
vector<double> a_pos,a_neg,a_0;
int can(double x)
{
    int res=0;
    if(x>=0)
    {
        res+=a_pos.size()*a_neg.size();
        res+=a_0.size()*(a_pos.size()+a_neg.size());
        res+=a_0.size()*((int)a_0.size()-1)/2;
        for(int i=0;i<a_pos.size();i++)
        {
            //cout<<x/a_pos[i]<<" "<<upper_bound(all(a_pos),x/a_pos[i])-a_pos.begin()<<'\n';
            res+=max(0LL,upper_bound(all(a_pos),x/a_pos[i])-a_pos.begin()-i-1);
        }
        for(int i=0;i<a_neg.size();i++)
        {
            res+=max(0LL,upper_bound(all(a_neg),x/a_neg[i])-a_neg.begin()-i-1);
        }
        //cout<<x<<" "<<res<<'\n';
    }
    else
    {
        x=-x;
        for(int i=0;i<a_neg.size();i++)
        {
            //cout<<x/a_neg[i]<<" "<<a_pos.end()-lower_bound(all(a_pos),x/a_neg[i])<<'\n';
            res+=a_pos.end()-lower_bound(all(a_pos),x/a_neg[i]);
        }
    }
    return res>=k;
}
void solve()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x>0)a_pos.pb(x);
        if(x<0)a_neg.pb(-x);
        if(x==0)a_0.pb(0);
    }
    sort(all(a_pos));
    sort(all(a_neg));
    int l=-1e18,r=1e18;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(can(mid))r=mid-1;
        else l=mid+1;
    }
    cout<<l<<'\n';
}
int32_t main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    //freopen("XORQUERY.inp","r",stdin);
    //freopen("XORQUERY.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 5360
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string> 
#include <vector> 
#include <set> 
#include <map> 
#include <queue> 
#include <cmath> 
#include <stack> 
#include <iomanip>  
#include <functional> 
#include <array> 
#include <memory> 
#include <bitset> 
#include <unordered_set> 
#include <unordered_map> 
#include <numeric>
#undef NDEBUG
#include <assert.h>
#include <fstream>

using namespace std;
typedef long long ll;

auto f(const vector<int> &a) {
	
	map<int, int> occ;
	for (auto &&x : a)
		++occ[x];
	vector<pair<int, int>> res(occ.begin(), occ.end());
	res.emplace_back(-1, 0);
	res.emplace_back(-2, 0);
	sort(res.begin(), res.end(), [](const pair<int, int> &lhs, const pair<int, int> &rhs) {
		return lhs.second > rhs.second;
	});
	res.resize(2);
	return res;
}


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

	int n;
	cin >> n;
	n >>= 1;

	vector<int> a(n), b(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i] >> b[i];

	auto occ1 = f(a);
	auto occ2 = f(b);


	int ans = 2 * n;
	for(auto &&x : occ1)
		for (auto &&y : occ2) {
			if (x.first != y.first) {
				ans = min(ans, 2 * n - x.second - y.second);
			}
		}

	cout << ans << '\n';
	
	return 0;
}

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

vector<int> C(26, 0); // C[i]
vector<vector<int> > S(365, vector<int>(26, 0)); // S[d][i]
int D;
int N;

int score(vector<int> V) {
	vector<int> c = C;
	int s = 0;
	for (int d = 0; d < D; d++) {
		c[V[d]] = 0;
		s += S[d][V[d]];
		s -= accumulate(c.begin(), c.end(), 0);
		for (int i = 0; i < N; i++) {
			c[i] += C[i];
		}
	}
	return s;
}

int ls1(int d, int i, int ci, int Ci) {
	return S[d][i] + 5 * ci;
}

int ls(int d, int i, int ci, int Ci) {
	return S[d][i] + 5 * ci - 30 * Ci;
}

vector<int> findmin() {
	vector<int> V(D, 0);
	vector<int> c = C;
	int s = 0;
	for (int d = 0; d < D; d++) {
		int mi = 0;
		for (int i = 0; i < N; i++) {
			if (ls(d,mi,c[mi],C[mi]) < ls(d, i, c[i], C[i])) mi = i;
		}
		V[d] = mi;
		c[V[d]] = 0;
		s += S[d][V[d]];
		s -= accumulate(c.begin(), c.end(), 0);
		for (int i = 0; i < N; i++) {
			c[i] += C[i];
		}
	}
	return V;
}

int main() {
	cin >> D;
	N = 26;
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	for (int d = 0; d < D; d++) {
		for (int i = 0; i < N; i++) {
			cin >> S[d][i];
		}
	}
	vector<int> V(D, 0);
	for (int d = 0; d < D; d++) {
//		cin >> V[d];
//		V[d]--;
		int i = 0;
		for (int j = 1; j < N; j++) {
			if (S[d][i] < S[d][j]) i = j;
		}
		V[d] = i;
	}

	vector<int> sV = findmin();
	if (score(V) < score(sV)) V = sV;

	random_device seed_gen;
	mt19937 engine(seed_gen());
	uniform_real_distribution<> dist1(0.0, 1.0);

	/*
	vector<int> newV = V;
	int ms = score(V);
	for (int j = 0; j < 100000; j++) {
		newV = V;
		for (int k = 0; k < 1; k++) {
			int d1 = int(dist1(engine) * D);
			int d2 = min(D-1, d1 + int(dist1(engine) * 3));
			newV[d1] = V[d2];
			newV[d2] = V[d1];
		}
		int ns = score(newV);
		if (ms < ns) V = newV;
	}
	*/

	for (int d = 0; d < D; d++) {
		cout << V[d] + 1 << endl;
	}
//	cerr << score(V) << endl;
  	return(0);
}


Measured memory_bytes: 3680
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 04/11/2018 13:24:01
	flamers will **** you
*/
//#include<flamers.h>

#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define POB pop_back

using namespace std;
bool compare(pair<int, pair<int, int>> p1, pair<int, pair<int, int>> p2){
	 return p1.S.F < p2.S.F || (p1.S.F == p2.S.F && p1.S.S <= p2.S.S);
}

bool cmp(pair<int, pair<int, int>> p1, pair<int, pair<int, int>> p2) {
	return p1.F < p2.F;
}

void fix(int x) {
	int r = 1e5;
	while(r > x) {
		cout<<0;
		r /= 10;
	}
	cout<<x;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	
	int n, m;
	cin>>n>>m;
	vector<pair<int, pair<int, int>>> v;
	for(int i = 0; i < m; i++) {
		int b, c;
		cin>>b>>c;
		v.PB({i+1, {b, c}});
	}
	sort(v.begin(), v.end(), compare);
	int k = -1;
	int r = 1;
	int ind = 0;
	while(ind < m) {
		if(v[ind].S.F != k) {
			k = v[ind].S.F;
			r = 1;
		}
		v[ind].S.S = r;
		r++;
		ind ++;
	}
	sort(v.begin(), v.end(), cmp);
	for(int i = 0; i < m; i++) {
		fix(v[i].S.F);
		fix(v[i].S.S);
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 2932
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define EPS 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f3f3f3f3f
#define MEM(a, b) memset(a, b, sizeof(a))
#define PPER(i, n, m) for (int i = n; i >= m; i--)
#define REPP(i, n, m) for (int i = n; i <= m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define PER(i, n, m) for (int i = n; i > m; i--)
#define SA(n) scanf("%d", &(n))
#define SLLA(n) scanf("%lld", &(n))
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define DE(val) cout << #val << ": " << val << endl;

const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 1, 0,-1};
const int dy4[6] = {-1, 0, 1,0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};
void update(ll& x,ll v){
    if(x==-1)x=v;
    else if(x>v)x=v;
}

ll po(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
void extgcd(ll a, ll b, ll &d, ll &x, ll &y)
{
    if (!b)
    {
        d = a;
        x = 1;
    }
    else
    {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
ll inverse(ll a, ll n)
{
    ll d, x, y;
    extgcd(a, n, d, x, y);
    return d == 1 ? (x + n) % n : -1;
}
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn = 2e3 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
/*************************************************************************/

int n,k;
void solve() {
    SA(n);
    SA(k);
    ll ans = 0;
    REPP(i, k, n + 1) {
        ll t = 1LL*(2*n - i + 1) * i / 2 - 1LL*i*(i-1)/2 + 1;
        ans += t; 
        ans %= mod;
    }
    cout<<ans<<endl;
}

int main()
{
#ifndef ONLINE_JUDGE
  //freopen("/Users/chong_wang/Desktop/ev/Code/i.txt", "r", stdin);
  //freopen("o.txt", "w", stdout);
#endif
  solve();
  return 0;
}





Measured memory_bytes: 3764
# def sign(x):
#     return (x > 0) - (x < 0)


def main():
    _ = int(input())
    a = [int(an) for an in input().split()]
    target = {1, -1}
    results = set()
    for sign in target:
        total = 0
        ans = 0
        for an in a:
            total += an
            if sign != ((total > 0) - (total < 0)):
                ans -= (total - sign) * sign
                total = sign
            sign *= -1
        results.add(ans)

    print(min(results))


if __name__ == "__main__":
    main()


Measured memory_bytes: 85536
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST

step acc x = acc + (x - acc)

solve :: Int -> VU.Vector Int -> Int
solve n vec 
  | (VU.length vec) < n = 10^9 
  | otherwise = min ((VU.last ts) - VU.head ts) (solve n ds)
  where
    ts = VU.take n vec
    ds = VU.tail vec

main = do
  [k,n] <- map read . words <$> getLine :: IO [Int]
  vec <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  let vec' = vec VU.++ (VU.map (+k) vec)
  let table = VU.scanl step 0 (VU.tail vec')
  print $ solve n table

Measured memory_bytes: 16764
fun main(arg: Array<String>) {
    val S = readLine()!!
    val B = S.mapIndexed { n, c -> S[n + (if (c == 'L') -1 else 1)] == c }
    val A = IntArray(S.length) { 1 }
    for (n in 0 until S.length) {
        if (S[n] == 'R' && B[n]) {
            A[n + 2] += A[n]
            A[n] = 0
        }
    }
    for (n in (0 until S.length).reversed()) {
        if (S[n] == 'L' && B[n]) {
            A[n - 2] += A[n]
            A[n] = 0
        }
    }
    println(A.joinToString(separator = " "))
}


Measured memory_bytes: 41216
#include <iostream>
#include <vector>
#include <cstring>
#include <cctype>
#include <string>
using namespace std;

int main(){
	vector<int>a(26, 0);
	char st;
	while (cin>>st){
		if (isalpha(st)){
			if (isupper(st))
				st = tolower(st);
			a[st - 'a']++;
		}
	}
	for (int i = 0; i <= 25; i++){
		cout << static_cast<char>(i + 'a') << " : " << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
long long gcd(long long a,long long b){
    if(a<b) swap(a,b);
    while(a%b!=0){
        swap(a,b);
        b = b%a;
    }
    return b;
}
int main(){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;   
    long long e = c*d/gcd(c,d);
    long long temans = b/c-(a-1)/c;
    temans+=b/d-(a-1)/d;
    temans+=(a-1)/e-(b)/e;
    cout << (b-a)+1-temans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	int N,f=0;
	cin >> N;
	
	for (int i = 1; i < 10; i++) {
		if (N%i == 0 && N / i < 10) {
			f = 1;
		}
	}
	if (f == 1) {
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256