akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int n,k,l,u,v;
struct DSU{
	int fa[200005],rk[200005];
	DSU(){
		int xb;
		for(xb=0;xb<200005;xb++){
			fa[xb]=xb;
		}
	}
	inline int gf(int x){
		if(fa[x]!=x) fa[x]=gf(fa[x]); 
		return fa[x];
	}
	inline void Union(int x,int y){
		x=gf(x);
		y=gf(y);
		if(rk[x]<=rk[y]){
			fa[x]=y;
			if(rk[x]==rk[y]) rk[y]++;
		}
		else fa[y]=x;
	}
}rail,road;
bool got[200005];
vector < int > pr1[200005],final[200005];
int res[200005];
int *bas;
inline bool comp(int x,int y){
	return bas[x]<bas[y];
}
inline void solve(vector < int > &vi){
	int xb,x2;
	bas=rail.fa;
	sort(vi.begin(),vi.end(),comp);
	for(xb=0;xb<vi.size();){
		for(x2=xb;x2<vi.size() && bas[vi[x2]]==bas[vi[xb]];x2++){
			final[vi[xb]].push_back(vi[x2]);
		}
		xb=x2;
	}
}
int main(){
	scanf("%d%d%d",&n,&k,&l);
	int xb,x2;
	for(xb=0;xb<k;xb++){
		scanf("%d%d",&u,&v);
		road.Union(u-1,v-1);
	}
	for(xb=0;xb<l;xb++){
		scanf("%d%d",&u,&v);
		rail.Union(u-1,v-1);
	}
	for(xb=0;xb<n;xb++) {
		road.gf(xb);
		rail.gf(xb);
	}
	for(xb=0;xb<n;xb++){
		pr1[road.fa[xb]].push_back(xb);
	}
	for(xb=0;xb<n;xb++){
		if(!pr1[xb].empty()) solve(pr1[xb]);
	}
	for(xb=0;xb<n;xb++){
		for(x2=0;x2<final[xb].size();x2++) res[final[xb][x2]]=final[xb].size();
	}
	for(xb=0;xb<n;xb++) printf("%d\n",res[xb]);
	return 0;
}

Measured memory_bytes: 24832
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n, m;
int cnt[55];
int main(){
	while(~scanf("%d %d", &n, &m)){
		for(int i = 1; i <= m; i++){
			int u, v;
			scanf("%d %d", &u, &v);
			cnt[u]++;
			cnt[v]++;
		}
		for(int i = 1; i <= n; i++)
			printf("%d\n", cnt[i]);
		memset(cnt, 0, sizeof(cnt));
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

int main() {
    int h, w, k;
    std::cin >> h >> w >> k;

    std::vector<std::string> ss(h);
    for (auto& s : ss) std::cin >> s;

    std::vector<std::vector<int>> ans(h, std::vector<int>(w, 0));
    int id = 1;
    for (int x = 0; x < h; ++x) {
        for (int y = 0; y < w; ++y) {
            if (ss[x][y] == '#') {
                ans[x][y] = id++;
            }
        }
    }

    for (int x = 0; x < h; ++x) {
        id = 0;
        for (int y = 0; y < w; ++y) {
            if (ans[x][y] == 0) {
                ans[x][y] = id;
            }
            id = ans[x][y];
        }

        id = 0;
        for (int y = w - 1; y >= 0; --y) {
            if (ans[x][y] == 0) {
                ans[x][y] = id;
            }
            id = ans[x][y];
        }
    }

    for (int y = 0; y < w; ++y) {
        id = 0;
        for (int x = 0; x < h; ++x) {
            if (ans[x][y] == 0) {
                ans[x][y] = id;
            }
            id = ans[x][y];
        }

        id = 0;
        for (int x = h - 1; x >= 0; --x) {
            if (ans[x][y] == 0) {
                ans[x][y] = id;
            }
            id = ans[x][y];
        }
    }

    for (auto& v : ans) {
        for (auto x : v) {
            std::cout << x << ' ';
        }
        std::cout << std::endl;
    }
    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];
    int ans = 0;
    rep(i, n) {
        bool mx = true;
        rep(j, i) {
            if (h[j] > h[i]) mx = false;
        }
        if (mx) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int N;
	cin >> N;

	int X[15], Y[15], P[15];
	rep(i, N) {
		cin >> X[i] >> Y[i] >> P[i];
	}

	int n = 1 << N;
	ll kotae[16] = {};
	rep(i, N + 1) kotae[i] = 1e18;

	rep(i, n - 1) {
		int XA[15], YA[15], PA[15], SA[15];
		int p = 0;
		rep(j, N) {
			if (!(i >> j & 1)) {
				XA[p] = X[j];
				YA[p] = Y[j];
				PA[p] = P[j];
				SA[p++] = min(abs(X[j]), abs(Y[j]));
			}
		}

		for (int j = i - 1 & i; j > 0; j = j - 1 & i) {
			int tmp[15];
			rep(q, p) tmp[q] = SA[q];
			rep(k, N) if (i >> k & 1) {
				if (j >> k & 1) {
					rep(q, p) {
						chmin(tmp[q], abs(XA[q] - X[k]));
					}
				}
				else {
					rep(q, p) {
						chmin(tmp[q], abs(YA[q] - Y[k]));
					}
				}
			}
			ll kari = 0;
			rep(q, p) kari += (ll)tmp[q] * PA[q];
			chmin(kotae[p], kari);
		}
		int tmp[15];
		rep(q, p) tmp[q] = SA[q];
		rep(k, N) if (i >> k & 1) {
			rep(q, p) {
				chmin(tmp[q], abs(XA[q] - X[k]));
			}
		}
		ll kari = 0;
		rep(q, p) kari += (ll)tmp[q] * PA[q];
		chmin(kotae[p], kari);
		rep(q, p) tmp[q] = SA[q];
		rep(k, N) if (i >> k & 1) {
			rep(q, p) {
				chmin(tmp[q], abs(YA[q] - Y[k]));
			}
		}
		kari = 0;
		rep(q, p) kari += (ll)tmp[q] * PA[q];
		chmin(kotae[p], kari);
	}

	for (int i = N; i >= 1; i--) {
		co(kotae[i]);
	}
	co(0);


	Would you please return 0;
}

Measured memory_bytes: 3616
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=[LI() for i in range(n)]
lis.sort()
sq=[]
for i in range(n):
    for j in range(i+1,n+1):
        new_lis=lis[i:j]
        hor=new_lis[-1][0]-new_lis[0][0]
        #print(new_lis)
        if len(new_lis)<k:
            continue
        new_lis.sort(key=lambda x:x[1])
        #print(new_lis)
        u=len(new_lis)
        for i in range(u-k+1):
            sq.append(hor*(new_lis[i+k-1][1]-new_lis[i][1]))
#print(sq)
print(min(sq))
    
            
        
        
    

    
        
    
    
    

Measured memory_bytes: 74652
n , m = map(int,input().split())
d = []
for i in range(n):
    a = list(input().split())
    a = a[1:]
    d.append(a)

d = sum(d,[])

import collections
c = collections.Counter(d)

keys = [k for k , v in c.items() if v == n]
print(len(keys))

Measured memory_bytes: 3316
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stdio.h>
#include<cstdlib>
#include<iomanip> //cout<<setiosflags(ios::fixed)<<setprecision(2);
#include<ctime> //double a=(double)clock();   cout<<a<<endl;
#include<vector>
#include<queue>
using namespace std;
inline int read(){
    int x=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return ff*x;
}
const int maxn=100010;
char s[maxn];
int N,L[maxn],R[maxn],ans[maxn];
int main(){
	//freopen("in","r",stdin);
	scanf("%s",s+1);
	N=strlen(s+1);
	for(int i=1;i<=N;i++)
		if(s[i]=='L')
			L[i]=L[i-1]+1;
	for(int i=N;i>=1;i--)
		if(s[i]=='R')
			R[i]=R[i+1]+1;
	/*for(int i=1;i<=N;i++)
		printf("%d %d\n",L[i],R[i]);*/
	for(int i=1;i<=N;i++){
		int pos;
		if(L[i]){
			if(L[i]&1)
				pos=i-L[i]+1;
			else
				pos=i-L[i];
		}
		else{
			if(R[i]&1)
				pos=i+R[i]-1;
			else
				pos=i+R[i];
		}
		ans[pos]++;
	}
	for(int i=1;i<N;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[N]);
	return 0;
}
 


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include<iostream>
#include <cstdio>
#include <cmath>
#define endl '\n'
typedef long long ll;
using namespace std;
int main()
{
	int n;
	ll a[51] = {0};
	cin>>n;
	double m = n-1;
	double p = pow((double)2,m);
	for(int i = 0; i<n; i++)
		cin>>a[i];
	sort(a,a+n);
	long double sum = a[0];
	//cout<<p<<endl;
	for(int j = n-1; j>0; j--)
	{
	    //cout<<"a[i] = "<<a[i]<<" p/2 = "<<p/2<<endl;
	    p = p/2;
	    ll r = a[j] * p;
		sum+=r;

		//cout<<" sum = "<<sum<<"p = "<<p<<endl;
	}
	long double ans = sum/pow((double)2,m);
	cout<<ans<<endl;
	return 0;
}


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

long long solve(vector<vector<long long> >&ans, vector<int> &val, vector<int> &wt, int i, int w)
{
    
    if(i<0)return 0;
    if(w==0)return 0;

    if(ans[i][w]!=-1)return ans[i][w];

    ans[i][w]=0;
    long long temp1 = solve(ans,val,wt,i-1, w);
    if(w>=wt[i])
        temp1 = max(temp1, (long long)val[i] + solve(ans,val,wt,i-1,w-wt[i]));
    ans[i][w]=temp1;
    return ans[i][w];
}

int main()
{
    int n,w;
    cin>>n>>w;
    vector<int> val(n);
    vector<int> wt(n);
    
    for(int i=0; i<n; i++)
        cin>>wt[i]>>val[i];

    vector<vector<long long> >  ans(n,vector<long long> (w+1,-1));

    cout<<solve(ans,val,wt,n-1,w);

    return 0;
} 

Measured memory_bytes: 79488
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int n = Integer.parseInt(sc.next());
int m = Integer.parseInt(sc.next());
String[] sn=new String[n];
String[] sm=new String[m];
for (int i = 0; i < n; i++) {sn[i]=sc.next();}
for (int i = 0; i < m; i++) {sm[i]=sc.next();}
int c=0;
for(int k=0;k<=n-m;k++){
    for(int i=0;i<=n-m;i++){
        c=0;
        for(int j=0;j<m;j++){
            if(sn[i+j].substring(k,k+m).equals(sm[j]))c++;
        }
        if(c==m)break;
    }
    if(c==m)break;
}
if(c==m){
    out.println("Yes");
}else{
    out.println("No");
}
}}

Measured memory_bytes: 22996
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;




int main(void){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        cout<<"x";
    }
    
    
    return 0;
}


Measured memory_bytes: 256
s = list(input())

tmp = 0
ans = 0

for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        tmp += 1
    else:
        ans = max(ans , tmp)
        tmp = 0

ans = max(ans , tmp)
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  rep(i, s.size()-1){
    if(s.at(i) == s.at(i+1)){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
    if(i < s.size()-2){
      if(s.at(i) == s.at(i+2)){
        cout << i+1 << " " << i+3 << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1" << endl;
  return 0;
}

Measured memory_bytes: 3756
W, H, N = map(int, input().split())
points = [list(map(int, input().split())) for _ in range(N)]

low_left_x = 0
low_left_y = 0
s = 0

for i in range(N):
    if points[i][2] == 1:
        if points[i][0] > low_left_x:
            low_left_x = points[i][0]
    elif points[i][2] == 2:
        if points[i][0] < W:
            W = points[i][0]
    elif points[i][2] == 3:
        if points[i][1] > low_left_y:
            low_left_y = points[i][1]
    elif points[i][2] == 4:
        if points[i][1] < H:
            H = points[i][1]
    
    if W<low_left_x:
        W = low_left_x
    if H < low_left_y:
        H = low_left_x

s = (W-low_left_x)*(H-low_left_y)
print(s)

Measured memory_bytes: 3064
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def arrp(a) a.each{|aa|p aa} end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
s = gets.chomp + " "
dp = na2(4,s.size,0)
we = "ABC" 
dp[3][s.size-1] = 1
(0..3).reverse_each do |d|
  (0...(s.size-1)).reverse_each do |i|
    dp[d][i] = (s[i] == "?")? dp[d][i+1]*3 : dp[d][i+1]
    if(d < 3) 
      if(s[i] == "?" or s[i] == we[d])
        dp[d][i] += dp[d+1][i+1]
      end
    end
    dp[d][i] %= 10**9+7 
  end
end
p dp[0][0]

Measured memory_bytes: 8444
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}




signed main() {

	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;





	return 0;
}

Measured memory_bytes: 256
#ceilevenoddformula
import math
import bisect
import copy
import time
from collections import Counter
from itertools import combinations
#map(int,input().split())
#int(x) for x in input().split()
d,t,s=map(int,input().split())
if d/s<=t:
	print('Yes')
else:
	print('No')








































Measured memory_bytes: 68044
import sys
from collections import deque
import copy
import bisect
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]
    A.sort()
    B.sort()
    C.sort()
    count = 0
    for j in range(N):
        b = B[j]
        a = bisect.bisect_left(A, b)
        c = bisect.bisect_right(C, b)
        count += a * (N - c)
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23800
#include <stdio.h>
#include <math.h>

struct P { double x,y;};

void koch(int n,struct P a,struct P b);

int main(){
  struct P a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}

void koch(int n,struct P a,struct P b){
  if(n==0) return;

  struct P s,t,u;
  double rad=M_PI/3;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(rad)-(t.y-s.y)*sin(rad)+s.x;
  u.y=(t.x-s.x)*sin(rad)+(t.y-s.y)*cos(rad)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}



Measured memory_bytes: 2040
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        int[] dp = new int[n+1];

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

        dp[1] = 0;
        dp[2] = Math.abs(a[1]-a[0]);
        for(int i = 3; i<n+1; i++)  {
            dp[i] = Integer.MAX_VALUE;
            for(int j = 1; j<=k; j++) {
                if(i-j>0) {
                    dp[i] = Math.min(dp[i], Math.abs(a[i - 1] - a[i - j - 1]) + dp[i-j]);
                }
            }
        }
        System.out.println(dp[n]);
    }
}

Measured memory_bytes: 51116
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long min = Long.MAX_VALUE;
        for(int i = 0; i < 5; i++) {
            min = Math.min(min, sc.nextLong());
        }
        double num = Math.ceil(n / (double)min);
        System.out.println((long)(num + 5 - 1));
    }
}




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

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

    while (1)
    {
        ll n, m, a, b, c, t;
        cin >> n >> m >> a >> b >> c >> t;
        if (n == 0)
            break;
        vector<ll> S(n);
        rep(i, n) cin >> S[i];
        ll A[60][60] = {}, AA[60][60] = {};
        rep(i, n)
        {
            if (i == 0)
            {
                A[0][0] = b;
                A[0][1] = c;
            }
            else if (i == n - 1)
            {
                A[n - 1][n - 2] = a;
                A[n - 1][n - 1] = b;
            }
            else
            {
                A[i][i - 1] = a;
                A[i][i] = b;
                A[i][i + 1] = c;
            }
        }
        rep(i, n) AA[i][i] = 1;
        for (ll I = 0; 1LL << I <= t; I++)
        {
            if (t & (1 << I))
            {
                ll tmp[60][60] = {};
                rep(i, n) rep(j, n) rep(k, n)(tmp[i][j] += A[i][k] * AA[k][j]) %= m;
                rep(i, n) rep(j, n) AA[i][j] = tmp[i][j];
            }
            ll tmp[60][60] = {};
            rep(i, n) rep(j, n) rep(k, n)(tmp[i][j] += A[i][k] * A[k][j]) %= m;
            rep(i, n) rep(j, n) A[i][j] = tmp[i][j];
        }
        ll ans[60] = {};
        rep(i, n)
        {
            rep(j, n)
            {
                (ans[i] += AA[i][j] * S[j]) %= m;
            }
        }
        rep(i, n)
        {
            if (i == n - 1)
                cout << ans[i] << endl;
            else
                cout << ans[i] << " ";
        }
    }
}


Measured memory_bytes: 3264
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	vector<int> inputs;
	int n;
	cin >> n;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(a);
	}
	int ans = 1e18;
	for (int i = 1; i <= 100; ++i) {
		int now = 0;
		REP(q, inputs.size()) {
			now += pow(inputs[q] - i, 2);
		}
		ans = min(ans, now);
	}
	cout << ans << endl;
}
#undef int
int main() {
	init();
	solve();
}

Measured memory_bytes: 256
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: usize = sc.read();
    let b: usize = sc.read();
    let mut k: usize = sc.read();
    for x in (1..std::cmp::max(a, b) + 1).rev() {
        if a % x == 0 && b % x == 0 {
            k -= 1;
        }
        if k == 0 {
            println!("{}", x);
            return;
        }
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
N = int(input())
ans = []
for i in range(1, N+1):
    if i % 15 == 0:
        continue
#         print("FizzBuzz")
    elif i % 3 == 0:
        continue
#         print("Fizz")
    elif i % 5 == 0:
        continue
#         print("Buzz")
    else:
        ans.append(i)
print(sum(ans))

Measured memory_bytes: 29844
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

const int N = 2e5 + 10;
const ll MOD = 1e9 + 7;
const int INF = 2e9;

ll f[N], g[N], mi[N];
int L[N], R[N], n, mx[N], mn[N];
PII a[N];
VI V[N];

ll query(int i, int j)
{
    if (i == 0)
        return g[j];
    else
        return (g[j] - g[i - 1] + MOD) % MOD;
}

int main()
{
    n = read();
    mi[0] = 1;
    for (int i = 1; i <= n; i++)
        mi[i] = mi[i - 1] * 2 % MOD;
    for (int i = 1; i <= n; i++)
    {
        int x = read(), v = read();
        a[i] = MP(v, x);
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++)
        mx[i] = max(mx[i - 1], a[i].se);
    mn[n + 1] = INF;
    for (int i = n; i >= 1; i--)
        mn[i] = min(mn[i + 1], a[i].se);
    for (int i = 1; i <= n; i++)
    {
        int l = 1, r = i;
        while (l < r)
        {
            int mid = l + r >> 1;
            if (mx[mid] >= a[i].se)
                r = mid;
            else
                l = mid + 1;
        }
        L[i] = l;
    }
    for (int i = 1; i <= n; i++)
    {
        int l = i, r = n;
        while (l < r)
        {
            int mid = l + r + 1 >> 1;
            if (mn[mid] <= a[i].se)
                l = mid;
            else
                r = mid - 1;
        }
        R[i] = l;
    }
    for (int i = 1; i <= n; i++)
        V[R[i]].push_back(L[i]);
    f[0] = 1;
    g[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        sort(V[i].begin(), V[i].end());
        for (int j = 0; j < V[i].size(); j++)
            (f[i] += query(V[i][j] - 1, i - 1) * mi[V[i].size() - j - 1] % MOD) %= MOD;
        g[i] = (g[i - 1] + f[i]) % MOD;
    }
    printf("%lld\n", f[n]);
}


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

using namespace std;

const int N = 100 + 5;

typedef long long LL;

int c[N];

int main(){

	int d , i , j , a[N] , b[N] , m , sum = 0 , sum1 = 0 , sum2 = 0 ;

	cin>>m;

	for(i = 0 ; i < m ; i++){

		cin>>d;

		a[i] = d;

		}

	for(i = 0 ; i < m ; i++){

		cin>>d;

		b[i] = d;

		}

	for(i = 0 ; i < m ; i++){

		sum1 = sum2 = 0;

		for(j = 0 ; j <= i ; j++){

			sum1 += a[j];

			}

		for(j = i ; j < m ; j++){

			sum2 += b[j];

			}

		c[i] = sum1 + sum2;

		}

	sort(c , c + m);

	cout<<c[m - 1]<<endl;

	return 0;

	}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <random>
#include <utility>
#include <map>
#include <vector>
#include <queue>
#include <bitset>
#include <sstream>
#define REP(i,x) for(int i=0; i<(x); i++)
typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
    string s;
    cin >>s;
    if (s=="zyxwvutsrqponmlkjihgfedcba") {
        cout<<-1<<endl;
        return 0;
    }
    int map[30];
    REP(i, 30)map[i]=0;
    int zpos=30;
    REP(i, s.length()){
        map[s[i]-'a']++;
        if (s[i]-s[i+1]<0) {
            zpos=i;
        }
    }
    REP(i, 26){
        if(map[i]==0){
            cout << s+static_cast<char>('a'+i) << endl;
            return 0;
        }
    }
    string ans ="";
    int zmap[30];
    REP(i, 30)zmap[i]=0;
    REP(i, zpos){
        ans+=s[i];
        zmap[s[i]-'a']++;
    }
    for(int i=s[zpos]-'a'+1;i<26;i++){
        if (zmap[i]==0) {
            ans+=static_cast<char>('a'+i);
            cout << ans << endl;
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N;
  cin >> N;
  int ans = 0;
  int64_t M = N;
  for (int i = 2; i <= sqrt(M); i++) {
    int memo = 0;
    while (N % i == 0) {
      N /= i;
      memo++;
    }
    for (int j = 1; j < 45; j++) {
      if (memo >= j) {
        ans++;
        memo -= j;
      }
      else {
        break;
      }
    }
  }
  if (N != 1) {
    ans++;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <cstdint>

using i64 = int64_t;
using i32 = int32_t;

void run() {
    i32 n;
    std::cin >> n;
    const i64 m = 60;
    std::vector<i64> cnt(60, 0);
    for (i32 i = 0; i < n; ++i) {
        i64 a;
        std::cin >> a;
        for (i64 j = 0; j < m; ++j) {
            cnt.at(j) += (a >> j) & 1;
        }
    }
    const i64 mod = 1000000000 + 7;
    i64 ans = 0;
    for (i64 j = 0; j < m; ++j) {
        i64 c = cnt.at(j);
        ans = (ans + ((i64)1 << j) % mod * c % mod * (n - c)) % mod;
    }
    std::cout << ans << '\n';
}

int main() {
    run();
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  bitset<100001> a = 0;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.set(tmp);
  }
  bitset<100001> win = 0;
  for (int i = 0; i < k; i++) {
    if (!win[i]) {
      win |= (a << i);
    }
  }
  if (win[k]) {
    cout << "First" << '\n';
  } else {
    cout << "Second" << '\n';
  }
  return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	int b[n];
	for (auto &i : b) i = ri();
	
	for (int i = 1; i < n; i += 2) std::swap(a[i], b[i]);
	
	int dp[1 << n][n];
	for (auto &i : dp) for (auto &j : i) j = 1000000000;
	for (int i = 0; i < n; i++) dp[1 << i][i] = 0;
	for (int i = 0; i < 1 << n; i++) {
		for (int j = 0; j < n; j++) {
			if (dp[i][j] == 1000000000) continue;
			for (int k = 0; k < n; k++) {
				if (i >> k & 1) continue;
				if (__builtin_popcount(i) & 1) { // 2
					if (b[k] < a[j]) continue;
				} else {
					if (a[k] < b[j]) continue;
				}
				int swapped = 0;
				for (int l = k + 1; l < n; l++) if (i >> l & 1) swapped++;
				dp[i | 1 << k][k] = std::min(dp[i | 1 << k][k], dp[i][j] + swapped);
			}
		}
	}
	int res = *std::min_element(dp[(1 << n) - 1], dp[(1 << n) - 1] + n);
	if (res == 1000000000) puts("-1");
	else std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 18688
n,a,b=map(int,input().split())
mod=10**9+7
ans=pow(2,n,mod)-1
def comb(n,m):
    mod=10**9+7
    import functools
    import operator
    x,y=1,1
    for i in range(n-m+1,n+1):
        x*=i
        x%=mod
    for i in range(1,m+1):
        y*=i
        y%=mod
    if n-m<0:
        return 0
    return((x*pow(y,mod-2,mod))%mod)

ans=(ans-comb(n,a)-comb(n,b))%mod
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

//最大公約数
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}

//最小公倍数
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

//素因数分解
map<int,int> prime_factor(int n,map<int,int> &res){
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            res[i]++;
            n/=i;
        }
    }
    if(n!=1){
        if(res[n]==0){
            res[n]=1;
        }else{
            res[n]++;
        }
    }
    return res;
}

//約数列挙
vector<ll> divisor(ll n){
    vector<ll> a;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            a.push_back(i);
            if(i*i!=n){
                a.push_back(n/i);
            }
        }
    }
    SORT(a);
    return a;
}

//拡張ユークリッドの互除法
int extgcd(int a,int b,int &x,int &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }else{
        int d=extgcd(b,a%b,y,x);
        y-=a/b*x;
        return d;
    }
}

//素数判定
void sieve(int n,vector<bool> &is_prime) {
	is_prime[0]=false;
	is_prime[1]=false;
	for (int i = 2; i * i <= n; i++) {
		if (is_prime[i]) {
			for (int j = i * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return;
}

//繰り返し2乗法
ll mod_pow(ll x,ll n,ll mod){
    x%=mod;
    ll res=1;
    while(n>0){
        if(n&1){
            res=res*x%mod;
        }
        x=x*x%mod;
        n>>=1;
    }
    return res;
}

//mod　m での a の逆元
int mod_inverse(int a,int m){
    int x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

//nCkの前計算
void init(ll n,ll m,vector<ll> &factrial,vector<ll> &inverse){
    factrial.resize(n+1);
    inverse.resize(n+1);
    factrial[0]=1;
    inverse[0]=1;
    for(ll i=1;i<=n;i++){
        factrial[i]=factrial[i-1]*i%m;
        inverse[i]=mod_inverse(factrial[i],m);
    }
}

//nCk
ll nCk(ll n,ll k,ll m,vector<ll> &factrial,vector<ll> &inverse){
    if(n<0||k<0||n<k){
        return 0;
    }
    return factrial[n]*inverse[k]%m*inverse[n-k]%m;
}

int main(){
    char s;
    cin>>s;
    cout<<(char)(s+1)<<endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        int answer = 0;
        int tap = 1;
        while(tap<B){
            tap = tap -1 + A;
            answer ++;
        }

        System.out.println(answer);

    }
}

Measured memory_bytes: 22996
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N, A[105];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	int c = 0;
	int minj, temp;

	for (int i = 0; i < N; i++)
	{
		minj = i;
		for (int j = i; j < N; j++)
		{
			if (A[j] < A[minj])
			{
				minj = j;
			}
		}

		if (minj != i)
		{
			temp = A[i];
			A[i] = A[minj];
			A[minj] = temp;
			c++;
		}
	}

	cout << A[0];
	for (int i = 1; i < N; i++)
	{
		cout << " " << A[i];
	}
	cout << endl;
	cout << c << endl;

	return 0;
}



Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,k,q;int a[100010];
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k>>q;
	for(register int i=1;i<=n;i++) a[i]=k;
	for(register int i=1;i<=q;i++) {
		int x;cin>>x;
		a[x]++;
	}
	for(register int i=1;i<=n;i++){
		if(a[i]<=q) cout<<"No"<<endl;
		else cout<<"Yes"<<endl; 
	}
}

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

root_n = n**0.5
if (root_n != int(root_n)):
    root_n = int(root_n)+1
else:
    root_n = int(root_n)    

for i in range(root_n, 0, -1):
    if(n%i == 0):
        ans = int(n/i)
        print(max([len(str(i)), len(str(ans))]))
        break

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

#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void youso(int A[], int N)
{
	int i;

	for(i = 0; i < N; i++){
		if(i){printf(" ");}
			printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N)
{
	int i, j, v;

	for(i = 1; i < N; i++){
		v = A[i];
		j = i-1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		youso(A, N);
	}
}


int main(void)
{

	int i, N, A[1000];

	scanf("%d", &N);

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

	youso(A, N);
	insertionSort(A, N);

	return 0;
}



Measured memory_bytes: 2020
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<17;

bool check(LL A,LL B,LL x){
    if(x%2){
        LL a,b;
        a=b=(x+1)/2;
        if(A<=(x+1)/2) a++;
        if(B<=(x+1)/2) b++;
        return A*B>a*b;
    }
    else{
        LL a[2],b[2];
        if(A<=x/2){
            a[0]=x/2+1;
            a[1]=x/2+2;
        }
        else if(A==x/2+1){
            a[0]=x/2;
            a[1]=x/2+2;
        }
        else{
            a[0]=x/2;
            a[1]=x/2+1;
        }
        if(B<=x/2){
            b[1]=x/2+1;
            b[0]=x/2+2;
        }
        else if(B==x/2+1){
            b[1]=x/2;
            b[0]=x/2+2;
        }
        else{
            b[1]=x/2;
            b[0]=x/2+1;
        }
        return A*B>max(a[0]*b[0],a[1]*b[1]);
    }
}


int main(){
    int Q;
    cin >> Q;
    while(Q--){
        LL a,b;
        cin >> a >> b;
        LL l=0LL,r=a+b;
        while(1){
            LL m=(l+r)/2;
            bool ok=check(a,b,m);
            if(ok){
                if(l==m){
                    cout << l << endl;
                    break;
                }
                l=m;
            }
            else{
                if(r==m){
                    cout << l << endl;
                    break;
                }
                r=m;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
c = [abs(x - y) for x, y in zip(a[:-1], a[1:])]
c_sum = sum(c)
for i in range(n):
    print(c_sum - c[i] - c[i + 1] + abs(a[i] - a[i + 2]))

Measured memory_bytes: 14044
#pragma GCC optimize ("-Ofast")
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) (long long)a.size()
#define all(a) a.begin(), a.end()
#define reset(a, n) a.clear(), a.resize(n)
#ifndef ONLINE_JUDGE
#define cin ___in
#endif
std::ifstream ___in("input.in");
using namespace std;
using ll = long long;
typedef pair<ll, ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > vvec;
typedef vector<pair<ll, ll> > vecpi;
typedef vector<vector<pair<ll, ll> > > vvecpi;
typedef set<ll> seti;
typedef set<pair<ll, ll> > setpi;
typedef multiset<ll> mseti;
typedef multiset<pair<ll, ll> > msetpi;
typedef map<ll, ll> mpi;

static const bool tc = 0;
static const ll mod = LLONG_MAX - 24;

void solve() {
        ll n, d, ans = 0;
        cin >> n >> d;
        while(n--) {
                ll x, y;
                cin >> x >> y;
                if(x * x + y * y <= d * d) ++ans;
        }
        cout << ans;
}

int main() {
        srand(time(0));
        int T = 1;
        if(tc) cin >> T;
        for(int i = 1; i <= T; ++i) {
                #ifndef ONLINE_JUDGE
                cout << "----- " << i << " -----\n";
                #endif
                solve();
        }
        return 0;
}


Measured memory_bytes: 3636
a = [int(input()) for _ in range(5)]
b = [(x % 10, x) for x in a]
b.sort()
ans = 0
flag = True
for c in b:
    if c[0] == 0:
        ans += c[1]
    else:
        if flag:
            flag = False
            ans += c[1]
        else:
            ans += c[1] - c[0] + 10
print(ans)


Measured memory_bytes: 3060
r=[59049,243,1,3125,1024,16807,32768,7776,0,32, \
371293,161051,100000,537824,1419857,1048576,1889568,248832,2476099,759375, \
20511149,11881376,7962624,9765625,4084101,3200000,5153632,14348907,17210368,6436343, \
33554432,60466176,28629151,69343957,79235168,52521875,24300000,45435424,90224199,39135393, \
229345007,254803968,184528125,102400000,130691232,147008443,205962976,164916224,282475249,115856201, \
601692057,418195493,459165024,380204032,312500000,345025251,714924299,503284375,550731776,656356768, \
1160290625,1350125107,916132832,1564031349,844596301,1252332576,1453933568,777600000,992436543,1073741824, \
2706784157,2887174368,3077056399,1934917632,2373046875,2535525376,2219006624,2073071593,1804229351,1680700000, \
3939040643,4437053125,4182119424,3276800000,3707398432,5277319168,5584059449,3486784401,4704270176,4984209207, \
7339040224,8587340257,6240321451,5904900000,6590815232,6956883693,7737809375,8153726976,9509900499,9039207968, \
10000000000,12762815625,11040808032,14693280768,15386239549,11592740743,14025517307,13382255776,12166529024,10510100501, \
20113571875,16105100000,17623416832,22877577568,21003416576,18424351793,21924480357,23863536599,19254145824,16850581551, \
33038369407,28153056843,27027081632,24883200000,30517578125,35723051649,34359738368,25937424601,31757969376,29316250624, \
46525874176,51888844699,41615795893,43204003424,40074642432,38579489651,44840334375,37129300000,48261724457,50049003168, \
57735339232,61917364224,71008211968,64097340625,68641485507,55730836701,66338290976,53782400000,73439775749,59797108943, \
75937500000,101621504799,78502725751,83841135993,92389579776,95388992557,89466096875,81136812032,98465804768,86617093024, \
118636749824,129891985607,108175616801,137858491849,122298103125,133827821568,115063617043,111577100832,104857600000,126049300576, \
146211169851,141985700000,159494694624,154963892093,173726604657,150536645632,168874213376,164130859375,178689902368,183765996899, \
199690286432,194264244901,188956800000,205236901143,216699865625,222620278176,210906087424,241162079949,234849287168,228669389707, \
312079600999,254194901951,274794888224,289254654976,296709280757,267785184193,304316815968,260919263232,281950621875,247609900000]
r.sort()
x=int(input())
for i in r:
  for j in r:
    if i-j ==x:
      print("%d %d" % (int(i**0.2),int(j**0.2)))
      exit()
    if i+j ==x:
      print("%d -%d" % (int(i**0.2),int(j**0.2)))
      exit()

Measured memory_bytes: 9448
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int dist(int x1, int x2, int y1, int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	int x = 0, y = 0, curr_t = 0;
	int a, b;
	int t;
	for (int i = 0; i < n; ++i) {
		cin >> t >> a >> b;
		int d = dist(x, a, y, b);
		if (t - curr_t < d || (t - curr_t) % 2 != d % 2) {
			cout << "No\n";
			return 0;
		}

		x = a;
		y = b;
		curr_t = t;
	}

	cout << "Yes\n";

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int suu,ei,koku;
	int x,y;
	int n;
	int i;

	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&suu,&koku,&ei);
			x=(suu+ei)/2;
			y=(suu+koku+ei)/3;
			if(suu==100 || koku==100 || ei==100){
				printf("A\n");
			}
			else if(x>=90){
				printf("A\n");
			}
			else if(y>=80){
				printf("A\n");
			}
			else if(y>=70){
				printf("B\n");
			}
			else if(y>=50 && (suu>=80 || ei>=80)){
				printf("B\n");
			}
			else{
				printf("C\n");
			}
		}
		scanf("%d",&n);
	}
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Vertex
{
    vector<ll> node;
};
Vertex V[205];
ll U[205];
bool T[205];
string S[205];
int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> S[i];
        FOR(j, N, i + 1)
        {
            if (S[i][j] == '1')
            {
                V[i].node.push_back(j);
                V[j].node.push_back(i);
            }
        }
    }

    ll max = -1;
    REP(i, N)
    {
        memset(U, 0, sizeof(U));
        memset(T, 0, sizeof(T));
        //! 頂点iをV0に入れる
        queue<pll> q;
        q.push(pll(i, 1));
        U[i] = 1;
        T[i] = true;
        ll m = 0;
        while (!q.empty())
        {
            pll t = q.front();
            ll v = t.second + 1;
            q.pop();
            REP(j, V[t.first].node.size())
            {
                ll n = V[t.first].node[j];
                if (U[n] > 0 && U[n] == v - 1)
                {
                    m = -1;
                    break;
                }
                if (U[n] > 0 && U[n] < v - 1)
                    continue;
                if (T[n])
                    continue;
                T[n] = true;
                U[n] = v;
                q.push(pll(n, v));
            }
            if (m == -1)
                break;
            m = std::max(m, v);
        }
        max = std::max(m, max);
    }

    if (max != -1)
        max--;
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    vector<ll> num(n,-1);
    ll count=0; ////
    ll s=0;  
    ll roopStart=0;
    ll roop=0;  
    ll now=0;  ////
    while(true){
        if(num[now]>=0){
            s=num[now];
            roopStart=now;
            roop=count-num[now];
            break;
        }
        num[now]=count;
        count++;
        now=a[now];
    }
    if(k<s){
        now=0;
        while(k){
            now=a[now];
            k--;
        }
        cout<<now+1<<endl;
    }else{
        k-=s;
        k%=roop;
        now=roopStart;
        while(k){
            now=a[now];
            k--;
        }
        cout<<now+1<<endl;
    }

}

Measured memory_bytes: 6020