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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

  int d, n;
  cin >> d >> n;

  if (d == 0) {
    if (n == 100) {
      cout << 101 << endl;
      return 0;
    }
    cout << n << endl;
  } else if (d == 1) {
    if (n == 100) {
      cout << 101 * 100 << endl;
      return 0;
    }
    cout << n * 100 << endl;
  } else {
    if (n == 100) {
      cout << 101 * 100 * 100 << endl;
      return 0;
    }
    cout << n * 10000 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    res=0
    ans=1
    for i in 1:n
        num=i
        cnt=0
        while num%2==0
            num=div(num,2)
            cnt+=1
        end
        if res<cnt
            ans=i
            res=cnt
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 109496
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
int r = sc.nextInt();
int g = sc.nextInt();
int b = sc.nextInt();
int total = (100*r ) +(10 * g) + b;
if(total % 4 == 0){
System.out.println("YES");
}else{
System.out.println("NO");
}

}
}

Measured memory_bytes: 23124
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}
macro_rules! tern {
    ($condition: expr, $_true: expr, $_false: expr) => {
        if $condition {
            $_true
        } else {
            $_false
        }
    };
}

fn main() {
    let (a, b) = get!(isize, isize);
    use std::cmp::max;
    println!("{}", max(a+b, max(a-b, a*b)));
}


Measured memory_bytes: 4352
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,K=1,C;
ll A,B,W;
ll T,a,b;
double v[55],D[55];
ll ans=0;
int l;
bool h;
//bool D[100005];
ll S[50][50]={};
char str1[100005],str2[4][100005];
map<string,int> m;

int main(){
	cin>>A>>B;
	if(A==1)A=14;
	if(B==1)B=14;	
	if(A>B){
		cout<<"Alice"<<endl;
	}else{
		if(A<B)cout<<"Bob"<<endl;
		else cout<<"Draw"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static int m = 0;
    private static int x = 0;

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        m = scan.nextInt();
        x = scan.nextInt();

        int[][] c = new int[n][m + 1];
        for (int row = 0; row < n; row++) {
            for (int line = 0; line <= m; line++) {
                c[row][line] = scan.nextInt();
            }
        }

        int minPrice = -1;
        for (int all = 1; all < Math.pow(2, n); all++) {
            int price = 0;
            String binary = Integer.toBinaryString(all);
            int[] level = new int[m];

            for (int row = 0, choice = binary.length(); 0 < choice; choice--, row++) {
                String judge = binary.substring(choice - 1, choice);

                if (judge.equals("1")) {
                    price += c[row][0];
                    for (int line = 0; line < m; line++) {
                        level[line] += c[row][line + 1];
                    }
                }
            }

            if (achieve(level)) {
                if (minPrice > price || minPrice == -1) {
                    minPrice = price;
                }
            }
        }

        System.out.println(minPrice);
    }

    private static boolean achieve(int[] level) {
        for (int a = 0; a < m; a++) {
            if (level[a] < x) {
                return false;
            }
        }
        return true;
    }
}


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

int main(){
    using namespace std;
    int N, X; cin >> N >> X;
    int bound = 1, pos = 0;
    for (int i = 0; i < N; i++)
    {
        int l; cin >> l;
        pos += l;
        if(pos<=X) bound++;
        else break;
    }
    cout << bound << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;

const int nax = 2e5 + 100;

int n;
int a;
vector <ll> v[nax];
ll x[nax], y[nax];
ll z[nax];


int main() {
	scanf ("%d", &n);
	rep(i, 0, n - 1) {
		scanf ("%d", &a);
		v[i / 2].pb(a);
	}
	int g = (n - 2) / 2;
	rep(i, 0, g) {
		x[i] = (i ? x[i - 1] : 0) + v[i][0];
		y[i] = (i ? y[i - 1] : 0) + v[i][1];
		z[i] = -1e18;
		if (i) z[i] = z[i - 1];
		z[i] = max(z[i], -y[i] + x[i]);
	}
	ll res = -1e18;
	rep(i, 0, g) {
		ll s = y[g];
		if (i) s -= y[i - 1];
		if (i) s += x[i - 1];
		res = max(res, s);
	}
	res = max(res, y[g]);
	res = max(res, x[g]);
	if (n % 2 == 1) {
		rep(i, 0, g) {
			ll s = v[g + 1][0];
			s += x[g] - x[i];
			if (i) {
				s += y[i - 1];
				s += z[i - 1];
			}
			res = max(res, s);
		}
	}
	printf ("%lld", res);
	
		
	
	return 0;
}


Measured memory_bytes: 13996
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  char c;
  cin>>c;
  cout<<char((int)c+1)<<endl;
}

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

int main() {
  int H, W;

  while (true) {
    cin >> H >> W;

    if (H == 0 && W == 0) {
      break;
    }

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if ((i + j) % 2 == 0) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 200007
using namespace std;
int n,k,l,p,q,r,s,f1[N],f2[N],a[N],cnt[N],ans[N];
int find1(int x){return f1[x]==x ? x:f1[x]=find1(f1[x]);}
int find2(int x){return f2[x]==x ? x:f2[x]=find2(f2[x]);}
bool cmp(int x,int y){return f1[x]<f1[y];}
int main(){
	scanf("%d%d%d",&n,&k,&l);
	for(int i=1;i<=n;++i)f1[i]=f2[i]=i;
	for(int i=1;i<=k;++i){
		scanf("%d%d",&p,&q);
		f1[find1(p)]=find1(q);
	}
	for(int i=1;i<=l;++i){
		scanf("%d%d",&r,&s);
		f2[find2(r)]=find2(s);
	}
	for(int i=1;i<=n;++i)f1[i]=find1(i),f2[i]=find2(i);
	for(int i=1;i<=n;++i)a[i]=i;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;++i){
		int j=i;
		while(j<n && f1[a[j+1]]==f1[a[j]])++j;
		for(int t=i;t<=j;++t)++cnt[f2[a[t]]];
		for(int t=i;t<=j;++t)ans[a[t]]=cnt[f2[a[t]]];
		for(int t=i;t<=j;++t)--cnt[f2[a[t]]];
		i=j;
	}
	for(int i=1;i<=n;++i)printf("%d ",ans[i]);
}

Measured memory_bytes: 4608
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(int argc, char* argv[])
{
	string a,b;
	cin>>a>>b;
	a+=b;
	int c;
	c=atoi(a.c_str());
	int i,j;
	for (i=1;i<=999;i++){
		for (j=1;j<=999;j++){
			if (i==j && i*j==c){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int x;
    cin >> x;
    vector<int> ans;
    ans.push_back(1);
    int b=2;
    while(b*b<=x){
        int tmp=b*b;
        ans.push_back(tmp);
        while(tmp*b<=x){
            tmp*=b;
        }
        ans.push_back(tmp);
        b++;
    }
    sort(ans.begin(), ans.end(), greater<int>());
    cout << ans[0];

    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
int main(void)
{
	int n, m, c, a[1000][1000], b[1000], d, e=0, i, j;
	
	scanf("%d%d%d",&n,&m,&c);
	for(i=0;i<m;i++) scanf("%d",&b[i]);
	for(i=0;i<n;i++){
	    for(j=0;j<m;j++) scanf("%d",&a[i][j]);
	}
	
	for(i=0;i<n;i++){
	    d=0;
	    for(j=0;j<m;j++){
	        d+=a[i][j]*b[j];
	    }
	    if(d+c>0) e++;
	}
	printf("%d\n",e);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 30;

ll P[101010];
ll pos[101010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    rep(i, 0, N) {
        cin >> P[i];
        pos[P[i]] = i;
    }
    ll ans = 0;
    map<ll, ll> pos_idx, neg_idx;
    pos_idx[N] = neg_idx[1] = INF;
    rrep(p, N + 1, 1) {
        // 降順に見ていく
        auto one = pos_idx.upper_bound(pos[p]);
        ll idx1 = one->first;
        ll idx2 = N;
        if (idx1 < N) {
            auto two = pos_idx.upper_bound(idx1);
            idx2 = two->first;
        }
        auto three = neg_idx.upper_bound(-pos[p]);
        ll idx3 = -1 * (three->first);
        ll idx4 = -1;
        if (idx3 >= 0) {
            auto four = neg_idx.upper_bound(-idx3);
            idx4 = -1 * (four->first);
        }
        // P[idx3]が最大
        ll l = idx3 - idx4;
        ll r = idx1 - pos[p];
        ans += l * r * (ll)p;
        // P[idx1]が最大
        l = pos[p] - idx3;
        r = idx2 - idx1;
        ans += l * r * (ll)p;
        // idxを追加
        pos_idx[pos[p]] = p;
        neg_idx[-pos[p]] = p;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14336
def solve(N, K, A):
    idx = [-1 for _ in range(len(A))]
    now = 0
    period = 0
    bias = 0
    tmp = []
    found = False
    i = 0
    while not found:
        tmp.append(now+1)
        if idx[now] == -1:
            idx[now] = i
        else:
            period = i - idx[now]
            cycle = tmp[-period-1:-1]
            bias = i - period
            break
        now = A[now]-1
        i += 1

    if K <= bias:
        now = 0
        for _ in range(K):
            now = A[now] - 1
        print(now + 1)
    else:
        K -= bias
        K = K % period
        print(cycle[K])

if __name__=="__main__":
    N,K = [int(a) for a in input().split()]
    A = [int(a) for a in input().split()]
    solve(N, K, A)

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

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

    ll ans = 0;
    // vector<int> X(N, 0);
    for (int i=1; i<N; i++){
        // X[i * i]++;
        if (i * i >= N) break; 
        ans++;

        for (int j=i+1; j<N; j++){
            if (i * j >= N) break;
            // X[i * j] += 2;
            ans += 2;
        }
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

func ScanInt() int {
	scanner.Scan()
	txt := scanner.Text()
	n, _ := strconv.Atoi(txt)
	return n
}

func IntMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func IntAbs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Info struct{ X, Y, H int }

func main() {
	n := ScanInt()
	infoList := make([]Info, n)
	for i := 0; i < n; i++ {
		infoList[i].X = ScanInt()
		infoList[i].Y = ScanInt()
		infoList[i].H = ScanInt()
	}

	for cx := 0; cx <= 100; cx++ {
		for cy := 0; cy <= 100; cy++ {
			var h int
			for _, info := range infoList {
				if info.H != 0 {
					h = info.H + IntAbs(info.X-cx) + IntAbs(info.Y-cy)
					break
				}
			}
			success := true
			for _, info := range infoList {
				if info.H != IntMax(h-IntAbs(info.X-cx)-IntAbs(info.Y-cy), 0) {
					success = false
					break
				}
			}
			if success {
				fmt.Printf("%d %d %d\n", cx, cy, h)
				return
			}
		}
	}
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=2e6+5;
unordered_map<int,int> head[maxn];
struct EDGE{
	int v,nex,c;
}edge[maxn];
int ecnt;
inline void add_edge(int u,int v,int c){
	edge[++ecnt]={v,head[u][c],c};head[u][c]=ecnt;
	edge[++ecnt]={u,head[v][c],c};head[v][c]=ecnt;
}
int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n,m;cin>>n>>m;
	bool vvis[maxn];
	map<pii,bool> vis;
	vector<vector<int>> nex(maxn);
	int vcnt=n;
	for(int i=1;i<=m;i++) {
		int u,v,c;cin>>u>>v>>c;
		add_edge(u,v,c);
	}
	std::function<void(int,int)> dfs= [&] (int u,int col) {
		nex[u].push_back(vcnt);nex[vcnt].push_back(u);
		vis[{u,col}]=1;vvis[u]=1;
		for(int i=head[u][col];i;i=edge[i].nex) {
			int v=edge[i].v;if(vvis[v]) continue;
			dfs(v,col);
		}
	};
	for(int i=1;i<=ecnt;i++) {
		if(!vis[{edge[i].v,edge[i].c}]) {
			++vcnt;
			dfs(edge[i].v,edge[i].c);
			for(auto x:nex[vcnt]) vvis[x]=0;
		}
	}

	vector<int> dis(maxn);queue<int> Q;Q.push(1);dis[1]=1;
	while(!Q.empty()) {
		int u=Q.front();Q.pop();
		for(auto v:nex[u]) {
			if(dis[v]) continue;
			dis[v]=dis[u]+1;
			Q.push(v);
		}
	}
	cout<<(dis[n]?(dis[n]-1)/2:-1)<<endl;
    return 0;
}

Measured memory_bytes: 225060
import java.io.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int a = Integer.parseInt(s);
        s = scan.next();
        int b = Integer.parseInt(s);
        s = scan.next();
        int c = Integer.parseInt(s);
        int  change = 0;
        
        if (a > b){
        	change = a;
        	a = b;
        	b = change;
        }
        
        if (b > c){
        	change = b;
        	b = c;
        	c = change;
        }
        
        if(a > c){
        	change = a;
        	a = c;
        	c = change;
        }
        
        if (a > b){
        	change = a;
        	a = b;
        	b = change;
        } 
        
        System.out.println(a + " " + b + " " + c);
        
	}
}

Measured memory_bytes: 26152
N = int(input())
h = list(map(int, input().split()))
dp = [0]*N
dp[1] = abs(h[1]-h[0])
for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

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

int main()
{
    string s;
    string t;
    cin >> s >> t;
    int a;
    int b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (s==u){
        a--;
    }else {
        b--;
    }
    cout << a<< " "<< b<< endl;
}


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

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

  for (int i = 0; i < N; i++)
  {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
N, M, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))

sumA = [0] * (N+1)
sumB = [0] * (M+1)
for i in range(N):
  sumA[i+1] = sumA[i] + A[i]
for i in range(M):
  sumB[i+1] = sumB[i] + B[i]

b_i = M
max_count = 0
for i in range(N+1):
  a = sumA[i]
  if a > K:
    continue
  if b_i>0:
    while a + sumB[b_i] > K:
      b_i -= 1
      if b_i==0:
        break
  max_count = max(max_count, i + b_i)
print(max_count)

Measured memory_bytes: 47484
n,m = map(int,input().split()) #nがスイッチ、mが電球の数
s = []
sw = []
 
for i in range(m):
  x = list(map(int,input().split()))
  s.append(x)
p = list(map(int,input().split()))
#print(s,p)
 
for i in range(0,2**n): #1は点灯とする
  x = format(i, 'b')
  x = x.zfill(n)
  sw.append(x)

ans = []
for x in sw:
  y = 0 #ａｎｓに加えるかどうかの判定
  for i in range(m):
    z = 0 #あまりの判定
    if y == 0:
      for j in range(s[i][0]):
        if x[s[i][j+1]-1] == "1":
          z += 1
      if z%2 != p[i]:
        y += 1
  if y == 0:
    ans.append(x)
print(len(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;

const int maxn = 10005;
int a[maxn], b[maxn], n;
ll sum, need;

int main() {
	scanf("%d", &n);
	rep (i, 1, n) scanf("%d", &a[i]);
	rep (i, 1, n) scanf("%d", &b[i]);
	rep (i, 1, n) {
		need += b[i] - a[i];
		if (b[i] < a[i]) sum += a[i] - b[i];
		else sum += (b[i] - a[i]) & 1;
	}
	puts(sum <= need ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int lef = a + b;
	int rig = c + d;

	if (lef > rig) {
		cout << "Left\n";
	}
	else if (lef < rig) {
		cout << "Right\n";
	}
	else {
		cout << "Balanced\n";
	}

	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }

ll m, n, ans = 1;

void prime_factor() {
  if (m == 1) {
    ans = n;
    return;
  }
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
    rep(j, res[i] / m) ans *= i;
  }
}

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

  prime_factor();
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 8704
N = int(input())
S = input()
cnt = 0

for i in range(1000):
  num = str(i).zfill(3)
  check1 = S.find(num[0])
  check2 = S.find(num[1], check1+1)
  check3 = S.find(num[2], check2+1)
  if check1 != -1 and check2 != -1 and check3 != -1:
    cnt += 1
print(cnt)

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

const ll INF = 1ll<<60;

typedef pair<ll,ll> P;

int main() {
  ll n, x, d;
  cin >> n >> x >> d;

  if (d == 0) {
    if (x == 0) {
      cout << 1 << endl;
    } else {
      cout << n+1 << endl;
    }
    return 0;
  }

  map<int,vector<P>> mp;
  rep(i,n+1) {
    ll s = x*i;
    ll l = (ll)i*(i-1)/2;
    ll r = l + (ll)i*(n-i);
    s += l*d;
    r -= l;
    mp[(s+(d<<30))%d].emplace_back(s,r);
  }

  ll ans = 0;
  for (auto p : mp) {
    auto a = p.second;
    int m = a.size();
    rep(i,m) a[i].first = (a[i].first-p.first)/d;
    vector<P> ev;
    rep(i,m) {
      ev.emplace_back(a[i].first, 1);
      ev.emplace_back(a[i].first+a[i].second+1, -1);
    }
    sort(ev.begin(), ev.end());
    ll cnt = 0, pre = -INF;
    for (auto e : ev) {
      ll len = e.first-pre;
      if (cnt) ans += len;
      cnt += e.second;
      pre = e.first;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 25476
#include <bits/stdc++.h>
#define INF 100000000;

using namespace std;
using ll = long long;
using p = pair<int, int>;

int     main(void){
    string s;
    cin >> s;
    int     i;
    i = 0;
    while (s[i]){
        s[i++] = 'x';
    }
    cout << s;
}

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

using namespace std;

int main() {
	int a, b, c, d;
	int t, k;
	cin >> a >> b >> c >> d;
	if (c % b == 0) t = c / b;
	else t = (c / b) + 1;
	if (a % d == 0) k = a / d;
	else k = (a/ d) + 1;
	

	if (t <= k) cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;
const int mod = 1e9 + 7;

ll mod_pow(ll base, int exp) {
	ll res = 1, b = base;
	while(exp) {
		if(exp&1) res *= b, res %= mod;
		exp >>= 1;
		b *= b;
		b %= mod;
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	vector<ll> cnt(k + 1);
	for(int g = k; g > 0; -- g) {
		cnt[g] = mod_pow(k / g, n);
		for(int i = 2 * g; i <= k; i += g) cnt[g] -= cnt[i], cnt[g] += mod, cnt[g] %= mod;
		ans += g * cnt[g];
		ans %= mod;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3960
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        -- a[i];
    }
    for(int i=0; i<n; ++i)
        cin >> b[i];
    for(int i=0; i<n-1; ++i)
        cin >> c[i];

    int ans = accumulate(b.begin(), b.end(), 0);
    for(int i=0; i<n-1; ++i){
        if(a[i] + 1 == a[i+1])
            ans += c[a[i]];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#define INF (int)1e9


void dijkstra(int m, int p, int q, std::vector<std::vector<std::pair<int, int> > > &v); 

int main(void) {
    int n;
    int m;
    int a;
    int b;
    int cost;
    int time;
    int k;
    int p;
    int q;
    int r;

    while (true) {
        std::cin >> n >> m;
        if (n == 0 && m == 0) {
            break; 
        }
        std::vector<std::vector<std::pair<int, int> > > vcost(m);
        std::vector<std::vector<std::pair<int, int> > > vtime(m);
        for (int i = 0; i < n; i++) {
            std::cin >> a >> b >> cost >> time;
            --a;
            --b;
            vcost[a].push_back(std::make_pair(cost, b));
            vcost[b].push_back(std::make_pair(cost, a));
            vtime[a].push_back(std::make_pair(time, b));
            vtime[b].push_back(std::make_pair(time, a));
        }
        std::cin >> k;
        for (int i = 0; i < k; i++) {
            std::cin >> p >> q >> r;
            --p;
            --q;
            if (r == 0) {
                dijkstra(m, p, q, vcost);
            } else {
                dijkstra(m, p, q, vtime);
            }
        }
    } return 0;
}

void dijkstra(int m, int p, int q, std::vector<std::vector<std::pair<int, int> > > &v) {
    std::vector<int> rvec(m, INF);
    rvec[p] = 0;
    std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > > pq;
    std::vector<int> search_count(m, 0);
    int start_value;
    int start_target;
    int end_value;
    int end_target;
    pq.push(std::make_pair(rvec[p], p));

    while(! pq.empty()) {
        start_target = pq.top().second;
        start_value = pq.top().first; 
        pq.pop();
        if (search_count[start_target] != 0) {
            continue;
        }
        ++search_count[start_target];
        for (int i = 0; i < v[start_target].size(); i++) {
            end_value = v[start_target][i].first;
            end_target = v[start_target][i].second;
            if (rvec[end_target] > end_value + rvec[start_target]) {
                rvec[end_target] = end_value + rvec[start_target];
                pq.push(std::make_pair(rvec[end_target], end_target));
            }
        }
    }
    std::cout << rvec[q] << std::endl;
    return;
} 

Measured memory_bytes: 3180
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] c = new int[n];
		int[] s = new int[n];
		int[] f = new int[n];
		for(int i = 0; i < n-1; i++){
		    c[i] = sc.nextInt();
		    s[i] = sc.nextInt();
		    f[i] = sc.nextInt();
		}
		
		// 計算
		int[] result = new int[n];
		for(int i = 0; i < n-1; i++){
		    result[i] = s[i] + c[i];
		    for(int j = i-1; j >= 0; j--){
		        if(result[j] <= s[i]){
		            result[j] = result[i];
		        }else{
		            result[j] += (f[i] - (result[j]-s[i])%f[i])%f[i] + c[i];
		        }
		    }
		}
		
		// 出力
		for(int i = 0; i < n; i++){
		    System.out.println(result[i]);
		}
	}
}




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

int main()
{
    int x,n;
    int a[101]={0};
    cin>>x>>n;
    int m;
    int i,j;
    for( i=0;i<n;i++)
    {
        cin>>m;
        a[m]=1;
    }
    i=x;
    j=x;
    int flag=0;
    while(1)
    {
        // cout<<i<<" "<<j<<endl;
        if(a[i]!=1||i<1)
        {
            cout<<i<<endl;
            flag=1;
            break;
        }
        if(a[j]!=1||j>100)
        {
            cout<<j<<endl;
            flag=1;
            break;
        }
        i--;
        j++;
    }
    if(flag==0)
    cout<<x<<endl;
}

Measured memory_bytes: 3592
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
S = list(input())[:-1]
if S[0] == "R" and S[1] == "R" and S[2] == "R":
    print(3)
elif S[0] == "R" and S[1] == "R":
    print(2)
elif S[1] == "R" and S[2] == "R":
    print(2)
elif S[0] != "R" and S[1] != "R" and S[2] != "R":
    print(0)
else:
    print(1) 


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

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for bit in range(2**n):
    vsum = 0
    csum = 0
    for i in range(n):
        if (bit & (1 << i)):
            vsum += v[i]
            csum += c[i]
    ans = max(vsum - csum, ans)

print(ans)


Measured memory_bytes: 73696
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

int pref[N];

void solve(){
	int n,q;
	cin >> n>> q;
	string s;
	cin >> s;
	rep(i, n-1){
		pref [i+1] += pref [i]+(s [i] == 'A' && s [i+1] == 'C');
	}
	while(q--){
		int l,r;
		cin >> l>> r;
		--l,--r;
		cout << pref[r]-pref[l] << "\n";
	}


}

int main(){
	Red;
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 1488
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
      	int B = sc.nextInt();
      	
      	if(B %A == 0) {
        	System.out.println(A + B); 
        } else {
        	System.out.println(B - A);  
        }
    }
}

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

const int MAGIC = 320000;
long long n, s;

long long f(long long n, int b) {
	long long res = 0;
	while(n) res += n % b, n /= b;
	return res;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> s;
	for (int b = 2; b <= MAGIC; ++b) {
		if (f(n,b) == s) return printf("%d\n", b), 0;
	}

	if (n < s) return printf("-1\n"), 0;
	if (n == s) return printf("%lld\n", n + 1), 0;

	n -= s;
	long long mn = 1e18;
	for (int p = 1; 1LL * p * p <= n; ++p) if (n % p == 0) {
		long long b = n / p + 1;
		long long q = s - p;
		if (q >= 0 && b >= 2 && q < b && p < b) {
			mn = min(mn, b);
		}
	}	

	if (mn == 1e18) printf("-1\n"); else printf("%lld\n", mn);
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	var S string
	fmt.Scan(&S)
	w := strings.Split(S, "-")
	if len(w) != 2 {
		fmt.Println("No")
		return
	}
	if len(w[0]) == A && len(w[1]) == B {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=110;
char s[N],t[N];
int main()
{
    int n,ans=0;
    scanf("%d%s%s",&n,s+1,t+1);
    for(int i=1;i<=n;i++)
    {
        int f=1;
        for(int j=1;j<=i;j++)if(s[n-i+j]!=t[j]){f=0;break;}
        if(f)ans=max(ans,i);
    }
    printf("%d\n",2*n-ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall
	
	ini(n);
	int one = 0;
	FOR(i,0,n){
		ini(x);
		if(x%2 == 1)one++;
	}
	if(one)out("first");
	else out("second");















	return 0;
}

Measured memory_bytes: 256
n, k, s = list(map(int, input().split()))
i = 0
list = []
while i < k:
  print(str(s) + ' ', end="")
  i = i + 1
while i < n:
  if s != 1000000000:
    print(str(s+1) + ' ',end="")
  else:
    print(str(s-1) + ' ',end="")
  i = i + 1



Measured memory_bytes: 47192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct node{ ll pa,point;};
node no[100010];
vector<vector<ll>> v(100000);

ll Struct(ll x){
    if(x==1){
        ll sum=0;
        rep(i,0,v[x].size()-1){
            no[v[x][i]].pa=x;
            sum+=Struct(v[x][i]);
        }
        no[x].point=sum+1;
        return no[x].point;
    }else{
        ll sum=0;
        rep(i,0,v[x].size()-1){
            if(v[x][i]!=no[x].pa){
                no[v[x][i]].pa=x;
                sum+=Struct(v[x][i]);
            }
        }
        no[x].point=sum+1;
        return no[x].point;
    }
    
}

            
int main(){
    ll n;cin>>n;
    ll a[n],b[n];
    rep(i,0,n-2){
        cin>>a[i]>>b[i];
        v[a[i]].pb(b[i]);
        v[b[i]].pb(a[i]);
    }
    no[1].pa=0;
    Struct(1);
    ll x=n;
    vector<ll> vv;
    vv.pb(no[x].point);
    while(x!=1){
        x=no[x].pa;
        vv.pb(no[x].point);
    }
    reverse(vv.begin(),vv.end());
    ll k=(vv.size()+1)/2;
    ll ans=vv[0]-2*vv[k];
    if(ans>0){
        cout<<"Fennec"<<endl;
    }else{
        cout<<"Snuke"<<endl;
    }
    
    return 0;
}


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

int main(){
  int X; cin >> X;
  bool p[100010]={};
  for(int i=0; i<6; i++) p[100+i]=true;
  for(int i=0; i<=100000; i++){
    for(int j=0; j<6; j++){
      if(i>=100+j) p[i]|=p[i-100-j];
    }
  }
  cout << (p[X]?1:0) << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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;
}
using namespace std;

vector<vector<int>>g;
vector<bool>visited;
vector<int>tp;

void dfs(int v){
	visited[v]=true;
	for(auto x:g[v]){
		if(visited[x])continue;
		dfs(x);
	}
	tp.pb(v);
}
void solve(){
	int v,e;
	cin>>v>>e;
	g.resize(v);
	visited.resize(v,false);
	rep(i,e){
		int s,t;
		cin>>s>>t;
		g[s].pb(t);
	}
	rep(i,v){
		if(visited[i])continue;
		dfs(i);
	}
	reverse(tp.begin(),tp.end());//逆順にするのを忘れない
	for(auto x:tp){
		cout<<x<<endl;
	}
	return ;
}

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



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
string s;
int m;
int d;

int main() {
    cin >> s;

    m = stoi(s.substr(5,2));
    d = stoi(s.substr(8,2));

    if (m == 4)
    {
        if (d<=30) {
            cout << "Heisei" << endl;
        } else {
            cout << "TBD" << endl;
        }
    } else {
        if (m<4) cout << "Heisei" << endl;
        if (m>4) cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

#define int long long
int X[100010];
int ans;
signed main(){
  int N;
  int A,B;


  cin>>N>>A>>B;

  rep(i,N){
    cin>>X[i];
  }
  rep(i,N-1){
    ans+=min((X[i+1]-X[i])*A,B);
  }
  cout<<ans<<endl;


}


Measured memory_bytes: 1024
import sys
from math import log
def main():
    n, p = map(int, input().split())
    if n == 1:
        print(p)
    else:
        ans = 1
        if n > int(log(p, 2))+2:
            print("1")
            sys.exit()
        if p % (2**n) == 0:
            while p % (2**n) == 0:
                ans *= 2
                p //= (2**n)
        for i in range(3, 10**6+1, 2):
            while p % (i**n) == 0:
                ans *= i
                p //= (i**n)
        print(ans)

if __name__ == "__main__":
    main()


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

def bubbleSort(A, N):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j]<A[j-1]:
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                count += 1
                flag = 1
    return A, count

A, count = bubbleSort(A, N)
print(*A)
print(count)


Measured memory_bytes: 5608
#include <algorithm>
#include <iostream>

int scores[200];

int main()
{
	while (true) {
		int input_count, nmin, nmax;
		std::cin >> input_count >> nmin >> nmax;

		if (input_count == 0) return 0;

		for (int i = 0; i < input_count; i++) {
			int p;
			std::cin >> p;
			scores[i] = p;
		}

		std::sort(&scores[0], &scores[input_count]);

		int result_pass_count;
		int max_gap = 0;
		for (int pass_count = nmin; pass_count <= nmax; pass_count++) {
			int gap = scores[input_count - pass_count] - scores[input_count - pass_count - 1];
			if (gap >= max_gap) {
				result_pass_count = pass_count;
				max_gap = gap;
			}
		}

		std::cout << result_pass_count << std::endl;
	}
}

Measured memory_bytes: 3164
import re


def main():
    N = int(input())
    S = input()
    a = ""
    Ans = ""

    for s in S:
        a = ord(s)+N
        if a > 90:
            a = a-26
        Ans += chr(a)

    print(Ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
# https://kyopro-friends.hatenablog.com/entry/2019/01/12/231000

def main():
    import sys
    readline = sys.stdin.readline

    n, k = map(int, readline().rstrip().split())
    *a, = sorted(map(int, readline().split()))

    dp = [False] * (k + 1)
    dp[0] = False
    # dp[手番開始時の石の個数]:=勝敗

    for i in range(1, k + 1):
        for x in a:
            if x > i: break
            if not dp[i - x]:
                dp[i] = True
                break

    print('First' if dp[k] else 'Second')


if __name__ == '__main__':
    main()


Measured memory_bytes: 41584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final long H = sc.nextInt();
		final long W = sc.nextInt();

		System.out.println(Math.min(findMin(H, W), findMin(W, H)));

		sc.close();
	}

	private long findMin(long H, long W) {
		final long S = H * W;
		long min = S;

		long s1, s2, s3;
		// horizontal line
		for (int i = 1; i < H; i++) {
			s1 = i * W;
			long h = H - i;

			// pattern1
			if (h >= 2) {
				s2 = (h / 2) * W;
				s3 = S - s1 - s2;
				min = Math.min(min, Math.max(Math.max(s1, s2), s3) - Math.min(Math.min(s1, s2), s3));
			}
			// pattern 2
			if (W >= 2) {
				s2 = h * (W / 2);
				s3 = S - s1 - s2;
				min = Math.min(min, Math.max(Math.max(s1, s2), s3) - Math.min(Math.min(s1, s2), s3));
			}
		}
		return min;
	}
}


Measured memory_bytes: 22100
from collections import Counter
n = int(input())
cnt = Counter(map(int, input().split()))
Asum = sum(k*v for k, v in cnt.items())
q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    Asum += (c-b)*cnt[b]
    print(Asum)
    cnt[b], cnt[c] = 0, cnt[b]+cnt[c]


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define int ll
#define tcase int t; cin>> t; for( ; t; --t)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
double n;

int32_t main(){
	fastio;
	cin>> n;
	cout<< 2*PI*n<< endl;
	return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, K;
    vector<int> h;

    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int buf;
        cin >> buf;
        h.push_back(buf);
    }

    int cost[100000];
    memset(cost, 0x7f, sizeof(cost));
    cost[0] = 0;
    for (int i = 0; i < N-1; i++) {
        for (int s = 1; s <= K; s++) {
            if (i + s > N-1) continue;
            int c = cost[i] + abs(h[i]-h[i+s]);
            cost[i+s] = min(cost[i+s], c);
        }
    }
    cout << cost[N-1] << endl;

    return 0;
}



Measured memory_bytes: 1144
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    bool ok = 1;
    forn(i, s.size()) if(t[i]!=s[i]) ok = 0;
    if(ok) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e18
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

const int maxn = 3005;
ll dp[2][maxn];

void solve() {
	ll n;
	string s;
	cin >> n >> s;

	memset(dp, 0, sizeof(dp));
	dp[0][1] = 1;

	vl pref(n + 3, 1);
	pref[0] = 0;

	FOR(i, 1, n - 1) {
		vl pref2(n + 3, 0);
		FOR(j, 1, i + 1) {
			ll st = 1, en = i + 1;
			if (s[i-1] == '>') st = j;
			else en = j - 1;

			dp[i%2][j] = (pref[en] - pref[st - 1] + MOD) % MOD;
			pref2[j] = (pref2[j - 1] + dp[i%2][j]) % MOD;
		}
		pref2[i+2] = pref2[i+1];
		pref = pref2;
		// pr(i, pref);
	}

	ll ans = 0;
	FOR(i, 1, n) ans = (ans + dp[(n - 1) % 2][i]) % MOD;

	cout << ans << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 384
a, b, c, d = map(int, input().split())

from fractions import gcd
#lcm = c * d // gcd(c, d)
lcm = int(c * d / gcd(c, d))

a_num = (a-1)//c + (a-1)//d - (a-1)//lcm
b_num = (b)//c + (b)//d - (b)//lcm

print(b-a+1 - (b_num - a_num))

Measured memory_bytes: 5104
#include <stdio.h>
int a[2][101],n,m,i,j,c,p,s;
int main(void){
	for(;scanf("%d",&n),n;m<300?printf("%d\n",m):puts("NA")){
		for(a[0][n]=a[1][n]=i=2;i--;)
			for(j=0;j-n;scanf("%d",a[i]+j++));
		m=999;
		for(i=2;i--;m>c?m=c:0)
			for(j=i,c=p=0;s=a[j][p],c<500&&s==2|n+~p;)
				s-2?s-1|a[j][p+1]-1?p+=2,j=1&~j,++c:++p:--p;
	}
	return 0;
}

Measured memory_bytes: 0
n, t = map(int, input().split())
f = [[0, 0] for i in range(t + 1)]
for i in range(n):
  w, v = map(int, input().split())
  for j in range(t, 0, -1):
    f[j][1] = max(f[j][1], f[j - 1][0] + v)
    if j >= w:
      f[j][0] = max(f[j][0], f[j - w][0] + v)
      f[j][1] = max(f[j][1], f[j - w][1] + v)
print(f[t][1])

Measured memory_bytes: 49384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int i,n,count=0;
  vector<int> data(20);
  cin >>n;
  for(i=0;i<n;i++){
    cin>>data.at(i);
  }

  for(i=0;i<(n-2);i++){
    if(data.at(i)<data.at(i+1)){
      if(data.at(i+1)<data.at(i+2)){
        count++;
      }
    }else if(data.at(i)>data.at(i+1)){
      if(data.at(i+1)>data.at(i+2)){
        count++;
      }
    }
  }

  cout <<count<<endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    int a, b;
    cin >> a >> b;
    
    if (a + b == 15) {
        cout << '+' << endl;
    } else if (a * b == 15) {
        cout << '*' << endl;
    } else {
        cout << 'x' << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n,k;
	while(cin>>n>>k)
	{
		if(n%k==0)
			cout<<0<<endl;
		else
		{
			cout<<1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256