akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
char a[100010]; bool f[100010];
using namespace std;
bool ok(int l, int r) {
	string ret;
	rep(i, l, r) ret += a[i];
	if (ret == "dream" || ret == "dreamer" || ret == "erase" || ret == "eraser") return true;
	return false;
}
int main() {
	scanf("%s", a + 1); int n = strlen(a + 1);
	if (n < 5) { printf("NO"); return 0; }
	f[0] = true;
	rep(i, 5, n) {
		if (ok(i - 5 + 1, i)) f[i] |= f[i - 5];
		if (i > 5 && ok(i - 6 + 1, i)) f[i] |= f[i - 6];
		if (i > 6 && ok(i - 7 + 1, i)) f[i] |= f[i - 7];
	}
	if (f[n]) printf("YES"); else printf("NO");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <math.h>
#include <algorithm>
#define rep(i,n) for(int i=0; i < (n); i++)
#define INF 1001001
using namespace std;
 
int main(){
  string s,t;
  cin >> s >> t;
  int count=0;
  rep(i,s.length()) if(s[i]==t[i])count++;

  cout << s.length()-count << endl;
 
  
}

Measured memory_bytes: 3848
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int del(int x) { return x>=P?x-P:x; }
void addd(int &x,int y) { x=del(x+y); }
int n,m,a[N],b[N];
int bit[N];
void add (int x,int d) { for (; x<=m; x+=x&-x) addd(bit[x],d); }
int sum (int x) { int ans=0; for (; x; x-=x&-x) addd(ans,bit[x]); return ans; }
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
pii p[N];
int f[N];
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n),sc(m);
	for (int i=1; i<=n; i++)
		sc(a[i]);
	for (int i=1; i<=m; i++)
		sc(b[i]);
	sort (b+1,b+m+1); b[++m]=oo;
	int k=0;
	for (int i=1; i<=n; i++)
	{
		int g=lower_bound (b+1,b+m+1,a[i])-b;
		if (g> 1&&g< m) p[++k]=mp(a[i]-b[g-1],b[g]-a[i]);
	}
	p[++k]=mp(oo,oo);
	n=k,m=0;
	for (int i=1; i<=n; i++)
		b[++m]=p[i].se;
	sort (b+1,b+m+1);
	m=unique (b+1,b+m+1)-b-1;
	sort (p+1,p+n+1,[](pii A,pii B) { return A.fi!=B.fi?A.fi< B.fi:A.se> B.se; });
	for (int i=1; i<=n; i++) if (i==1||p[i]!=p[i-1])
	{
		int g=lower_bound (b+1,b+m+1,p[i].se)-b;
		f[i]=1+sum (g-1),add (g,f[i]);
	}
	pr(f[n]);


    return 0;
}

Measured memory_bytes: 10752
fn main() {
    let mut n: usize = read();
    let mut ki: HashSet<usize> = HashSet::new();
    for i in 2..(n as f64).powf(0.5) as usize + 1 {
        if n % i == 0 {
            ki.insert(i);
            n /= i;
            let mut j = 2;
            while n % i.pow(j) == 0 {
                n /= i.pow(j);
                ki.insert(i.pow(j));
                j += 1;
            }
            while n % i == 0 {
                n /= i;
            }
            if n == 1 {
                break;
            }
        }
    }
    if n != 1 {
        ki.insert(n);
    }
    println!("{}", ki.len());
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2180
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	int N,min,dp[300000]={};
	vector<int> v;
	cin>>N;
	dp[1]=1;
	v.push_back(1);
	for(int i=6;i<=N;i*=6){
		dp[i]=1;
		v.push_back(i);
	}	
	for(int i=9;i<=N;i*=9){
		dp[i]=1;
		v.push_back(i);

	}
	for(int i=1;i<=N;i++){
		for(int j=0;j<v.size();j++){
			if(dp[i+v[j]]==0){
				dp[i+v[j]]=dp[i]+1;
			}else if(dp[i+v[j]]>dp[i]+1){
				dp[i+v[j]]=dp[i]+1;
			}
			
		}
	}
	cout<<dp[N]<<endl;
}




Measured memory_bytes: 1408
#include<stdio.h>
#define N 44
int F[N];

int makefibonacci(int n){
  int i;
  F[0]=1;
  F[1]=1;
  for(i=2;i<=n;i++){
    F[i]=F[i-2]+F[i-1];
  }
  return F[n];
}
int main(){
  int i,n;
  scanf("%d",&n);

  printf("%d\n",makefibonacci(n));
  return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int r;

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

  cin >> r;

  cout << pow(r,2) << "\n";
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/05/31.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC169
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const int MOD = 1000000007;
// const double PI = 3.141592653589793;
//#define __DBG__



void solve(void){
  
  int A, B;
  cin >> A >> B;
  
  cout << A*B << endl;
  return;
}



#define TESTCASES 1

int main() {
  


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

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}




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

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

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

    vector<pair<pair<string, int>, int>> p;
    rep(i, N) {
        string s;
        int po;
        cin >> s >> po;
        pair<pair<string, int>, int> tmp;
        tmp.first = {s, po};
        tmp.second = i;
        p.push_back(tmp);
    }

    sort(p.begin(), p.end(), [](const pair<pair<string, int>, int>& a, const pair<pair<string, int>, int>& b) {
        if (a.first.first == b.first.first) {
            return a.first.second > b.first.second;
        }
        return a.first.first < b.first.first;
    });

    int ans[101];
    int cur = 1;
    rep(i, p.size()) {
        cout << p[i].second+1 << endl;
    }

}


Measured memory_bytes: 256
import java.util.*;

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

        dfs("a", 1, N);
    }

    private static void dfs(String w, int mx,  int N) {
        if (w.length() == N) {
            System.out.println(w);
            return;
        }

        for (int i = 0; i <= mx; i++) {
            StringBuilder builder = new StringBuilder(w);
            dfs(builder.append((char)('a'+i)).toString(), i+1 < mx ? mx : i+1, N);
        }
    }
}



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

int n;
const int maxn = 55;
int a[maxn];

int main(){
	cin >> n;
	int id = 0,ans = 0;
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
		if(abs(a[i]) > ans){
			ans = abs(a[i]);
			id = i;
		}
	}
	if(a[id] == 0){
		puts("0");
	}else if(a[id] > 0){
		printf("%d\n",2 * (n - 1));
		for(int i = 2;i <= n;i++){
			printf("%d %d\n",id,i);	
			printf("%d %d\n",id,i);	
			id = i;
		}	
	}else{
		printf("%d\n",2 * (n - 1));
		for(int i = n - 1;i >= 1;i--){
			printf("%d %d\n",id,i);	
			printf("%d %d\n",id,i);	
			id = i;
		}	
	}
	return 0;
}


Measured memory_bytes: 256
# 問題 https://atcoder.jp/contests/abc103/tasks/abc103_d

# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, M = read_ints()

AB = [tuple(map(int, read().split())) for _ in range(M)]

from operator import itemgetter

AB.sort(key=itemgetter(1))  # リスト1は2次元以の配列

# . - . - . - .

i = -1  # いま考慮している島の位置
ans = 0
for a, b in AB:
    # zero-based index
    a -= 1
    b -= 1
    if a < i:
        # 考えなくてもいい(もう満たしている)要望は飛ばす
        # 同じ島からスタートする橋は許容できるので<=ではなく<
        continue
    ans += 1
    i = b

print(ans)


Measured memory_bytes: 18284
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String s = in.next();
            int indexOfC = s.indexOf('C');
            int indexOfF = s.lastIndexOf('F');
            System.out.println((indexOfC >= 0 && indexOfF >= 0 && indexOfC < indexOfF) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <utility>
#include <cstring>
using namespace std;

int dp[110],K[110],O[110],L[110],R[110];

int gcd(int a,int b){
	int tmp;
	if(a<b) swap(a,b);
	while((tmp=a%b)!=0){
		a=b;
		b=tmp;
	}
	return b;
}


int mobi(int bou){
	if(bou==0) return 1;
	if(dp[bou]!=0) return dp[bou];
	int l,r,li,ri,gc2,a,b;
	l=mobi(L[bou]);
	r=mobi(R[bou]);
	li=K[bou];ri=O[bou];
	gc2=gcd(li*l,ri*r);
	b=(li*l)/gc2;
	a=(ri*r)/gc2;
	dp[bou]=(a*l+b*r);
	return dp[bou];
}

int main(){
	int N,k,o,g;
	int res;
	while(1){
		cin>>N;
		if(N==0) break;
		memset(dp,0,sizeof(dp));
		K[0]=O[0]=L[0]=R[0]=0;
		for(int i=1;i<=N;i++){
			cin>>k>>o>>L[i]>>R[i];
			g=gcd(k,o);
			K[i]=k/g;
			O[i]=o/g;
		}
		res=0;
		for(int i=1;i<=N;i++){
			res=max(res,mobi(i));
		}
		/*
		for(int i=1;i<=N;i++){
			cout<<i<<" "<<dp[i]<<endl;//
		}
		*/
		cout<<res<<endl;
	}
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 100005;

VI g[MAX];

int dfs(int v)
{
	VI a;
	FOR(i,0,SZ(g[v]))
	{
		int to = g[v][i];
		a.PB(dfs(to));
	}

	int ans = SZ(g[v]);
	sort(ALL(a));
	reverse(ALL(a));

//	cerr<<"V "<<v+1<<" "<<SZ(g[v])<<" "<<SZ(a)<<endl;
	FOR(i,0,SZ(a))
	{
		ans = max(ans,a[i]+i+1);
//		cerr<<a[i]<<" ";
	}
//	cerr<<endl;
//	cerr<<v+1<<" "<<ans<<endl;
	return ans;
}
int main()
{
  // freopen("in.txt", "r", stdin);
 //   ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    FOR(i,1,n)
    {
    	int a;
    	cin>>a;
    	--a;
    	g[a].PB(i);
    }

    cout<<dfs(0);

	return 0;
}


Measured memory_bytes: 15104
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,n,K,iti,i;cin>>n>>K;
	cout<<(n+K-3)/(K-1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define mod 998244353

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int n;cin >> n;
        vector<int> ar(n), st(n);
        lp(i, n) { cin>> ar[i]; st[i] = ar[i]; }
        sort(all(st));
        lp(i, n) {
                if (ar[i] == st[n - 1])cout<< st[n - 2]<< "\n";
                else cout << st[n - 1]<< "\n";
        }
return 0;
}


Measured memory_bytes: 3200
import math
N = int(input())

MOD_VALUE = math.pow(10, 9) + 7

def pow_mod(value, pow):
    ret = 1
    for _ in range(pow):
        ret = ret * value % MOD_VALUE
    return ret

result = pow_mod(10, N) - pow_mod(9, N) * 2 + pow_mod(8, N)

print(int(result % MOD_VALUE))


Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

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

    ll ans = 0;
    vector<ll> cnt(N + 1, 1);
    repd(i, 2, N + 1) {
        for (ll j = i; j <= N; j += i) {
            cnt[j]++;
        }
    }

    repd(i, 1, N + 1) {
        ans += i * cnt[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81324
import itertools

n, d = map(int, input().split())
x = []
for _ in range(n):
    xli = list(map(int, input().split()))
    x.append(xli)

cnt = 0
for c in list(itertools.combinations(range(n), 2)):
    total = 0
    for i in range(d):
        total += (abs(x[c[0]][i] - x[c[1]][i])) ** 2
    ans = total ** 0.5
    if ans == int(ans):
       cnt += 1
print(cnt)

Measured memory_bytes: 38460
#CGL_4-A Convex Polygon - Convex Hull
def isCLKWISE(ph):
    if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0 : return False
    return True
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = []
for i in n:
    P.append([int(x) for x in input().split()])
      
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33768
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
    static decimal result;
static StringBuilder sb = new StringBuilder();
static int N,M,K;
    static void Main()
    {
string tmp = Console.ReadLine();
if(tmp[2]==tmp[3] && tmp[4]==tmp[5]){Console.WriteLine("Yes");}
                   else{ Console.WriteLine("No");}

    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {

 
    }


}

Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	int T;
	cin >> T;
	while (T--)
	{
		int gx, gy, p;
		bool right[128][128], up[128][128];
		CLEAR(right, 0);
		CLEAR(up, 0);
		cin >> gx >> gy >> p;
		while (p--)
		{
			int x1, x2, y1, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			if (x1 > x2)
				swap(x1, x2);
			if (y1 > y2)
				swap(y1, y2);
			if (x1 == x2)
				up[y1][x1] = true;
			else if (y1 == y2)
				right[y1][x1] = true;
		}

		int dp[32][32];
		CLEAR(dp, 0);
		dp[0][0] = 1;
		for (int y = 0; y <= gy; ++y)
		{
			for (int x = 0; x <= gx; ++x)
			{
				if (!right[y][x])
					dp[y][x + 1] += dp[y][x];
				if (!up[y][x])
					dp[y + 1][x] += dp[y][x];
			}
		}
		
		if (dp[gy][gx])
			printf("%d\n", dp[gy][gx]);
		else
			puts("Miserable Hokusai!");
	}
}

Measured memory_bytes: 0
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
def main():
    a = input()
    b="abcdefghijklmnopqrstuvwxyz"
    b=list(b)
    print(b[b.index(a)+1])



if __name__ == "__main__":
    main()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N;
    cin >> N;
    ll a[N];
    REP(i, N) cin >> a[i];
    int x=0, y=0;
    REP(i, N){
        if(a[i]%2==0){
            if(a[i]%4==0){
                x++;
            }else{
                y++;
            }
        }
    }
    if(2*x+1>=N){
        cout << "Yes" << endl;
    }else if(2*x+y>=N){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc= new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();
		
		int max=a[0];
		
		long step=0;
		for(int i : a)
		{
			max=Math.max(i, max);
			step+=max-i;
		}
		System.out.println(step);
	}

}


Measured memory_bytes: 60728
/*
ID: Aman Raj
LANG: C++
TASK: prefix
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#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 (1000*1000*1000+7)
//#define mod 13
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
   ll power(ll a,ll b)//a raised to power b
   {  if(b==0)return 1;if(b==1)return a;
       ll c=power(a,b/2);
       c*=c;c%=mod;if(b%2==1)c*=a;c%=mod;
        return c;
   }
   ll mi(ll a)
   {
       return power(a,mod-2);
   }
   vector<vector<ll> > vtree;
   vector<ll> vcolor;
   vector<ll> visited;
    vector<ll> dp;
    ll ans=0;;
   ll aman(ll a)
   {  visited[a]=1;

     ll no=0;vector<ll> vcol;
     for(auto x:vtree[a])
     {
         if(!visited[x])no=aman(x);
         vcol.push_back(no);

     }
     if(vcolor[a]==1)
     { ll pr=1;
        for(auto x:vcol){pr*=x;pr%=mod;   }
        ans+=pr;
        return 1;

     }
     ll send=0;
     for(auto x:vcol)send+=x;return send+1;


   }
   int main()
{  /*ll n;cin>>n;
    vtree.resize(n);
    for(ll i=0;i<n-1;i++)
    {   ll a;cin>>a;
        vtree[i+1].push_back(a);
        vtree[a].push_back(i+1);
    }
     vcolor.resize(n);
    for(ll i=0;i<n;i++)cin>>vcolor[i];

    visited.resize(n,0);
    dp.resize(n);
     for(ll i=0;i<n;i++){if(vcolor[i]==1)aman(i);   }
      cout<<ans;*/
      ll n;cin>>n;ll sum=0;
      vector<ll> v;
      for(ll i=0;i<n;i++)
      {
          ll a;cin>>a;sum+=a;
          v.push_back(sum);
      }
      ll ans=1000000;
      for(ll i=0;i<n;i++)
      {
          ll ab=abs(sum-2*v[i]);
          ans=min(ans,ab);
      }
      cout<<ans;

    return 0;
 }


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
    if (n == 0)return 1;
    if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
    return (x * modexp((x * x) % md, n / 2, md)) % md;
}


int main() {
    fastio;
    // clock_t tm = clock();
    map<string,int>ans;
    ans["AC"]=0;ans["TLE"]=0;
    ans["WA"]=0;ans["RE"]=0;
    int n;string s;
    cin>>n;
    f(i,0,n){
        cin>>s;
        ans[s]++;
    }
    cout<<"AC x "<<ans["AC"]<<endl;
    cout<<"WA x "<<ans["WA"]<<endl;
    cout<<"TLE x "<<ans["TLE"]<<endl;
    cout<<"RE x "<<ans["RE"]<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}


Measured memory_bytes: 3664
#include <iostream>

using namespace std;

int main()
{
    int K, A, B;
    cin >> K >> A >> B;

    int kakeru = A / K;
    if (A % K != 0) kakeru++;

    if (K * kakeru <= B) cout << "OK";
    else cout << "NG";


    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)

using namespace std;

string S, T, U;
int A, B;

void resolve()
{
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    bool b = true;
    if (U.length() != S.length()) {
        b = false;
    } else {
        RPT0(i, U.length())
        {
            if (U[i] != S[i]) {
                b = false;
                break;
            }
        }
    }

    if (b) A--;
    if (!b) B--;

    cout << A << " " << B << endl;
}

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


Measured memory_bytes: 256
x, y = map(int, input().split())

g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]

if x in g1 and y in g1:
    print("Yes")
elif x in g2 and y in g2:
    print("Yes")
elif x in g3 and y in g3:
    print("Yes")
else:
    print("No")

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

typedef long long ll;

int main(){
    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    if(2*N >= M){
        ans += M/2;
    }else if(2*N < M){
        ans += N;
        M -= 2*N;
        ans += M/4;
    }
    cout<< ans <<endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let a: Vec<i64> = (0..n)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();
    let b: Vec<i64> = (0..n)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();

    let mut d_sum = 0;
    let mut minus_sum = 0;
    let mut count = 0;
    let mut plus_d: Vec<i64> = Vec::new();
    for i in 0..n {
        let d = a[i] - b[i];
        d_sum += d;
        if d < 0 {
            minus_sum += d;
            count += 1;
        } else {
            plus_d.push(d);
        }
    }

    if d_sum < 0 {
        return "-1".to_string();
    }

    plus_d.sort();

    while minus_sum < 0 {
        let d = plus_d.pop().unwrap();
        minus_sum += d;
        count += 1;
    }

    return count.to_string();
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, r;
  cin >> n >> r;

  if (n >= 10) {
  } else {
    r += 100*(10-n);
  }
  cout << r << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<math.h>
using namespace std;
using LL = long long;
const int INF = 1e9;
int main(){
    int N;
    cin >> N;
    int h[111];
    h[0] = 0;
    int ans = 0;
    for(int i = 1;i <= N;i++){
        cin >> h[i];
        if(h[i] > h[i-1])ans += h[i] - h[i-1];
    }
    cout << ans;
}



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

int main(void)
{
    int i,n;
        double x,mean,poi[1010]={0};
    
    while(scanf("%d",&n)==1 && n!=0){
        x=0;
        for(i=0;i<n;i++){
            scanf("%lf",&poi[i]);
            x+=poi[i];
        }
        mean=x/n;
        x=0;
        
        for(i=0;i<n;i++){
            x+=pow(poi[i]-mean,2);
        }
        
        mean=sqrt(x/n);
        printf("%f\n",mean);
    }
    return 0;
}


Measured memory_bytes: 2056
import sys
#import math
stdin = sys.stdin
     
pi=3.1415
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

R=int(input())
print(2*R*pi)

Measured memory_bytes: 9168
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

type UnionFind struct {
	par []int
	r   []int
}

func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	u.r = make([]int, N)
	for i := 0; i < N; i++ {
		u.par[i] = i
		u.r[i] = 0
	}
	return u
}

func (p *UnionFind) root(x int) int {
	if p.par[x] == x {
		return x
	}
	return p.root(p.par[x])
}

func (p *UnionFind) unite(x, y int) {
	x = p.root(x)
	y = p.root(y)
	if p.r[x] < p.r[y] {
		p.par[x] = y
	} else {
		p.par[y] = x
		if p.r[x] == p.r[y] {
			p.r[x]++
		}
	}
}

func (p *UnionFind) same(x, y int) bool {
	return p.root(x) == p.root(y)
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K, L := getInt(), getInt(), getInt()

	u0 := newUnionFind(N)
	u1 := newUnionFind(N)
	for i := 0; i < K; i++ {
		x, y := getInt()-1, getInt()-1
		u0.unite(x, y)
	}

	for i := 0; i < L; i++ {
		x, y := getInt()-1, getInt()-1
		u1.unite(x, y)
	}

	type key struct {
		x, y int
	}
	m := make(map[key]int, N*2)

	for i := 0; i < N; i++ {
		k := key{u0.root(i), u1.root(i)}
		m[k]++
	}

	wr := bufio.NewWriter(os.Stdout)

	for i := 0; i < N; i++ {
		k := key{u0.root(i), u1.root(i)}
		if i != N-1 {
			fmt.Fprintf(wr, "%d ", m[k])
		} else {
			fmt.Fprintf(wr, "%d\n", m[k])
		}
	}
	wr.Flush()
}


Measured memory_bytes: 24192
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e9;
ll inf = LLONG_MAX, mod1 = 1e9 + 7, mod2 = 998244353;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll a[200001];

int main()
{
    fast_io;
    ll n, i, s = 0;
    cin >> n;
    for (i = 1; i <= n; i++) cin >> a[i];
    for (i = 2; i <= n; i++)
    {
        if (a[i] < a[i - 1]) s += a[i - 1] - a[i], a[i] = a[i - 1];
    }
    cout << s;
    return 0;
}

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

long long N, A, B, C;
string S[100005];
char ans[100005];

int main(){
	cin >> N >> A >> B >> C;

	for(long long i = 0; i < N; i++){
		cin >> S[i];
	}

	for(long long i = 0; i < N; i++) {
		if(S[i] == "AB") {
			if(A < B) {
				ans[i] = 'A';
			} else if (A > B) {
				ans[i] = 'B';
			} else if(A == 1 && i < N - 1) {
				if(S[i+1] == "AB") {
					ans[i] = 'B';
				} else if(S[i+1] == "AC") {
					ans[i] = 'A';
				} else if(S[i+1] == "BC") {
					ans[i] = 'B';
				}
			} else {
				ans[i] = 'B';
			}

			if(ans[i] == 'A') {
				A++;
				B--;
			} else {
				A--;
				B++;
			}

		} else if(S[i] == "AC") {
			if(A < C) {
				ans[i] = 'A';
			} else if (A > C) {
				ans[i] = 'C';
			} else if(A == 1 && i < N - 1) {
				if(S[i+1] == "AC") {
					ans[i] = 'C';
				} else if(S[i+1] == "AB") {
					ans[i] = 'A';
				} else if(S[i+1] == "BC") {
					ans[i] = 'C';
				}
			} else {
				ans[i] = 'C';
			}

			if(ans[i] == 'A') {
				A++;
				C--;
			} else {
				A--;
				C++;
			}

		} else if(S[i] == "BC") {

			if(B < C) {
				ans[i] = 'B';
			} else if (B > C) {
				ans[i] = 'C';
			} else if(B == 1 && i < N - 1) {
				if(S[i+1] == "AC") {
					ans[i] = 'C';
				} else if(S[i+1] == "AB") {
					ans[i] = 'B';
				} else if(S[i+1] == "BC") {
					ans[i] = 'B';
				}
			} else {
				ans[i] = 'C';
			}

			if(ans[i] == 'B') {
				B++;
				C--;
			} else {
				B--;
				C++;
			}

		} else {
			return 1;
		}
		if(A < 0 || B < 0 || C < 0) {
			cout << "No" << endl;
			return 0;
		}
	}
cout << "Yes" << endl; for(long long i = 0; i < N; i++) {
		cout << ans[i] << endl;
	}
}



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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define int long long
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)

signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	int st=0;
	lp(i,c){
		if(st==0){
			if(a%2==1) a--;
			b+=a/2;
			a/=2;
			st=1;
		}
		else{
			if(b%2==1) b--;
			a+=b/2;
			b/=2;
			st=0;
		}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}

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


int main(){
int i,j;
char str[21];
char temp[21];

scanf("%s",str);
strcpy(temp,str);

for(i=0;temp[i]!='\0';i++);

for(j=0;j<i;j++){str[j]=temp[i-j-1];}

printf("%s\n",str);

return 0;
}

Measured memory_bytes: 1748
#include <iostream>
using namespace std;
int main(void){
    int N,K;
    int te=0;
    cin>>N>>K;
    if(N<K)cout<<1<<endl;
    else{
      while(N>=K){
        N=N/K;
        te++;
      }
    cout<<te+1<<endl;
        
    }
return 0;
    
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char , char> pcc;
#define pb push_back
#define mp make_pair
#define ft first
#define se second
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)


int main()
{
	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	ll n,W;
  	cin >> n >> W;
  	ll w[n+5];
  	ll c[n+5];
  	ll dp[n+5][W+5];
  	for(ll i=1;i<=n;i++)
  	{
  		cin >> w[i] >> c[i];
  	}
  	for(ll i=0;i<=n;i++)
  	{
  		dp[i][0]=0;
  	}
  	for(ll i=1;i<=W;i++)
  	{
  		dp[0][i]=0;
  	}
  	for(ll i=1;i<=n;i++)
  	{
  		for(ll j=1;j<=W;j++)
  		{
  			if(j-w[i]>=0)
  			{
  				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+c[i]);
  			}
  			else 
  			{
  				dp[i][j]=dp[i-1][j];
  			}
  		}
  	}
  	cout << dp[n][W] << endl;
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define REP(i,n) for(int i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")

using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;

const int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int dy[8] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  int n;
  cin >> n;
  vector<double> x(n), y(n);
  rep(i,n) cin >> x[i];
  rep(i,n) cin >> y[i];
  double mad = 0;
  rep(i,n) mad += abs(x[i]-y[i]);
  double ud = 0;
  rep(i,n) ud += pow(abs(x[i]-y[i]) ,2);
  ud = sqrt(ud);
  double mid = 0;
  rep(i,n) mid += pow(abs(x[i]-y[i]), 3);
  mid = cbrt(mid);
  double td = 0;
  rep(i,n) td = max(td, abs(x[i]-y[i]));
  printf("%.10lf\n%.10lf\n%.10lf\n%.10lf\n", mad, ud, mid, td);
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     string str;
     ll mx=0;
     map<char,ll>mp;
     cin>>str;
     for(int i=0;i<str.size();i++)
     {
         mp[str[i]]++;
         mx=max(mp[str[i]],mx);
     }
     if(mx==1)
        cout<<"yes"<<endl;
     else
        cout<<"no"<<endl;
}


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

int main(){
    string a, b;
    cin >> a >> b;
    for(int i = 0; i <= 1000; i++){
        if(to_string(i * i) == a + b){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
import sys

n = int(input())
A = list(map(int, sys.stdin.readline()[:-1].split()))

q = int(input())
M = list(map(int, sys.stdin.readline()[:-1].split()))

R = [[None] * 2000 for i in range(n+1)]
def solve(A, n, i, m):
    if R[i][m] != None:
        return R[i][m]
    if m == 0:
        R[i][m] = True
        return True
    if n <= i:
        R[i][m] = False
        return False
    a = A[i]
    R[i][m] = (solve(A, n, i+1, m) or solve(A, n, i+1, m - a))
    return R[i][m]

for m in M:
    if solve(A, n, 0, m):
        print('yes')
    else:
        print('no')

Measured memory_bytes: 8152
#include<iostream>
#include<math.h> 
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<climits>
using namespace std;
typedef long long int lli;
lli mod=1000000007;
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    lli n;
    cin>>n;
    double ans=0;
    if(n%2==0)
        ans=0.5;
    else
        ans=(n/2+1.0)/(n);
    cout<<ans<<endl;
}

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

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	int size=s.size();
	int a=size,z=0;
	for(int i=1;i<=size;i++)
	{
		if(s[i-1]=='A')
			a=min(a,i);
		if(s[i-1]=='Z')
			z=i;
	}
	cout << z-a+1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

int A,B,C,ans;

int main()
{
    cin >> A >> B >> C;
    ans=min(B/A,C);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import functools
from operator import add

def main():
    h,w,k = tuple([int(t)for t in input().split()])

    s = [[int(i) for i in list(input())] for _ in range(h)]
    
    cusum = [accumelist(s_) for s_ in s]

    candidates = []

    for i in range(1<<(h-1)):
        subcu = divide(cusum,i)
        subs = divide(s,i)

        subcusum = []

        rowsum = []

        for sub_ in subcu:
            subcusum.append(functools.reduce((lambda a,b:list(map(add,a,b))),sub_))

        for sub_ in subs:
            rowsum.append(functools.reduce((lambda a,b:list(map(add,a,b))),sub_))


        cutnum = 0

        temp = [0]*len(subcusum)

        for j in range(w):
            for l in range(len(subcusum)):
                if subcusum[l][j]-temp[l]>k:
                    if rowsum[l][j]>k:
                        cutnum+=10000
                    temp = [x[j-1] for x in subcusum]
                    cutnum+=1
                    break
        
        candidates.append(cutnum+bin(i).count('1'))

    print(min(candidates))
            
def divide(s,i):
    subs = []
    counter = 0
    pos = 0
    while i!= 0:
        counter +=1
        if i%2==1:
            subs.append(s[pos:counter])
            pos = counter
        i >>=1
 
    subs.append(s[pos:])
    return subs

def accumelist(s):
    if s == []:
        return []
    res = [s[0]]
    for i in range(1,len(s)):
        res.append(res[i-1]+s[i])

    return res

def _add_(a,b):
    return map(add,a,b)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 54120
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int a;
  cin >> a;
  int ans = 0;
  if(a==2){
    cout << 1;
    return 0;
  }
  for(int i=2;i<=sqrt(a);i++){
    if(a%i==0){
      int t1 = i;
      int t2 = a/i;
      int temp1 = a;
      int temp2 = a;
      while(temp1%t1==0){
        temp1 /= t1;
      }
      temp1 %= t1;
      while(temp2%t2==0){
        temp2 /= t2; 
      }
      temp2 %= t2;
      
      ans += (temp1==1);
      ans += (temp2==1);
      if(t1==t2){
        ans--;
      }
    }
  }
  ans++;
  int a2 = a-1;
  for(int i=2;i<=sqrt(a2);i++){
    if(a2%i!=0){
      continue;
    }
    int idk1 = a2/i;
    int idk2 = i;
    if(a%idk1!=0){
      ans++;
    }
    if(a%idk2!=0){
      ans++;
    }
    if(idk1==idk2){
      ans--;
    }
  }
  cout << ans+1;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x[]=new int[n];
		for(int i=0;i<n;i++) {
			x[i]=scan.nextInt();
		}
		scan.close();
		long  min = Integer.MAX_VALUE;
		Arrays.sort(x);
		for(int i=1; i<=x[n-1];i++) {
			long sum =0;
			for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			}
			if(min > sum) min = sum;
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int d[N];
  for(int i=0;i<N;i++)cin>>d[i];
  sort(d,d+N);
  int t=0;
  int res=0;
  for(int i=0;i<N;i++){
    if(t!=d[i])res++;
    t=d[i];
  }
  cout<<res;
  return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll x;
    cin >> x;
    repd(i, 1, 1000) {
        if ((x * i) % 360 == 0) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 3548
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#define int long long
using namespace std;
int ans;
string S;
void dfs(int n,int s,int p)
{
	if (n==S.size())
	{
		ans+=s+p;
		return;
	}
	int d=S[n]-'0';
	if (p) dfs(n+1,s+p,d);
	dfs(n+1,s,p*10+d);
}
signed main()
{
	cin>>S;
	dfs(0,0,0);
	cout<<ans;
	//system("pause");
    return 0;
}

Measured memory_bytes: 256
n = int(input())
aa = list(map(int,input().split()))
bb = list(map(int,input().split()))
cc = list(map(int,input().split()))
ans = 0
Cnum = 0
cur_a = 100
for a in aa:
    ans += bb[a-1]
    if a == cur_a+1:
        ans += cc[cur_a-1]
        Cnum += 1
    cur_a = a
print(ans)


Measured memory_bytes: 3060
#辞書順
#a<b,a*<b(先頭が大きいため)
#a
from itertools import permutations
S=input()
N=len(S)
alp=[0]*26
searched=[0]*26
flag=0
c=0
sub=100
minsub=100
#zxywvutsrqponmlkjihgfedcba→
for i in range(N):
    alp[ord(S[i])-97]=alp[ord(S[i])-97]+1
    #print(alp)
if (max(alp)!=1)or(S=="zyxwvutsrqponmlkjihgfedcba"):
    flag=0
else:
    if N!=26:
        for i in range(26):
            if alp[i]==0:
                c=chr(97+i)
                S="".join((S,c))
                flag=1
                break
    else:
        i=len(S)-2
        s=S[i:]
        #print(s)
        while True:
            piv=s[0]
            #print(s,S[:i],piv)
            for j in range(len(s)-1):
                if ord(s[j+1])>ord(piv):
                    sub=ord(s[j+1])-ord(piv)
                    #print(sub)
                    if sub<minsub:
                        minsub=sub
            if (minsub!=100):
                #print(minsub,chr(ord(piv)+minsub))
                S="".join((S[:i],chr(ord(piv)+minsub)))
                flag=1
                break

            minsub=100
            sub=0
            i=i-1
            s=S[i:]

if flag==0:
    print("-1")
else:
    print(S)

Measured memory_bytes: 38384