akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

bool arr[100100];

void e(){
  
  for(ll i = 0; i < 100100; i++){ arr[i] = true;}
  arr[0] = false; arr[1] = false;
  
  for(ll i = 2; i < 100100; i++){
    if( arr[i] ){ 
      
      for(ll j = 2*i; j < 100100; j += i){
        arr[j] = false;}
      
    }
  }
  
  return ;
}

int main(){ 
  int X; cin >> X;
  e();
  
  for(ll i = X; ;i++){ 
    if( arr[i] ){ cout << i << endl; return 0;}
    
  }
  
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str_nums = br.readLine().split(" ");
        int[] nums = new int[3];
        nums[0] = Integer.parseInt(str_nums[0]);
        nums[1] = Integer.parseInt(str_nums[1]);
        nums[2] = Integer.parseInt(str_nums[2]);
        int count = 0;
        
        while (!(nums[0] == nums[1] && nums[1] == nums[2])) {
            Arrays.sort(nums);
            if ((nums[0] == nums[1] || nums[1] == nums[2] || nums[2] == nums[0]) && (!(nums[0] == nums[1] && nums[1] == nums[2]))) {
                if (nums[2] > nums[1]) {
                    nums[0] += 1;
                    nums[1] += 1;
                    count++;
                }
                else {
                    nums[0] += 2;
                    count++;
                }
            }
            else {
                nums[0] += 1;
                nums[1] += 1;
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22612
program r20628c
 
implicit none
integer :: c(1:26)
integer, allocatable :: interval(:, :)
integer, allocatable :: s(:, :)
integer, allocatable :: t(:), v(:)
integer :: i, j, d, m, h
integer, allocatable :: smalld(:)
integer, allocatable :: q(:)
 
 
read *, d
 
allocate(s(1:26, 1:d))
allocate(interval(1:26, 0:d))
allocate(t(1:d))
allocate(v(0:d))
 
interval(:, :) = 0 !interval(i,d) = d - last(d,i)
v(0) = 0
 
read *, c(1:26)
 
do i = 1, d
 read *, s(:, i)
end do
 
do i = 1, d 
  do j = 1, 26
  if (s(j, i) - (c(j) * interval(j, i-1)) > m) then
  m = s(j, i)
  h = j
  end if
  end do
 
print *, h
 
v(i) = h
 
 v(i) = v(i-1) + s(t(i), i)
 
 do j = 1, 26
  if(t(i) == j) then
   interval(j, i) = 0
  else
   interval(j, i) = interval(j, i-1) + 1
  end if
  v(i) = v(i) - (c(j) * interval(j, i))
 end do
 
! print *, v(i)
end do
 
end program r20628c

Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second

// 1次元vectorの出力
template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(void){
	int n; cin >> n;
	vector<ll> a(n); rep(i,n) cin >> a[i];
	vector<ll> b(n,0);
	rep(i,n-1){
		b[i+1] = a[i] * 2 - b[i];
	}
	print(b);
	b[0] = a[n-1] - b[n-1]/2;
	cout << b[0];
	rep(i, n-1){
		b[i+1] = a[i] * 2 - b[i];
		cout <<' '<< b[i+1];
	}
	cout << endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int n,m;
    int ans=0;
    cin >> n >> m;
    vector<int> hako(n,1);
    vector<bool>hakof(n,false);
    hakof[0] = true;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        hako[a]--; hako[b]++;
        if(hakof[a] == true) hakof[b] = true;
        if(hako[a] == 0) hakof[a] = false;
    }
    rep(i,n){
        if(hako[i]>0 && hakof[i] == true) ans++;
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 3740
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import copy
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  Y=sorted(X)
  ans1=Y[t-1]
  ans2=Y[t]
  median=ans1+ans2
  for i in range(N):
    s=X[i]
    if s==ans1:
      print(ans2)
    elif s==ans2:
      print(ans1)
    elif  2*s<median:
      print(ans2)
    elif 2*s>median:
      print(ans1)
  return 

main()

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

typedef long long LL;

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

int main() {
    string s;
    cin >> s;
    auto res = s == "ABC" ? "ARC" : "ABC";
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    ll x, y;
    cin >> x >> y;
    REP(i,100000){
        x *= 2;
        if (x > y){
            cout << i+1 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
nn, kk = gets.split.map(&:to_i)
vv = gets.split.map(&:to_i)

max = 0
l_sum = 0
minus_left = []

# pop from left
0.upto([kk,nn].min) do |l|
  if l > 0
    minus_left << vv[l-1] if vv[l-1]<0
    l_sum += vv[l-1]
    #puts "l:#{l_sum}"
  end

  # pop from right
  r_sum = 0
  minus_right = []
  0.upto([kk,nn].min-l) do |r|
    if r > 0
      minus_right << vv[nn-r] if vv[nn-r]<0
      r_sum += vv[nn-r]
      #puts "r:#{r_sum}\n\n"
    end

    sorted = (minus_left + minus_right).sort
    pop_sum = 0
    push_cnt = kk-(l+r)
    #puts "pus_cunt:#{push_cnt}"
    if push_cnt==0
    elsif sorted.size < push_cnt
      pop_sum = sorted.inject(:+).to_i
    else
      pop_sum = sorted[0..push_cnt-1].inject(:+).to_i
    end

    sum = l_sum + r_sum - pop_sum
    max = sum if max < sum
    #puts "max:#{max}"
  end
end


puts max


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

namespace ABC_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ci = 99;
            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'C')
                {
                    ci = i;
                    break;
                }
            }
            var fi = -1;
            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'F')
                {
                    fi = i;
                }
            }
            if (ci < fi)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
            
        }

    }
}


Measured memory_bytes: 11092
n, m = map(int, input().split())

root = [-1]*n
def r(x):
    if root[x] < 0:
        return x
    else:
        root[x] = r(root[x])
        return root[x]

def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

ans = 0
for i in range(n):
    ans = max(ans, -root[i])

print(ans)

Measured memory_bytes: 13380
N=int(input())
T,A=map(int,input().split())
mylist=list(map(int,input().split()))
mymin=10**6
index=0

for i in range(N):
  if(mymin>abs(A-(T-0.006*mylist[i]))):
    mymin=abs(A-(T-0.006*mylist[i]))
    index=i
print(index+1)


Measured memory_bytes: 38256
#include <algorithm>
#include <unordered_set>
#include <queue>
#include <iostream>
#include <vector>

using namespace std;

class Edge {
  public:
    int x;
    int y;
    int cost;
    Edge(int _x, int _y, int _cost) {
      x = _x;
      y = _y;
      cost = _cost;
    }
    Edge(const Edge& e) {
      x = e.x;
      y = e.y;
      cost = e.cost;
    }
};

bool hasLargerCost(const Edge& a, const Edge& b)
{
  return a.cost > b.cost;
}

int main()
{
  int nnode, nedge;
  cin >> nnode >> nedge;
  vector<vector<Edge>> node(nnode);
  for (int i = 0; i < nedge; i++) {
    int x, y, cost;
    cin >> x >> y >> cost;
    node.at(x).emplace_back(x, y, cost);
    node.at(y).emplace_back(x, y, cost);
  }
  vector<bool> visited(nnode, false);
  priority_queue<Edge, vector<Edge>, decltype(&hasLargerCost)> pq(&hasLargerCost);
  visited.at(0) = true;
  for (const auto& e : node.at(0)) {
    pq.emplace(e);
  }
  int res = 0;
  while (!pq.empty()) {
    auto e = pq.top();
    pq.pop();
    if (visited.at(e.x) && visited.at(e.y)) {
      continue;
    }
    int new_node;
    if (visited.at(e.y)) {
      new_node = e.x;
    } else {
      new_node = e.y;
    }
    res += e.cost;
    visited.at(new_node) = true;
    for (const auto& e : node.at(new_node)) {
      pq.emplace(e);
    }
  }
  cout << res << '\n';
  return 0;
}



Measured memory_bytes: 10096
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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 Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll ans=0;
  if(x>=y){
    ans+=y*min(a+b,c*2);
    ans+=(x-y)*min(c*2,a);
  }else{
    ans+=x*min(a+b,c*2);
    ans+=(y-x)*min(c*2,b);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a=(s[0]-'0')*10+s[1]-'0';
	int b=(s[2]-'0')*10+s[3]-'0';
	if(a>=1&&a<=12&&b>=1&&b<=12){
		puts("AMBIGUOUS");
	}
	else if(a>=1&&a<=12){
		puts("MMYY");
	}
	else if(b>=1&&b<=12){
		puts("YYMM");
	}
	else puts("NA");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int a, b;
    cin >> a >> b;
    cout << round_up(a + b, 2) << endl;
    return 0;
}

Measured memory_bytes: 256
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    int n; cin>>n;

    vi a(n);
    for(int &x : a)cin>>x;

    vi lc(n), rc(n);

    for(int i = 0; i < n; i++){
        int left = max(0, i - a[i]);
        int right = min(n-1, i + a[i]);
        lc[left]++, rc[right]++;
    }

    ll ans = 0;

    for(int i = 0; i < n; i++){
        ans += (ll)lc[i] * rc[i];
    }

    cout<<ans<<"\n";


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 5556
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   string n;
   cin >> n;
   int cnt = 0;
   for(int i=1;i<=stoi(n);i++){
      if((to_string(i).size())%2 != 0) cnt++;
   }

   cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 256
s = str(input())
ans = 0
for i in range(1 << (len(s)-1)):
    si = s[0]
    for j in range(len(s)-1):
        if i & (1 << j):
            si += "+"+s[j+1]
        else:
            si += s[j+1]
    ans += eval(si)
print(ans)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
from collections import deque
N, M = map(int, input().split())
C = [list(map(int, input().split())) for i in range(M)]

def bfs(now):
    plan = deque([])
    plan.append(now)
    visited[now][0] = True
    while plan:
        now = plan.popleft()
        for i in PATH[now]:
            if visited[i][0] == True:
                continue
            else:
                plan.append(i)
                visited[i][0] = True
                visited[i][1] = now

if __name__ == '__main__':
    PATH = [deque([]) for i in range(N+1)]
    
    for i in range(M):
        PATH[C[i][0]].append(C[i][1])
        PATH[C[i][1]].append(C[i][0])
    visited = [[False,0] for i in range(N+1)]
    bfs(1)
    print("Yes")
    for i in range(2,N+1):
        print(visited[i][1])

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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
    string s;
    while(1){
        getline(cin,s);
        if(s=="0")break;
        s+=" ";
        vector<string> st;
        string buf="";
        rep(i,s.size()){
            if(s[i]!=' ')buf+=s[i];
            else{
                st.pb(buf);
                buf="";
            }
        }
        
        int score=0;
        int c=0;
        rep(i,st.size()){
            if(st[i]!="1"){
                int num=stoi(st[i]);
                if(10<=num)score+=10;
                else score+=num;
            }
            else{
                score+=1;
                c++;
            }
        }
        rep(i,c){
            if(21-score>=10)score+=10;
        }
        if(score>21)cout<<"0"<<endl;
        else cout<<score<<endl;
    }
}

Measured memory_bytes: 1208
Scanf.scanf "%d" (fun d ->
    let c = Array.init 26 (fun _ -> Scanf.scanf " %d" (fun c -> c)) in
    let s = Array.init d (fun _ ->
        Array.init 26 (fun _ ->
            Scanf.scanf " %d" (fun s -> s)))
    in
    let last = Array.make 26 (-1) in
    let f a = a * (a - 1) / 2 in
    for i = 0 to d - 1 do
        let rec loop j mi mx =
            if j = 26 then (last.(mi - 1) <- i; Printf.printf "%d\n" mi) else
                let g = s.(i).(j) + c.(j) * (i - last.(j)) in
                if g > mx then loop (j + 1) (j + 1) g else loop (j + 1) mi mx
        in
        loop 0 0 0
    done
)

Measured memory_bytes: 6024
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int main()
{
	int x[5] = {0}, i = 0;
	for (i = 0; i < 5; i++) {
		scanf("%d", &x[i]);
	}
	int ans = 0;
	for (i = 0; i < 5; i++) {
		if (x[i] == 0) {
			ans = i + 1;
			break;
		}
	}
	printf("%d\n", ans);
	//yesno(ans);
	//okng(ans);
	return 0;
}


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

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N);
	for(int i=0;i<N;i++){
		cin >> a.at(i);
	}
	// if(N==2){
		// cout<<llabs(a.at(0)-a.at(1))<<endl;
	// }
	// else{
		vector<ll> sum(N);
		sum.at(0)=a.at(0);
		for(int i=1;i<N;i++){
			sum.at(i)=sum.at(i-1)+a.at(i);
		}
		ll asum=sum.at(N-1);
		ll ans=10000000000000000;
		for(int i=0;i<N-1;i++){
			// cout<<"sum:"<<sum.at(i)<<endl;
			ll K=llabs(asum-sum.at(i)-sum.at(i));
			if(K<ans){
				ans=K;
			}
			
		}
		// cout<<"sum;"<<sum.at(N-1)<<endl;
		// cout<<"asum;"<<asum<<endl;
		cout<<ans<<endl;
	// }
}

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


int main(){
    int K;
    string S;

    cin >> K >> S;
    if(S.size()<=K)
        cout << S << endl;
    else {
        S.erase(K);
        cout << S << "..." << endl;
    }

    return 0;
}


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

int main() {
  int N,M,total =0; cin >> N;
  int T[N]; 
  for (int i =0; i<N; i++) {
    cin >> T[i]; total += T[i];
  }
  cin >> M;
  int P[M],X[M]; for (int i =0; i<M; i++) cin >> P[i] >> X[i];
  
  for (int i =0; i<M; i++) {
    cout << total - T[P[i] -1] + X[i] << endl;
  }
}

Measured memory_bytes: 3584
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (PrintWriter out = new PrintWriter(System.out); Scanner sc = new Scanner(System.in);) {
			Task task = new Task();
			task.solve(sc, out);
			out.flush();

		} catch (Exception e) {

		}

	}

	static class Task {
		public void solve(Scanner sc, PrintWriter out) {
			long a = nlong(sc);
			long b = nlong(sc);

			if (b <= 0) {
				out.print(0);
				return;
			}
			if (a < b) {
				out.print(1);
				return;
			}
			if (a % b != 0) {
				out.print(1);
			} else {
				out.print(0);
			}

		}
	}

	// method
	static int nint(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static long nlong(Scanner sc) {
		return Long.parseLong(sc.next());
	}

	static double ndouble(Scanner sc) {
		return Double.parseDouble(sc.next());
	}

	static float nfloat(Scanner sc) {
		return Float.parseFloat(sc.next());
	}

	static String nstr(Scanner sc) {
		return String.valueOf(sc.next());
	}

	static long[] longLine(Scanner sc, int size) {
		long[] lLine = new long[size];
		for (int i = 0; i < size; i++) {
			lLine[i] = nlong(sc);
		}
		return lLine;
	}

	static int[] intLine(Scanner sc, int size) {
		int[] iLine = new int[size];
		for (int i = 0; i < size; i++) {
			iLine[i] = nint(sc);
		}
		return iLine;
	}

	static String[] strLine(Scanner sc, int size) {
		String[] strLine = new String[size];
		for (int i = 0; i < size; i++) {
			strLine[i] = nstr(sc);
		}
		return strLine;
	}

	static long maxFromList(List<Long> longList) {
		return longList.stream().max(Comparator.naturalOrder()).get();
	}

	static long minFromList(List<Long> longList) {
		return longList.stream().min(Comparator.naturalOrder()).get();
	}

	public static int sumDigits(int n) {
		int sum = 0;
		while (n != 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}

	public static long sumDigits(long n) {
		long sum = 0;
		while (n != 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}

	static List<Integer> getIntegerList(Scanner sc, int size) {
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < size; i++) {
			list.add(nint(sc));
		}
		return list;
	}

	static List<Long> getLongList(Scanner sc, int size) {
		List<Long> list = new ArrayList<>();
		for (int i = 0; i < size; i++) {
			list.add(nlong(sc));
		}
		return list;
	}
}


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

using namespace std;

#define int long long

void solve() {
    int n, x;
    cin >> n >> x;
    x *= x;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        if (a * a + b * b <= x) ++ans;
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

int main(void)
{
    int h = 0;
    int m = 0;
    int s = 0;
    int x;
    cin >> x;
    s = x % 60;
    m = x / 60;
    h = m / 60;
    m = m % 60;
    
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3124
mod = 10**9+7
import sys
import math
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations, combinations_with_replacement
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# def combinations(n, r):
# 	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# def gcd(a, b):
# 	if b == 0:
# 		return a
# 	else:
# 		return gcd(b, a%b)
 
# def lcm(a, b):
# 	return a // gcd(a, b) * b

# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))

A,B,H,M = MI()

d = abs(30*H - (330 * M / 60))
d = min(d,360-d)

ans = math.sqrt(A**2 + B**2 - 2*B*A*math.cos(math.radians(d)))

print(ans)


















Measured memory_bytes: 9952
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }
 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    string s;
    unordered_map<char, int> hash;

    cin >> s;

    for (int i = 0; i < s.size(); i++)
        hash[s[i]]++;

    int cnt = 0;
    for (auto it = hash.begin(); it != hash.end(); it++)
        if (it->second == 2) cnt++;

    if (cnt == 2) cout << "Yes\n";
    else cout << "No\n";
 
    return 0;
}

Measured memory_bytes: 384
#include<cstdio> 
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=3000+10,mo=1000000007;
int f[maxn][maxn],right[maxn],sum[maxn];
int i,j,k,l,r,t,n,m,ans,one,zero;
char get(){
	char ch=getchar();
	while (ch!='0'&&ch!='1') ch=getchar();
	return ch;
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n) sum[i]=get()-'0';
	fo(i,1,n+1) sum[i]+=sum[i-1];
	fo(i,1,n+1) right[i]=i;
	fo(i,1,m){
		scanf("%d%d",&j,&k);
		right[j]=max(right[j],k);
	}
	fo(i,1,n) right[i]=max(right[i],right[i-1]);
	f[1][sum[right[1]]]=1;
	fo(i,1,n)
		fo(j,0,n)
			if (f[i][j]){
				l=right[i]+1;r=right[i+1];
				one=j;zero=right[i]-i+1-j;
				if (zero) (f[i+1][j+sum[r]-sum[l-1]]+=f[i][j])%=mo;
				if (one) (f[i+1][j-1+sum[r]-sum[l-1]]+=f[i][j])%=mo;
			}
	ans=f[n+1][0];
	(ans+=mo)%=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 33792
n=int(input())
a=[]
candies=[]
for i in range(2):
    a1=list(map(int,input().split()))
    a.append(a1)
for i in range(n):
    candy=sum(a[0][:i+1])+sum(a[1][i:])
    candies.append(candy)
print(max(candies))

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
    ll x;
    cin >> x;
    ll ans = x/11 * 2;
    x %= 11;
    if(x > 6)
    {
      ans += 2;
    }
    else if (x > 0)
    {
        ans++;
    }

    cout << ans << endl;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

int main(void){
    int n;
    cin >> n;
    while(n != 0){
        VI imos(86402,0);
        REP(i,n){
            string a,b; cin >> a >> b;
            auto va = split(a,':');
            auto vb = split(b,':');
            int s = 3600*toInt(va[0]) + 60*toInt(va[1]) + toInt(va[2]);
            int t = 3600*toInt(vb[0]) + 60*toInt(vb[1]) + toInt(vb[2]);
            imos[s]++; imos[t]--;
        }
        int ans = 0, now = 0;
        REP(i,86402){
            now += imos[i];
            chmax(ans, now);
        }
        cout << ans << en;
        cin >> n;
    }
    return 0;
}


Measured memory_bytes: 3520
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

		while (true) {
			String input = sc.nextLine();

			if("0".equals(input)){
				break;
			}
			
			long sum = 0;
			for (char c : input.toCharArray()) {
				sum += (c - '0');
			}
			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 17464
#!/usr/bin/env python3

N = int(input())
A = [0] + list(map(int, input().split())) + [0]
distance = 0
Ret = []
for i in range(len(A)-1):
    distance += abs(A[i]-A[i+1])

for i in range(1, N+1):
    ret = distance + abs(A[i-1]-A[i+1]) - (abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))
    Ret.append(ret)

for r in Ret:
    print(r)


Measured memory_bytes: 20628
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD=1e9+7;
const int INF=1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m=MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------// 
void solve(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto &it:v)cin>>it;
    sort(all(v));
    int mid=n;
    mid>>=1;
    int ret=v[mid]-v[mid-1];
    cout << ret <<  endl;	
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


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

int main(void) {
    int H,A;
    cin >> H >> A;
    if(H < A){
 cout << "1\n";
    return 0;
}
    if(H%A) cout << H/A + 1 << "\n";
    else cout << H/A  << "\n";
    return 0;
}


Measured memory_bytes: 256
N=int(input())
S=input()

ans=S.count("R")*S.count("G")*S.count("B")

#j-i= k-j k=2*j-i

for i in range(N):
  for j in range(i+1,N):
    if 2*j-i>=N:
      break
      
    if S[i]!=S[j] and S[i]!=S[2*j-i] and S[j]!=S[2*j-i]:
      ans -=1
        
print(ans)
      
    
    

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int h,w,K;
  cin >> h >> w >> K;
  vector<string> s(h);
  rep(i,h)cin >> s[i];
  int res = 0;
  for(int i = 0;i < (1 << h);i++){
    for(int j = 0;j < (1 << w);j++){
      vector<string> k = s;
      int cnt = 0;
      rep(g,h)if(i >> g & 1)k[g] = string('1',w);
      rep(g,w)if(j >> g & 1)rep(l,h)k[l][g] = '1';
      rep(l,h)rep(r,w)if(k[l][r] == '#')cnt++;
      if(cnt == K)res++;
    }
  }
  cout << res << endl;



  return 0;
}

Measured memory_bytes: 3604
def get_num(n, x):
    ans = 0
    for n3 in range(min(n, x), (x + 2) / 3, -1):
        for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1):
            for n1 in range(n2 - 1, 0, -1):
                s = n1 + n2 + n3
                if s < x:
                    break
                elif s == x:
                    ans += 1
                    break
    return ans


while True:
    [n, x] = [int(m) for m in raw_input().split()]
    if [n, x] == [0, 0]:
        break
    if x == 0:
        print(0)
    else:
        print(get_num(n, x))

Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
vector<ll> divs(ll n){
	vector<ll>ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i==n){
				ret.push_back(i);
			}
			else{
				ret.push_back(i);
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
void solve(){
	ll n,i,x;
	cin>>n;
	ll ans=0;
	nfl(i,n){
		cin>>x;
		if(x%2 && (i+1)%2){
			ans++;
		}
	}
	cout<<ans<<endl;
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	

Measured memory_bytes: 3656
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(H: int, A: int):
    from math import ceil
    print(ceil(H/A))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(H, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,t;cin>>n>>t;
    vector<ll> a(n);
    ll maxv=-1,minv=1e+9+1;
    rep(i,n){
        cin>>a[i];
        chmax(maxv,a[i]-minv);
        chmin(minv,a[i]);
    }
    //最大利益はmaxv*t;
    ll res=0;
    ll buf=maxv;
    maxv=-1,minv=1e+9+1;
    rep(i,n){
        chmax(maxv,a[i]-minv);
        chmin(minv,a[i]);
        if(buf==a[i]-minv) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  bool zero = false;
  long long res = 1, input;
  vector<long long> numbers;
  for (int i = 0; i < n; ++i) {
  	cin >> input;
  	if (!input) {
  		zero = true;
  		break;
  	}
  	numbers.push_back(input);
  }
  if (zero)
	res = 0;
  else {
  	  for (int i = 0; i < n; ++i) {
	      if (res > 1000000000000000000 / numbers[i]) {
	          res = -1;
	          break;
	      }
          res *= numbers[i];
      }
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 4292
m = {"M"=>0,"A"=>0,"R"=>0,"C"=>0,"H"=>0,}
gets.to_i.times do
  s = gets.chomp[0]
  if "MARCH".include?(s)
    m[s] += 1
  end
end
ans = 0
m = m.to_a
for i in 0..2
  for j in i+1..3
    for k in j+1..4
      ans += m[i][1]*m[j][1]*m[k][1]
    end
  end
end
puts ans

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

int main(void){
	ll A, B, C, K;
	cin >> A >> B >> C >> K;

	if (K <= A) cout << K << endl;
	else if (A < K && K < (A+B)) cout << A << endl;
	else cout << A - (K - A - B) << endl;
return 0;
}


Measured memory_bytes: 3604
from itertools import product
from sys import exit, stdin

N, M = [int(_) for _ in stdin.readline().rstrip().split()]
xyz = [list(map(int, stdin.readline().rstrip().split())) for i, _ in enumerate(range(N))]

ans = 0
sign = [1, -1]
for xs, ys, zs in product(sign, repeat=3):
    tmp = []
    for x, y, z in xyz:
        tmp.append(x*xs + y*ys + z*zs)
    tmp.sort(reverse=True)
    ans = max(ans, sum(tmp[:M]))
print(ans)

Measured memory_bytes: 3444
#include <stdio.h>
#include <string.h>
#define W 1000
#define H 1000
#define MOD 1000000007

long long dp[W][H];

int main(){
  int h,w;
  int i,j;
  scanf("%d %d", &h, &w);
  char s[1000][1000];
  for(i=0;i<h;i++)scanf("%s", s[i]);

  int p_h = 0;
  int p_w = 0;
  dp[0][0]=1;
  for(i=0;i<w;i++){
    if(!(strncmp(&s[0][i],"#",1)))break;
    dp[0][i]=1;
  }

  for(i=0;i<h;i++){
    if(!(strncmp(&s[i][0],"#",1)))break;
    dp[i][0]=1;
  }



  for(i=1;i<h;i++){
    for(j=1;j<w;j++){
      if((strncmp(&s[i][j], "#", 1)))dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;

    }
  }

  

  printf("%d\n", dp[h-1][w-1]);



  return 0;
}


Measured memory_bytes: 8960
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	double L, base;
	cin >> L;
	base = L / 3;
	cout << fixed << setprecision(12);
	cout << base * base * base << '\n';
	return 0;
}


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

using namespace std;

int main() {
	int n;
	
	scanf("%d", &n);
	
	int flag = 0;
	
	int head = n / 100, tail = n % 100;
	
	if((head == 0 && (tail == 0 || tail > 12) 
	|| (tail == 0 && (head == 0 || head > 12) ) ) ){
	    printf("NA");
	    return 0;
	}
	if(head > 12 && tail > 12){
	    printf("NA");
	    return 0;
	}
	
	if(head < 13 && head != 0) flag += 1;
	if(tail < 13 && tail != 0) flag += 2;
	
	if(flag == 3) printf("AMBIGUOUS");
	if(flag == 2) printf("YYMM");
	if(flag == 1) printf("MMYY");
}


Measured memory_bytes: 256
#include<math.h>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point
{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) {return Point(x + p.x, y + p.y); }
    Point operator - (Point p) {return Point(x - p.x, y - p.y); }
    Point operator * (double a) {return Point(x * a, y * a);}
    Point operator / (double a) {return Point(x / a, y / a);}

    double abs() {return sqrt(norm());}
    double norm() {return x * x + y * y;}
    
    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
};typedef Point Vector;

struct Segment {
    Point p1, p2;
};

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b){
    return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
    return isOrthogonal(a1 - a2, b1 - b2);
}

bool isParallel(Vector a, Vector b){
    return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
    return isParallel(a1 - a2, b1 - b2);
}

#include<iostream>
int main(){
    int q, dots[8];
    std::cin >> q;
    for (int i = 0; i < q; i++)
    {
        for (int i = 0; i < 8; i++)
            std::cin >> dots[i];
        Point a1 = Point(dots[0], dots[1]);
        Point a2 = Point(dots[2], dots[3]);
        Point b1 = Point(dots[4], dots[5]);
        Point b2 = Point(dots[6], dots[7]);
        if (isParallel(a1, a2, b1, b2))
            std::cout << 2 << std::endl;
        else if (isOrthogonal(a1, a2, b1, b2))
            std::cout << 1 << std::endl;
        else
            std::cout << 0 << std::endl;
    }   
}


Measured memory_bytes: 3108
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n, k = map(int, input().split())
    as_ = list(map(int, input().split()))

    print(1 + (n - k + k - 1 - 1) // (k - 1))

if __name__ == '__main__':
    main()

Measured memory_bytes: 14188
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

h,w = inpl()
d = [inpl() for _ in range(10)]
a = [inpl() for _ in range(h)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])
res = 0
for i in range(h):
    for j in range(w):
        now = a[i][j]
        if now == -1:
            continue
        res += d[now][1]
        # print(res,now)
print(res)

Measured memory_bytes: 66520
#include<cstdio>
int main(){
	int a,b,c,d,e,i;
	int n;
	while(~scanf("%d%d",&a,&b))
	{	d=0;e=1;
		for(i=0;i<a;i++)
		{
			scanf("%d",&n);
	
			d+=n;
			if(d<=b)
			e+=1;
		}
		printf("%d\n",e);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb emplace_back

inline void print(){return;} 
template <typename T, typename... Types> 
inline void print(T var1,Types... var2){cout<<var1<<" ";print(var2...);} 

inline void println(){cout<<"\n";} 
template <typename T, typename... Types> 
inline void println(T var1,Types... var2){cout<<var1<<" ";println(var2...);}

int mod=1e9+7;

main()
{
    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    string s;
    cin>>s;

    for(int i=1;i<4;i++)
    {
        if(s[i]==s[i-1])
        {
            print("Bad");
            return 0;
        }
    }
    print("Good");
}

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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int t1,t2,a1,a2,b1,b2;cin>>t1>>t2>>a1>>a2>>b1>>b2;
  a1-=b1;a2-=b2;
  if(a1>0)a1*=-1,a2*=-1;
  int A=t1*a1+t2*a2,B=-t1*a1;
  if(A<0)fin(0);
  if(!A)fin("infinity");
  fin(B/A+(B-1)/A+1);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    public static void Main(string[] args){
    var vals = Console.ReadLine().Split().Select(x => long.Parse(x)).ToList();
    var A=vals[0];
    var B=vals[1];
    var C=vals[2];
    var D=vals[3];
    Console.WriteLine(divide(B,C,D)-divide(A-1,C,D));
    }
static long divide(long N, long C, long D){
    var CD=Lcm(C,D);
return N-N/C-N/D+N/CD;
}

    static long Gcd(long a, long b)
 {
     var v = new[] { a, b };
     while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
     return v[0];
 }
  static long Lcm(long a, long b)
 {
     return a / Gcd(a, b) * b;
 }

    
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,ans=0;
    scanf("%d %d",&n,&k);
    vector<int> d(k);
    bool s[10]={0};
    bool f=0;
    for (auto&e:d) scanf("%d",&e);
    for (int i=0;i<k;i++) s[d[i]]=1;
    for (int i=n;;i++) {
        ans=i;
        f=1;
        if (ans>9999 && s[ans/10000]) f=0;
        if (ans>999 && s[(ans%10000)/1000]) f=0;
        if (ans>99 && s[(ans%1000)/100]) f=0;
        if (ans>9 && s[(ans%100)/10]) f=0;
        if (s[ans%10]) f=0;
        if (f) break;
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;
typedef long long ll;
#define FOR(i, l, r) for(ll i = l; i <= r; i++)
ll a[15][15];

bool scp(ll n){
    ll x = sqrt(n);
    if(x * x < n) return false;
    else return true;
}

int main(){
    ll n, d; cin >> n >> d;
    FOR(i, 1, n){
        FOR(j, 1, d) cin >> a[i][j];
    }
    ll ans = 0;
    FOR(i, 1, n){
        FOR(j, i + 1, n){
            ll num = 0;
            FOR(k, 1, d){
                num += pow(a[i][k] - a[j][k], 2);
            }
            if(scp(num) == true) ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 900000000000000000
signed main(void) {
    int n;cin>>n;
    bool ans=false;
    rep(i,n/4+1){
        if((n-i*4)%7==0){
            ans=true;
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    System.out.print(n+":");
    for(int i=2;i<=Math.sqrt(n);i++){
      while(n%i==0){
        System.out.print(" "+i);
        n/=i;
      }
    }
    if(n!=1) System.out.print(" "+n);
    System.out.println();
  }
}



Measured memory_bytes: 26296
"""ABC133_D"""
n = int(input())
a = list(map(int,input().split()))
x = [0]*n
for i in range(n):
    if i%2 == 0:
        x[0] += a[i]
    else:
        x[0] -= a[i]
x[0] = x[0] // 2
for i in range(n-1):
    x[i+1] = a[i] - x[i]
for i in range(n):
    print(x[i]*2,end=" ")
print()

Measured memory_bytes: 64228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<bool, bool>> hune(n, {false, false});
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (a == 0) hune[b].first = true;
        if (b == n - 1) hune[a].second = true;
    }
    string ans = "IMPOSSIBLE";
    for (int i = 0; i < n; i++) {
        if (hune[i].first and hune[i].second) ans = "POSSIBLE";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3796