akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  double t,x;
  cin>>t>>x;
  cout << t/x << endl;
  return 0;
}


Measured memory_bytes: 256
l = list(map(int,input().split()))
a = l[0]
b = l[1]
n = l[2]

def floor(a,b,x):
    p = (a*x)//b - a*(x//b)
    return p

max = 0
if b == 1:
    max = 0
elif n <= b-1:
    max = floor(a,b,n)
elif n > b-1:
    for i in range(b-1,n+1,b):
        c = floor(a,b,i)
        if c >= max:
            max = c

print(max)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  string a;
  cin >> a;
  int num0 =0;
  int num1 =0;
  REP(i, a.size()){
    if(a[i] == '0'){
      num0 ++ ;
    }else{num1 ++;}
  }
  cout << min(num1, num0)*2 << endl;

}


Measured memory_bytes: 512
object Main{
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val arr = List.fill(26)(0).toArray
    while (sc.hasNext){
      val chars = sc.next.toLowerCase.toCharArray
      chars.filter(c => 'a' <= c && c <= 'z').foreach(c => arr(c - 'a') += 1)
    }
    'a' to 'z' foreach(c => println(c + " : " + arr(c - 'a')))
  }
}

Measured memory_bytes: 45848
import itertools
N = int(input())
s = list(input())

def hantei(N,s):
    for onetwo in itertools.product((0, 1), (0, 1)):
        res = {}
        for n in range(N):
            if n == 0:
                res[n] = onetwo[0]
            elif n == 1:
                res[n] = onetwo[1]
            else:
                if res[n-1] == 0 and s[n-1] == "o":
                    res[n] = res[n-2]
                elif res[n-1] == 0 and s[n-1] == "x":
                    res[n] = 1 if res[n-2] == 0 else 0
                elif res[n-1] == 1 and s[n-1] == "o":
                    res[n] = 1 if res[n-2] == 0 else 0
                elif res[n-1] == 1 and s[n-1] == "x":
                    res[n] = res[n-2]
        # check s[0]
        if (res[1] == res[N-1]) and res[0] == 0 and s[0] == "x":
            continue
        if (res[1] == res[N-1]) and res[0] == 1 and s[0] == "o":
            continue
        if (res[1] != res[N-1]) and res[0] == 0 and s[0] == "o":
            continue
        if (res[1] != res[N-1]) and res[0] == 1 and s[0] == "x":
            continue
        # check s[n-1]
        if (res[0] == res[N-2]) and res[N-1] == 0 and s[N-1] == "x":
            continue
        if (res[0] == res[N-2]) and res[N-1] == 1 and s[N-1] == "o":
            continue
        if (res[0] != res[N-2]) and res[N-1] == 0 and s[N-1] == "o":
            continue
        if (res[0] != res[N-2]) and res[N-1] == 1 and s[N-1] == "x":
            continue

        print(''.join(map(lambda x: "S" if x == 0 else "W", res.values())))
        return True

    return False

if not hantei(N, s):
    print(-1)
    
        


Measured memory_bytes: 19332
#!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
print(eval(input()))
#B

#C
"""
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
for i in d.items():
    if i[0] != 0 and i[1] == 1:
        print(0)
        quit()
    elif i[1] > 2:
        print(0)
        quit()
print(pow(2,n//2,mod))
"""

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38640
import java.util.*;

public class Main {
    public static long solve(int arr[],int n,int k){
        long mod = 1000000007;
        long dp[][] = new long[n+1][k+1];

        for(int j=0;j<=k;j++){
            dp[1][j] = (j > arr[1]) ? 0 : 1;
        }

        for(int i=2;i<=n;i++){
            for(int j=0;j<=k;j++){
                if(j == 0){
                    dp[i][j] = dp[i-1][j];
                }
                else{
                    dp[i][j] = (mod +  dp[i][j-1] + dp[i-1][j] - ( (j-arr[i]-1 >= 0) ? dp[i-1][j-arr[i]-1] : 0 ) )% mod;
                }
            }
        }

        return dp[n][k];
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int arr[] = new int[n+1];
        for(int i=1;i<=n;i++) arr[i] = sc.nextInt();
        System.out.println(solve(arr,n,k));
    }
}

Measured memory_bytes: 126416
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

int main()
{
	int N,t1=0,t2=0;
	vector<int> A;
	vector<int> B;
	cin >> N;
	
	for (int i = 0; i < N; i++)
	{
		cin >> t1;
		t2 = t2 + t1;
		A.push_back(t2);
	}

	for (int i = 0; i < N-1; i++)
	{
		t1 = A[i] - (A[N-1] - A[i]);
		if (t1 >= 0)
		{
			B.push_back(t1);
		}
		if (t1 < 0)
		{
			B.push_back(-1*(t1));
		}
	}

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

	cout << B.front() << endl;

}

Measured memory_bytes: 256
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

const ll mod = 1000000009;

inline ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

inline ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

inline ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

const int N = 1e5 + 5;

int sz[N];
int par[N];

int find(int u) { return par[u] == u ? u : (par[u] = find(par[u])); }

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

	for(int i=0; i<N; i++) {
		sz[i] = 1;
		par[i] = i;
	}

	int n, m;
	cin >> n >> m;
	int a, b, c;
	for(int i=0; i<m; i++) {
		cin >> a >> b >> c;
		int x = find(a);
		int y = find(b);
		if(x != y) {
			par[y] = x;
			sz[x] += sz[y];
		}
	}

	int ans = 0;
	for(int i=1; i<=n; i++) {
		if(find(i) == i) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"

    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    ll fre[100005]={0};
    rep(i,n)cin>>a[i],fre[a[i]]++;
    ll sum=0;
    f(i,1,100005)sum+=fre[i]*i;
    
    ll q;
  cin>>q;
    while(q--){
        ll a,b;
        cin>>a>>b;
        sum-=fre[a]*a;
        sum+=(fre[a])*b;
        fre[b]+=fre[a];
        fre[a]=0;
        cout<<sum;
        cl;
    }
    

}




Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int main(){
  int r;cin>>r;
  cout<<3*r*r<<endl;
}

Measured memory_bytes: 256
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  n=chomp(readline())
  l=length(n)-1
  println(n==string(n[1])*"9"^l ? 9*l+pI(n[1]) : pI(n[1])+9*l-1)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 165916
import collections

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

C = list(collections.Counter(A).values())
count = 0

if len(C) <= K:
    print(0)
else:
    C.sort()
    for i in range(len(C) - K):
        count += C[i]
    print(count)


Measured memory_bytes: 32564
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};

struct minqueue {
	deque<ll> dq;
	vector<ll> vec;
	ll head = 0;
	ll tail = 0;
	bool op(ll a, ll b) {
		return a <= b;
	}

	bool can_push(ll x) {
		if (dq.empty()) {
			return true;
		}
		else {
			return op(x, vec[dq.back()]);
		}
	}

	void push(ll x) {
		while (!can_push(x)) {
			dq.pop_back();
		}
		dq.push_back(tail);
		tail++;
		vec.push_back(x);
	}

	ll val() {
		return vec[dq.front()];
	}

	void pop() {
		if (head == dq.front()) {
			dq.pop_front();
		}
		head++;
	}
};


ll const MAX = 1e5 + 5;
vll a(MAX);
vvll dp(MAX, vll(305));


int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	REP(i, 1, n) {
		cin >> a[i];
	}
	ll ans = 0;

	REP(j, 1, k) {
		minqueue mq;
		mq.push(dp[j - 1][j - 1]);
		REP(i, j, n) {
			dp[i][j] = mq.val() + j * a[i];
			mq.push(dp[i][j - 1]);
			if (i >= j + m - 1) {
				mq.pop();
			}
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 246044
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n;
double dp[301][301][301];
int c[3];

double rec(int i, int j, int k) {
    if (dp[i][j][k] > -0.5)
        return dp[i][j][k];
    double d = 1. - (double)(n - i - j - k) / n;
    dp[i][j][k] = 1. / d;
    if (i > 0)
        dp[i][j][k] += rec(i - 1, j, k) * (double)(i) / n / d;
    if (j > 0)
        dp[i][j][k] += rec(i + 1, j - 1, k) * (double)(j) / n / d;
    if (k > 0)
        dp[i][j][k] += rec(i, j + 1, k - 1) * (double)(k) / n / d;
    return dp[i][j][k];
}

int main() {
    cin >> n;
    rep(i, n) {
        int m;
        cin >> m;
        c[m - 1]++;
    }
    rep(i, 301) rep(j, 301) rep(k, 301) dp[i][j][k] = -1;
    dp[0][0][0] = 0;
    cout << fixed << setprecision(10);
    cout << rec(c[0], c[1], c[2]) << endl;
    return 0;
}

Measured memory_bytes: 216852
//Created Time:2020/2/4 10:48:43
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int get(int ,int);

int main(){
	int n, s = 0; cin >> n;
	while(n--){
		int a, k; cin >> a >> k;
		s ^= get(a, k);
	}
	if(!s) puts("Aoki");
	else puts("Takahashi");
	return 0;
}

int get(int a, int k){
	if(a < k) return 0;
	if(a % k == 0) return a / k;
	int m = a / k;
	return get(a - (a - m * (k - 1)) / (m + 1) * (m + 1), k);
}

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

int main()
{
	int N, i, Ans;
	cin >> N;

	for (i = 1; i <= 100000; i++) {
		Ans = i * i;
		if (Ans > N) {
			Ans = (i - 1)*(i - 1);
			break;
		}
	}

	cout << Ans << endl;
	return 0;

}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

cnt = 0
l = [0]*(10**5+1)
for v in A:
    l[v] += 1
    cnt += v

for i in range(Q):
    b,c = map(int, input().split())
    cnt += (c-b)*l[b]
    print(cnt)
    l[c] += l[b]
    l[b] = 0

Measured memory_bytes: 20968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll MOD=1e9+7;
const ll INF=1ll<<60;

//
//　定数, 変数 *********************************************
int N;

// *********************************************************
int main(){

    // 入力スタンダード
    cin >> N;
    
    N = N%10;
    if(N==3){
        cout << "bon" <<endl;
    }else if(N==0 || N==1 || N==6 || N==8){
        cout << "pon" <<endl;
    }else{
        cout << "hon" <<endl;
    }




    return 0;
}

Measured memory_bytes: 3676
#include<iostream>
using namespace std;
const int N=1e5+7,M=37;
int sum[M][N],n,c,i,j,x,l,r,mid,ans;
bool check(int x){
	int used=0,res=x;
	for(i=1;i<=1e5;++i){
		for(j=1;j<=c;++j)if(sum[j][i]==1&&sum[j][i-1]==0)res--,used++;
		if(res<0)return false;
		for(j=1;j<=c;++j)if(sum[j][i]==0&&sum[j][i-1]==1)res++,used--;
	}
	return true;
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	for(cin>>n>>c,i=1;i<=n;++i)cin>>l>>r>>x,r--,sum[x][l]++,sum[x][r+1]--;
	for(i=1;i<=c;++i)for(j=1;j<=1e5;++j)sum[i][j]+=sum[i][j-1];
	for(l=1,r=c;l<=r;)check(mid=l+r>>1)?(r=(ans=mid)-1):(l=mid+1);
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 12160
import copy
import sys
from _operator import itemgetter
from collections import Counter
from math import log2, pi, ceil

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n = ni()
p = na()
ct = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
        ct += 1
print(ct)

Measured memory_bytes: 3444
import sys

printf = sys.stdout.write

word = []
new_word = []
for line in sys.stdin:
    word.append((line.strip("\n")).lower())
 
for i in range(len(word)):
    new_word.append(word[i].split(" "))

ans = 0
for i in range(len(new_word)):
    for j in range(len(new_word[i])):
        if new_word[i][j].count(new_word[0][0]) > 0:
            if len(new_word[i][j]) == len(new_word[0][0]):
                ans += new_word[i][j].count(new_word[0][0])


print ans - 1

Measured memory_bytes: 6456
#include <bits/stdc++.h>
#define s second
#define f first
using namespace std;
pair < int, int >  E[100005];
long long rg[100005], p[100005], v[100005];
int fnd(int x) {
    int xx = x;

    while (p[x] != x) {
        x = p[x];
    }
    while (p[xx] != xx) {
        int aux = p[xx];
        p[xx] = x;
        xx = aux;
    }

    return x;
}
void unite(int x, int y) {
    if (rg[x] >= rg[y]) {
        p[y] = x;
        rg[x] += rg[y];
    }
    else {
        p[x] = y;
        rg[y] += rg[x];
    }
}
int main() {
    long long n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        cin >> E[i].f >> E[i].s;
    }
    for (int i = 1; i <= n; i++) {
        rg[i] = 1;
        p[i] = i;
    }
    n = n * (n - 1) / 2;
    for (int i = m; i >= 1; i--) {
        v[i] = n;
        int x = fnd(E[i].f);
        int y = fnd(E[i].s);
        if (x == y);
        else {
        n = n - (1ll*rg[x] * rg[y]);
        unite(x, y);
        v[i - 1] = n;
        }
    }
    for (int i = 1; i <= m; i++) {
        cout << v[i] << "\n";
    }
}


Measured memory_bytes: 4480
import Data.List
import Text.Printf
nextPyramid (x,y) = if y+1<101 then (x,y+1) else if x+1<101 then (x+1,0) else (-1,-1)
listToTuple [x,y,z] = (x,y,z)

check::(Integer,Integer)->[(Integer,Integer,Integer)]->Integer->Integer
check (x,y) (d:ds) h
    | h==0 = check (x,y) ds (abs (a-x) + abs (b-y) + c)
    | c==tmp = if ds==[] then h else check (x,y) ds h
    | otherwise = -1
    where
        (a,b,c) = d
        tmp = max (h - abs (a-x) - abs (b-y)) 0

solve (x,y) tbl
    | ans == (0-1) = solve (nextPyramid (x,y)) tbl
    | otherwise = (x,y,ans)
    where
        ans = check (x,y) tbl 0

main::IO()
main=do
    getLine
    tbl <- map (listToTuple.map read.words) . lines <$> getContents :: IO [(Integer,Integer,Integer)]
    let (x,y,h) = solve (0,0) (sortBy (\(a0,a1,a2) (b0,b1,b2) -> compare b2 a2) tbl)
    printf "%d %d %d\n" x y h

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

int main(){
  long long n,k;
  cin >> n >> k;
  vector<long long> a(n+1,1);
  vector<long long> b(n+1,1);
  for(int i=1;i < n+1;i++){
    cin >> a.at(i);
    b.at(i) = a.at(i) * b.at(i-1);
    if(i >= k){
      b.at(i) /= a.at(i-k);
      //cout << b.at(i) << endl; 
    }
  }
  
  for(int i=k;i < n;i ++){
    //if(b.at(i+k) < b.at(i+k+1)){
    if(a.at(i+1) > a.at(i-k +1)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    
    cout << (1900*m+100*(n-m))*pow(2, m) << endl;
    
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


vector<string> split(string str, string delim)
{
    vector<string> result;
    int cutAt;
    while( (cutAt = str.find_first_of(delim)) != str.npos )
    {
        if(cutAt > 0)
        {
            result.push_back(str.substr(0, cutAt));
        }
        str = str.substr(cutAt + 1);
    }
    if(str.length() > 0)
    {
        result.push_back(str);
    }
	return result;
}


struct P{ P() : x(0), y(0){} double x, y; };

#define range(x) (0 <= x && x < table[y - 1].size())

int main()
{
	vector<vint> table;;

	string input;
	for(int i = 0; cin >> input; i++)
	{
		table.push_back(vint());
		vector<string> vs = split(input, ",");

		rep(j, vs.size())
			table[i].push_back(atoi(vs[j].c_str()));
	}


	REP(y, 1, table.size()) rep(x, table[y].size())
	{
		int dx = (y < table.size() / 2 ? -1 : 1);
				
		table[y][x] += max((range(x) ? table[y - 1][x] : 0), (range(x + dx) ? table[y - 1][x + dx] : 0));
	}
	

	cout << table[table.size() - 1][0] << endl;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int e;
  while(cin >> e, e) {
    int m = 1e9;
    for(int y = 0; y * y <= e; y++) {
      for(int z = 0; z * z * z + y * y <= e; z++) {
        int x = e - y * y - z * z * z;
        if(x >= 0) m = min(m, x + y + z);
      }
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 3032
N,T=input().split()
aaaaaaaaaaaaaaaaaaaaaa=0
b=0
for i in range(int(N)):
    c,t=input().split()
    if int(t)<=int(T):
        if b==0:
            aaaaaaaaaaaaaaaaaaaaaa=c
            b+=1
        if int(c)<int (aaaaaaaaaaaaaaaaaaaaaa):
            aaaaaaaaaaaaaaaaaaaaaa=c
            i+=1
if aaaaaaaaaaaaaaaaaaaaaa==0:
    print("TLE")
else :
    print(aaaaaaaaaaaaaaaaaaaaaa)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    long a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    long ans = 1L << 50;
    for(long i=0;i<=200000;i+=2){
        long tmp = 0;
        tmp += c*i;
        if(x*2 > i)tmp += a * (x-i/2);
        if(y*2 > i)tmp += b * (y-i/2);
        ans = min(tmp,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    from itertools import accumulate
    input = sys.stdin.readline
    N = int(input())
    a = list(map(int, input().split()))
    inf = 10 ** 13
    dp = [[0]*N for i in range(N)]
    s = [0] + list(accumulate(a))
    for i, x in enumerate(a):
        dp[i][i] = 0
    for i in range(N-2, -1, -1):
        DP = dp[i]
        si = s[i]
        for j in range(i+1, N):
            tmp = s[j+1] - si
            D = inf
            for k in range(i, j):
                cost = DP[k]+dp[k+1][j]
                if D > cost:
                    D = cost
            DP[j] = D + tmp
    print(dp[0][N-1])


main()


Measured memory_bytes: 7560
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}


template <typename T> vector<tuple<int,int,T>> prim(int n, const vector<vector<pair<int,T>>> &graph){
  using tii = tuple<int,int,T>;

  vector<bool> visit(n, false);
  vector<tii> ret;

  function<bool(tii,tii)> cmp = [](const tii &a, const tii &b){return get<2>(a) > get<2>(b);};
  priority_queue<tii, vector<tii>, decltype(cmp)> pq(cmp);
  
  visit[0] = true;
  for(auto &p : graph[0]) pq.push(make_tuple(0,p.fst,p.snd));

  while(not pq.empty()){
    auto t = pq.top(); pq.pop();

    if(visit[get<0>(t)] == visit[get<1>(t)]) continue;

    int i = visit[get<0>(t)] ? get<1>(t) : get<0>(t);
    for(auto &p : graph[i]){
      pq.push(make_tuple(i,p.fst,p.snd));
    }

    visit[i] = true;
    ret.push_back(t);
  }

  return ret;
}




int main(){

  int n;
  while(cin >> n){
    vector<pair<int,int>> xs(n), ys(n);
    REP(i,n){
      int x,y; cin >> x >> y;
      xs[i] = {x,i};
      ys[i] = {y,i};
    }

    sort(ALL(xs));
    sort(ALL(ys));

    vector<vector<pair<int,int>>> g(n);
    
    REP(i,n-1){
      g[xs[i].snd].push_back({xs[i+1].snd, abs(xs[i].fst-xs[i+1].fst)});
      g[xs[i+1].snd].push_back({xs[i].snd, abs(xs[i].fst-xs[i+1].fst)});

      g[ys[i].snd].push_back({ys[i+1].snd, abs(ys[i].fst-ys[i+1].fst)});
      g[ys[i+1].snd].push_back({ys[i].snd, abs(ys[i].fst-ys[i+1].fst)});      
    }

    auto v = prim(n, g);
    LLI ans = 0;
    for(auto &t : v) ans += get<2>(t);
    
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 14900
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e7;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e6;
int prime(int x){
    if(x<2)
        return 0;
    for(int i=2;i*i<=x;i++){
        if(x%i==0)
            return 0;
    }
    return 1;
}
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2)%MOD;
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a % MOD * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[j]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}
int check(int x){

}
int ternary(int s,int e){
    int mid,mid2;
    while(s+3<e){
        mid=s+(e-s)/3;
        mid2=s+(e-s)/3*2;
        if(mid>=mid2)
            e=mid2;
        else{
            s=mid;
        }
    }
    int mx=0;
    while(s<e){
        mx=max(mx,check(s));
        s++;
    }
    return mx;
}
int binary(int s,int e){
    int mid;
    while(s<e){
        mid=ceil((s+e)/2.0);
        if(check(mid))
            s=mid;
        else
            e=mid-1;
    }
    return s;
}



in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc);
    while(tc--)
    {
        int a,b;
        cin>>a>>b;
        cout<<(a*3+b)/2<<endl;
    }
    RETURN;
}


Measured memory_bytes: 256
ss = input()

ans = [0] * len(ss)

now = 'R'
last = -1
left = -1
right = -1

for i,s in enumerate(ss):
    if(s != now):
        if(s == 'L'):
            now = 'L'
            left = i-1
            right = i
        else:
            now='R'
            sumnum = i-1 - last
            if(sumnum%2 == 0):
                ans[left] = sumnum//2
                ans[right] = sumnum//2
            else:
                ans[left] = sumnum//2 + (left-last)%2
                ans[right] = sumnum//2 + (right-last)%2
            last = i-1

sumnum = i - last
if(sumnum%2 == 0):
    ans[left] = sumnum//2
    ans[right] = sumnum//2
else:
    ans[left] = sumnum//2 + (left-last)%2
    ans[right] = sumnum//2 + (right-last)%2

print(' '.join(map(str, ans)))


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

#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define m(q,w,e) (f[(q)]&&f[(w)]&&f[(e)])

void solve() 
{
    int a[9];
    REP(i,9)cin>>a[i];
    bool f[9];REP(i,9)f[i]=0;
    int n;cin>>n;
    REP(i,n){
        int x;cin>>x;
        REP(j,9){
            if(a[j]==x){
                f[j]=1;break;
            }
        }
    }
    if(m(0,1,2)||m(3,4,5)||m(6,7,8)||m(0,3,6)||m(1,4,7)||m(2,5,8)||m(0,4,8)||m(2,4,6))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  vector<pair<int,int>> id;
  for(int i=0; i<N-1; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    id.emplace_back(a,b);
  }
  vector<bool> dist(N,false);
  queue<int> que;
  que.emplace(0);
  map<pair<int,int>,int> mp;
  dist[0] = true;
  int K=0;
  vector<int> cs(N,0);
  while(!que.empty()){
    int v;
    v = que.front();
    que.pop();
    int c=1;
    if(K < (int)G[v].size()){
      K = G[v].size();
    }
    for(int nv: G[v]){
      if(dist[nv]){
        continue;
      }
      if(c == cs[v]){
        c++;
      }
      cs[nv] = mp[make_pair(v, nv)] = mp[make_pair(nv, v)] = c;
      c++;
      dist[nv] = true;
      que.emplace(nv);
    }
  }
  cout << K << endl;
  for(auto p: id){
    cout << mp[p] << endl;
  }
  return 0;
}


Measured memory_bytes: 19700
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000000000000;
const double PI = acos(-1);

int n, a;
LL dp[100][100][2501];
int x[100];

int main() {
	cin >> n >> a;
	dp[0][0][0] = 1;
	int X = 0;

	for (int i = 1; i <= n; i++) {
		cin >> x[i];
		if (x[i] > X)X = x[i];
	}

	for (int j = 0; j <= n; j++) {
		for (int k = 0; k <= n; k++) {
			for (int s = 0; s <= n * X; s++) {
				if (j >= 1 && s < x[j])dp[j][k][s] = dp[j - 1][k][s];
				if (j >= 1 && k >= 1 && s >= x[j])dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j]];
			}
		}
	}
	LL ans = 0;
	for (int k = 1; k <= n; k++) {
		ans += dp[n][k][k*a];
	}
	cout << ans << endl;
}

Measured memory_bytes: 98688
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)a.size() 
#define all(a) a.begin(),a.end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 

#define int long long 

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define pi acos(-1)

void solve() {
	double a,b,h,m;
	cin >> a >> b >> h >> m;

	double min = double(m/5) ;
	double hour = (60*h+m)/60 ;

	double ang = abs((hour-min) * 30 * pi/180) ;

	// cout << ang << nl ;

	cout << fixed << setprecision(12) << sqrt((a*a) + (b*b) - 2*a*b*cos(ang)) ;
}	

int32_t main() {


    fast; 
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 4232
# cook your dish here
s = input()
if 'SSS' == s:
    print(0)
elif "RSS" ==s or s=="SRS" or "SSR" == s or "RSR"==s:
    print(1)
elif "RRR" == s:
    print(3)
elif "RRS"==s or "SRR" == s:
    print(2)

Measured memory_bytes: 8916
package main

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

//scanで一行づつ読み込む
var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)

//sort
// array := []int{5, 1, 4, 2, 3}
// sort.Sort(sort.IntSlice(array))

func main() {
	// A := strings.Split(nextLine(), " ")

	X := strings.Split(nextLine(), " ")

	// Z := strings.Split(nextLine(), " ")
	// n, _ := strconv.Atoi(input[0])

	A, _ := strconv.Atoi(X[0])
	B, _ := strconv.Atoi(X[1])

	ans := 0
	// board := make([]cities, N)

	if B%A == 0 {
		ans = A + B
	} else {
		ans = B - A
	}

	fmt.Fprintln(wtr, ans)

	_ = wtr.Flush()
}

func addBuiscket(b int64) int64 {
	return b + 1
}
func exchangeToYen(b int64, rate int64) (rest int64, money int64) {
	return b - rate, 1
}
func exchangeToBuiscket(mone int64, buis int64, rate int64) (b int64, money int64) {
	return buis + rate, mone - 1
}

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func com(a, b int) int {

	if a > b {
		return 0
	}
	return abs(a - b)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

type block struct {
	x     int
	y     int
	point int
}

type cities []block

func (p cities) Len() int {
	return len(p)
}

func (p cities) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p cities) Less(i, j int) bool {

	return p[i].point > p[j].point //p[i].x+p[i].y > p[j].x+p[j].y
}


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

using namespace std;

const long long N=1e9+7;
long long n,m;
long long ans;

int main()
{
	scanf("%lld%lld",&n,&m);
	if(abs(n-m)>=2)printf("0\n");
	else
	{
		long long a=1;
		for(int i=1;i<=n;i++)
		{
			a=a*i;
			a%=N;
		}
		a=(a+N)%N;
		long long b=1;
		for(int i=1;i<=m;i++)
		{
			b=b*i;
			b%=N;
		}
		b=(b+N)%N;
		ans=(a*b)%N;
		if(n==m)ans=ans*2;
		ans%=N;
	    printf("%lld\n",ans);
	}

	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int gcd(int m,int n){
    if(m==0||n==0){
        return m;
    }
    return gcd(n,m%n);
}
int main(){
    int N,X;
    cin >> N >> X;
    int x[N];
    for(int i=0;i<N;i++){
        cin >> x[i];
        x[i] = abs(x[i]-X);
    }
    int ans = x[0];
    for(int i=1;i<N;i++){
        ans = gcd(ans,x[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const int INF = 100000; 

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    int ans = 0;
    if(n <= k){
        ans = x * n;
    }else{
        ans = x * k + y * (n - k); 
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <set>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

typedef long long ll;

int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    long long n, a, b;
    cin >> n >> a >> b;
    if (a > b) {
        cout << 0 << endl;
        return 0;
    }
    if (n == 1) {
        cout << int(a == b) << endl;
        return 0;
    }
    cout << 1 + (b - a) * (n - 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    ll n, z=0;
    cin>>n;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ll a=i, b=n/i;
            if(a<b&&a<=b-2){
                z+=b-1;
            }
        }
    }
    cout<<z<<endl;
}


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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<vector<i64>> digits(10, vector<i64>(10));
  for (int i = 1; i <= N; ++i) {
    int d1 = i % 10;
    int d2 = d1;
    int x = i;
    while (x) {
      d2 = x % 10;
      x /= 10;
    }
    if (d1 != 0 && d2 != 0) {
      digits[d1][d2]++;
    }
  }
  i64 ans = 0;
  REP(i, 10) REP(j, 10) { ans += digits[i][j] * digits[j][i]; }
  cout << ans << endl;
}

Measured memory_bytes: 3624
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	list := make([]int, m+1)
	var k, a int
	for i := 0; i < n; i++ {
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			fmt.Scan(&a)
			list[a]++
		}
	}

	var result int
	for i := 1; i < m+1; i++ {
		if list[i] == n {
			result++
		}
	}
	fmt.Println(result)
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <fstream>
#include <sstream>
using namespace std;

int main()
{
	int p=0,g=0,w=0,y=0,n,i;
	char a;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		if(a=='P')
			p=1;
		if(a=='G')
			g=1;
		if(a=='W')
			w=1;
		if(a=='Y')
			y=1;
	}
	if(p+g+w+y==3)
		cout<<"Three";
	if(p+g+w+y==4)
		cout<<"Four";
	return 0;
}


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

typedef long long int ll;

int main () {
  int A, B;
  cin >> A >> B;
  if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0){
    cout << "Possible" << endl;
  }else {
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <iostream>
#include <queue>
#include <set>

#define ll long long
#define sf(a) scanf("%lld",&a)
#define pf(b) printf("%lld",b)
#define sp printf(" ")
#define nw printf("\n")
#define mp make_pair
#define pi pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define fast ios_base::sync_with_stdio(false)
using namespace std;

vector<int>prime;
void sieve()
{
    int sroot=10000;
    bool a[sroot];
    memset(a, 0, sizeof(a));

  for(int i = 2; i <= sroot; i++) {
    if(a[i] == 0) {
      for (int j = i + i; j <= sroot; j = j + i) {
        a[j] = 1;
      }

    }

  }

  for (int i = 2; i <= sroot; i++) {
    if(a[i] == 0) {
      prime.push_back(i);
    }

  }
}
int mark[1000000];
int main()
{

  sieve();
  int n,sprime,pprime,gc;
  sprime=pprime=1;
  cin>>n;
  int ar[n+1];
  for(ll i=1;i<=n;i++)
  {
     cin>>ar[i];
     if(i>1)
     gc=__gcd(gc,ar[i]);
     else gc=ar[i];
     int val=ar[i];
     for(ll j=0;prime[j]*prime[j]<=val and j<prime.size();j++)
     {
      while(val%prime[j]==0){
          mark[prime[j]]++;
          val/=prime[j];
      }
     }
     if(val>1) mark[val]++;
  }
  if(gc!=1) sprime=0;
  for(ll i=1;i<=n;i++)
  {
     int val=ar[i];
     for(ll j=0;prime[j]*prime[j]<=val and j<prime.size();j++)
     {
      while(val%prime[j]==0){
          mark[prime[j]]--;
          val/=prime[j];
      }
     }
     if(val>1) mark[val]--;
     val=ar[i];
     for(ll j=0;prime[j]*prime[j]<=val and j<prime.size();j++)
     {
      while(val%prime[j]==0){
          if(mark[prime[j]])
          {
            pprime=0;
            break;
          }
          val/=prime[j];
      }
      if(!pprime) break;
     }
     if(val>1)  if(mark[val]) pprime=0;
     if(!pprime) break;
  }
  if(pprime) printf("pairwise coprime");
  else if(sprime) printf("setwise coprime");
  else printf("not coprime");
}

Measured memory_bytes: 11420
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
ll d[MAX],ans[MAX];
int main(){FAST;
cin>>n;
for(ll i=0;i<n;i++){
	cin>>d[i];
}
ll c = 0;
for(ll i=0;i<n;i++){
	if(i&1){
		c-=2*d[i];
	}
	else{
		c+=2*d[i];
	}
}
ans[0] = c/2;
for(ll i=1;i<n;i++){
	ans[i]=2*d[i-1]-ans[i-1];
}
for(ll i=0;i<n;i++)cout<<ans[i]<<' ';
return 0;
}

Measured memory_bytes: 2944
n = gets.to_i
a = gets.split.map(&:to_i)
h = %w[0 1 2].zip([-1, 0, 1]).to_h
count = 0

(3**n).times do |i|
  bit = format("%0#{n}d", i.to_s(3))
  prod = 1

  bit.each_char.with_index do |b, idx|
    prod *= (a[idx] + h[b])
  end

  count += 1 if prod.even?
end

puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

#define fs first
#define sc second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

    cout << n * n * n << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int N,rem;
    scanf("%d",&N);
    if(N>0 && N<1000)
    {
      rem=N%10;
      if(rem == 2 || rem == 4 || rem == 5 || rem == 7 || rem == 9)
      {
        printf("hon\n");
      }
      else if(rem == 0 || rem == 1 || rem == 6 || rem == 8)
      {
        printf("pon\n");
      }
      else
      {
        printf("bon\n");
      }
    }
    else
    {
      printf("Enter N between 1 to 999\n");
    }
    return 0;
}

Measured memory_bytes: 1644
from bisect import bisect_left
from collections import deque
N = int(input())
ls = deque([])
ans = 0
for i in range(N):
  a = int(input())
  if ls:
    ID = bisect_left(ls, a)
    if ID==0:
      ans += 1
      ls.appendleft(a)
    else:
      ls[ID-1]= a
  else:
    ans += 1
    ls.append(a)
print(ans)

Measured memory_bytes: 7412
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;
ll power(ll x,ll y)
{
    if(y==0)
    return 1;
    ll res=power(x,y/2);
    res=(res*res)%M;
    if(y&1)
    res=(res*x)%M;
    return res;
}
void solve()
{
    int h,w,n;
    cin>>h>>w>>n;
    int ma=max(h,w);
    cout<<(int)ceil(n*1.0/ma);
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256