akhauriyash/Code-Regression huggingface dataset:
import math
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

#maincode-------------------------------------------------
n = ini()
l = inl()
ans = 0
for k in range(n):
    for j in range(k):
        if l[k] == l[j]:
            continue
        for i in range(j):
            if l[k] == l[i] or l[j] == l[i]:
                continue
            if l[j] + l[i] <= l[k] or l[k] + l[i] <= l[j] or l[j] + l[k] <= l[i]:
                continue
            ans += 1
print(ans)

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

void solve()
{
    string a, b, c;
    cin >> a >> b >> c;
    string ans;
    ans += a[0] - 'a' + 'A';
    ans += b[0] - 'a' + 'A';
    ans += c[0] - 'a' + 'A';
    cout << ans << endl;
}

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

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    vector<int> prime(SIZE+1, 1);
    prime[1] = 0;
    for(int i = 2; i <= 1000; i++){
        for(int j = (i << 1); j <= SIZE; j+=i){
            prime[j] = 0;
        }
    }
    vector<int> ans;
    while(true){
        int idx = 0;
        int res = 0;
        int a, d, n; cin >> a >> d >> n;
        if(a == 0) break;
        while(idx < n){
            if(prime[a]){
                idx++;
            }
            if(idx == n) res = a;
            a += d;
        }
        ans.push_back(res);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 6612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    ll a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    ans=min(a,k);
    k-=a;
    if(k>0){
        k-=b;
    }
    if(k>0){
        ans-=k;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int a, b, c, d, n,res=0, m, tmp = 1, q, sum[200000] = {}, x[200000] = {}, v[200000] = {};
	string str;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	for (int i = 1; i <= n; i++) {
		sum[x[i]]++;
		sum[x[i] + 1]++;
		sum[x[i] + 2]++;
	}
	for (int i = 0; i <= 100005; i++) {
		if (res < sum[i]) { res = sum[i]; }
	}
	cout << res;
}

Measured memory_bytes: 3328
def main():
    s = input()
    tmp = 0


    for i in range(len(s)):
        if s[i] == "R":
            tmp += 1
    if tmp == 3:
        print(3)
    elif tmp == 2:
        if s[1] == "S":
            print(1)
        else:
            print(2)
    elif tmp == 1:
        print(1)
    else:
        print(0)



if __name__ == "__main__":
    main()

Measured memory_bytes: 61724
A, B, C, D = map(int, input().split(' '))
i = (B - A + D - C - abs(D-A))
if A<C and D<B:
    print(abs(D-C))
elif C<A and B<D:
    print(abs(B-A))
elif A<=C and C <=B:
    print(B-C)
elif C <= A and A<=D:
    print(D-A)    
else:
    print(0)


Measured memory_bytes: 3060
// 区間DPをします

#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
vector<ll> a,s;
ll dp[500][500];
int n;
/*
あからさまに区間DP
F(L,R) := [L,R]の区間のコストの最小値とする

[L,R)の区間のスライムを1つにする一手前の状態を考えると、[L,R)が2つに別れていることが分かる。
1 2 3 | 4 5
なので、分ける境界を全探索して、コストの最小値を求めていく。
累積和で区間和を高速に求められるようにしておかないとTLEする。
*/

ll rec(int l, int r) {
    if (dp[l][r] != -1) return dp[l][r];
    if (abs(l-r) <= 1) return 0;
    ll ret = LINF;
    for (int k = l+1; k < r; ++k) {
        // printf("l = %d, r = %d, k = %d\n",l,r,k);
        ret = min(ret, rec(l,k)+rec(k,r)+(s[r]-s[l]));
    }
    // printf("dp[%d][%d] = %lld\n",l,r,ret);
    return dp[l][r] = ret;
}

int main(int argc, char const *argv[]) {
    cin>>n;
    a.resize(n);
    s.resize(n+1);
    rep(i,n) cin>>a[i];
    rep(i,n) s[i+1] = s[i]+a[i];
    memset(dp,-1,sizeof(dp));
    cout << rec(0,n) << endl;
    return 0;
}

Measured memory_bytes: 2304
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int z = sc.nextInt();
    int t;
    t = x;
    x = y;
    y = t;
    t = x;
    x = z;
    z = t;
    System.out.print(x);
    System.out.print(" "+y);
    System.out.println(" "+z);
  }
}

Measured memory_bytes: 21972
from functools import reduce

# 入力
N = int(input())
S = input()

# 閉じられていない '(' の個数だけ S の末尾に ')' を、
# 閉じられていない ')' の個数だけ S の先頭に '(' を付与した文字列が解である
a, b = reduce(
    lambda acc, s: (
        (
            acc[0] + 1 if s == '(' else
            max(0, acc[0] - 1)
        ),
        (
            acc[1] + 1 if s == ')' and acc[0] == 0
            else acc[1]
        )
    ),
    S,
    (0, 0)
)
ans = b * '(' + S + a * ')'

# 出力
print(ans)


Measured memory_bytes: 3572
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
	int n,i;cin>>n;
    ll A[n],B[n],mn,mx;
    fo(i,0,n)cin>>A[i]>>B[i];
    sort(A,A+n);
    sort(B,B+n);
    if(n&1)
    mn=A[n/2],mx=B[n/2];
    else
    mn=A[n/2]+A[n/2-1],mx=B[n/2]+B[n/2-1];
    
    cout<<mx-mn+1<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 6764
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
class Bit{
public:
	vector<int>bit;
	Bit(){}
	Bit(int n){
		bit=vector<int>(n+10);
	}
	void add(int k,int x){
		k++;
		while(k<(int)bit.size()){
			bit[k]+=x;
			k+=k&-k;
		}
	}
	int sum(int k){
		k++;
		int res=0;
		while(k){
			res+=bit[k];
			k-=k&-k;
		}
		return res;
	}
};

template<class T>
class Rangetree{
	vector<vector<T>>dat;
	vector<T>v;
	void init(int k,int l,int r){
		if(r-l==1){
			if(l<(int)v.size())dat[k].push_back(v[l]);
			return;
		}
		int lb=k*2+1,rb=k*2+2;
		init(lb,l,(l+r)/2);
		init(rb,(l+r)/2,r);
		dat[k].resize(r-l);
		merge(dat[lb].begin(),dat[lb].end(),dat[rb].begin(),dat[rb].end(),dat[k].begin());
	}
public:
	Rangetree(){}
	Rangetree(int n,T*a){
		v.resize(n);
		for(int i=0;i<n;i++)v[i]=a[i];
		dat.resize(4*v.size());
		init(0,0,v.size());
	}
	Rangetree(vector<T>&a){
		v=a;
		dat.resize(4*v.size());
		init(0,0,v.size());
	}
	int query(int a,int b,int c,int d,int k,int l,int r){
		if(b<=l||r<=a)return 0;
		if(a<=l&&r<=b){
			int u=lower_bound(dat[k].begin(),dat[k].end(),d)-dat[k].begin();
			int v=lower_bound(dat[k].begin(),dat[k].end(),c)-dat[k].begin();
			return u-v;
		}
		int lb=query(a,b,c,d,k*2+1,l,(l+r)/2);
		int rb=query(a,b,c,d,k*2+2,(l+r)/2,r);
		return lb+rb;
	}
	int query(int a,int b,int c,int d){
		return query(a,b,c,d,0,0,v.size());
	}
};

string c[5000];
int a[5000];
ll dp[3000][3000];
int p[2][5000];
 
signed main(){
	int n;scanf("%d",&n);
	rep(i,2*n){
		cin>>c[i]>>a[i];a[i]--;
		if(c[i]=="B"){
			p[0][a[i]]=i;
		}
		else{
			p[1][a[i]]=i;
		}
	}
	vector<Bit>bit(2,Bit(n));
	ll ans=0;
	int c1=0,c2=0;
	rep(i,2*n){
		if(c[i]=="B"){
			ans+=c1-bit[0].sum(a[i]);
			c1++;
			bit[0].add(a[i],1);
		}
		else{
			ans+=c2-bit[1].sum(a[i]);
			c2++;
			bit[1].add(a[i],1);
		}
	}
	vector<Rangetree<int>>tree{
		Rangetree<int>(n,p[0]),
		Rangetree<int>(n,p[1])
	};
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	rep(i,n+1)rep(j,n+1){
		if(i<n){
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]+tree[1].query(0,j,p[0][i],2*n+1));
		}
		if(j<n){
			dp[i][j+1]=min(dp[i][j+1],dp[i][j]+tree[0].query(0,i,p[1][j],2*n+1));
		}
	}
	cout<<dp[n][n]+ans<<endl;
}

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

if M%2==0:
  for i in range(M//2):
    print(i+1,M-i)
  for i in range(M//2):
    print(M+i+1,2*M-i+1)  
else:
  for i in range(M//2):
    print(i+1,M-i)
  for i in range(M//2+1):
    print(M+i+1,2*M-i+1)

Measured memory_bytes: 9220
N, A, B = map(int, input().split())
S = input()

a = 0
b = 0
for s in S:
    if s == 'a':
        if a+b < A+B:
            print('Yes')
            a += 1
        else:
            print('No')
    elif s == 'b':
        if a+b < A+B and b < B:
            print('Yes')
            b += 1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 9200
n = int(input())
l = input().split()
num_list = []
for i in l:
    num_list.append(int(i))
num_list.sort()
min_num = num_list[0]
max_num = num_list[-1]
total = 0
for i in num_list:
    total += i

print(min_num, max_num, total)


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

#define N 3
#define Na 4
#define Nb 9
#define Nc 100

int puz[N][N];
int temp[N][N];
int dx[Na]={0,1,0,-1};
int dy[Na]={1,0,-1,0};

void emp(int x[],int y[]) {
  int i, j;
  for(i=0; i<N; i++) {
    for(j=0; j<N; j++) {
      if(!puz[i][j]) {
        *x = j;
        *y = i;
        return;
      }
    }
  }
}

void swap(int a[], int b[]){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}

int calsum(){
  int i, a, sum=0;
  for(i=0; i<Nb; i++){
    a = puz[i/N][i%N];
    if(a){
      a--;
      sum += abs((i/N)-(a/N)) + abs((i%N)-(a%N));
    }
  }
  return sum;
}

int dfs(int x,int y,int p,int dep,const int lim){
  int i, c, nx, ny, res;
  c = calsum();
  if(c==0) return dep;
  if(dep+c>lim) return -1;
  for(i=0;i<Na;i++){
    nx = x + dx[i];
    ny = y + dy[i];
    if(~p && i==(p+2)%Nb) continue;
    if(!(0<=nx && nx<N && 0<=ny && ny<N)) continue;
    swap(&puz[y][x],&puz[ny][nx]);
    res = dfs(nx,ny,i,dep+1,lim);
    if(~res) return res;
    swap(&puz[y][x],&puz[ny][nx]);
  }
  return -1;
}

int main() {
  int i, j, k, x, y, ans;
  for(i=0; i<N; i++){
    for(j=0; j<N; j++) scanf("%d",&puz[i][j]);
  }
  emp(&x,&y);
  for(k=0; k<Nc; k++){
    for(i=0; i<N; i++){
      for(j=0; j<N; j++) temp[i][j] = puz[i][j];
    }
    ans=dfs(x,y,-1,0,k);
    if(ans!=-1){
      printf("%d\n",ans);
      break;
    }
    for(i=0;i<N;i++){
      for(j=0;j<N;j++) puz[i][j] = temp[i][j];
    }
    ans = -1;
    if(k==Nc-1) printf("%d\n",ans);
  }
  return 0;
}



Measured memory_bytes: 2112
N, K = map(int, input().split())

mod = 10 ** 9 + 7

memo = [0] * (K + 1)
ans = 0
for i in range(K, 0, -1):
    memo[i] = pow(K // i, N, mod)
    j = 2
    while i * j <= K:
        memo[i] -= memo[i * j]
        j += 1
    ans += memo[i] * i
    ans %= mod

print(ans)


Measured memory_bytes: 11288
n, m = gets.split.map(&:to_i)
city = []
m.times do |i|
  city[i] = i, *gets.split.map(&:to_i)
end
city.sort! do |c1, c2|
  if c1[1] == c2[1]
    c1[2] <=> c2[2]
  else
    c1[1] <=> c2[1]
  end
end
pref = nil
idx = 1
city.each do |c|
  if c[1] != pref
    idx = 1
    pref = c[1]
  else
    idx += 1
  end
  c[3] = idx
end
city.sort! do |c1, c2|
  c1[0] <=> c2[0]
end
city.each do |c|
  printf "%06d%06d\n", c[1], c[3]
end


Measured memory_bytes: 27264
def main():
    N, K = map(int, input().split())
    d_list = []
    Ai_list = []
    dict = {}
    b_list = []
    for i in range(0,K) :
        d = int(input())
        d_list.append(d)
        A_list = [A for A in input().split()]
        A_list = list(map(int, A_list))
        dict[d] = A_list
        b_list.extend(A_list)
        A_list = []

    b_list = list(set(b_list))
    print (N - len(b_list))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9260
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;



int main() {
	long long t,w,s=0;
	cin>>t>>w;
	while(t<=w) {
	    w>>=1;
	    s++;
	}
	cout<<s;
}

Measured memory_bytes: 256
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



n = I()
ans=0
c = [[0]*10 for i in range(10)]

for i in range(1,n+1):
    s = str(i)
    if s[0]=="0" or s[-1]=="0":
        continue
    c[int(s[0])][int(s[-1])]+=1


for i in range(1,10):
    for j in range(1,10):
        ans+=c[i][j]*c[j][i]
print(ans)



Measured memory_bytes: 5196
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

M, D = map(int, input().split())

if D < 22:
    print(0)
    sys.exit()

ans = 0
for i in range(22, D+1):
    if (i//10)*(i%10) <= M and i%10 > 1: 
        ans += 1

print(ans)


Measured memory_bytes: 2940
"use strict";
    
const main = arg => {
  // とりあえず切り分け
  let Nums = arg.split("\n");
  let N = Nums[0].split(" ")[0]*1;
  let K = Nums[0].split(" ")[1]*1;
  let bowls = Nums[1].split(" ");
  // 0埋めした配列
  let bowl_amount = new Array(N).fill(0);
  let ans = 0;
  bowls.forEach(
    (bowl)=>{
      	// 配列の要素に格納するために１つずらして該当するものを見つけるたびに足してく
    	bowl_amount[bowl - 1]++;
    }
  );
  // 小さい順に並べる
  let bowlArr = bowl_amount.sort((a,b)=>{return a-b}).reverse();
  // 該当する要素数の足し合わせ
  for(let i = N-1; i >= K; i--){
  	ans += bowlArr[i];
  }
  
  console.log(ans);
}

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


Measured memory_bytes: 33956
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <cmath>
#include <iomanip>


class engine{
public:
  double X, Y;
  
  engine(double x, double y){
    X = x;
    Y = y;
  }
};

int main(){
  
  // read problem
  long long int N;
  double tmp1, tmp2;
  std::vector<class engine> engines;
  
  scanf("%lld", &N);
  for(long long int i = 0; i < N; i++){
    scanf("%lf%lf", &tmp1, &tmp2);
    engines.push_back(engine(tmp1, tmp2));
  }
  
  for(long long int i = 0; i < N; i++){
    std::cerr << "engine:" << i << " " << engines[i].X << " " << engines[i].Y << std::endl;
  }
  
  // solve problem
  double ans = 0.0;
  double nx, ny, x, y;
  
  
  for(long long int i = 0; i < 1e5; i++){
    x = 0.0;
    y = 0.0;
    nx = std::cos(2*3.141593 * (i/100000.0));
    ny = std::sin(2*3.141593 * (i/100000.0));
    for(long long int j = 0; j < N; j++){
      if(nx*engines[j].X + ny*engines[j].Y > 0){
        x += engines[j].X;
        y += engines[j].Y;
      }
    }
    ans = std::max(ans, std::sqrt(x*x+y*y));
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << std::setprecision(20) << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
const int MD=1e9+7;
vector<int> G[N];
int f[N],ans[N];
int n,a,b;
int quick_pow(int x,int y) {
	int ans=1;
	while(y) {
		if(y&1) ans=1LL*ans*x%MD;
		y>>=1;
		x=1LL*x*x%MD;
	}
	return ans;
}
void dfs(int u,int fa) {
	for(auto v:G[u]) {
		if(v==fa) continue;
		dfs(v,u);
		f[u]+=f[v];
	}
	f[u]++;
}
void cal(int u,int fa) {
	for(auto v:G[u]) {
		if(v==fa) continue;
		ans[v]=1LL*ans[u]*quick_pow(f[v],MD-2)%MD*(n-f[v])%MD;
		cal(v,u);
	}
}
int main() {
    //freopen("in.txt","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(1,-1);
	ans[1]=1;
	for(int i=1;i<=n;i++) {
		ans[1]=1LL*ans[1]*f[i]%MD;
	}
	cal(1,-1);
	int t=1;
	for(int i=1;i<=n;i++) t=1LL*t*i%MD;
	for(int i=1;i<=n;i++) {
		printf("%d\n",1LL*t*quick_pow(ans[i],MD-2)%MD);
	}
    return 0;
}


Measured memory_bytes: 15476
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <stack>
#include <iomanip>

using namespace std;

#define MAX_DATA_NUM 10000000

double S[MAX_DATA_NUM];
int head;

void push(double num){
  S[head] = num;
  head++;
  if(head == MAX_DATA_NUM)head = 0;
}

double pop(){
  head--;
  double res = S[head];
  return res;
}

// 入力を1行読み込み, 扱いやすい形式に変換する
// 例 : "10 2 12 - /" -> {"10", "2", "12", "-", "/"}
vector<string> read_input()
{
  string line;
  getline(cin, line);
  istringstream ss(line);

  vector<string> parsed_str;
  while (!ss.eof()) {
    string tmp; ss >> tmp;
    parsed_str.push_back(tmp);
  }

  return parsed_str;
}


double solve(vector<string> input_strs)
{
  for(int i = 0; i < input_strs.size(); i++){
    if(input_strs[i] == "+"){
      double a = pop(), b = pop();
      push(a + b);
    }else if(input_strs[i] == "-"){
      double a = pop(), b = pop();
      push(b - a);
    }else if(input_strs[i] == "*"){
      double a = pop(), b = pop();
      push(a * b);
    }else if(input_strs[i] == "/"){
      double a = pop(), b = pop();
      push(b / a);
    }else {
      push(stod(input_strs[i]));
    }
  }
  double res = pop();
  return res;
}


int main()
{
  while (true) {
    vector<string> input_strs = read_input();

    // 全てのテストケースを処理し終わったらループを抜ける
    if (cin.eof()) break;

    double ans = solve(input_strs);
    cout << fixed << setprecision(10) << ans << endl;
  }
}

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

int main(){
    int n;
    cin >> n;
    
    for(int i = 0; i <= 999; i++){
        if(n % 111 == 0){
            cout << n << endl;
            break;
        }else{
            n++;
        }
    }
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 51;
int x[N], a[N], b[N], c[N], d[N];
long res = 0;
int n, m, Q;

void Try(int u){
  for (int i = x[u - 1]; i <= m; i++){
    x[u] = i;
    if (u == n){
      long cur = 0;
      for (int j = 1; j <= Q; j++){
        if (x[b[j]] - x[a[j]] == c[j]) cur += d[j];
      }
      res = max(res, cur);
    }
    else Try(u + 1);
  }
}

int main()
{
  fastio;
  cin >> n >> m >> Q;
  for (int i = 1; i <= Q; i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  x[0] = 1; Try(1);
  cout << res;
  return 0;
}

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

int main(void) {
  int N, P;
  scanf("%d %d", &N, &P);
  int A[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    A[i] = A[i]%2;
  }
  
  int cnt0 = 0;
  int cnt1 = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == 0) cnt0++;
    else cnt1++;
  }
  
  
  long long int ans = 0;
  if (P == 1) {
    if (cnt1 == 0) printf("%d", 0);
    else {
      ans = pow(2, cnt0 +(cnt1-1) )*1;
      printf("%lld", ans);
    }
  } else {
    if (cnt0 == 0) {
      ans = pow(2, cnt1-1)*1;
      printf("%lld", ans);
    } else if (cnt1 == 0){
      ans = pow(2, N);
      printf("%lld", ans);
    }else {
      ans = pow(2, cnt0 + (cnt1-1) )*1;
      printf("%lld", ans);
    }
  }
  
  return 0;
}


Measured memory_bytes: 128
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int BIG = 1e+18+3;
int mod = 1e+9+7;

int memoized[1005][1005];
char grid[1005][1005];

int dp(int x,int y)
{
    if (memoized[x][y]!=-1)
        return memoized[x][y];

    int buffer = 0;

    if (x>1)
        buffer = (dp(x-1,y)*(grid[x][y]=='.')+buffer)%mod;
    if (y>1)
        buffer = (dp(x,y-1)*(grid[x][y]=='.')+buffer)%mod;

    memoized[x][y] = buffer;

    return buffer;
}

signed main()
{
    IOS;
    
    int h,w; cin>>h>>w;

    repa(i,0,1000)
        repa(j,0,1000)
            memoized[i][j] = -1;

    memoized[1][1] = 1;

    repa(i,1,h)
        repa(j,1,w)
            cin>>grid[i][j];

    cout<< dp(h,w) <<endl;

}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    int ans = 1;
    int d = 0;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
        d += l[i];
        ans += (d <= x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
#define N 200
 
main(){
 
  int i,j,a,b,c,d;
  int Adj[N][N];
 
 scanf("%d",&a);
 
  for(i = 1; i <= a; i++){
    for(j = 1; j <= a; j++){
      Adj[i][j] = 0;
    }
  }
  for(i = 1; i <= a; i++){
    scanf("%d%d",&b,&c);
      for(j = 1; j <= c; j++){
    scanf("%d",&d);
    Adj[b][d] = 1;
      }
  }
 
  for(i = 1; i <= a; i++){
    for(j = 1; j <= a; j++){
      if(j == a) printf("%d\n",Adj[i][j]);
      else printf("%d ",Adj[i][j]);     
      }
  }
 
  return 0;
}

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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	string S;
	string divide[4] = {"dream", "dreamer", "erase", "eraser"};
	
	cin >> S;
	
	reverse(S.begin(), S.end());
	for(int i=0; i<4; i++)
		reverse(divide[i].begin(), divide[i].end());
	
	bool can = true;
	
	for(int i=0; i<S.size();){
		bool can2 = false;
		for(int j=0; j<4; j++){
			string d = divide[j];
			if(S.substr(i, d.size()) == d){
				can2 = true;
				i += d.size();
			}
		}
		if(!can2){
			can = false;
			break;
		}
	}
	
	if(can)
		cout << "YES";
	else
		cout << "NO";
	
	return 0;
}

Measured memory_bytes: 512
/*
Author : N_o_o_B
Created : April 22 2020 22:52:41 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    string o,e;
    cin >> o >> e;
    int p1=0,p2=0;
    fori(i,sz(o)+sz(e)){
        if(i%2==0){
            cout << o[p1++];
        }
        else cout << e[p2++];
    }
    cout << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
h,w,k = map(int,input().split())
cho=[input()for i in range(h)]

size=[[0]*h for i in range(1<<h)]
ans=[bin(x).count("1") for x in range(1<<h)]
for stage in range(w):
    new=[[0]*h for i in range(1<<h)]
    for column in range(h):
        if int(cho[column][stage]):
            for bit in range(1<<h):
                length=(((1<<column)-1) & bit).bit_length()
                new[bit][length]+=1
    for bit in range(1<<h):
        frag=True#Trueのままならnewを足し算
        for column in range(h):
            if new[bit][column]+size[bit][column]>k:
                if new[bit][column]>k:#一列の時点でkを超えていたらもう無理
                    ans[bit]+=1010
                frag=False
                ans[bit]+=1
                size[bit]=new[bit]
                break
        if frag:
            for column in range(h):
                size[bit][column]+=new[bit][column]
print(min(ans))

Measured memory_bytes: 66140
#include<stdio.h>
int main(void){
  int n,i,j=0;
  char s[101],t[101],u[250];
  scanf("%d",&n);
    scanf("%s",s);
    scanf("%s",t);
  for(i=0;i<=n;i++){
    u[j]=s[i];
    j++;
    u[j]=t[i];
    j++;
  }
  printf("%s\n",u);
  return 0;
}
    
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n,k,q;
  cin>>n>>k>>q;
  map<int,int> mp;
  int a;
  REP(i,q){
    cin>>a;
    mp[a]++;
  }
  int temp;
  REPP(i,n){
    temp = k-q+mp[i];
    if(temp>0){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}


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



int main(){
	ll N;
	ll a,b;
	cin>>N;

	for(int i=1;i<=sqrt(N);i++){
		if(N%i==0){
			a=i;
			b=N/i;
		}
	}
	cout<<a-1+b-1<<endl;
}

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

int main() {
    cout << fixed << setprecision(10);
    int N , K , n = 0;
    double ans = (double)0 , part ;
    cin >> N >> K;
    for(int i = 1;i<=N;i++){
        part=1.0/N;
        n = i;
        while(n<K){
            n *=2; 
            part/=2;
        }
        ans +=part;
        }
        cout << ans << endl;
}
    


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

//降順
int des(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main() {
  int n;
  scanf("%d", &n);
  int l[n], ans = 0;
  for (int i=0; i<n; i++) scanf("%d", l+i);
  qsort(l, n, sizeof(int), des);
  for (int i=0; i<n-2; i++) {
    for (int j=i+1; j<n-1; j++) {
      int k=j+1;
      while (l[k]>l[i]-l[j] && k<n) {
        ans++;
        k++;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n, k;
    cin >> n >> k;
    ll h[n];

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

    sort(h, h+n);

    ll ans = h[k-1] - h[0];

    for (int i = 0; i <= n - k; i++) {
        ans = min(ans, h[i+k-1] - h[i]);
    }

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

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

int main() {
    int n, k;
    int sum=0;
    cin >> n >> k;
    int i[n];

    for (int t=0; t < n; t++) {
        cin >> i[t];
    }
    sort(i, i + n);
    for (int t=0; t < k; t++) {
        sum += i[t];
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3636
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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 dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG

using namespace std;


int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>>data(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> data[i][j];
		}
	}
	vector<vector<char>>ans(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (data[i][j] == '#') {
				ans[i][j] = '#';
			}
			else{
				int n = 0;
				for (int k = 0; k < 8; k++) {
					int ni = i + dx[k];
					int nj = j + dy[k];
					if (ni < 0 || H <= ni) {
						continue;
					}
					if (nj < 0 || W <= nj) {
						continue;
					}
					if (data[ni][nj] == '#') {
						n++;
					}
				}
				ans[i][j] = char(n + '0');
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << ans[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>

typedef long long ll;

#define debug(x) cerr << #x << ": " << x << "\n";
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s[s.size()-1] == '3') cout << "bon" << endl;
  else if(s[s.size()-1] == '0' || s[s.size()-1] == '1' || s[s.size()-1] == '6' || s[s.size()-1] == '8')
    cout << "pon" << endl;
  else cout << "hon" << endl;
}
      


Measured memory_bytes: 3628
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;

int main()
{
	int n;
	while (cin >> n) {
		if (n == 0)
			break;

		string s;
		cin >> s;

		for (int i = 0; i < n; ++i) {
			s.append(";");

			int cnt = 1;
			char prev = s[0];
			string next = "";
			for (unsigned int j = 1; j < s.size(); ++j) {
				if (s[j] == prev) {
					++cnt;
				} else {
					stringstream ss;
					ss << cnt;
					next += ss.str() + prev;

					prev = s[j];
					cnt = 1;
				}
			}
			s = next;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1048
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair < ll, int > PLI;


#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

#define fname ""

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int n, a[N], ans;

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

	#ifdef krauch
        freopen("input.txt", "r", stdin);
    #else
        //freopen(fname".in", "r", stdin);
        //freopen(fname".out", "w", stdout);
    #endif

    cin >> n;
    forn(i, 1, n) {
        cin >> a[i];
    }

    int cnt = 1;
    forn(i, 2, n) {
        if (a[i - 1] != a[i]) {
            ans += cnt / 2;
            cnt = 0;
        }
        ++cnt;
    }

    ans += cnt / 2;

    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = input()
    l = len(S)
    ans = INF
    for i in range(l - 2):
        x = int(S[i:i + 3])
        score = abs(x - 753)
        ans = min(ans, score)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61836
from collections import defaultdict as dd

N,K=map(int,input().split())
a = list(map(int,input().split()))


res = 1
dic=dd(int)

now = 1
mita = set()
mita.add(now)
dic[now] = 1
start = 0
end = 0
# loop
while 1:
    next_town = a[now-1]
    # print(next_town)
    if next_town in mita:
        start = next_town
        end = now
        break
    else:
        res += 1
        now = next_town
        mita.add(next_town)
        dic[next_town] = res
    if res == K+1:
        print(next_town)
        exit()
# print(dic)

loop_num = dic[end] - dic[start] + 1
Kmod = (K-res)%loop_num
# print(K,res,loop_num,Kmod)
now = next_town
for i in range(Kmod):
    next_town = a[now-1]
    now = next_town
print(now)




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

int main(){
  int a;
  cin >> a;
  int ans = -1;
  int now = 7%a;
  for(int i = 0; i <= a; i++){
    if (now % a == 0){
      ans = i+1;
      break;
    }
    now = now*10+7;
    now %= a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a) (a).begin(), (a).end()

const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec)
    is >> x;  // for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}

int main() {
  ll h, w;
  cin >> h >> w;

  vector<vector<char>> s(40, vector<char>(40, '#'));

  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      cin >> s[i][j];
    }
  }
  // わーシャルフロイド使えそう


  ll f = h * w;
  vector<vector<ll>> wdist(1000, vector<ll>(1000, LLINF));

  for (ll i = 0; i < h; i++) {    // i行
    for (ll j = 0; j < w; j++) {  // j列
      if (s[i][j] == '#') continue;

      if (i > 0)
        if (s[i - 1][j] == '.') wdist[i * w + j][(i - 1) * w + j] = 1;

      if (i < h - 1)
        if (s[i + 1][j] == '.') wdist[i * w + j][(i + 1) * w + j] = 1;

      if (j > 0)
        if (s[i][j - 1] == '.') wdist[i * w + j][(i)*w + j - 1] = 1;

      if (j < w - 1)
        if (s[i][j + 1] == '.') wdist[i * w + j][(i)*w + j + 1] = 1;
    }
  }

  for (ll i = 0; i < h; i++) {    // i行
    for (ll j = 0; j < w; j++) {  // j列
      if (s[i][j] == '#') continue;
      wdist[i * w + j][i * w + j] = 0;
    }
  }

  // cerr << endl;
  //   for (ll i = 0; i < h; i++) {    // i行
  //     for (ll j = 0; j < w; j++) {  // j列
  //     cerr << wdist[h*0+3][h*i + j] << " ";
  //     }
  //     cerr << endl;
  //   }
  //   cerr << endl;

  for (ll i = 0; i < f; ++i) {
    for (ll j = 0; j < f; j++) {
      for (ll k = 0; k < f; k++) {
        wdist[j][k] = min(wdist[j][k], wdist[j][i] + wdist[i][k]);
      }
    }
  }


  ll ans = 0;
  for (ll i = 0; i < f; ++i) {
    for (ll j = 0; j < f; j++) {
      if (wdist[i][j] == LLINF) continue;
      ans = max(ans, wdist[i][j]);
    }
  }



  cout << ans << endl;
}


Measured memory_bytes: 8064
#include<stdio.h>
#include<string.h>

int main(){
int a,b;
scanf("%d%d",&a,&b);
if(a==b){
	printf("a == b\n");
	
	
}else if(a>b){
	
	printf("a > b\n");
	
	
}else if(a<b){
	
	
	printf("a < b\n");
		
		
		
	
	
}

	return 0;
}

Measured memory_bytes: 580
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int n=nextInt();
		long[] a = nextLongs();
		StringBuffer sb=new StringBuffer();
		if(n%2==1){
			for(int i=n-1;i>=0;i-=2){
				sb.append(a[i]);
				sb.append(" ");
			}
			for(int i=1;i<n-1;i+=2){
				sb.append(a[i]);
				sb.append(" ");
			}
		}else{
			for(int i=n-1;i>=0;i-=2){
				sb.append(a[i]);
				sb.append(" ");
			}
			for(int i=0;i<n-1;i+=2){
				sb.append(a[i]);
				sb.append(" ");
			}
		}
		sb.delete(sb.length()-1, sb.length());
		System.out.println(sb.toString());

	}



	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 64596
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b);
int main(){
    long long a,b;
    cin>>a>>b;
    long long n=gcd(a,b);
    //cout<<n<<endl;
    vector<int> prime(1000001,0);
    int ans=1;
    for(long long i=2;i*i<=n;i++){
        //cout<<i<<" "<<n<<endl;
        if(n%i==0){
            while(n%i==0){
                n/=i;
            }
            ans++;
        }
    }
    if(n!=1)ans++;
    cout<<ans<<endl;
    return 0;
}

long long gcd(long long a,long long b){
    if(b==0)return a;
    else return gcd(b,a%b);
}

Measured memory_bytes: 4096
N, K = map(int, input().split())
R = N - K
count = 0
P = 1000000007

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N+1):
    fact.append((fact[-1] * i) % P)
    inv.append((-inv[P % i] * (P//i) % P))
    factinv.append((factinv[-1] * inv[-1] % P))


def cmb_mod(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n-r)
    return fact[n] * factinv[r] * factinv[n-r] % p


for i in range(1, K+1):
    print((cmb_mod(R+1, i, P) * cmb_mod(K-1, i-1, P)) % P)


Measured memory_bytes: 74104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    // k回前のが同じなら勝てない
    // それ以外勝てる

    ll n, k;
    cin >> n >> k;
    ll r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;

    ll ret = 0;
    vector<bool> used(n);
    REP(i, n) {
        if(t[i]=='r') {
            if(i<k || t[i-k]!='r' || !used[i-k]) ret += p, used[i] = true;
        } else if(t[i]=='s' ) {
            if(i<k || t[i-k]!='s' || !used[i-k]) ret += r, used[i] = true;
        } else {
            if(i<k || t[i-k]!='p' || !used[i-k]) ret += s, used[i] = true;
        }
    }
    dump(used);
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
using vi = vector<int>;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

int main() {
  string S, T;
  ins(S, T);

  map<char, vi> m_s;
  rep(i, S.size())
    m_s[S[i]].push_back(i);

  int idx = -1;
  int n = 0;
  rep(i, T.size()) {
    if (m_s.count(T[i]) == 0) {
      cout << "-1\n";
      return 0;
    }
    auto it = all(upper_bound, m_s[T[i]], idx);
    if (it == m_s[T[i]].end()) {
      ++n;
      idx = m_s[T[i]][0];
    } else
      idx = *it;
  }
  cout << 1LL * idx + n*S.size() + 1 << endl;

  return 0;
}


Measured memory_bytes: 1216
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
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() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    int maxa = 0;
    rep(i, n) {
        cin >> a[i];
        maxa = max(maxa, a[i]);
    }
    vector<map< int64_t, int >> m(n+1);
    rep(i, n) {
        m[i] = prime_factor(a[i]);
    }
    vector<int> cnt(1000001, 0);
    bool break_flag = false;
    rep(i, n) {
        for(auto e:m[i]) {
            if (cnt[e.first]==1) {
                break_flag = true;
                break;
            }
            cnt[e.first] = 1;
        }
        if(break_flag) break;
    }
    if (!break_flag) {
         cout << "pairwise coprime\n";
        return 0;
    }
    vector<int> cumgcd(n+2);
    cumgcd[0] = a[0];
    rep(i, n) {
        cumgcd[i+1] = gcd(cumgcd[i], a[i]);
    }
    // auto t = prime_table(1000000);


    if(cumgcd[n]==1) {
        cout << "setwise coprime\n";
    }else{
        cout << "not coprime\n";
    }


}

Measured memory_bytes: 377748
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, k, ans =0;
	cin >> n >> k;
	vector<lli> a(n+1, 0);
	rep(i,k){
		lli d;
		cin >> d;
		rep(i,d){
			lli t;
			cin >> t;
			a[t]++;
		}
	}
	loop(i, 1, n+1){
		if(a[i] < 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3672