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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int  n; VI a(3);
	cin >>n >>a[0] >>a[1] >>a[2];
	VI l(n);
	rep(i, n) cin >>l[i];
	ll ans = 1LL<<60;
	int ym=n, xmx=4;  
	vector<int> ct(ym,0);
	auto rcf=[&](auto rcf, int idx){
		if(idx==ym){
			VI sk(4, 0); VL sm(4, 0);
			rep(i, n){ sk[ct[i]]++; sm[ct[i]] +=l[i]; }
			bool ok=true;
			rep(i, 3) if(sk[i]< 1) ok=false;
			if(!ok) return;
			ll zsm = 0;
			rep(i, 3) if(sk[i]>1) zsm += 10 * (sk[i]-1);
			rep(i, 3) zsm += abs(a[i] - sm[i]);
			ans = min(ans, zsm);
			return ;
		}
		rep(i, xmx){
			ct[idx]=i;
			rcf(rcf, idx+1);
		}
	};
	
	rcf(rcf, 0);
	cout << ans <<"\n";
	return 0;
}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)
char mat[1010][1010];
int component[1010][1010];
int xi, yi, xf, yf;
int n, m;
bool visited[1010][1010];
int now;
map<int , vector<int>> adj;
map<int ,bool> visitedcomp;
map<int,int> depth;



int dx[4] = {-1 , 0 , 0 ,1};
int dy[4] = {0 , -1 , 1 , 0};
map<pair<int,int>, bool> connection;


void dfs(int x, int y){
	visited[x][y] = true;
	component[x][y] = now;

	for (int f = 0 ; f < 4 ; f++){
			int i = dx[f];
			int j = dy[f];
			if (x + i >= 0 && x + i < n && y + j >= 0 && y + j < m && visited[x + i][y + j] == false && mat[x + i][y + j] == '.'){
				dfs(x + i , y + j);
			}
		
	}

}










void solve(){
	
	
	cin >> n >> m >> xi >> yi >> xf >> yf;

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


	for (int i = 0 ; i < n ; i++){
		for (int j = 0 ; j < m ; j++){
			if (visited[i][j] == false && mat[i][j] == '.'){
				now++;
				dfs(i,j);
			}
		}
	}



	for (int i = 0 ; i < n ; i++){
		for (int j = 0 ; j < m ; j++){
			if ((mat[i+1][j] == '#' || mat[i][j+1] == '#') && mat[i][j] == '.'){

				for (int f = i - 2 ; f < i + 3 ; f++){
					for (int k = j - 2 ; k < j + 3 ; k++){
						if (f < 0 || k < 0 || f >= n || k >= m)continue;
						if (component[f][k] > 0 && component[f][k] != component[i][j] && connection[{component[f][k], component[i][j]}] == false){
							connection[{component[f][k], component[i][j]}] = connection[{component[i][j], component[f][k]}] = true;
							adj[component[f][k]].push_back(component[i][j]);
							adj[component[i][j]].push_back(component[f][k]); 
						}

					}
				}


			}
		}
	}




	int start = component[xi - 1][yi - 1];
	int end = component[xf - 1][yf - 1];

	

	depth[start] = 1;

	// cout << start << " " << end  << "ff " << endl;



	queue<int> q;

	q.push(start);

	visitedcomp[start] = true;

	while(q.size()){
		int p = q.front();
		q.pop();

		for (int i : adj[p]){
			if (visitedcomp[i] == false){
				visitedcomp[i] = true;
				depth[i] = depth[p] + 1;
				q.push(i);
			}
		}



	}

	
	cout << depth[end] - 1 << endl;

	



}



int main()
{
    FAST;
    int t;
   	t = 1;

    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 63688
#include<stdio.h>
int main(void){
	int a,b,c,n;
	scanf("%d %d %d",&a,&b,&c);
	while(a>b || a>c || b>c){
		if(a>b){
			n=a;
			a=b;
			b=n;
		}else if(a>c){
			n=a;
			a=c;
			c=n;
		}else if(b>c){
			n=b;
			b=c;
			c=n;
		}
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
import Control.Monad
import Data.List
import qualified Data.Map.Strict as M

main=do
    s <- getLine
    print.(+) 1.(-) (comb2 $ length s).sum.map (comb2.snd).M.toList $ foldl (\m k->M.insertWith(+)k 1 m) M.empty s

comb2 n = (n*(n-1)) `div` 2

Measured memory_bytes: 13820
from itertools import combinations

# input
N, D = map(int, input().split())
X = []
append = X.append
for n in range(N):
    x = list(map(int, input().split()))
    append(x)

# check
cnt = 0
for i, j in combinations(X, 2):
    k = sum([abs(i[d] - j[d]) ** 2 for d in range(D)]) ** 0.5
    if k % 1 == 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
import scipy.sparse.csgraph as c,numpy
_,*s=open(0)
s=numpy.array([list(map(int,t[:-1]))for t in s])
m=c.floyd_warshall(s)
i=m[0]%2<1
j=i^True
print((s[i][:,i]<1).all()*(s[j][:,j]<1).all()*int(m.max()+1)or-1)

Measured memory_bytes: 15000
from math import degrees,atan2
a,b,x = map(int, input().split())
ans = 0
if (a*a*b/2 >= x):
    ans = degrees(atan2(a*b*b,2*x))
else:
    x = a*a*b - x
    ans = degrees(atan2(2*x,a*a*a))

print(ans)


Measured memory_bytes: 9324
// CODE © by 𝕌𝕥𝕜𝕒𝕣𝕤𝕙 𝔾𝕒𝕣𝕘
// Copying or sharing of this code without permission of the Author is strictly prohibited!!!
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define endl "\n"
vector<int>v[100001];
int dp[100001];
int f(int sp, unordered_set<int> &s) {
	// cout << "on vertex no. " << sp << " - ";
	s.insert(sp);
	int ans = 0;
	if (dp[sp] != -1)return dp[sp];
	for (int i = 0; i < v[sp].size(); i++)
		ans = max(ans, f(v[sp][i], s));
	return dp[sp] = 1 + ans;
}
signed main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
#endif
	int a = 0, b = 0, c = 0, d = 0, i = 0, j = 0, k = 0, t = 0, n = 0, q = 0, m;
	cin >> n >> m;
	memset(dp, -1, sizeof(dp));
	for (i = 0; i < m; i++)
	{cin >> a >> b; v[a].pb(b);}
	unordered_set<int> s;
	int ans = 0;
	for (i = 1; i <= n; i++) {
		if (dp[i] != -1)continue;
		// cout << "calc for " << i << endl;
		ans = max(f(i, s), ans);
		// cout << endl;
		// cout << "ans for " << i << " is " << f(i, s) << endl << "---------------------------------" << endl;
	}
	cout << ans - 1 ;
}

Measured memory_bytes: 16332
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	float mon,low=1000000,high=0;
	while(cin>>mon){
		if(low>mon)low=mon;
		if(high<mon)high=mon;
	}
	cout<<high-low<<endl;
	return 0;
}

Measured memory_bytes: 3124
import math
n,d=map(int,input().split())
cnt=0
dlist=[list(map(int,input().split())) for _ in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        ans=0
        for k in range(d):
            ans+=(dlist[i][k]-dlist[j][k])**2
        cnt+=math.floor(ans**0.5)==math.ceil(ans**0.5)

print(cnt) 

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

int main() {
	int N;
	int ans=0;
	cin >> N;

	vector<int> p(N);

	for (int i=0; i < N; i++) {
		cin>>p.at(i);
		ans += p.at(i);
	}
	ans -= *max_element(p.begin(), p.end()) / 2;
	cout << ans << endl;
}

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

int main() {
    int D;
    cin >> D;
    vector<int> c(26);
    for(int i = 0; i<26; i++){
        cin >> c.at(i);
    }

    vector<vector<int>> s(D, vector<int>(26));
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> s.at(i).at(j);
        }
    }


    vector<int> v;  //過去の選択肢記憶用
    int score = 0;  //現在の点数

    for (int i =0; i < D; i++){
        vector<int> w(26);  //選択肢比較用配列
        for(int j=0; j<26; j++){
            int M=0;
            for(int k=0; k<26; k++){
                int last;
                std::vector<int>::iterator itr = find(v.begin(), v.end(),k+1);
                size_t index = std::distance(v.begin(), itr);
                last = itr == v.end()? 0 : index;
                M += c.at(k) * (i + 1 - (v.size() - last));
            }
            w.at(j) = s.at(i).at(j) - M;
        }
        std::vector<int>::iterator iter = std::max_element(w.begin(), w.end());
        size_t index = std::distance(w.begin(), iter);

        v.insert(v.begin(), index + 1);
    }


    for(int i=D-1; i>-1; i--){
        cout << v.at(i) << endl;
    }

}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;

    int d_a, d_b;

    if(x-a>0) d_a = x-a;
    else d_a = a-x;

    if(x-b>0) d_b = x-b;
    else d_b = b-x;

    if(d_a>d_b) cout << 'B' << endl;
    else cout << 'A' << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#define f first
#define s second
#define INF (1e9)
#define N 7
using namespace std;
typedef pair<int,int> P;
int bfs(int,int,int,int,int,int);
bool check(int,int,int,int,int,int);
int w,h,data[N][N],d[N][N],cnt[N][N];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
typedef struct data{
  int cy,cx,wy,wx;
} dat;

int main(){
  int sy,sx,gy,gx,wy,wx,ans;
  while(1){
    cin>>w>>h;
    if(!w&&!h) break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	cin >> data[i][j];
	if(data[i][j]==2) sy=i,sx=j;
	else if(data[i][j]==3) gy=i,gx=j;
	else if(data[i][j]==4) wy=i,wx=j;
	d[i][j]=INF;
      }
    ans=bfs(sy,sx,wy,wx,gy,gx);
    cout << ans << endl;
  }
  return 0;
}

int bfs(int sy,int sx,int wy,int wx,int gy,int gx){
  queue<dat > q;
  int flag;
  dat k={sy,sx,wy,wx};
  q.push(k);
  d[sy][sx]=0;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) cnt[i][j]=0;
  while(!q.empty()){
    dat u=q.front();
    q.pop();
    flag=0;
    for(int i=0;i<4;i++){
      int ny=u.cy+dy[i],nx=u.cx+dx[i];
      if(ny<0||nx<0||h<=ny||w<=nx||data[ny][nx]==1) continue;
      if(check(u.wy,u.wx,u.cy-dy[i],u.cx-dx[i],u.cy,u.cx)){
	d[ny][nx]=d[u.cy][u.cx]+1;
	cnt[nx][ny]++;
	if(cnt[nx][ny]==100000){
	  flag=1;
	  break;
	}
	if(d[gy][gx]!=INF){
	  flag=2;
	  break;
	}
	dat t={ny,nx,u.cy-dy[i],u.cx-dx[i]};
	q.push(t);
      }
    }
    if(flag) break;
  }
  if(flag==2) return d[gy][gx];
  if(flag) return -1;
  if(d[gy][gx]!=INF) return d[gy][gx];
  return -1;
}

bool check(int sy,int sx,int gy,int gx,int xy,int xx){
  if(gy<0||gx<0||h<=gy||w<=gx) return false;
  if(data[gy][gx]==1) return false;
  bool c[N][N];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) c[i][j]=false;
  queue<P > q;
  q.push(make_pair(sy,sx));
  c[sy][sx]=true;
  while(!q.empty()){
    P u=q.front();
    q.pop();
    for(int i=0;i<4;i++){
      int ny=u.f+dy[i],nx=u.s+dx[i];
      if(ny<0||nx<0||h<=ny||w<=nx||data[ny][nx]==1||(ny==xy&&nx==xx)) continue;
      if(c[ny][nx]==true) continue;
      c[ny][nx]=true;
      q.push(make_pair(ny,nx));
    }
  }
  if(c[gy][gx]==true) return true;
  return false;
}

Measured memory_bytes: 3692
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-03 17:35:02
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

string s;

void rec(int rem, int c) {
    if (rem == 0) {
        cout << s << "\n";
        return;
    }
    rep(i, 0, c + 2) {
        s.push_back(char('a' + i));
        rec(rem - 1, max(c, i));
        s.pop_back();
    }
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    rec(n, -1);
    return 0;
}

Measured memory_bytes: 1536
N, M = map(int, input().split())
S = []
for _ in range(M):
    k, *s = map(int, input().split())
    S.append(s)
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
    check = [0 for _ in range(N)]
    tmp = i
    flg = True
    for j in range(N):
        check[j] = tmp % 2
        tmp //= 2
    for l, s in enumerate(S):
        cnt = 0
        for k in s:
            cnt += check[k - 1]
        if cnt % 2 != p[l]:
            flg = False
    if flg:
        ans += 1
print(ans)

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

using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	vector<int> cnt(n + 1), a(n), b(n);
	rep(i,n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	rep(i,n) {
		cin >> b[i];
		cnt[b[i]]++;
	}
	rep(i, n) {
		if (cnt[i + 1] > n) {
			cout << "No" << endl;
			return 0;
		}
	}
	int j = 0;
	rep(i, n) {
		if (a[i] == b[i]) {
			for (; j < n; j++) {
				if (a[j] != a[i] && b[j] != a[i]) {
					swap(b[i], b[j]);
					break;
				}
			}
		}
		if (i != n - 1) {
			if (a[i] != a[i + 1]) j = 0;
		}
	}
	cout << "Yes" << endl;
	rep (i, n) cout << b[i] << ' ';

	return 0;
}


Measured memory_bytes: 5636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

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


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

using namespace std;

typedef long long ll;

#define eps 1e-9
#define all(a)   a.begin(),a.end()
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define sz size()
#define rd(inp) scanf("%lld",&inp)
#define rd2(inp1, inp2) scanf("%lld %lld",&inp1, &inp2)
#define rl(inp) scanf("%d",&inp)
#define pf(out) printf("%lld\n", out);

const long long linf = 1e18+5;
const int mod = (int) 1e9 + 7;
const int inf = 1e9;

ll fpow(ll base,ll power){
	ll result = 1;
	while (power > 0){
		if (power%2 == 1) result=(result*base);
  		base = (base*base);
  		power /= 2;
  	}
	return result;
}

int main(){
	ll i, n, k, m = 0, g;
	cin >> n >> k;
	ll x;
	cin >> x;
	g = x;
	m = max(m, x);
	for ( i = 1 ; i < n ; i ++ ){
		cin >> x;
		g = __gcd(g, x);
		m = max(m, x);
	}
	ll cnt = m / g;
	if ( k % g == 0 && (k / g) <= cnt ){
		return 0 * printf("POSSIBLE\n");
	}
	return 0 * printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))
def fde(): print("-flag-")

def divisors(n):
    res = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n//i)

    return res


def main():
    N=ii()
    A=list(mi())
    R = divisors(A[0]) + divisors(A[1])

    ans = 0
    for r in R:
        miss_count = 0
        for a in A:
            if a % r != 0:
                miss_count += 1
                if miss_count == 2:
                    break
        
        if miss_count <= 1:
            ans = max(ans,r)
            

    print(ans)








if __name__ == "__main__":
    main()

Measured memory_bytes: 87904
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;


int main(){
	string a,b,c;
	std::cin >> a>>b>>c;
	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])std::cout << "YES" << std::endl;
	else std::cout << "NO" << std::endl;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2==0)
	cout<<a-b<<"\n"<<endl;
	else
	cout<<b-a<<"\n"<<endl;
	return 0;
} 

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

typedef long long ll;

const int N = 51;

string grid[N];
int steps[N][N];
int h, w;

int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

struct pt {
	int x, y;
	pt(int _x = 0, int _y = 0): x(_x), y(_y) {}
};

bool valid (pt p) {
	return (0 <= p.x and p.x < h and 0 <= p.y and p.y < w);
}

void bfs() {
	queue<pt> q;
	q.push(pt(0,0)); steps[0][0] = 1; 
	while (not q.empty()) {
		pt cur = q.front(); q.pop();
		// cout << "propagating: " <<  cur.x << ' ' << cur.y << endl;
		for (int i = 0; i < 4; i++) {
			pt next(cur.x+dx[i], cur.y+dy[i]);
			if (valid(next) and (steps[next.x][next.y] == -1 or steps[cur.x][cur.y]+1 < steps[next.x][next.y])) {
				q.push(next);
				steps[next.x][next.y] = steps[cur.x][cur.y]+1;
			}
		}
	}
}

int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	memset(steps, -1, sizeof steps);
	cin >> h >> w;
	int tot = h*w;
	int pounds = 0;
	for (int i = 0; i < h; i++) {
		cin >> grid[i];
		for (int j = 0; j < w; j++) {
			if (grid[i][j] == '#') {
				pounds++;
				steps[i][j] = -69;
			}
		}
	}

	bfs();

	// for (int i = 0; i < h; i++) {
	// 	for (int j = 0; j < w; j++) {
	// 		cout << steps[i][j] << ' ';
	// 	}
	// 	cout << endl;
	// }

	cout << (steps[h-1][w-1] != -1 ? tot-pounds-steps[h-1][w-1] : -1) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A;
int B;
int main(){
  rd(A);
  rd(B);
  if(max_L(A, B)<=8){
    wt_L("Yay!");
    wt_L('\n');
  }
  else{
    wt_L(":(");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A, B;
// {
//   rd(A,B);
//   wt( if[max(A,B)<=8, "Yay!", ":("] );
// }


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//////////////////////////

struct edge{
    ll to,a,b;
};

struct NOW{
    l_l z;
    ll time;
    bool operator<(const NOW &opp) const{return time < opp.time;}
    bool operator>(const NOW &opp) const{return time > opp.time;}//小さい順に取り出す時に必要
};

int main(){fastio
    ll n,m,s;cin>>n>>m>>s;
    vector<edge>v[n+1];
    ll M=3;
    
    rep(i,1,m){
        edge e;
        ll u;
        cin>>u>>e.to>>e.a>>e.b;
        v[u].pb(e);
        swap(u,e.to);
        v[u].pb(e);
        
        M+=e.a;
    }
    Min(M,50*53);
    ll c[n+1],e[n+1];
    rep(i,1,n)cin>>c[i]>>e[i];
    
    s=min(s,M-1);
    ll d[n+1][M];
    rep(i,1,n)rep(j,0,M-1)d[i][j]=inf;
    d[1][s]=0;
    
    priority_queue<NOW,vector<NOW>,greater<NOW>>q;
    q.push({{1,s},0});//頂点、硬貨の枚数
    while(!q.empty()){
        NOW front=q.top();q.pop();
        l_l fro=front.z;
        ll t=fro.fi;
        ll mai=fro.se;
        for(ll j=mai+c[t];j<=M-1;j+=c[t]){
            if(chmin(d[t][j],d[t][j-c[t]]+e[t])){
                q.push({{t,j},d[t][j]});
            }
        }
        
        for(auto x:v[t]){
            if(mai-x.a<0)continue;
            if(chmin(d[x.to][mai-x.a],d[t][mai]+x.b)){
                q.push({{x.to,mai-x.a},d[x.to][mai-x.a]});
            }
        }
    }
    ll ans[n+1];rep(i,1,n)ans[i]=inf;
    rep(i,2,n){
        rep(j,0,M-1){
            Min(ans[i],d[i][j]);
        }
    }
    rep(i,2,n)cout<<ans[i]<<endl;
    
    return 0;
}


Measured memory_bytes: 28792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int get_up = 60 * h1 + m1;
  int bed_in = 60 * h2 + m2;
  cout << bed_in - k - get_up << endl;
}


Measured memory_bytes: 3180
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n = I()
ans = int(math.log10(n)+1)
for i in range(2,int(n**0.5)+1):
    if n%i == 0:
        ans = min(ans, max(int(math.log10(i)+1),int(math.log10(n//i)+1)))
print(ans)
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 3700
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 2e5 + 10, inf = 1e9 + 42, LOG = log2(inf) + 2;

struct shop {
	ll a, b;
	bool operator<(const shop& o) const {
		if (a == 1 and o.a == 1) {
			return b < o.b;
		} else {
			return b * (o.a - 1) < o.b * (a - 1);
		}
	}
};

int main() {
	fast_cin();
	int n; ll T;
	cin >> n >> T;
	++T;
	vector<shop> s(n);
	for (auto& i : s) {
		cin >> i.a >> i.b;
		++i.a; ++i.b;
	}
	sort(s.begin(), s.end());
	int bak_n = n;
	while (n > 0 and s[n - 1].a == 1) {
		--n;
	}
	vector<ll> dp(LOG + 1, inf);
	dp[0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = LOG - 1; j >= 0; --j) {
			dp[j + 1] = min(dp[j + 1], s[i].a * dp[j] + s[i].b);
		}
	}
	ll ans = 0;
	for (int j = 0; j < LOG; ++j) {
		if (dp[j] > T) {
			continue;
		}
		ll cand = j, t = dp[j];
		for (int i = n; i < bak_n; ++i) {
			if (t + s[i].b <= T) {
				++cand;
				t += s[i].b;
			}
		}
		ans = max(ans, cand);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3456
from collections import defaultdict
n = int(input())

dct = defaultdict(list)

for _ in range(n):
    a,b = map(int,input().split())
    dct[b].append(a)

ans = 0
dct_list = sorted(dct.items())
for el in dct_list:
    ans += sum(el[1])
    if el[0] < ans:
        print("No")
        exit()
print("Yes")

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


int main(){
  int x;
  cin >> x;
  if (x==0){
    cout<<1<<endl;
  }else if(x==1){
    cout<<0<<endl;
  }
  }


Measured memory_bytes: 3616
A,B,C,D = map(int,input().split())

x = B // C - (A-1)//C
y = B // D - (A-1) //D
import fractions as f
a = C*D // f.gcd(C,D)
z = B //a - (A-1) // a

print(B-A+1 -(x+y-z))



Measured memory_bytes: 64876
#define _USE_MATH_DEFINES    
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define quickIO()   {cin.tie(0);    cout.sync_with_stdio(false);}
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 +7;
     
ld sqrtld(ld x){
    ld left = 0, right = x;
    rep(i, 100){
        ld mid = (left + right)/2;
        if (mid*mid <= x)   left =mid;
        else    right = mid;
    }
    return left;
}

ll nCr (int n, int r){
    ll ans =1;
    for(int i=0; n-i>r; i++){
        ans *= n-i;
        ans = ans/(i +1);
    }
    return ans;
}

int dn[30][30];
int cn[500][500];
ll rr[3][30];

int main (){
    int n,c ; cin >> n >> c;
    rep(i,c) rep(j,c){
        cin >> dn[i][j];
    }
    rep(i,n) rep(j,n){
        cin >> cn[i][j];
    }
    rep(k,3){
        rep(r,c){
            rep(i,n) rep(j,n){
                if( (i+j) % 3 == k ){
                    rr[k][r] += dn[cn[i][j]-1][r];
                }
            }        
        }
    }
    ll ret = inf;
    rep(i,c) rep(j,c) rep(k,c){
        if(i==j || j==k || i==k) continue;
        ll tmp = rr[0][i] + rr[1][j] + rr[2][k];
        ret = min(ret, tmp);
        
    }
    cout << ret << endl;
    return 0;
}

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll h,a;
	cin>>h>>a;
	cout<<h/a+(h%a!=0);

	return 0;
}


Measured memory_bytes: 384
package main

import (
  "bufio"
  "fmt"
  "os"
  "sort"
  "strconv"
  "strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
  sc.Scan()
  return sc.Text()
}

func nextLineValue() int {
  sc.Scan()
  return getInt(sc.Text())
}

func nextLineValues() []int {
  sc.Scan()
  return getIntArray(sc.Text())
}

func getInt(s string) int {
  v, _ := strconv.Atoi(s)
  return v
}

func getIntArray(s string) []int {
  var v []int
  valstr := strings.Split(s, " ")
  for _, c := range valstr {
    va, _ := strconv.Atoi(c)
    v = append(v, va)
  }
  return v
}

func digitTotal(v int) int {
  total := 0
  d := strings.Split(strconv.Itoa(v), "")
  for _, c := range d {
    dv, _ := strconv.Atoi(c)
    total += dv
  }
  return total
}

func sortDesc(v *[]int) {
  sort.Sort(sort.Reverse(sort.IntSlice(*v)))
}

func removeDupIntSlice(values *[]int) []int {
  m := make(map[int]bool)
  uniq := []int{}
  for _, v := range *values {
    if !m[v] {
      uniq = append(uniq, v)
      m[v] = true
    }
  }
  return uniq
}


func main() {
  s := nextLineValue()

  if s % 2 == 1 {
    fmt.Print((s+1)/2)
  } else {
    fmt.Print(s/2)
  }
}


Measured memory_bytes: 640
function main()
    N = parse(Int128,readline())
    A = parse.(Int128,split(readline()))
    a = 1
    for i in 1:N
        if A[i] == 0
            a = 0
        end
    end
    if a == 0
        println(0)
    else
        for i in 1:N
            a = a*A[i]
            if a > 10^18
                a = -1
                break
            end
        end
    println(a)
   end
end
main()

Measured memory_bytes: 215932
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int INF =2000000000;
const int MOD = 1000000007;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
int pow_kai(int a, int n){//aのn乗を計算します。
  int x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
// a^n mod を計算する
long long modPow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a^{-1} mod を計算する
ll modInv(ll a, ll mod) {
    return modPow(a, mod - 2, mod);
}

long long fac[MAX], finv[MAX], inv[MAX];

// combinationのテーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
 
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main() {
    //COMinit();
    int k,n;
    cin>>k>>n;
    int a[n+1];
    REP(i,n) cin>>a[i];
    a[n]=a[0]+k;
    int ans=INF;
    REP(i,n) {
        int dis=a[i+1]-a[i];
        if(k-dis<=ans) ans=k-dis;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    ll sum = 0;
    vector<ll> rui(n+1,0);
    rep(i,n){
        cin>>a[i];
        rui[i+1]=rui[i]+a[i];
        sum+=a[i];
    }
    ll ans = 2020202020;
    for(int i=1;i<n;i++){
        ll t1 = rui[i];
        ll t2 = sum-rui[i];
        ans=min(ans,abs(t1-t2));
        
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

int n;

struct node
{
	int id, pid, bid, k, d;
	int* cid;
	string type;
}N[100005];

void GetDepth(node& GN)
{
	GN.d = 0;
	node temp = GN;

	while (temp.pid != -1)
	{
		GN.d++;
		temp = N[temp.pid];
	}
}

void GetType(node& GN)
{
	if (GN.pid == -1)
		GN.type = "root";
	else if (GN.k == 0)
		GN.type = "leaf";
	else
		GN.type = "internal node";
}

void print()
{
	for (int i = 0; i < n; i++)
	{
		cout << "node " << N[i].id << ": " << "parent = " << N[i].pid << ", " << "depth = " << N[i].d << ", " << N[i].type << ", " << "[";

		if (N[i].k != 0)
		{
			for (int j = 0; j < N[i].k - 1; j++)
				cout << N[i].cid[j] << ", ";
			cout << N[i].cid[N[i].k - 1];
		}

		cout << "]" << endl;
	}	
}

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

	int place;
	cin >> n;
	
	for (int i = 0; i < n; i++)
		N[i].pid = -1;
	
	for (int i = 0; i < n; i++)
	{
		cin >> place;
		N[place].id = place;
		cin >> N[place].k;

		if (N[place].k > 0)
			N[place].cid = (int*)malloc(sizeof(int) * N[place].k);

		for (int j = 0; j < N[place].k; j++)
		{
			cin >> N[place].cid[j];
			N[N[place].cid[j]].pid = N[place].id;
		}			
	}

	for (int i = 0; i < n; i++)
		GetDepth(N[i]);

	for (int i = 0; i < n; i++)
		GetType(N[i]);	

	print();

	return 0;
}




Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
 
const int md=1000000007;
 
int fac[8009],inv[8009];
int f[4005][4005];
int a[200005];
int b[200005];
int ans,n;

inline long long qpow(long long a,int b)
{
	long long ret=1;
	while(b)
	{
		if(b&1)
			ret=ret*a%md;
		a=a*a%md;
		b>>=1;
	}
	return ret;
}

inline int c(int n,int m)
{
	return 1ll*fac[n]*inv[m]%md*inv[n-m]%md;
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",a+i,b+i);
		f[2001-a[i]][2001-b[i]]++;
	}

	for(int i=1;i<4002;i++)
		for(int j=1;j<4002;j++)
			f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%md;	
	
	fac[0]=1;
	for(int i=1;i<=8002;i++)
		fac[i]=1ll*fac[i-1]*i%md;
	inv[8002]=qpow(fac[8002],md-2);
	for(int i=8001;i>=0;i--)
		inv[i]=1ll*inv[i+1]*(i+1)%md;

	for(int i=0;i<n;i++)
		ans=(ans+f[2001+a[i]][2001+b[i]])%md;
	for(int i=0;i<n;i++)
		ans=((ans-c((a[i]+b[i])<<1,b[i]<<1))%md+md)%md;

	ans=(500000004ll*ans)%md;
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 64512
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;
const ll INF = 1LL << 60;
using namespace std;

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

  int N, M; cin >> N >> M;
  vector<pair<int, int> > vec;
  rep(i, N) {
      int a, b; cin >> a >> b;
      vec.push_back(make_pair(a, b));
  }
  sort(vec.begin(), vec.end());

  ll ans = 0, sum = 0;
  rep(i, N) {
      while(sum < M && vec[i].second > 0) {
          ++sum;
          --vec[i].second;
          ans += vec[i].first;
      }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x){return x*x;}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin>>n;
    map<string ,int> mp;
    while(n--){
        string s; cin>>s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << "\n"; 
    cout << "WA x " << mp["WA"] << "\n";
    cout << "TLE x " << mp["TLE"] << "\n";
    cout << "RE x " << mp["RE"] << "\n";
   
    return 0;
}

// Химаншу    

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string s;
    cin >> s;
    for (int i= 0; i < 19; i++) {
        if (s[i] == ',') {
            cout << " ";
        } else {
            cout << s[i];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define SENTINEL (-1)
#define M (1001)

// ia, ib以降のindexに対するLCSを返す
// (ia, ib)に対するLCSがわかっているとき, (ia-1, ib), (ia, ib-1)
// に対するLCSは, a[ia-1] == a[ib],...であれば+1される....
// と考えたくなるが, iaとibでカウントされている場合, ダブルカウントになってしまうから,
// 必ずしもそうとは言えない.
// X: abcbdab
// Y: bdcaba
// 1-originで考えると,
// LCS(7,6,X,Y) = 0
// LCS(6,6,X,Y) = 1
// LCS(5,5,X,Y) = 1
// LCS(4,5,X,Y) = 2
// ... ????
// 部分問題に分解したい
// X: abc
// Y: ac
// -> 2
// X[3],Y[2] -> 1
// X[2],Y[2] -> 
// lcs(i,j)
// : if a[i] == b[j] => lcs(i,j) = lcs(i-1,j-1) + 1
// : else lcs(i,j) = max ( lcs(i-1,j), lcs(i, j-1) )
// lcs(0,0) := 0
// lcs(

int lcs(int i, int j, string &a, string &b, int memo[][M]) {
	if (i==0 || j==0) {
		memo[i][j] = 0;
		return 0;
	}
	if (memo[i][j] != SENTINEL) {
		return memo[i][j];
	}
	// i, j as 1-origin index
	if (a[i-1] == b[j-1]) {
		memo[i][j] = lcs(i-1, j-1, a, b, memo) + 1;
	} else {
		memo[i][j] = max(lcs(i-1,j,a,b,memo), lcs(i,j-1,a,b,memo));
	}
	return memo[i][j];
}

// この多次元配列の書き方は汎用性がなくて嫌
void fill(int a[][M], int size1, int size2, int v) {
	for (int i=0;i<size1;++i) {
		for (int j=0;j<size2;++j) {
			a[i][j] = v;
		}
	}
}

int main () {
	int q;
	cin >> q;
	int LCS[1001][M];
	fill(LCS, 1001, 1001, SENTINEL);// -1 is sentinel
	vector<int> res;
	for (int i=0; i<q; ++i) {
		string a, b;
		cin >> a >> b;
		res.push_back(lcs(a.size(),b.size(),a,b,LCS));
		fill(LCS, M, M, SENTINEL);
	}
	for (auto i : res) {
		cout << i << endl;
	}
	return 0;
}




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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll x=c-a-b;
    if(x<0)
    {
        cout<<"No";
    }
    else if(4*a*b>=x*x)
    {
        cout<<"No";
    }
    else cout<<"Yes";
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        sc.close();

        // 主処理
        long[] divCount = new long[10000001];
        Arrays.fill(divCount, 1);
        for (int i = 2; i < 10000001; i++) {
            for (int j = i; j < 10000001; j += i) {
                divCount[j]++;
            }
        }
        long result = 0;
        for (int i = 1; i <= n; i++) {
            result += (long) i * divCount[i];

        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 115700
use proconio::{*, marker::*};

pub fn pow(n: usize, m: usize) -> usize {
    let mut ret = 1;
    let mut s = 2;
    let mut n = n;
    while n > 0 {
        if n & 1 > 0 {
            ret *= s;
            ret %= m;
        }
        s *= s;
        s %= m;
        n >>= 1;
    }
    ret
}

fn main() {
    input!{
        n: usize,
        x: Chars,
    }

    let mut dp = vec![1_000_000_000usize; n*3];

    dp[0] = 0;
    dp[1] = 1;

    for i in 2..3*n {
        let t = i % (i as usize).count_ones() as usize;
        dp[i] = dp[t] + 1;
    }

    let mut ppcnt = 0;
    let mut x: Vec<char> = x;
    x.reverse();
    for i in 0..n {
        if x[i] == '1' {
            ppcnt += 1;
        }
    }

    let mut sums = vec![0; 3];
    for i in 0..n {
        if x[i] == '0' {
            continue;
        }
        for j in 0..3 {
            let tt = ppcnt as i32 - 1 + j as i32;
            if tt <= 0 {
                continue;
            }
            let t = pow(i, tt as usize);
            sums[j] += t;
            sums[j] %= tt as usize;
        }
    }

    for i in (0..n).rev() {
        if x[i] == '1' {
            let tt = ppcnt as i32 - 1;
            if tt == 0 {
                println!("0");
                continue;
            }
            let t = (sums[0] + tt as usize - pow(i, tt as usize)) % tt as usize;
            println!("{}", dp[t] + 1);
        } else {
            let tt = ppcnt as i32 + 1;
            let t = (sums[2] + pow(i, tt as usize)) % tt as usize;
            println!("{}", dp[t] + 1);
        }
    }
}


Measured memory_bytes: 7744
#include<bits/stdc++.h>
using namespace std;
int rating(int n,int r)
{
  if(n>10)
    return r;
  else
  {
    r=r+100*(10-n);
    return r;
  }
}
int main()
{
  int n,r,res;
  cin>>n>>r;
  res=rating(n,r);
  cout<<res<<endl;
  return 0;
}

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

#define INF 1e9

int main(void){
  int n, temp;
  cin >> n;

  vector<int> c(n+1);
  cin >> c[0] >> c[1];
  for(int i=2; i<n+1; i++)
    cin >> temp >> c[i];

  vector< vector<int> > dp(n, vector<int>(n+1, INF));
  for(int i=0; i<n; i++)
    dp[i][i+1] = 0;
  
  for(int i=2; i<n+1; i++)
    for(int j=0; j<n; j++)
      for(int k=1; k<i; k++)
	if(j+i < n+1)
	  dp[j][j+i] = min(dp[j][j+i],
			   dp[j][j+k]+dp[j+k][j+i]+c[j]*c[j+k]*c[j+i]);
  
  cout << dp[0][n] << endl;
  
  return 0;
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  vector<long long> list;
  long long num,a,fin=0;
  cin >> num;
  for (long long i=0; i<num; i++) {
    cin >> a;
    list.push_back(a);}
  for (long long i=1; i<num-1; i++) {
    if (list[i]>list[i-1] && list[i]<list[i+1]) {
      fin++;}
    else if (list[i]<list[i-1] && list[i]>list[i+1]) {
      fin++;}}
  cout << fin;}

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

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

    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}

		boolean possible = false;
		int index = -1;
		for (int i = 0; i < N - 1; i++) {
			int sum = a[i] + a[i + 1];
			if (sum >= L) {
				index = i;
				possible = true;
				break;
			}
		}

		if (!possible) {
			System.out.println("Impossible");
			return;
		}

		System.out.println("Possible");
		List<String> list = new ArrayList<>();
		for (int i = 0; i < index; i++) {
			list.add(Integer.toString(i + 1));
		}
		for (int i = 1; i < N - index; i++) {
			list.add(Integer.toString(N - i));
		}
		System.out.println(String.join(System.lineSeparator(), list));
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public int[] nextInt(int n) throws IOException {
			int[] array = new int[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextInt();
			}

			return array;
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 23964