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

typedef long long ll;
typedef unsigned long long ull;

#define int ll

typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

#define MAX_V 2010

struct edge{
  int to,cap,cost,rev;
};

int V;
vector<edge> g[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void init(int v){
  V=v;
  for(int i=0;i<MAX_V;i++){
    g[i].clear();
  }
}

void add_edge(int from,int to,int cap,int cost){
  g[from].push_back((edge){to,cap,cost,(int)g[to].size()});
  g[to].push_back((edge){from,0,-cost,(int)g[from].size()-1});

  //printf(" %lld -> %lld : %lld \n", from,to,cost);
}

int min_cost_flow(int s,int t,int f){
  int res=0;
  memset(h,0,sizeof(h));
  while(f>0){
    priority_queue<P,vector<P>,greater<P> > que;
    fill(dist,dist+V,INF);
    dist[s]=0;
    que.push(P(0,s));
    while(que.size()){
      P p=que.top(); que.pop();
      int v=p.second;
      if(dist[v]<p.first)continue;
      for(int i=0;i<(int)g[v].size();i++){
        edge e=g[v][i];
        if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
          dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
          prevv[e.to]=v;
          preve[e.to]=i;
          que.push(P(dist[e.to],e.to));
        }
      }
    }
    if(dist[t]==INF)return -1;
    for(int v=0;v<V;v++) h[v]+=dist[v];

    int d=f;
    for(int v=t;v!=s;v=prevv[v]){
      d=min(d,g[prevv[v]][preve[v]].cap);
    }
    f-=d;
    res+=d*h[t];
    for(int v=t;v!=s;v=prevv[v]){
      edge &e=g[prevv[v]][preve[v]];
      e.cap-=d;
      g[v][e.rev].cap+=d;
    }
  }
  return res;
}

int sgnx[]={+1,-1,-1,+1};
int sgny[]={+1,+1,-1,-1};

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

  int N;
  cin>>N;

  init(2*N+4+2);
  int typv=2*N;
  int source=2*N+4,sink=2*N+5;
  int sum=0;

  rep(i,N){
    int x,y,c;
    cin>>x>>y>>c;
    sum+=c;
    add_edge(source,i,c,0);

    rep(j,4){
      add_edge(i,typv+j,INF,-(sgnx[j]*x+sgny[j]*y));
    }
  }

  rep(i,N){
    int x,y,c;
    cin>>x>>y>>c;
    add_edge(i+N,sink,c,0);

    rep(j,4){
      int nj=(j+2)%4;
      add_edge(typv+j,i+N,INF,-(sgnx[nj]*x+sgny[nj]*y));
    }
  }

  cout<<-min_cost_flow(source,sink,sum)<<endl;

  return 0;
}


Measured memory_bytes: 36072
def main():
    n, m = [int(e) for e in input().split()]
    AB = [[int(e) for e in input().split()] for i in range(n)]

    AB.sort(key=lambda x: x[0])
    ans = 0
    cnt = 0
    for ab in AB:
        cnt += ab[1]
        ans += ab[0]*ab[1]
        if cnt >= m:
            ans -= ab[0]*(cnt - m)
            break

    print(ans)

if __name__ == "__main__":
    main()


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

a = [0]*N
b = [0]*N

for i in range(N):
    a[i],b[i] = map(int,input().split())

x = [0]*M
y = [0]*M

for  i in range(M):
    x[i],y[i]= map(int,input().split())

for i in range(N):
    dis = 10000000000000000
    res = 0
    for j in range(M):
        if dis > (abs(a[i]-x[j])+abs(b[i]-y[j])):
            dis = min(dis,(abs(a[i]-x[j])+abs(b[i]-y[j])))
            res = j

    print(res+1)


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

int main(void){
    int a, b, i = -1, n = 0, count = 0;
    
    cin >> a;
    vector<int> tab(a);
    while (++i < a)
    {
        cin >> b;
        tab.at(i) = b;
    }
    i = -1;
    while (++i < a)
    {
        count++;
        if ((n = tab.at(n) - 1) == 1)
        {
            cout << count << endl;
            return (0);
        }
    }
    cout << -1 << endl;
    return (0); 
}


Measured memory_bytes: 640
#include <stdio.h>

int main (void) {
  int N, ans;

  scanf ("%d", &N);

  if (N < 10) {
    ans = N;
  } else if (N > 9 && N < 100) {
    ans = 9;
  } else if (N > 99 && N < 1000) {
    ans = N - 90;
  } else if (N > 999 && N < 10000) {
    ans = 909;
  } else if (N > 9999 && N < 100000) {
    ans = N - 9090;
  } else if (N == 100000) {
    ans = 90909;
  }

  printf ("%d", ans);
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long  ballsLeft = n% (a+b);
        long times = n / (a+b);
        if (ballsLeft >= a) {
            System.out.println(a * (times + 1));
        }
        else {
            System.out.println(a * (times) + (ballsLeft));
        }
    }
}

Measured memory_bytes: 25044
def main():
    import sys
    input = sys.stdin.readline

    mod = 10**9+7
    # comb init
    nmax = 10 ** 5 + 1  # change here
    fac = [0] * (nmax + 1)
    finv = [0] * (nmax + 1)
    inv = [0] * (nmax + 1)
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    N = int(input())
    X = list(map(int, input().split()))

    Y = [0] * (N-1)
    for i in range(N-1):
        Y[i] = X[i+1] - X[i]

    dp = [0] * (N-1)
    cs = [0]
    for i in range(N-1):
        dp[i] = ((cs[i] * inv[i+1])%mod + 1)%mod
        cs.append(cs[-1] + dp[i])
    ans = 0
    for i in range(N-1):
        ans = (ans + ((dp[i] * Y[i])%mod * fac[N-1])%mod)%mod

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 78104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <numeric>

using namespace std;
typedef long long ll;

bool is_prime(ll n){
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++){
        if (n % i == 0 ) return false;
    }
    return true;
}

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

    vector<double> value(N);
    vector<string> unit(N);

    for (int i = 0; i < N; i++){
        cin >> value[i] >> unit[i];
    }

    double y = 0.0;
    for (int i = 0; i < N; i++){
        if (unit[i] == "JPY") y += value[i];
        else y += value[i] * 380000.0;
    }

    cout << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if( a == b ){
    cout << c << endl; 
    return 0;
  }
  if( a == c ){
    cout << b << endl;
    return 0;
  }
  if( b == c ){
    cout << a << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>

using namespace std;

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

    if (N % (D * 2 + 1) == 0)
    {
        cout << N / (D * 2 + 1) << endl;
    }
    else
    {
        cout << N / (D * 2 + 1) + 1 << endl;
    }

}

Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main(){
  int n; 
  set<string> g;
  string s;
  cin >> n;
  for(int i = 0; i < n; i++){
      cin >> s;
      g.insert(s);
  }
  cout << g.size() << endl;
}

Measured memory_bytes: 19228
#include<iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int llint;
using namespace std;


int main() {
	int n,k,a;
	cin >> n >> k;
	int d,ita[n];
  	rep(i,n){ ita[i]=0 ;} 
  	rep(i,k){
      	cin >> d;
     	rep(j,d){
         	cin >> a;
          	ita[a-1]++ ;
        }
    }
  	int ans=0;
  	rep(i,n){
      if(ita[i]==0){
       	ans++; 
      }
    }
	cout << ans;   
	return 0;
}

Measured memory_bytes: 3628
#import numpy as np
from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n,k,*a=map(int,open(0).read().split())
    a=array(a)
    b=0
    c=0
    for i in range(1,n):
        ac=array(a[i:])
        b+=len(ac[ac<a[i-1]])
    for i in range(n):
        c+=len(a[a<a[i]])
    print( (b*k+c*k*(k-1)//2) % (10**9+7) )
if __name__ == '__main__':
    main()

Measured memory_bytes: 22748
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string t;
	string box[3]={"that","this","the"};
	int i;
	int flg;
	int x,n;
	while(1){
		getline(cin,t);
		if(cin.eof()==1)	break;
		flg=0;
		n=26;
		while(n--){
			for(i=0;i<(int)t.size();i++){
				if('a'<=t[i]&&t[i]<='z')	t[i]+=1;
				if(t[i]=='{')				t[i]='a';
			}
			//cout<<t<<endl;
			for(i=0;i<3;i++){
				x=(int)t.find(box[i]);
				if(x!=-1){
					flg=1;
					break;
				}
			}
			if(flg==1)	break;
		}
		cout<<t<<endl;
	}
	return 0;
}	


Measured memory_bytes: 3164
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
    long answer = 0;
    long[] divideNum = new long[1000];//素因数の個数

    for(int i = 0; i < 100; i++) divideNum[i] = 1;
    
    for(int i = 2; i <= n; i++)
    {
    int ii = i;//iを直接使うと、割られてしまい無限ループなのでiiとする
      for(int j = 2; j <= ii; j++)
      {
        while(ii % j == 0)
        {
        divideNum[j]++;//素因数を加算
        ii /= j;
        if(ii == 1) break;
        }
      }
    }

    for(int i = 2; i < 50; i++)
    {
    //Console.WriteLine(divideNum[i]+" "+i);
      for(int j = i+1; j < 50; j++)
      {
        for(int k = j+1; k < 50; k++)
        {
          if(divideNum[i] > 4 && divideNum[j] > 4 && divideNum[k] > 2) answer++;
          if(divideNum[i] > 4 && divideNum[j] > 2 && divideNum[k] > 4) answer++;
          if(divideNum[i] > 2 && divideNum[j] > 4 && divideNum[k] > 4) answer++;
          if(divideNum[i] > 14 && divideNum[j] > 4 && k == 49) answer++;
          if(divideNum[i] > 4 && divideNum[j] > 14 && k == 49) answer++;
          if(divideNum[i] > 24 && divideNum[j] > 2 && k == 49) answer++;
          if(divideNum[i] > 2 && divideNum[j] > 24 && k == 49) answer++;
          if(divideNum[i] > 74 && j == 48 && k == 49) answer++;
        }
      }
    }
    
		Console.WriteLine(answer);
	}

}

Measured memory_bytes: 13124
var lines =[];


var readline = require("readline");
var rl = readline.createInterface({
  input:  process.stdin,
  output: process.stdout
});

rl.on('line',function(x){
  lines.push(x);
});

rl.on('close',function(){

  var date = lines[0].split("/");
  var year = Number(date[0]);
  var month= Number(date[1]);
  var day= Number(date[2]);

  if(year<=2019&&month<=4){console.log("Heisei");}
  else if(year<2019){console.log("Heisei");}
  else{console.log("TBD");}
  
});

Measured memory_bytes: 21320
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <regex>
#include <cmath>

using namespace std;

int main() {
    int x, tmp;
    cin >> x;

    tmp = 1;
    for (int i = 1; i <= x; ++i) {
        for (int j = 2; pow(i,j) <= x && j <= x; ++j) {
            tmp = max(tmp, (int)pow(i,j));
        }
    }

    cout << tmp << endl;

    return 0;
}

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

/*求める三角形の成立条件
辺a,b,c(ただし、a<b<c とする)についてa+b>c
*/
/*方針：配列を先にソートし、
「すべて異なる」かつ「a+b>c」が成立する場合のみインクリメントする。
※計算量はO(N^3)となる。
*/

int main(){
  int N;
  cin >> N;
  vector<int> rod(N);
  rep(i,N) cin >> rod[i];
  
  sort(rod.begin(),rod.end());
  int ans=0;
  
  rep(i,N){
    rep(j,i){
      rep(k,j){
        if(rod[k]!=rod[j] and rod[j]!=rod[i] and rod[k]+rod[j]>rod[i]) ans++;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
  
  
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int d = abs(i - j);
      chmin(d, abs(i - x) + 1 + abs(j - y));
      chmin(d, abs(i - y) + 1 + abs(j - x));
      ans[d]++;
    }
  }
  for (int i = 1; i < n; i++) { cout << ans[i] << endl; }
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


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

using namespace std;

int main()
{
    int n;
    string str[1000];
  
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> str[i];
    }

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j != i) {
                if (str[i] == str[j]) {
                    cout << "No" << endl;
                    return (0);
                }
            }
        }

        if (str[i][0] != str[i-1].back()) {
            cout << "No" << endl;
            return (0);
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int ascSort(const void* v1, const void* v2);

int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 > _v2 ) {
        return 1;
    } else if ( _v1 < _v2 ) {
        return -1;
    } else {
        return 0;
    }
}

int main(void){
  int N, L[2*1000];
  int a, b, c, i;
  int ans = 0;
  
  scanf("%d", &N);
  for(i = 0; i < N; i++){
    scanf("%d", &L[i]);
  }
  
  qsort(L, N, sizeof(L[0]), ascSort);
  
  for(a = 0; a < N; a++){
    for( b = a + 1; b < N; b++){
      for( c = b + 1; (c < N) && (L[c] < L[a] + L[b]); c++){
        if((L[a] < L[b] + L[c]) && (L[b] < L[a] + L[c]) && (L[c] < L[a] + L[b])){
          ans++;
        }
      }
    }
  }
  printf("%d", ans);
  
  return 0;
}


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

int main(){
  int n,y;
  cin >> n >> y;
  rep(i,n+1){
    rep(j,n+1){
      if(10000*i+5000*j+1000*(n-i-j)==y && n-i-j>=0){
        printf("%d %d %d",i,j,n-i-j);
        return 0;
      }
    }
  }
  printf("%d %d %d",-1,-1,-1);
  return 0;
}

Measured memory_bytes: 3732
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m, d;
  cin >> n >> m >> d;
  double ret;
  if (d == 0) {
    ret = 1.0 * (m - 1) / n;
  } else {
    ret = 2.0 * (n - d) * (m - 1) / n / n;
  }
  printf("%.10f\n", ret);
  return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
MAX = 700000
fact = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX


def CombInit():
    fact[0] = fact[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fact[i] = fact[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


def Comb(n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fact[n] * (finv[k] * finv[n - k] % MOD) % MOD


X, Y = map(int, input().split())
if (X + Y) % 3:
    print(0)
else:
    CombInit()
    m = (2 * X - Y) // 3
    n = (2 * Y - X) // 3
    print(int(Comb(m + n, m)))


Measured memory_bytes: 55152
#include <iostream>

// S n = S (n-1) + S (n-2)

int S[100005];
int a[100005];

int main(void) {
    int N, M;
    std::cin >> N >> M;

    for(int i = 0; i < M; i++) {
        int x;
        std::cin >> x;
        a[x] = 1;
    }

    // 動的計画法
    S[0] = 1;
    if(!a[1])
        S[1] = 1;
    for(int i = 2; i <= N; i++) {
        if(a[i])
            continue;
        S[i] = S[i-1] + S[i-2];
        if(S[i] > 1000000007)
            S[i] -= 1000000007;
    }

    std::cout << S[N] << std::endl;
    return 0;
}


Measured memory_bytes: 1024
let n = read_int ()
let s = read_line ()
let t = read_line ()
let f m = Printf.printf "%d\n" @@ 2 * n - m; exit 0
let _ = for i = 0 to n - 1 do if String.(sub s i (n - i) = sub t 0 (n - i)) then f (n - i) done; f 0

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

using namespace std;

/*int main(){
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    for(int i=0;i<n;++i){
        cin>>b[i];
    }
    for(int i=0;i<n;++i){
        cin>>c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    cout<<ans<<endl;
}*/

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    int ans=0;
    while(1){
        for(int i=0;i<n;++i){
            if(a[i]%2==0)a[i]/=2;
            else{
                cout<<ans<<endl;
                return 0;
            }
        }
        ans++;
    }
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if b-a >k:
  print(":(")
  exit()
if c-b >k:
  print(":(")
  exit()
if d-c >k:
  print(":(")
  exit()
if e-a >k:
  print(":(")
  exit()
print("Yay!")
 

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int K = Integer.parseInt(br.readLine());
        String S = br.readLine();

        if (S.length() <= K) {
            System.out.println(S);
        } else {
            System.out.println(S.substring(0, K) + "...");
        }
    }
}

Measured memory_bytes: 36252
class FordFulkerson:
    """Ford-Fulkerson Algorithm: find max-flow
       complexity: O(FE) (F: max flow)
    """
    class edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V, E, source, sink):
        """ V: the number of vertexes
            E: adjacency list
            source: start point
            sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]
        for fr in range(V):
            for to, cap in E[fr]:
                self.E[fr].append(self.edge(to, cap, len(self.E[to])))
                self.E[to].append(self.edge(fr, 0, len(self.E[fr])-1))
        self.maxflow = self.ford_fulkerson(source, sink)

    def ford_fulkerson(self, source, sink, INF=10**9):
        """find max-flow"""
        def dfs(vertex, sink, flow):
            """find augmenting path"""
            if vertex == sink:
                return flow
            used[vertex] = True
            for i, e in enumerate(self.E[vertex]):
                if not used[e.to] and e.cap > 0:
                    d = dfs(e.to, sink, min(flow, e.cap))
                    if d > 0:
                        self.E[vertex][i].cap -= d
                        self.E[e.to][e.rev].cap += d
                        return d
            return 0

        maxflow = 0
        while True:
            used = [False] * self.V
            flow = dfs(source, sink, INF)
            if flow == 0:
                return maxflow
            else:
                maxflow += flow

V, E = map(int, input().split())
edge = [[] for _ in range(V)]
for _ in range(E):
    u, v, cap = map(int, input().split())
    edge[u].append((v, cap))
print(FordFulkerson(V, edge, 0, V-1).maxflow)

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

int main() {
  int N,M,a,c,n;
  cin >> N >> M;
  vector<int>k(M);
  vector<int>p(M);
  vector<int>b(M);
  vector<vector<int> >s(M,vector<int>(N));
  for(int i=0;i<M;i++){
    cin >> k.at(i);
    for(int j=0;j<k.at(i);j++){
      cin >> s.at(i).at(j);
      
    }
  }
  for(int i=0;i<M;i++){
    cin >> p.at(i);
  }
  a=0;
  int d=1;
  for(int i=0;i<N;i++){
    d=d*2;
  }
  while(a<d){
    c=0;
    for(int i=0;i<M;i++){
      int g=0;
      for(int j=0;j<k.at(i);j++){
        int e=1;
        for(int k=0;k<s.at(i).at(j);k++){
          e=e*2;
        }
        
        if((a%e)>=(e/2)){
          g++;
        }
      }
      if((g%2)==p.at(i)){
        c++;
      }
    }
    if(c==M){
      n++;
    }
    a++;
  }
  cout << n << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(x+r<=w && x-r>=0 && y+r<=h && y-r>=0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
    int A,B,C,D,flag1=0,flag2=0;
    cin>>A>>B>>C>>D;
    while(1){
        C-=B;
    if(C<=0) {
        flag1=1;
         break;}
    A-=D;
    if(A<=0) {
        flag2=1;
         break;}

    }
    if(flag1) p("Yes");
    else if(flag2) p("No");
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
const ll mod = 1000000007;
const ll INF = 1000000000000099;
vector<vector<pair<ll,ll>>> e(310,vector<pair<ll,ll>>(0));
ll n;

template <typename T>
vector<T> dijkstra(int s,vector<vector<pair<T, T> > > & G){     
  using Pa = pair<T, T>;
  vector<T> D(301,INF);//----------------
  priority_queue<Pa,vector<Pa>,greater<Pa> > q;
  D[s]=0;
  q.emplace(D[s],s);//最短距離、ゴール頂点番号

  while(!q.empty()){
    ll spath=q.top().first;
    int v=q.top().second;
    q.pop();

    if(D[v]<spath) continue;
    for(auto& e:G[v]){
      int u=e.first;//頂点番号
      T c=e.second;//最短距離
      if(D[u]>D[v]+c){
        D[u]=D[v]+c;
        q.emplace(D[u],u);
      }
    }
  }
  return D;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll ans=0;cin>>n;
    vector<tuple<int,int,int>> v(0);
    for(int i=0;i < n;i++)
    {
        for(int j=0;j < n;j++)
        {   
            int l;cin>>l;
            if(i<j){
                v.emplace_back(l,i,j);
            }
        }
    }

    sort(all(v));

    for(int i=0;i < siz(v);i++)
    {    
        ll el=get<0>(v[i]);
        ll a=get<1>(v[i]);
        ll b=get<2>(v[i]);
        vector<ll> u = dijkstra(a,e);
        ll spath = u[b];
        //cout<<a<<":"<<b<<";"<<spath<<":"<<el<<endl;

        if(el<spath /* || i==0*/){
            e[a].emplace_back(b,el);
            e[b].emplace_back(a,el);
            ans+=el;
            //cout<<"DEBUG"<<ans<<endl;
        }else if(spath<el){
            cout<<-1<<endl;
            return 0;
        }
    }

    cout<<ans<<endl;
}

/*短い辺から順に入れればよさそう
 */
            

Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

int main() {
    ll y;

    cin >> y;

    ll h = 0;

    h += (y / 500) * 1000;
    y = (y % 500);
    h += (y/5) * 5;
    
    cout << h << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
i=0
cnt = 0
flg = 0

while i < N:
    i += 1
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
        if cnt >= 3:
            flg = 1
    else:
        cnt = 0

if flg == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main(){
  int i,n,ans=0;
  scanf("%d",&n);
  vector<pair<int,int>> a(n),c(n);
  for(i=0;i<n;i++){
    cin >> a[i].second >> a[i].first;
  }
  for(i=0;i<n;i++){
    cin >> c[i].first >> c[i].second;
  }
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());

  int z[n]={};
  for(i=0;i<n;i++){
    int x=0,flag=0;
    for(int j=0;j<n;j++){
      if(a[j].second<c[i].first&&a[j].first<c[i].second){
        if(z[j]==0){
          x=j;
          flag=1;
        }
      }
    }
    if(flag){
      z[x]=1;
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;
int main(){
    int s,w;
    cin>>s>>w;
    if(s<=w){
        cout<<"unsafe";
    }
    else{
        cout<<"safe";
    }
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using  namespace std;
int main(){
	long int i,j,k,W,n,w,v;
	vector <long int> v1,v2;
	cin>>n>>W;
	for(i=0;i<n;i++){
		cin>>w>>v;
		v1.push_back(w);
		v2.push_back(v);
	}
	long int dp[n+1][W+1];
	for(i=0;i<=n;i++){
		for(w=0;w<=W;w++){
			if(i==0||w==0)
				dp[i][w]=0;
			else if(v1[i-1]<=w)
				dp[i][w]=max(v2[i-1]+dp[i-1][w-v1[i-1]],dp[i-1][w]);
			else
				dp[i][w]=dp[i-1][w];

		}
	}
	cout<< dp[n][W]<<endl;
	return 0;
}


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

int main(){
  string ST; cin >> ST;
  int n = ST.size();
  vector<int> S(n);
  long long ans;
  long long jud;
  
  for(int i=0; i<n; i++){
    S[i]= ST[i] - '0';
  }
  
  for(int bit=0; bit < (1 << (n-1)) ; bit++){
    jud = S[0];
    for(int i=0; i<n-1; i++){
      if(bit & (1 << i)){
        ans += jud;
        jud = S[i+1];
      }
      
      else {
				jud = jud * 10 + S[i + 1];
      }
    }
    ans += jud;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

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

		int N = sc.nextInt();
		int T = sc.nextInt();

		long sum = 0;

		int[] t_array = new int[N];

		for(int i = 0;i < N;i++){
			t_array[i] = sc.nextInt();
		}

		int pre_time = t_array[N-1] + T;
		for(int i = N - 1;0 <= i;i--){
			int delta = pre_time - t_array[i];

			if(delta < T){
				sum += delta;
			}else{
				sum += T;
			}

			pre_time = t_array[i];
		}

		System.out.println(sum);

		sc.close();
	}

}


Measured memory_bytes: 64548
//https://atcoder.jp/contests/dp/tasks/dp_c
#include<bits/stdc++.h>
#define endl "\n"
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
typedef long long int ll;
const int INF = 1e9;

using namespace std;

void solve()
{
    ll i, j, n, k, a, b, c;
    cin>>n;

    vector<vector<ll>> arr, dp;
    dp.assign(n, vector<ll> (3));
    for(i=0; i<n; ++i)
    {
        cin>>a>>b>>c;
        arr.push_back({a,b,c});
    }

    dp[0] = arr[0];

    for(i=1; i<n; ++i)
    {
        for(j=0; j<3; ++j)
        {
            dp[i][j] = arr[i][j] + max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);
        }
    }

    cout<<*max_element(dp[n-1].begin(), dp[n-1].end())<<endl;
}
 
int main()
{
    FASTIO
    solve();
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll p = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  int n; cin >> n;
  vector<vector<int> > adj(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v; cin >> u >> v;
    --u; --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  vector<vector<ll>> memo(n, vector<ll>(2, -1));
  function<ll(int, int, int)> dp = [&](int u, int parent, int color) {
    if (memo[u][color] != -1) return memo[u][color];
    else {
      ll& ret = memo[u][color];
      ret = 1;
      for (auto v: adj[u]) {
        if (v == parent) continue;
        if (color == 0) ret *= (dp(v, u, 0) + dp(v, u, 1)) % p;
        else ret *= dp(v, u, 0);
        ret %= p;
      }
      return ret;
    }      
  };
  cout << (dp(0, -1, 0) + dp(0, -1, 1)) % p << endl;
  return 0;
}


Measured memory_bytes: 22272
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll s;
  cin>>s;
  ll x1=0,y1=0,x2=1000000000,y2=1,x3,y3;
  y3=(s+999999999)/1000000000;
  x3=1000000000*y3-s;
  cout<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<' '<<x3<<' '<<y3<<endl;
}


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

int main() {
  int m1,d1,m2,d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  if (d2 - d1 <= 0) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3620
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import bisect
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

MOD = 10**9 + 7
 
n, m = reads()
X = reads()
Y = reads()

P = sum(i * (n-i) * (X[i] - X[i-1]) % MOD for i in range(1, n)) % MOD
Q = sum(j * (m-j) * (Y[j] - Y[j-1]) % MOD for j in range(1, m)) % MOD
ans = P * Q % MOD
print(ans)

Measured memory_bytes: 83044
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;

int main()
{
	ll int a,b;
	cin>>a>>b;
	ll int c=a*b;
	cout<<c<<endl;
	
		
}

	
			

		


 







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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl

int main() {

    int k;

    cin >> k;
    
    cout << (k / 2) * ((k+1) / 2) << endl;
    return 0;
}



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

const double eps = 1e-8;
int x1, y1, x2, y2, x3, y3, x4, y4, r;

double distDbl(double ax, double ay, double bx, double by) {
    return (bx - ax) * (bx - ax) + (by - ay) * (by - ay);
}

double getPerpDist(double ax, double ay, double bx, double by, double cx, double cy) {
    double a, b, x, y, res;
    if (ax == bx) {
        y = cy;
        if (min(ay, by) <= y && y <= max(ay,by)) {
            res = (cx - ax) * (cx - ax);
        } else {
            res = min(distDbl(ax,ay,cx,cy), distDbl(bx,by,cx,cy));
        }
    } else {
        a = (by - ay) / (bx - ax);
        b = ay - a * ax;
        x = (cx + a * (cy - b)) / (1 + a * a);
        y = a * x + b;
        if (min(ax, bx) <= x && x <= max(ax,bx) &&
            min(ay, by) <= y && y <= max(ay,by)) {
            res = distDbl(x,y,cx,cy);
        } else {
            res = min(distDbl(ax,ay,cx,cy), distDbl(bx,by,cx,cy));
        }
    }
    return res;
}

bool isA() {
    int c = 0;
    if (0 <= (x2-x1)*(y4-y1)-(y2-y1)*(x4-x1)) ++c;
    if (0 <= (x3-x2)*(y4-y2)-(y3-y2)*(x4-x2)) ++c;
    if (0 <= (x1-x3)*(y4-y3)-(y1-y3)*(x4-x3)) ++c;
    if (c % 3 != 0) return false;
    if (getPerpDist(x1, y1, x2, y2, x4, y4) + eps < r*r) return false;
    if (getPerpDist(x2, y2, x3, y3, x4, y4) + eps < r*r) return false;
    if (getPerpDist(x3, y3, x1, y1, x4, y4) + eps < r*r) return false;
    return true;
}

bool isB() {
    if (distDbl(x1,y1,x4,y4) <= r*r && distDbl(x2,y2,x4,y4) <= r*r && distDbl(x3,y3,x4,y4) <= r*r) {
        return true;
    }
    return false;
}

bool isC() {
    if (getPerpDist(x1,y1,x2,y2,x4,y4) <= r*r + eps) return true;
    if (getPerpDist(x2,y2,x3,y3,x4,y4) <= r*r + eps) return true;
    if (getPerpDist(x3,y3,x1,y1,x4,y4) <= r*r + eps) return true;
    return false;
}

int main() {
    while (cin >> x1 >> y1, (x1 || y1)) {
        cin >> x2 >> y2 >> x3 >> y3 >> x4 >> y4 >> r;
        if (isB()) cout << "b" << endl;
        else if (isA()) cout << "a" << endl;
        else if (isC()) cout << "c" << endl;
        else cout << "d" << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
// http://sesenosannko.hatenablog.com/entry/2017/09/01/214852
// https://beta.atcoder.jp/contests/abc061/submissions/3322496
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3166760#1
// 0-index
struct Bellman_Ford{
	struct edge{ll from, to, cost;};
	ll inf = 1e16;
	vector<edge> es;
	vector<ll> d;
	ll V,E;
	void init(ll v,ll e){
		V = v; E = e;
		d.resize(V);
	}
	void shortest_path(ll s){
		FOR(i,0,V) d[i] = inf;
		d[s] = 0;
		FOR(i,0,V){
			FOR(j,0,E){
				edge e = es[j];
				if(d[e.from]!=inf && d[e.to]>d[e.from] + e.cost){
					d[e.to] = d[e.from] + e.cost;
				}
			}
		}
	}
	bool find_negative_loop(){// all graph
		FOR(i,0,V)d[i] = 0;
		FOR(i,0,V){
			FOR(j,0,E){
				edge e = es[j];
				if(d[e.to]>d[e.from] + e.cost){
					d[e.to] = d[e.from] + e.cost;
					if(i == V-1) return true;
				}
			}
		}
		return false;
	}
	bool find_negative_loop(ll s){// from s
		ll cnt = 0;
		FOR(i,0,V)d[i]=inf;
		d[s]=0;
		while(true){
			bool update = false;
			cnt++;
			FOR(i,0,E){
				edge e = es[i];
				if(d[e.from] != inf && d[e.to]>d[e.from] + e.cost){
					d[e.to] = d[e.from] + e.cost;
					if(cnt == V){
						return true;
					}
					update = true;
				}
			}
			if(! update)break;
		}
		return false;
	}
	bool shortest_path(int s, int t){ // t: destination
		FOR(i,0,V)d[i] = inf;
		d[s] = 0;
		FOR(i,0,2*V){
			FOR(j,0,E){
				edge e = es[j];
				if(d[e.from]!=inf && d[e.to]>d[e.from] + e.cost){
					d[e.to] = d[e.from] + e.cost;
					if(i>=V-1 && e.to==t) return true;
				}
			}
		}	
		return false;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll V,E;
	cin >> V >> E;
	ll d[V][V];
	FOR(i,0,V){
		FOR(j,0,V){
			d[i][j] = INF;
		}
		d[i][i] = 0;
	}
	Bellman_Ford bf;
	bf.init(V,E);
	FOR(i,0,E){
		ll a,b,c;
		cin >> a >> b >> c;
		d[a][b] = c;
		bf.es.push_back({a,b,c});
	}
	if(bf.find_negative_loop()){
		cout << "NEGATIVE CYCLE" << endl;
		return 0;
	}
	FOR(k,0,V){
		FOR(i,0,V){
			FOR(j,0,V){
				if(d[i][k]!=INF && d[k][j]!=INF)
					d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	FOR(i,0,V){
		FOR(j,0,V){
			if(j!=0)cout << " ";
			if(d[i][j]==INF){
				cout << "INF";
			}else{
				cout << d[i][j];
			}
		}
		cout << endl;
	}

}



Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var x,y  int
	fmt.Scan(&x,&y)

	for i:= 0; i <= x; i++ {
		if y == (2 * (x-i) + 4*i) {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")

}



Measured memory_bytes: 1752
// URL: https://atcoder.jp/contests/abc132/tasks/abc132_c

import std.algorithm, std.container, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  int n; io.getV(n);
  int[] d; io.getA(n, d);

  d.sort();
  io.put(d[n/2]-d[n/2-1]);
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, T v)
  {
    v = new T(r, c);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


Measured memory_bytes: 4536
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define endl "\n"
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
vector<int> cmp;
ll power(ll x, ll y, ll p) { 
    ll res = 1;    x = x % p;  
    while(y > 0) {
        if(y & 1) res = (res*x) % p; 
        y = y>>1;    x = (x*x) % p; 
    } return res; 
}
void dfs(int i, vector<bool>&vis, vector<int>adj[])
{
    vis[i]=1;
    cmp.pb(i);
    for(int child: adj[i])
    {
        if(!vis[child])
        dfs(child,vis,adj);
    }
}
int main()
{
    Imposter
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll p=1e9 +7;
        ll n;
        cin>>n;
         ll a[n];
         input(a,n);
         ll suff[n];
         suff[n-1]=0;
         for(int i=n-2;i>=0;i--)
         {
             suff[i]=(suff[i+1]+a[i+1])%p;
         }
         ll ans=0;
         for(int i=0;i<n;i++)
         {
             ans=((ans%p)+((a[i]*suff[i])%p))%p;
         }
         cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 6744
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    k = int(ipt())
    q = queue.Queue()
    for i in range(1,10):
        q.put(i)
    for _ in [0]*k:
        qi = q.get()
        if not qi%10 == 0:
            q.put(qi*10+qi%10-1)
        q.put(qi*10+qi%10)
        if not qi%10 == 9:
            q.put(qi*10+qi%10+1)
    print(qi)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 80480
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f m e j
  | any (==100) [m,e,j] = "A"
  | m+e >= 180 = "A"
  | m+e+j >= 240 = "A"
  | m+e+j >= 210 = "B"
  | m+e+j >= 150 && any (>=80) [m,e] = "B"
  | otherwise = "C"


main = do
    n <- getInt
    unless (n==0) $ map (apply3 f) <$> replicateM n getInts >>= mapM_ putStrLn >> main


Measured memory_bytes: 4112