akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N, M;
        cin >> N >> M;
        vector<Int> dig(N, -1);

        for (int i = 0; i < M; ++i) {
            Int s, c;
            cin >> s >> c;
            if (dig[s - 1] == -1 || dig[s - 1] == c) {
                dig[s - 1] = c;
            } else {
                cout << -1 << endl;
                return;
            }

            if (N > 1 && s == 1 && dig[s - 1] == 0) {
                cout << -1 << endl;
                return;
            }
        }

        for (int i = 0; i < N; ++i) {
            if (dig[i] == -1) {
                if (i == 0 && N > 1) {
                    dig[i] = 1;
                } else {
                    dig[i] = 0;
                }
            }
        }
        Int ans = 0;
        for (int i = 0; i < N; ++i) {
            ans *= 10;
            ans += dig[i];
        }
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc168_a
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000


int main() {
    int n;
    scanf("%d", &n);
    if(n%10==3) puts("bon");
    else {
        n = n%10;
        if(n==0 || n==1 || n==6 || n==8) puts("pon");
        else puts("hon");
    }
}


Measured memory_bytes: 3688
N = int(input())
A = [0]
for i in range(N):
    A.append(int(input()))
old = []
bo = 1
ind = 1
while ind <= N:
    if A[bo] == 2:
        print(ind)
        exit()
    else:
        ind += 1
        bo = A[bo]
print(-1)


Measured memory_bytes: 7080
#include<stdio.h>
#include<stdlib.h>
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}Node;



int main(){

  int n,i,j,id,child,k,r,depth;
  Node *Tree;

  scanf("%d",&n);

  Tree = malloc(sizeof(Node)*n);

  for(i = 0 ; i < n ; i++){
    Tree[i].parent = NIL;
    Tree[i].left = NIL;
    Tree[i].right = NIL;
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&id,&k);

    for(j = 0 ; j < k ; j++){

      scanf("%d",&child);
      Tree[child].parent = id;

      if(j == 0)
        Tree[id].left = child;
      else if(j > 0){
        Tree[r].right = child;
      }
      r = child;
    }
  }



  for(j = 0 ; j < n ; j++){
    depth = 0;
    i = Tree[j].parent;

    while(i != NIL){
      i = Tree[i].parent;
      depth++;
    }
    if(depth == 0){
      printf("node %d: parent = %d, depth = %d, root, "
        ,j,Tree[j].parent,depth);
    }
    else if(Tree[j].left == NIL){
      printf("node %d: parent = %d, depth = %d, leaf, "
        ,j,Tree[j].parent,depth);
    }
    else{
      printf("node %d: parent = %d, depth = %d, internal node, "
        ,j,Tree[j].parent,depth);
    }

    i = Tree[j].left;
    printf("[");
      if(i != NIL){
        printf("%d",i);
      }
      while(i != NIL){ 
        i = Tree[i].right;
        if(i != -1){
          printf(", %d", i);
        }
      }
      printf("]\n");
    }
    return 0;
  }

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

diff = [0] * N
for x in range(N):
    if x + 1 >= N:
        x -= N
    if A[x + 1] < A[x]:
        a = A[x + 1] + K
    else:
        a = A[x + 1]
    diff[x] = a - A[x]

ans = 0
temp = 0
for x in range(N - 1):
    ans += diff[x]
    temp += diff[x]

for x in range(N):
    idx = x + N - 1
    if idx >= N:
        idx -= N
        
    temp = (temp - diff[x] + diff[idx])
    if ans > temp:
        ans = temp
print(ans)

    




Measured memory_bytes: 77772
n=int(input())
x=input().split()
ans=0
for i in range(n):
    x[i]=int(x[i])
x.sort()
ans=x[0]
for i in range(1,n):
    ans= (ans+x[i])/2
if(ans-int(ans)==0):
    print(int(ans))
else:
    print(ans)

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

int main() {

    ll K;
    cin >> K;
    // Xを桁ごとのvectorに変換
    auto ll2vec = [&](ll X){
        vector<int> res;
        ll tmp = X;
        while(tmp > 0){
            res.push_back(tmp%10);
            tmp/=10;
        }
        reverse(all(res));
        return res;
    };
    auto check = [&](ll X){
        vector<int> vx = ll2vec(X);
        //桁数
        int N = vx.size();
        // dp[i][smaller][0以外を一度でも取ったか][最後の数字]
        ll dp[N+1][2][2][10];
        rep(i,N+1)rep(j,2)rep(k,2)rep(l,10)
            dp[i][j][k][l] = 0;
        dp[0][0][0][0] = 1;
        //dpの遷移
        for(int i = 0; i < N; i++)rep(j,2)rep(k,2)rep(l,10){
            for(int nxt = max(0, l-1); nxt <= (k ? min(l+1, (j ? 9:vx[i])): j ? 9 : vx[i]); nxt++){
                dp[i+1][j || nxt < vx[i]][k || nxt > 0][nxt] +=  dp[i][j][k][l];
            }
        }
        ll cnt = 0;
        rep(j,2)rep(l,10)cnt += dp[N][j][1][l];
        return cnt >= K;
    };

    ll ng = 0;
    ll ok = 3234566667;
    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid))ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

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

using namespace std;
const int maxn=1e5;

int n;
vector<int> G[maxn+5];

int dfs(int x,int r)
{
	int res=0;
	if (G[x].size()==1 && x!=1) return 0;
	for (int e:G[x])
	{
		if (e==r) continue;
		res^=(dfs(e,x)+1);
	}
	return res;
}

bool solve()
{
	for (int i=1;i<=n;++i)
	{
		G[i].clear();
	}
	
	int u,v;
	for (int i=1;i<=n-1;++i)
	{
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	if (dfs(1,-1)) return true;
	else return false;
}

int main(void)
{
	#ifdef ex
	freopen ("in","r",stdin);
	#endif
	
	while (scanf("%d",&n)==1)
	{
		if (solve())
		{
			printf("Alice\n");
		}
		else 
		{
			printf("Bob\n");
		}
	}
}

Measured memory_bytes: 10368
package main

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

var sc = bufio.NewScanner(os.Stdin)

const initBufSize, maxBufSize = 10000, 1000000

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

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

func nextInts(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = nextInt()
	}
	return res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(r, n int) int {
	return int(math.Pow(float64(r), float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initBufSize), maxBufSize)
	x := nextInt()
	deposit := 100.0
	count := 0
	for {
		count++
		deposit = math.Floor(deposit * 1.01)
		if int(deposit) >= x {
			break
		}
	}
	fmt.Println(count)
}


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

using namespace std;
 
int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    map<long long,int> A_pair;
    for (long long i = 0; i < N; i++)
    {
        cin >> A.at(i);
        A_pair[i + A.at(i)]++;
    }
    long long count = 0;
    for (long long j = 0; j < N; j++)
    {
        auto po = A_pair[j-A.at(j)];
        count += po;
    }
    cout << count;
}

Measured memory_bytes: 27420
b1,b2,b3 = map(int,input().split())

if b1 == 1:
    if b2 == 1:
        print("Open")
    else:
        print("Close")
else:
    if b2 == 1:
        print("Close")
    else:
        if b3 == 1:
            print("Open")
        else:
            print("Close")


Measured memory_bytes: 5596
N,C = map(int,input().split())

D = [[0]*C for i in range(C)]

for i in range(C):
    D[i] = list(map(int,input().split()))

c = [0 for i in range(N)]

for i in range(N):
    c[i] = list(map(int,input().split()))
    for j in range(N):
        c[i][j] -= 1
#print(c)

differ = [[0]*C for i in range(3)]
###differ[i][j] (x+y)%3==i　となるようなマス全ての色をCにした時の違和感の合計

for i in range(N):
    for j in range(N):
        for k in range(C): 
            differ[(i+j)%3][k] += D[c[i][j]][k]

ans = 25 *(10**7)

for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or j==k or k==i:
                continue
            ans = min(ans,differ[0][i]+differ[1][j]+differ[2][k])
            #print(i,j,k,ans)

print(ans)

Measured memory_bytes: 46300
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int, A: "List[int]"):
    minv = min(A)
    minvs = [i  for i, a in enumerate(A) if a == minv]
   
    c = 0
    ret = 0
    for p in minvs:
        if p <= c:
            c += 1
            continue

        n = (p - c + (K - 2)) // (K - 1)
        ret += n
        c += n * (K - 1)
        c = max(c, p) + 1
    c -= 1
    n = (N-1 - c + (K - 2)) // (K - 1)
    ret += n
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, K, A)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16468
n = int(input())
a = list(map(int, input().split()))
money = 1000
kabu = 0
for i in range(n-1):
    if a[i] < a[i+1] and money != 0:
        kabu += money // a[i]
        money -= a[i] *(money // a[i])
    elif a[i] > a[i+1] and kabu != 0:
        money += a[i] * kabu
        kabu = 0
print(money + a[-1] * kabu)

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	ll N; cin >> N;
	map<ll, int>mp;
	for (int i = 2;i <= sqrt(N);++i) {
		if (N % i == 0) {
			while (N % i == 0) {
				mp[i]++;
				N /= i;
			}
		}
	}
	if (N > 1)mp[N]++;
	int ans = 0;
	for (auto p : mp) {
		int x = p.second, cnt = 1;
		while (x - cnt >= 0) {
			ans++;
			x -= cnt;
			++cnt;
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3684
N = int(input())

dp = [[0 for _ in range(3)] for _ in range(N+1)]
#dp[i][j]:i日目に活動a~cを行ったときに得られる最高の累積幸福度

for i in range(1, N+1):
    a,b,c = map(int, input().split())
    dp[i][0] = a + max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = b + max(dp[i-1][0], dp[i-1][2])
    dp[i][2] = c + max(dp[i-1][0], dp[i-1][1])

print(max(dp[-1][0], dp[-1][1], dp[-1][2]))

Measured memory_bytes: 24308
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
ans=list()
for i in range(N-2):
    if l[i][0] == l[i][1]:
        if l[i+1][0] == l[i+1][1]:
            if l[i+2][0] == l[i+2][1]:
                ans.append("y")
if "y" in ans:
    print("Yes")
else:
    print("No")
    
        
    

Measured memory_bytes: 62536
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    //ll P , Q , R;
    //cin >> P >> Q  >> R;

    ll r, D , x;
    cin >> r >> D >> x;
    vector<ll > X;
    X.push_back(x);
    for(ll i = 0; i < 10; i++){
        cout << r * X[i] - D << endl;
        X.push_back(r * X[i] - D);
    }



}

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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; }

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



int main() {
	int A,B,C;
  cin>>A>>B>>C;
  int K;
  cin>>K;
  for(int i=0;i<K;i++){
    if(A>=B){
      B*=2;
    }else if(B>=C){
      C*=2;
    }
  }
  if(A<B&&B<C){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string bans(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int h,n;cin>>h>>n;
  rep(i,n){
    int a;cin>>a;
    h-=a;
  }
  bool ans=(h<=0);
  cout << bans(ans) << endl;
  return 0;
}


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

int main() {
	char ch;
	int num, count[1200] = {0};

	while (cin >> ch){
    		num = ch - 'a';
    		if('A' <= ch && ch <= 'Z') count[ch - 'A']++;
		else count[num]++; 
	}
	for(int i=0; i<26; i++)
		cout << char('a'+i) << " : " << count[i] << endl;
	return 0;
}


Measured memory_bytes: 3088
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int x, a;
  cin >> x >> a;
  if (x < a) cout << 0 << '\n';
  else cout << 10 << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3660
# -*- coding: utf-8 -*-

# input
N = int(input())
p = list(map(int, input().split()))

# solve
l = sorted(p)
count = 0
for i in range(N):
    if p[i] != l[i]:
        count += 1

# output
print('YES' if count == 2 or count == 0 else 'NO')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;

signed main(){
  int n,a,b,c,x;
  while(cin>>n>>a>>b>>c>>x,n){
    vector<int> y(n);
    REP(i,n)cin>>y[i];
    int ans=0;
    for(int p=0;;){
      if(ans>10001){
        cout<<-1<<endl;
        break;
      }
      if(p==n){
        cout<<ans-1<<endl;
        break;
      }
      if(x==y[p]){
        ans++;p++;
      }else{
        ans++;
      }
      x=(a*x+b)%c;

    }
  }

  return 0;
}



Measured memory_bytes: 2980
def f()
  a, op, b = gets.split.map(&:to_s)
  a = a.to_i
  b = b.to_i
  case
  when op == "+"
    puts a + b
  when op == "-"
    puts a - b
  when op == "*"
    puts a * b
  when op == "/"
    puts a / b
  else
    return
  end
  f()
end

f()




Measured memory_bytes: 6872
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
from heapq import heappush, heappop
import networkx as nx
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
a = [0]+[INT() for _ in range(N)]

visited = [0]*(N+1)
visited[1] = 1
now = 1
cnt = 0
while not visited[a[now]]:
    now = a[now]
    visited[now] = 1
    cnt += 1
    if now == 2:
        print(cnt)
        break
else:
    print(-1)


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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const ll MAX = 1e12 + 1;
const int MAXV = 2e5 + 1;
const ll p = 41;

ll diff[p][MAXV];

stack<int> pos[MAXV];

int		main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	ll N, K;
	read2(N, K);

	vl a(N);
	readv(a);
	
	for (int i(0); i < N; ++i)
	{
		while (!pos[a[i]].empty())
		{
			ll j = pos[a[i]].top();
			pos[a[i]].pop();
			diff[0][j] = i-j+1;
		}
		pos[a[i]].push(i);
	}
	for (int i(0); i < N; ++i)
	{
		while (!pos[a[i]].empty())
		{
			ll j = pos[a[i]].top();
			pos[a[i]].pop();
			diff[0][j] = N + i -j+1;
		}
	}

	for (int i(1); i < p; ++i)
		for (int k(0); k < N; ++k)
			diff[i][k] = diff[i-1][k] + diff[i-1][(k + diff[i-1][k])%N];

	ll cur = 0;
	while (1)
	{
		int po = p-1;
		while (po >= 0 && cur + diff[po][cur%N] > N*K)
			po--;
		if (po < 0) break;
		cur += diff[po][cur%N];
	}

	while (cur < N*K)
	{
		int po = p-1;
		while (po >= 0 && cur + diff[po][cur%N] > N*K)
			po--;
		if (po < 0) 
			cout << a[(cur++)%N] << ' ';		
		else if (cur + diff[po][cur%N] == N*K) break;
		else
			cur += diff[po][cur%N];	
	}
	cout << endl;
}



Measured memory_bytes: 201472
#include <bits/stdc++.h>
#define ll long long
#define MAX 1000001

using namespace std;

ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    vector<ll> prime(MAX, 0);
    for(ll i=2; i*i<MAX; i++){
        if(!prime[i]){
            for(ll j=i*i; j<MAX; j+=i)
                prime[j]=i;
        }
    }
    for(ll i=1; i<MAX; i++)
        if(!prime[i]) prime[i]=i;
    ll n, flag=0, g=0;
    cin >> n;
    vector<ll> v(n);
    map<ll, vector<ll> > mp;
    for(ll i=0; i<n; i++){
        cin >> v[i];
        g=GCD(g, v[i]);
        ll ele=v[i];
        while(ele>1 && flag==0){
            ll div=prime[ele];
            mp[div].push_back(i);
            if(mp[div].size()>1){
                flag=1;
                break;
            }
            while(ele%div==0)
                ele/=div;
        }
    }
    if(flag==0){
        cout << "pairwise coprime" << endl;
    }
    else if(flag==1 && g==1){
        cout << "setwise coprime" << endl;
    }
    else
        cout << "not coprime" << endl;
	return 0;
}


Measured memory_bytes: 20328
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
    
import numpy as np
A = np.array(A)
l = []
for i in range(N):
  if b[i] in A:
    l.append(tuple(nd[0] for nd in np.where(A == b[i])))
if (0, 0) in l and (1, 0) in l and (2, 0) in l:
  print("Yes")
elif (0, 0) in l and (1, 1) in l and (2, 2) in l:
  print("Yes")
elif (0, 1) in l and (1, 1) in l and (2, 1) in l:
  print("Yes")
elif (0, 2) in l and (1, 1) in l and (2, 0) in l:
  print("Yes")
elif (0, 2) in l and (1, 2) in l and (2, 2) in l:
  print("Yes")
elif (0, 0) in l and (0, 1) in l and (0, 2) in l:
  print("Yes")
elif (1, 0) in l and (1, 1) in l and (1, 2) in l:
  print("Yes")
elif (2, 0) in l and (2, 1) in l and (2, 2) in l:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 12236
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n;
int arr[N];
long long solve(int pos , bool positive , long long sum){
	if(pos > n){
		return 0;
	}
	if(positive){
		if(sum + arr[pos] > 0){
			return solve(pos + 1 , !positive , sum + arr[pos]);
		}
		else{
			return solve(pos + 1 , !positive , 1LL) + 1 - sum - arr[pos];
		}
	}
	else{
		if(sum + arr[pos] < 0){
			return solve(pos + 1 , !positive , sum + arr[pos]);
		}
		else{
			return solve(pos + 1 , !positive , -1) + sum + arr[pos] + 1;
		}
	}
}
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d" , arr + i);
	}
	printf("%lld\n" , min(solve(1 , 0 , 0) , solve(1 , 1 , 0)));
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define longinf 9223372036854775807LL
#define intinf 2147483647
#define inf 998244353
#define lol long long
#define in(n,s) insert(n,s)//ノート参照
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d,e=0,g,h;
int i[111110][3];
lol dp[100011][3];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>a;
  memset(dp,-1,sizeof(dp));
  for(int n=0;n<a;n++){
      cin >>i[n][0]>>i[n][1]>>i[n][2];
  }
  dp[0][0]=i[0][0];
  dp[0][1]=i[0][1];
  dp[0][2]=i[0][2];
  for(int n=1;n<a;n++){
      dp[n][0]=max(dp[n-1][1],dp[n-1][2])+i[n][0];
      dp[n][1]=max(dp[n-1][0],dp[n-1][2])+i[n][1];
      dp[n][2]=max(dp[n-1][0],dp[n-1][1])+i[n][2];
  }
  cout <<max(dp[a-1][0],max(dp[a-1][1],dp[a-1][2]))<<'\n';
  return (0);
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  ll n;
  cin >> n;
  ll ans = (n - 1) * n / 2;
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3588
n=int(input())
A=list(map(int,input().split()))
flag=1
count =0
while flag ==1:
    flag=0
    for j in range(n-1,0,-1):
        if A[j]<A[j-1]:
            A[j],A[j-1]= A[j-1],A[j]
            flag=1
            count+=1
print(" ".join(map(str,A)))
print(count)


Measured memory_bytes: 5600
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define SIZE(a) int((a).size();
const int INF=INT_MAX;
int main(){
  ll n,m,x,y;
  cin>>n>>m>>x>>y;
  vll xx(n),yy(m);
  rep(i,0,n){cin>>xx[i];}
  rep(i,0,m){cin>>yy[i];}
  sort(xx.begin(),xx.end());
  sort(yy.begin(),yy.end());
  bool ok=false;
  rep(i,x+1,y+1){
    if(i>xx[n-1]&&yy[0]>=i){ok=true;break;}
  }
  if(ok){cout<<"No War"<<endl;}
  else{cout<<"War"<<endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
	int n, a, b, c;
	cin >> n;
	while(n--){
		cin >> a >> b >> c;
		if(a*a == b*b + c*c
			|| b*b == a*a + c*c
			|| c*c == b*b + a*a){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(N+1, vector<int>(N-1));
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j < N - 1; ++j) {
            cin >> A[i][j];
        }
    }
    set<pair<int, int>> se;
    queue<pair<int, int>> que;
    vector<int>id(N+1, 0);
    int clear = 0;
    for (int i = 1; i <= N; ++i) {
        que.push({min(i, A[i][0]), max(i, A[i][0])});
    }
    ll ans = 0;
    while (clear != N){
        if(que.empty()){
            ans = -1;
            break;
        }
        queue<pair<int, int>> que1;
        while (! que.empty()){
            auto t = que.front();
            que.pop();
            if(se.erase(t)){
                int x = t.first;
                int y = t.second;
                id[x]++;
                id[y]++;
                if(id[x] == N-1){
                    clear++;
                } else{
                    que1.push({min(x, A[x][id[x]]), max(x, A[x][id[x]])});
                }
                if(id[y] == N-1){
                    clear++;
                } else{
                    que1.push({min(y, A[y][id[y]]), max(y, A[y][id[y]])});
                }
            } else{
                se.insert(t);
            }
        }
        que.swap(que1);
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6272
n=int(input())

w_list=list(map(int,input().split()))

r_list=[]
l_list=[]

for i in range(n-1):
    if i==0:
        r_list.append(w_list[n-1])
        l_list.append(w_list[0])
    else:
        r_list.append(r_list[len(r_list)-1]+w_list[n-1-i])
        l_list.append(l_list[len(l_list)-1]+w_list[i])

ans_list=[]
for i in range(n-1):
    ans_list.append(abs(r_list[i]-l_list[len(l_list)-1-i]))

print(min(ans_list))


Measured memory_bytes: 3064
n = int(input())
h = list(map(int, input().split()))
global count
count = 0
def calc(data):
    if len(data) == 0:
        return 0
    if min(data) > 0:
        data = list(map(lambda x:x - 1, data))
        global count
        count += 1
        calc(data)
    else:
        k = data.index(min(data))
        calc(data[0:k])
        calc(data[k+1:])
calc(h)
print(count)

Measured memory_bytes: 3188
/*in the name of Allah the most beneficent the most merciful.*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
// #define MOD 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define out(x) cout << #x << " -> " << x << endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
using namespace std;
const ll B = 20, N = 300010, M = 2000000;
ll t, n, a[N], freq[N], cnt;
string s;
int solve()
{
    cin >> s;
    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') printf("3\n");
    else if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) printf("2\n");
    else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') printf("1\n");
    else printf("0\n");
    return 0;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    return solve();
}

Measured memory_bytes: 3632
#include "stdio.h"

int main(int argc, char const *argv[]) {
  int a,b,c,d,e,k;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);
  scanf("%d", &k);
  if (e-a>k) {
    printf(":(");
  }else{
    printf("Yay!");
  }
  return 0;
}


Measured memory_bytes: 128
use whiteread::parse_line;

fn main() {
    let (a, b, c): (u32, u32, u32) = parse_line().unwrap();
    let max = a.max(b).max(c);
    let ans;

    if (max * 3 - (a + b + c)) % 2 == 0 {
        ans = (max * 3 - (a + b + c)) / 2;
    } else {
        ans = (max * 3 - (a + b + c)) / 2 + 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2184
#include <iostream>
#include<cstdio>
using namespace std;
long long gcd(int a,int b)
{
    return b==0? a:gcd(b,a%b);
}

long long lcm(int a,int b)
{
    return a/gcd(a,b)*b;
}
int main()
{
    //freopen("in.txt","r",stdin);
    long long a,b;
    while(cin>>a>>b)
    {
        cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
    }


    return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
#define NUM 100000

int main(){
  int n,i,j,x,a,A[NUM];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  x= A[n-1];
  i=-1;
  for(j=0;j<n-1;j++){
    if(A[j]<=x){
      i++;
      a=A[i];
      A[i]=A[j];
      A[j]=a;
    }
  }
  a=A[i+1];
  A[i+1]=A[n-1];
  A[n-1]=a;

  for(j=0;j<=i;j++){
    printf("%d",A[j]);
    if(i+1!=n-1){
      printf(" ");
    }
  }
  printf("[%d]",A[i+1]);
  for(j=i+2;j<n;j++){
    printf(" %d",A[j]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll a[100005];

int main(){
    int n;
    cin >> n;
    rep(i,n) cin >> a[i];

    ll ans[n];
    ll sum=0;
    for(int i=0;i<n;i++){
        sum += a[i];
    }
    ans[0] = sum;
    for(int i=1;i<n;i+=2){
        ans[0] -= 2*a[i];
    }

    for(int i=0;i<n-1;i++){
        ans[i+1] = 2*a[i] - ans[i];
    }

    rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;



int main()
{
    string S;
    lint ans = 0, b = 0;
    cin >> S;
    REP(i, S.size())
    {
        if (S[i] == 'W') ans += b;
        else b++;
    }
    cout << ans << endl;
}


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

#define NUM 1000

int main(void){
  int junk[NUM]={0};
  int input[2];
  int odd=0,i;

  for(i=0;i<NUM;i++) junk[i]=0;

  while(scanf("%d %d",&input[0],&input[1])!=EOF){
    if(input[0]==0 && input[1]==0){
      for(i=odd=0;i<NUM;i++)
	odd+=(junk[i]==1);
      if(odd>=3 || odd==1){
	puts("NG");
      }else if(odd==0){
	puts("NG");
      }else{
	if(junk[0]==1 && junk[1]==1) puts("OK");
	else puts("NG");
      }
      for(i=0;i<NUM;i++) junk[i]=0;
    }else{
      junk[input[0]-1]^=1;
      junk[input[1]-1]^=1;
    }
  }
  return 0;
}

Measured memory_bytes: 588
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <iterator>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
typedef long long int ll;
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const int MOD = 1000000007;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

int SumDigitValues(int x)
{
	int sum = 0;
	while (x)
	{
		sum += x % 10;
		x = x / 10;
	}

	return sum;
}

int Factorial(int n)
{
	if (n < 0) return 0;
	if (n == 0) return 1;
	return n * Factorial(n - 1);
}

int factorial(int n)
{
	if (n > 1)
	{
		return n * factorial(n - 1);
	}
	else
	{
		return 1;
	}
}


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

vector<int> Divisors(int x)
{
	vector<int> divisors;
	divisors.push_back(1);
	for (int a = 2; a <= x; a++)
	{
		if (x % a == 0) divisors.push_back(a);
	}
	return divisors;
}

vector<int> CommonDivisors(int a, int b)
{
	vector<int> divisorsA = Divisors(a);
	vector<int> divisorsB = Divisors(b);
	vector<int> commonDivisors;
	set_intersection(divisorsA.begin(), divisorsA.end(), divisorsB.begin(), divisorsB.end(), std::back_inserter(commonDivisors));
	return commonDivisors;
}

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

	int a, b, c;
	cin >> a >> b >> c;

	int capacity = a - b;
	int r = c - capacity;
	if (r < 0) r = 0;
	cout << r << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B int

	fmt.Scan(&A, &B)
	a := float64(A)
	amin := int(math.Ceil(float64(a * 12.5)))
	amax := int(math.Ceil(float64((a+1.0)*12.5))) - 1
	b := float64(B)
	bmin := int(math.Ceil(float64(b * 10.0)))
	bmax := int(math.Ceil(float64((b+1.0)*10.0))) - 1
	// fmt.Printf("%v %v %v %v\n", amin, amax, bmin, bmax)

	if amin < bmin {
		if amax >= bmin {
			fmt.Printf("%d\n", bmin)
		} else {
			fmt.Printf("-1\n")
		}
	} else {
		if bmax >= amin {
			fmt.Printf("%d\n", amin)
		} else {
			fmt.Printf("-1\n")
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long LL;

int main(){
  int N,M,K;
  cin >> N >> M >> K;
  //  K=n*N+m*M-n*m*2;
  for(int i=0;i<=N;i++){
	for(int j=0;j<=M;j++){
	  if(j*N+i*M-j*i*2==K){
		cout << "Yes" << endl;
		return 0;
	  }
	}
  }
  cout << "No" << endl;
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  int pdays, wdays;
  wdays = 0;
  for(int i = 0; i<M; i++){
    cin >> A.at(i);
    wdays += A.at(i);
  }
  pdays = N - wdays;
  
  if(pdays >= 0){
    cout << pdays << endl;
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<ll> mi, ma;
    rep(i, n)
    {
        if (a[i] < 0)
        {
            mi.push_back(a[i]);
        }
        else if (a[i] > 0)
        {
            ma.push_back(a[i]);
        }
    }
    if ((ll)mi.size() * (ll)ma.size() < k && n * (n - 1) / 2 - (ll)ma.size() * ((ll)(ma.size() - 1)) / 2 - (ll)mi.size() * ((ll)(mi.size() - 1)) / 2 >= k)
    {
        cout << 0 << endl;
        return 0;
    }
    if (n * (n - 1) / 2 - (ll)ma.size() * ((ll)(ma.size() - 1)) / 2 - (ll)mi.size() * ((ll)(mi.size() - 1)) / 2 < k)
    {
        k -= n * (n - 1) / 2 - (ll)ma.size() * ((ll)(ma.size() - 1)) / 2 - (ll)mi.size() * ((ll)(mi.size() - 1)) / 2;
        ll l = 0;
        ll r = (ll)1e18;
        rep(i, mi.size())
        {
            mi[i] *= -1;
        }
        sort(mi.begin(), mi.end());
        while (r - l > 1)
        {
            ll mid = (l + r) / 2;
            ll now = 0;
            rep(i, (ll)ma.size())
            {
                ll dif = upper_bound(ma.begin(), ma.end(), mid / ma[i]) - ma.begin();
                if (dif > i)
                {
                    dif--;
                }
                now += max(dif - i, 0LL);
            }
            rep(i, (ll)mi.size())
            {
                ll dif = upper_bound(mi.begin(), mi.end(), mid / mi[i]) - mi.begin();
                if (dif > i)
                {
                    dif--;
                }
                now += max(dif - i, 0LL);
            }
            if (now >= k)
            {
                r = mid;
            }
            else
            {
                l = mid;
            }
        }
        cout << r << endl;
        return 0;
    }
    ll l = -(1e18);
    ll r = 0;
    while (r - l > 1)
    {
        ll mid = (l + r) / 2;
        ll now = 0;
        rep(i, mi.size())
        {
            now += ma.size() - (upper_bound(ma.begin(), ma.end(), -mid / (-mi[i])) - ma.begin());
        }
        if (now >= k)
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }
    cout << l << endl;
}

Measured memory_bytes: 7064
#include <iostream>
using namespace std;
int main()
{
	int W,H,x,y,r;
	
	cin>>W>>H>>x>>y>>r;
	if (x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)
	cout<<"Yes"<<endl;
	
	else
	cout<<"No"<<endl; 
	
	
	return 0;
	
}


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

using namespace std;
using ll = long long;

//cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    ll n = 0;
    cin >> n;
    ll cnt,MAX = 0;
    vector<ll> h(n);
    for(ll i = 0;i < n;i++){
        cin >> h[i];
    }
    for(ll i = 0;i < n - 1;i++){
        if(h[i] >= h[i + 1]){
            cnt ++;
        }else{
            cnt = 0;
        }
        MAX = max(cnt,MAX);
    }
    cout << MAX << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include <string.h>
#include<math.h>

int main(){
	int d,s,i;
	
	while(scanf("%d",&d)!=EOF){
		s=0;
		for(i=0;i<600/d;i++){
			s+=i*i*d*d; 
		}
		s*=d;
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
#define MAX 1001
using namespace std;

int main()
{
    int n, arr[MAX];
    scanf("%d", &n);
    for (int i = 0; i < n ; i++)
    {
        scanf("%d", &arr[i]);
    }

    int q, b, m, e, k;
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d %d %d", &b, &m, &e);
        int limit = e - b;
        int krr[MAX] = {0};

        for (k = 0; k < limit; k++)
        {
            krr[b + (k + e - m) % (e - b)] = arr[b + k];
        }
        for (int j = b; j < b + limit; j++)
        {
            arr[j] = krr[j];
        }
    }

    printf("%d", arr[0]);
    for (int i = 1; i < n; i++)
    {
        printf(" %d", arr[i]);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int M, K;
	int a_max;

	cin >> M >> K;
	a_max = (1 << M) - 1;

	if ((K > a_max)
	|| (M == 1 && K == 1)) {
		cout << -1 << endl;
		return 0;
	}
	else if (M == 1 && K == 0) {
		cout << "0 0 1 1" << endl;
		return 0;
	}

	rep(i, a_max + 1) {
		if (i != K) printf("%d ", i);
	}

	printf("%d ", K);

	rrep(i, a_max + 1) {
		if (i != K) printf("%d ", i);
	}

	printf("%d\n", K);

	return 0;
}

Measured memory_bytes: 1792
def is_kaibun(string):
    return string == string[::-1]

def clip1(string, N):
    end = int((N-1)/2)
    return string[:end]

def clip2(string, N):
    start = int((N+3)/2)-1
    end = N
    return string[start:end]


s1 = input()
N = len(s1)

s2, s3 = clip1(s1, N), clip2(s1, N)
#  print(s2, "  ", s3)

#  print(is_kaibun(s1))
#  print(is_kaibun(s2))
#  print(is_kaibun(s3))

ans = 'Yes' if is_kaibun(s1) and is_kaibun(s2) and is_kaibun(s3) else 'No'
print(ans)

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N,A[114514];

int memo[4000][6000];

int dfs(int l,int r){
    if(r-l-1==N)return 0;
    int &ret=memo[l][r];
    if(ret!=-1)return ret;

    if((r-l-1)&1){
        if(A[l]>A[r])ret=dfs(l-1,r);
        else ret=dfs(l,r+1);
    }
    else{
        ret=max(dfs(l-1,r)+A[l],dfs(l,r+1)+A[r]);
    }
    return ret;
}

signed main(){
    cin>>N;
    rep(i,N){
        cin>>A[i];A[i+N+N]=A[i+N]=A[i];
    }
    memset(memo,-1,sizeof(memo));
    int ans=0;
    rep(i,N)chmax(ans,A[i+N]+dfs(i+N-1,i+N+1));
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int n, m;
	string u, t;
	map<string, bool> IC;
	bool flag = false;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> u;
		IC[u] = true;
	}
	cin >> m;
	for(int i = 0; i < m; ++i){
		cin >> t;
		if(IC[t]){
			if(flag){
				cout << "Closed by " << t << endl;
			}
			else{
				cout << "Opened by " << t << endl;
			}
			flag ^= 1;
		}
		else{
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1240
w = raw_input()
wl = []
for i in range(0, len(w)):
	wl.append(w[i])
wl.sort()

if len(wl) % 2 != 0: print("No")
else:
	flag = True
	for i in range(0, len(wl)/2):
		if wl[2*i] != wl[2*i+1]:
			flag = False
			break
	if flag: print("Yes")
	else: print("No")

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  int ans = INT_MAX;
  int N = S.length(), M = T.length();
  for (int i = 0; i + M <= N; i++) {
    int cnt = 0;
    for (int j = 0; j < M; j++) {
      cnt += S[i + j] != T[j];
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,ans;
signed main(){
	ans=read();
	n=read();m=read();
	for(re int i=n;i<=m;++i){
		if(i%ans==0){
			puts("OK");
			return 0;
		}
	}
	return puts("NG"),0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double num1 = 0.5*m + 30*h;
		double num2 = 6*m;
		double num3 = 0;
		
		if(num1 > num2) {
			num3 = num1 - num2;
		} else if (num2 > num1){
			num3 = num2 - num1;
		}
		
		if(num3 > 180) {
			num3 = 360- num3;
		}
		
		if(num1 == num2) {
			if(a > b) {
				System.out.println(a-b);
				return;
			} else if (b > a) {
				System.out.println(b-a);
				return;
			} else if (a == b) {
				System.out.println(0);
				return;
			}
		}
		
	

		double cos =  Math.cos(Math.toRadians(num3));
		double c = (a*a+b*b)-(2*a*b*cos);
		double ans = Math.sqrt(c);
		System.out.println(ans);
	}
}


Measured memory_bytes: 37380
s = list(input())
count_max = 0
count_on = False
for i in range(len(s)):
    if count_on != True and s[i]=="A" :
       count_stt = i
       count_on = True
    if count_on == True and s[i]=="Z" :
        count_end = i
print(count_end - count_stt+1)

Measured memory_bytes: 4840
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		int strength = sc.nextInt();
		int total = 1;
		int size = 1;
		count--;
		while (true) {
		    int x = (total + strength - 1) / strength;
		    if (count >= x) {
		        size++;
		        total += x;
		        count -= x;
		    } else {
		        break;
		    }
		}
		System.out.println(size);
	}
}



Measured memory_bytes: 26300