akhauriyash/Code-Regression huggingface dataset:
import math
import random
class Prime:
    seed_primes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
    def is_prime(self,n):
        is_prime_common=self.is_prime_common(n)
        if is_prime_common is not None:return is_prime_common
        if n<2000000:return self.is_prime_brute_force(n)
        return self.is_prime_miller_rabin(n)
    def is_prime_common(self,n):
        if n==1:return False
        if n in Prime.seed_primes:return True
        if any(map(lambda x:n%x==0,self.seed_primes)):return False
    def is_prime_brute_force(self,n):
        for k in range(2,int(math.sqrt(n))+1):
            if n%k==0:return False
        return True
    def is_prime_miller_rabin(self,n):
        d=n-1
        while d&1==0:d>>=1
        witnesses=self.get_witnesses(n)
        for w in witnesses:
            y=pow(w,d,n)
            while d!=n-1and y!=1and y!=n-1:
                y=y*y%n
                d<<=1
            if y!=n-1and d&1==0:return False
        return True
    def get_witnesses(self,num):
        def _get_range(num):
            if num<2047:return 1
            if num<1373653:return 2
            if num<25326001:return 3
            if num<3215031751:return 4
            if num<2152302898747:return 5
            if num<3474749660383:return 6
            if num<341550071728321:return 7
            if num<3825123056546413051:return 9
            return 12
        return self.seed_primes[:_get_range(num)]
    def gcd(self,a,b):
        if a<b:return self.gcd(b,a)
        if b==0:return a
        while b:a,b=b,a%b
        return a
    @staticmethod
    def f(x,n,seed):
        p=Prime.seed_primes[seed%len(Prime.seed_primes)]
        return(p*x+seed)%n
    def find_factor(self,n,seed=1):
        if self.is_prime(n):return n
        x,y,d=2,2,1
        count=0
        while d==1:
            count+=1
            x=self.f(x,n,seed)
            y=self.f(self.f(y,n,seed),n,seed)
            d=self.gcd(abs(x-y),n)
        if d==n:
            return self.find_factor(n,seed+1)
        return self.find_factor(d)
    def find_factors(self,n):
        primes={}
        if self.is_prime(n):
            primes[n]=1
            return primes
        while n>1:
            factor=self.find_factor(n)
            primes.setdefault(factor,0)
            primes[factor]+=1
            n//=factor
        return primes
*d,=sorted(Prime().find_factors(math.factorial(int(input()))).values())
a=0
n=len(d)
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            a+=3*(d[i]>3)or d[i]>1and d[j]>3and d[k]>3
        a+=(2*(d[i]>13)or d[i]>3and d[j]>13)+(2*(d[i]>23)or d[i]>1and d[j]>23)
    a+=d[i]>73
print(a)

Measured memory_bytes: 42992
#include<iostream>
#include<cstdio>
using namespace std;
main(){
	int t,s;
	int a=0,b=0,c=0;
	while(cin>>t){
		scanf(",%d",&s);
		a+=t*s;
		b+=s;
		c++;
	}
	s=(double)b/c+0.5;
	cout<<a<<endl<<s<<endl;
}

Measured memory_bytes: 1236
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<assert.h>
using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

signed main(){
  int n,h,w;
  cin >> n >> h >> w;
  int ans = 0;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    if(a >= h && b >= w)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	int red = 0;
	int blue = 0;
	cin >> n >> s;
	for(int i=0;i<n;i++){
		if(s[i]=='R'){
			red++;
		} else {
			blue++;
		}
	}
	if(red>blue){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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 pair<int,int> P;
typedef pair<ll,ll> PL;

VI e[150000];
double p1[150000], ans[150000];

double dfs(int now, int past){
    double res = 0.0;
    double p = 1.0/e[now].size();
    if (past != -1) p = 1.0/(e[now].size()-1);
    for (auto next : e[now]){
        if (next == past) continue;
        double a = dfs(next,now);
        res += p * (1 + a);
        ans[now] += 1.0/e[now].size() * (1 + a);
    }
    return p1[now] = res;
}

double dfs2(int now, int past, double pp){
    int n = e[now].size();
    pp /= n;
    ans[now] += pp;
    if (n == 1){
        if (e[now][0] != past) dfs2(e[now][0], now, 1.0);
        return 0;
    }
    for (auto next : e[now]){
        if (next == past) continue;
        dfs2(next, now, (ans[now] - (p1[next]+1)/n)*n/(n-1.0) + 1);
    }
}

int main() {
    int n;
    cin >> n;
    REP(i,n-1){
        int u, v;
        scanf("%d %d", &u, &v);
        u--;
        v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    dfs(0, -1);
    dfs2(0,-1,0.0);
    REP(i,n){
        printf("%.10f\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 19712
<?php

fscanf(STDIN, "%d", $n);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

$min = PHP_INT_MAX;

$B = [];
for ($i = 0; $i < $n; $i++) {
    $B[] = $A[$i] - ($i + 1);
}
sort($B);

$x = $B[intdiv($n, 2)];

$ans = 0;
for ($i = 0; $i < $n; $i++) {
    $ans += abs($A[$i] - ($x + $i + 1));
}
echo $ans, PHP_EOL;


Measured memory_bytes: 31220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main{
    public static void main(String[] args) throws IOException{
        final PrintWriter out = new PrintWriter(System.out);
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final String[] in = br.readLine().split(" ");
        final int[] a = new int[n];
        for(int i = 0; i<n; i++){
            a[i] = Integer.parseInt(in[i]);
        }
        int num = 0;
        for(int i = 0; i<n; i++){
            for(int j = n-1; j>i; j--){
                if(a[j]<a[j-1]){
                    final int t = a[j];
                    a[j] = a[j-1];
                    a[j-1] = t;
                    num++;
                }
            }
        }
        out.print(a[0]);
        for(int i = 1; i<n; i++)
            out.print(" "+a[i]);
        out.println();
        out.println(num);
        out.flush();
    }
}

Measured memory_bytes: 24264
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    char s;
    cin >> s;

    if (isupper(s))
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }

    return 0;

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
 using namespace std;
  int Arr[4][1001];
  int ColPart[1000001]={},RowPart[1000001]={};
  bool Area[2010][2010]={};
  int Row=0,Col=0;
  int W,H;
  int n;
 
  typedef struct{
   int x,y;
  }NODE;
  queue<NODE> q;
  NODE mknd(int x,int y){
   NODE T;
   T.x = x;
   T.y = y;
   return T;
  }
   void Floodfill(int x,int y){
   q.push(mknd(x,y));
   while(!q.empty()){
        int X = q.front().x;
        int Y = q.front().y;
        q.pop();
    if(X+1<Row&&Area[X+1][Y]==0){
        Area[X+1][Y]=1;
        q.push(mknd(X+1,Y));
    }
    if(X-1>=0&&Area[X-1][Y]==0){
        Area[X-1][Y]=1;
        q.push(mknd(X-1,Y));
    }
    if(Y+1<Col&&Area[X][Y+1]==0){
        Area[X][Y+1]=1;
        q.push(mknd(X,Y+1));
    }
    if(Y-1>=0&&Area[X][Y-1]==0){
        Area[X][Y-1]=1;
        q.push(mknd(X,Y-1));
    }
   }
   return;
  }
  int main(){
    do{
    Row = Col = 0;
   for(int i=0;i<1000001;i++){
    RowPart[i] = -1;
    ColPart[i] = -1;
   }
   for(int i=0;i<2010;i++){
    for(int j=0;j<2010;j++){
        Area[i][j] =false;
    }
   }
   for(int i=0;i<1001;i++){
    Arr[0][i] = 0;
    Arr[1][i] = 0;
    Arr[2][i] = 0;
    Arr[3][i] = 0;
   }
   scanf("%d%d",&W,&H);
   if(W==0&&H==0)break;
   scanf("%d",&n);
   for(int i=1;i<=n;i++){
    scanf("%d%d%d%d",&Arr[0][i],&Arr[1][i],&Arr[2][i],&Arr[3][i]);
    ColPart[Arr[0][i]] = 0;
    ColPart[Arr[2][i]] = 0;
    RowPart[Arr[1][i]] = 0;
    RowPart[Arr[3][i]] = 0;
   }
   Arr[0][0] = 0;
   Arr[1][0] = 0;
   Arr[2][0] = W;
   Arr[3][0] = H;
    ColPart[Arr[0][0]] = 0;
    ColPart[Arr[2][0]] = 0;
    RowPart[Arr[1][0]] = 0;
    RowPart[Arr[3][0]] = 0;
    int RS= 0 ,CS= 0 ;
   for(int i=0;i<1000001;i++){
    if(!RowPart[i]){
        RowPart[i]=Row;
        Row++;
    }
    if(!ColPart[i]){
        ColPart[i]=Col;
        Col++;
    }
   }
   for(int i=1;i<=n;i++){
    int x1 = Arr[0][i];
    int y1 = Arr[1][i];
    int x2 = Arr[2][i];
    int y2 = Arr[3][i];
    for(int j=RowPart[y1];j<RowPart[y2];j++){
        for(int k=ColPart[x1];k<ColPart[x2];k++){
            Area[j][k] = 1;
        }
    }
   }
   int Count = 0;
  Row = Row-1;
  Col = Col-1;
   for(int i=0;i<Row;i++){
    for(int j=0;j<Col;j++){
        if(Area[i][j]==0){
        Floodfill(i,j);
        Count++;
        }
    }
   }
   printf("%d\n",Count);
   }while(true);
  }

Measured memory_bytes: 15032
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

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

int N;
int c[10][10];

long long p(int x,int y){
	long long ret=1;
	for(int i=0;i<y;i++)ret*=x;
	return ret;
}

int main(){
	cin >> N;
	int l=1;
	int n=N;
	while(n>9){
		n/=10;
		l++;
	}
	
	if(l==1){
		cout << N << endl;
		return 0;
	}
	
	long long ans=0;
	
	for(int x=1;x<=9;x++)for(int y=1;y<=9;y++){
		c[x][y]=0;
		if(x==y)c[x][y]++;
		for(int k=0;k<l-2;k++){
			c[x][y]+=p(10,k);
		}
		if(x==n){
			c[x][y]+=(N-n*p(10,l-1))/10+1;
			if(y>(N%10))c[x][y]--;
		}
		else if(x<n){
			c[x][y]+=p(10,l-2);
		}
	}
	
	for(int x=1;x<=9;x++)for(int y=1;y<=9;y++){
		ans+=c[x][y]*c[y][x];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,ans=0;
  cin >> n;
  double pos1,pos2,now=-2e9,x,l;
  vector<pair<double,double>> p;
  for(int i=0; i<n; i++) {
    cin >> x >> l;
    pos1=x-l+0.1,pos2=x+l-0.1;
    p.push_back(make_pair(pos2,pos1));
  }
  sort(p.begin(),p.end());
  for(int i=0; i<n; i++) {
    if(now<p[i].second) {
      ans++;
      now=p[i].first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2420
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long N;
  cin >> N;
  
  vector<vector<long>> happiness(3, vector<long>(N+1, 0));
  for (size_t n = 1; n <= N; ++n) {
    for (size_t activity = 0; activity < 3; ++activity) {
	  cin >> happiness[activity][n];
    }
  }
  
  vector<vector<long>> dp(3, vector<long>(N+1, 0));
  for (size_t n = 1; n <= N; ++n) {
    for (size_t i = 0; i < 3; ++i) {
      long res = 0;
      for (size_t j = 0; j < 3; ++j) {
        if (i == j) continue;
        long val = dp[j][n-1] + happiness[i][n];
   	    res = max(res, val);
      }
      dp[i][n] = res;
    }
  }
  cout << max(dp[0][N], max(dp[1][N], dp[2][N])) << endl;
  
  return 0;
}


Measured memory_bytes: 5744
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int64_t N;
    cin >> N;
    vector<int>vec(N);
    for (int i=0; i<N; i++) {
        cin >> vec.at(i);
    }

    int64_t current_money = 1000;
    for (int i=0; i<N-1; i++) {
        if (vec[i] < vec[i+1]) {
            int64_t kabusuu = current_money / vec[i];
            current_money = (kabusuu * vec[i+1]) + (current_money % vec[i]);
        }
    }

    cout << current_money << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
int main(void)
{
   char A[11],B[11],C[11];
   int ae,be;

   scanf("%s%s%s",A,B,C);
   ae=strlen(A);
   be=strlen(B);
   if((A[ae-1]==B[0])&&(B[be-1]==C[0]))
      printf("YES\n");
   else
      printf("NO\n");
   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
const int MOD = 1000000007;
const int maxN = 1000005;
#define PI 3.1415926535897932384626

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int r;
	cin >> r ;
	cout << (2 * r)*PI << "\n";
	return 0;
}



Measured memory_bytes: 3804
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = sc.nextInt();
		int count = 0;
		int count2 = 0;
		while (count < n){
			count += x;
			count2 += t;
		}
		System.out.println(count2);
	}

}


Measured memory_bytes: 35644
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);


int main(){
        ll n;
        cin >> n;
        if(n % 2 == 0){
                cout << n / 2 - 1 << endl;
        }else{
                cout << n /2 <<endl;
        }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n, k;
  cin >> n >> k;
  vi p(n);
  rep(i,n) cin >> p[i];
  rep(i,n) p[i]++;
  vector<int> csum(p.size()+1);
  rep(i,p.size()) {
    csum[i+1] = csum[i] + p[i];
  }
  int mx = 0;
  int s = 0;
  rep(i,n-k+1) {
    s = csum[i+k] - csum[i];
    mx = max(mx, s);
  }
  double ans = mx;
  ans /= 2;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

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

  int M = 55555;
  auto p = vector<int>(M);
  for(int i = 0; i < M; i++) {
    if(i == 0 || i == 1) {
      p[i] = 0;
    } else {
      p[i] = 1;
    }
  }
  for(int i = 2; i < sqrt(M); i++) {
    if(p[i]) {
      for(int j = 0; i * (j + 2) < M; j++) {
        p[i * (j + 2)] = 0;
      }
    }
  }
  auto primes = vector<int>();
  REP(i, M) {
    if(p[i] && i % 5 == 1) {
      primes.push_back(i);
    }
  }
  REP(i, N) { cout << primes[i] << " "; }
  cout << endl;
}


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


int main() {
    int N,b,f,r,v;
    int building1[3][10] = {0};
    int building2[3][10] = {0};
    int building3[3][10] = {0};
    int building4[3][10] = {0};
    cin >> N;
    for (int i=0; i<N; ++i) {
        cin >> b >> f >> r >> v;
        switch(b) {
        case 1:
            building1[f-1][r-1] +=v;
            break;
        case 2:
            building2[f-1][r-1] +=v;
            break;
        case 3:
            building3[f-1][r-1] +=v;
            break;
        case 4:
            building4[f-1][r-1] +=v;
            break;
        default:
            break;
        }
    }
    
    for (int p=0; p<4; ++p) {
        for (int i=0; i<3; ++i) {
            for (int j=0; j<10; ++j) {
                if (p==0) {
                    cout << ' ' << building1[i][j];
                }else if (p==1) {
                    cout << ' ' << building2[i][j];
                }else if (p==2) {
                    cout << ' ' << building3[i][j];
                }else{
                    cout << ' ' << building4[i][j];
                }
            }
            cout << endl;
        }
        if (p != 3) {
            for (int k=0; k<20; ++k) {
            cout << '#';
            if (k == 19) cout << endl;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}



int main(int argc, const char * argv[]) {
    
    
    cin.tie(0);
    ios::sync_with_stdio(false);
   
    
    ll a,b;
    cin >> a >> b;
    
    
    map<ll,ll> Ans{};
    ll ans=0;
    for(auto p : prime_factor(a)) {
        Ans.insert(make_pair(p.first,1));
       
    }
  
    for(auto q : prime_factor(b)) {
       
        if(Ans.count(q.first)) ans++;
        
    }
   
    
    cout << ans + 1<< endl;
    
    
    
    
}


Measured memory_bytes: 256
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val x = DoubleArray(N)
    val y = DoubleArray(N)
    
    for (i in x.indices) {
      x[i] = input.nextDouble()
      y[i] = input.nextDouble()
    }
    
    var pathLen = 0.0
    for (i in x.indices) {
      for (j in (i + 1) .. x.lastIndex) {
        val xDiff = x[i] - x[j]
        val yDiff = y[i] - y[j]
        
        pathLen += Math.sqrt(xDiff * xDiff + yDiff * yDiff) * 2
      }
    }
    
    println(pathLen / N)
  }
}

Measured memory_bytes: 41260
N = int(input())
A = list(map(int, input().split()))
old_a = A[0]
step = 0

for i in range(len(A)):
  if A[i] - old_a < 0:
    diff = (old_a - A[i])
    step += diff
  else:
    diff =0
  old_a = A[i] + diff
  
print(step)

Measured memory_bytes: 32248
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007
int i,j,k,l;
static const int MAX_N=10e5;
int main(void){
	
	int N,X,T;
	cin >> N >> X >> T;
	N+=X-1;
	cout << N/X*T << endl;
	return 0;
}


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

int main() {
    ll n, w, t;
    cin >> n >> w >> t;
    vector<ll> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    ll ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        ans += min(w * (x[i + 1] - x[i]), t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            T = [L[i],L[j],L[k]]
            T.sort()
            s,m,l = T
            if s != m and m != l and l != s:
                if l < s+m:
                    ans += 1
print(ans)

Measured memory_bytes: 9200
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> input(n);

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

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

  cout << input[n / 2] - input[n / 2 - 1] << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		final int n = Integer.parseInt(sc.nextLine());
		long cntM=0;
		long cntA=0;
		long cntR=0;
		long cntC=0;
		long cntH=0;
		for(int i=0;i<n;i++){
			String[] name = sc.nextLine().split("");
			if(name[0].equals("M")){
				cntM=cntM+1;
			}else if(name[0].equals("A")){
				cntA=cntA+1;
			}else if(name[0].equals("R")){
				cntR=cntR+1;
			}else if(name[0].equals("C")){
				cntC=cntC+1;
			}else if(name[0].equals("H")){
				cntH=cntH+1;
			}
		}
		long answer=cntM*cntA*cntR+cntM*cntA*cntC+cntM*cntA*cntH+
					cntM*cntR*cntC+cntM*cntR*cntH+
					cntM*cntC*cntH+
					cntA*cntR*cntC+cntA*cntR*cntH+
					cntA*cntC*cntH+
					cntR*cntC*cntH;
		System.out.println(answer);
	}
}

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

int main() {
  int x;
  cin >> x;
  
  int k;
  for(int i=360; i>0; i += 360){
    if(i%x==0){
      k = i/x;
      break;
    }
  }
  
  cout << k << endl;
}

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

char S[100050];

int main() {
    scanf("%s", S);
    int n = strlen(S), ans = 0;
    for (int i = 1; i < n; ++i)
        if (S[i] != S[i-1]) ans++;
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> dp(K + 1, false);

    rep(i, K) {
        rep(j, N) {
            if ((i + 1) - A[j] >= 0) {
                dp[i + 1] |= !dp[(i + 1) - A[j]];
            }
        }
    }
    if (dp[K]) {
        cout << "First" << '\n';
    } else {
        cout << "Second" << '\n';
    }
}

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


Measured memory_bytes: 1024
from itertools import *
import fractions
 
N = int(input())
A = list(map(int, input().split()))
 
L = list(accumulate([0]+A, fractions.gcd))
R = list(accumulate([0]+A[::-1], fractions.gcd))
 
print(max(fractions.gcd(s, t) for s, t in zip(L, R[::-1][1:])))

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

int n;
vector<int> a(2000000);

int main(int argc, char **argv)
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	int target = 1;

	int count = 0;
	while (count < n)
	{
		if (target == 2)
		{
			std::cout << count << std::endl;
			return 0;
		}

		
		target = a[target];
		count++;		
	}

	std::cout << -1 << std::endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,temp;
	cin>>n;
	for(int i=1;i<=n;i++) {
		scanf("%d",&temp);
		if(temp%2==1) {
			cout<<"first";
			exit(0);
		}
	}
	cout<<"second";
	return 0;
} 

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

using namespace std;

int main()
{
	string s;
	int cnt[2] = { 0, 0 };

	cin >> s;

	for(int i = 0; i < s.size(); ++i)
	{
		++cnt[s[i] - '0'];
	}

	cout << min(cnt[0], cnt[1]) * 2 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

 
int main() {

    int x,y;
    cin >> x >> y;

    if(x*4>=y&&x*2<=y&&y%2==0) {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

 return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define sz(v) ((int)((v).size()))
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
   int n,m;
   cin>>n>>m;
   vi v(m);
   int sum =0;
   for(int i=0;i<m;i++){
       cin>>v[i];
       sum+=v[i];
   }
   if(sum>n)puts("-1");
   else printf("%d",n-sum);
    return 0;
}

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

#define N 2*123456

int isPrime[1+N];

void sieve()
{
  int i, j;
  
  for(i = 2; i <= N; ++i){
    isPrime[i] = 1;
  }
  
  for(i = 2; i <= N; ++i){
    if( isPrime[i] ){
      for(j = 2; i * j <= N; ++j){
        isPrime[i * j] = 0;
      }
    }
  }
}

int main(int argc, char *argv[])
{
  sieve();

  while(1){
    int x, n;
    int res = 0;

    // printf("n = ");
    scanf("%d", &n);
    if( n == 0 ) break;
    
    for(x = n+1; x <= 2*n; ++x){
      if( isPrime[ x ] ) ++res;
    }
    
    printf("%d\n", res);
  }
  return (EXIT_SUCCESS);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  cout<<(a-c)*(b-d)<<endl;
  return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    if(a+b < c+d) cout<<"Right\n"<<endl;
    if(a+b > c+d) cout<<"Left\n"<<endl;
    if(a+b == c+d) cout<<"Balanced"<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * Created by abhishek on 8/4/2016.
 */
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int array[] = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            array[i] = Integer.parseInt(br.readLine());
        }
        long ans = 0;
        for (int i = 1; i < n; i++) {
            if ((array[i] & 1) == 1 && (array[i + 1] & 1) == 1) {
                ans += array[i] / 2 + array[i + 1] / 2 + 1;
                array[i + 1] = 0;
            } else if ((array[i] & 1) == 1 && array[i + 1] > 0) {
                ans += array[i] / 2 + array[i + 1] / 2;
                array[i + 1] = 1;
            }
            else ans += array[i]/2;
            //System.out.println(array[i] + " " + ans);
        }
        ans += array[n]/2;
        System.out.print(ans);
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

double ff(double x1, double y1, double x2, double y2, double x3, double y3) {
	double d12 = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	double d23 = sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
	double d31 = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
	
	double cos1 = (d23*d23-d12*d12-d31*d31)/(-2.0*d12*d31);
	double sin1 = sqrt(max(1.0-cos1*cos1, 0.0));
	double cot1 = cos1/sin1;
	double cos2 = (d31*d31-d12*d12-d23*d23)/(-2.0*d12*d23);
	double sin2 = sqrt(max(1.0-cos2*cos2, 0.0));
	double cot2 = cos2/sin2;
	
	double A = 0.0;
	
	A += 2.0;
	A += 1.0*sin1;
	A += 1.0*sin2;
	
	A += (1+cos1)*cot1;
	A += (1+cos2)*cot2;
	
	return d12/A;
}

int main () {
	double x1, y1, x2, y2, x3, y3;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	double S = 0;
	S = max(S, ff(x1, y1, x2, y2, x3, y3));
	S = max(S, ff(x2, y2, x3, y3, x1, y1));
	S = max(S, ff(x3, y3, x1, y1, x2, y2));
	printf ("%.9lf\n", S);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
#s = input()
#print(s)
a = list(map(int,input().split()))
#print(a)
print(' '.join(map(str,a)))

for i in range(1, n):
    v = a[i]
    j = i - 1
    while (j>=0 and a[j] > v):
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    print(' '.join(map(str,a)))



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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long ans = 1, n, a = 2, b = 1;
    cin >> n;
    n--;
    while(n--) {
        ans = a + b;
        a = b;
        b = ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>

using namespace std;
typedef long long int ll;


int main(int argc, char const *argv[])
{
	ll x, y, z;
	cin >> x >> y >> z;
	ll ans = 0;
	x -= z;

	while (x >= y + z)
	{
		ans++;
		x -= y;
		x -= z;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] T = new int[N];
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                T[i] = in.nextInt();
                A[i] = in.nextInt();
            }

            long[] T2 = new long[N];
            long[] A2 = new long[N];
            T2[0] = T[0];
            A2[0] = A[0];
            for (int i = 1; i < N; i++) {

                long l = 0;
                long r = (long) 1e18 / Math.max(T[i], A[i]);
                for (; Math.abs(l - r) > 1;) {
                    long c = (l + r) / 2;
                    T2[i] = T[i] * c;
                    A2[i] = A[i] * c;
                    if (isValid(T2, A2, i)) {
                        r = c;
                    } else {
                        l = c;
                    }
                }

                T2[i] = T[i] * r;
                A2[i] = A[i] * r;
            }

            System.out.println(T2[N - 1] + A2[N - 1]);
        }
    }

    private static boolean isValid(long[] T2, long[] A2, int i) {
        return T2[i] >= T2[i - 1] && A2[i] >= A2[i - 1];
    }
}


Measured memory_bytes: 31044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<vector<int>>z(n);
    UnionFind u(n*2);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < n; j++) {
            if (s[j] == '1') {
                z[i].push_back(j);
                u.merge(i, j + n);
            }
        }
    }
    int ansi = 0;
    for (int i = 0; i < n; i++) {
        if (u.issame(i, i + n))ansi = -1;
    }
    if (ansi == -1)cout << ansi << endl;
    else {
        int anss = 0;
        for (int i = 0; i < n; i++) {
            vector<bool> seen(n,false);
            vector<int> ans(n);
            queue<int> q;
            q.push(i);
            while (!q.empty()) {
                int h = q.front();
                seen[h] = true;
                for (int i = 0; i < z[h].size(); i++) {
                    if (!seen[z[h][i]]) {
                        seen[z[h][i]] = true;
                        q.push(z[h][i]);
                        ans[z[h][i]] = ans[h] + 1;
                    }
                }
                q.pop();
            }
            for (int j = 0; j < n; j++) {
                anss = max(anss, ans[j] + 1);
            }
        }
        cout << anss << endl;
    }
}

Measured memory_bytes: 3836
n = int(input())
b = list(map(int,input().split()))
a = [0] *n
for i in range(0,n-2):
    a[i+1] = min([b[i],b[i+1]])
    # if a[n-1-i] <= b[n-2-i]:
    #     a[n-2-i] = b[n-2-i]
    # else:
    #     a[n-1-i] = b[n-2-i]
    #     a[n-2-i] = b[n-2-i]
a[0] =b[0]
a[n-1] = b[n-2]
print(sum(a))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	//	String line = br.readLine();

		Scanner scan = new Scanner(System.in);
		int str1 = Integer.parseInt(scan.next());
		int str2 = Integer.parseInt(scan.next());
		int str3 = Integer.parseInt(scan.next());


		System.out.println((str1+str2)*str3/2);

	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int main() {
   int a, b;
   cin >> a >> b;
   if ((a > 0 && b < 0) || (a < 0 && b > 0)){
       cout << "Zero" << endl;
   } else if(a > 0 && b> 0){
       cout << "Positive" << endl;
   } else if(a < 0 && b < 0){
       if((abs(b - a) + 1) % 2 == 0){
           cout << "Positive" << endl;
       } else {
           cout << "Negative" << endl;
       }
   }
   return 0;
}


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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    int N, M, ansac, answa;
    int ac[100005], wa[100005];
    int p[100005];
    string s[100005];

    cin >> N >> M;
    REP(i, M)
        cin >> p[i] >> s[i];
    REP(i, N){
        ac[i] = 0;
        wa[i] = 0;
    }
    REP(i, M){
        if(s[i] == "AC")
            ac[p[i]-1] = 1;
        else{
            if(ac[p[i]-1] == 0)
                wa[p[i]-1]++;
        }
    }
    ansac = 0;
    answa = 0;
    REP(i, N){
        ansac += ac[i];
        answa += wa[i] * ac[i];
    }
    cout << ansac << " " << answa << endl;
    return 0;
}



Measured memory_bytes: 6912
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-03-06(Fri)
   note
**********************************************************************/

#include <iostream>
using namespace std;

int main() {
  int s, w; cin >> s >> w;
  if (w >= s) {
    cout << "unsafe" << endl;
  }
  else {
    cout << "safe" << endl;
  }
}


Measured memory_bytes: 3632
from itertools import groupby
N, K = map(int,input().split())
S = list(input())
Sg = groupby(S)
L = []
if S[0] =="0":
  L.append(0)
for k, g in Sg:
  L.append(len(list(g)))
if S[-1] == "0":
  L.append(0)
#print(L)
acu = [0]
for i in range(len(L)):
  acu.append(acu[-1] + L[i])
#print(acu)
ans = 0
for left in range(0,len(acu),2):
  right = min(left + 2 * K + 1,len(acu) - 1)
  ans = max(ans,acu[right] - acu[left])
print(ans)
  



Measured memory_bytes: 8624
k = int(input())
s = input()
n = len(s)

mod = 10**9 + 7

## nCkのmodを求める関数
# テーブルを作る(前処理)
max = 2 * 10**6 + 100
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 0
ex25 = [1] * (k+1)
ex26 = [1] * (k+1)
for i in range(1,k+1):
    ex25[i] = (ex25[i-1] * 25)%mod
    ex26[i] = (ex26[i-1] * 26)%mod

for i in range(k+1):
    j = k-i
    tmp = pow(25,i,mod) * com(n+i-1,i) * pow(26,j,mod)
    tmp = ex25[i] * com(n+i-1,i) * ex26[j]
    ans = (ans+tmp)%mod

print(ans)

Measured memory_bytes: 133368
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cmath>
#include <set>

#define ll unsigned long long
#define p(a, b) pair<a,b>

using namespace std;

//ifstream cin("Input.txt");
//ofstream cout("Output.txt");

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, T;
    cin >> n >> T;
    int mn = 100000000;
    for (int i = 0; i < n; ++i) {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            mn = min(mn, c);
        }
    }
    if (mn == 100000000) {
        cout << "TLE";
    } else {
        cout << mn;
    }
    return 0;
}

Measured memory_bytes: 256
h,w = map(int, input().split())
a = [list(map(int, input().split()))+[0] for i in range(h)] + [[0]*(w+1)]
b = [list(map(int, input().split()))+[0] for i in range(h)] + [[0]*(w+1)]
diff = [[abs(x-y) for x,y in zip(i,j)] for i,j in zip(a,b)]
dp = [[0 for j in range(w+1)] for i in range(h+1)]
dp[0][0] = (1 << diff[0][0])


def reverse(d, x):
  res = 0
  for i in range(x+1):
    res <<= 1
    if (1<<i) & d:
      res |= 1
  return res


for i in range(h):
  for j in range(w):
    dp[i][j+1] |= (dp[i][j] << diff[i][j+1])
    dp[i][j+1] |= (dp[i][j] >> diff[i][j+1])
    dp[i][j+1] |= reverse(dp[i][j], diff[i][j+1])
    dp[i+1][j] |= (dp[i][j] << diff[i+1][j])
    dp[i+1][j] |= (dp[i][j] >> diff[i+1][j])
    dp[i+1][j] |= reverse(dp[i][j], diff[i+1][j])
last = dp[h-1][w-1]
for i in range(6401):
  if (last >> i) & 1:
    ans = i
    break
print(ans)

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

template<class t> void vin(vector<t>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    double d;
    cin >> d;
    double ans = d * sqrt(2);
    for (int x=1; x<=10; ++x) {
        if (d*d - x*x >= 0) {
            double y = sqrt(max(0.0, d*d-x*x));
            ans = max(ans, x+(y < 1.0 ? 1.0 : y));
        }
    }
    printf("%.12lf\n", ans);
}



Measured memory_bytes: 3296
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
bool bitcheck(int bit, int position){
    if((bit >>position)& 1) return true;
    else return false;
}
int main(){
    string s;
    cin>>s;
    lint ans=0;      
    for (int bit = 0; bit < 1<<(s.size() - 1); bit++)
    {
        lint cc = 0;
        int l = 0;
        int r;
        for (r = 0; r < s.size() - 1; r++)
        {
            if(bitcheck(bit,r)){
                string t=s.substr(l,r-l+1);
                lint num=stoll(t);
                cc+=num;
                l = r + 1;
            }        
        }
        string t=s.substr(l,r-l+1);
        cc += stoll(t);
        ans += cc;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long res = 1;
	int N, K; cin >> N >> K;
	if (N % K == 0) res = 0;


	cout << res << endl;

}

Measured memory_bytes: 256