akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
typedef pair<int, int>p;
p mov[200005];
long long mod = 1e9 + 7;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long n, x;
	cin >> n >> x;
	long long s[203];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	long long dp[2][100004];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 100004; j++) {
			dp[i][j] = 0;
		}
	}
	long long jun[203];
	jun[1] = 1;
	for (int i = 2; i < 203; i++) {
		jun[i] = jun[i - 1] * i;
		jun[i] %= mod;
	}
	for (int i = 0; i < 100004; i++) {
		dp[0][i] += i%(s[0]);
		dp[0][i] %= mod;
	}
	for (int z = 1; z < n; z++) {
		for (int i = 0; i < 100004; i++) {
			dp[1][i] += dp[0][i%(s[z])];
			dp[1][i] %= mod;
			dp[1][i] += dp[0][i] * z;
			dp[1][i] %= mod;
		}
		for (int i = 0; i < 100004; i++) {
			dp[0][i] = dp[1][i];
			dp[1][i] = 0;
		}
	}
	cout << dp[0][x];
}

Measured memory_bytes: 1920
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
using namespace std;
int main() {
	int hoge = 0;
	scanf("%d", &hoge);
	int n = hoge;
	hoge = sqrt(hoge);
	printf("%d:",n);
	int a = 2;
	while (true) {
		if (a > hoge) { printf(" %d\n", n);goto end; }
		if (n%a == 0) {
			n = n / a;
			printf(" %d", a);
			if (n == 1) {
				printf("\n");
				goto end;
			}
		}
		else {
			a++;
		}
	}
end:;
	return 0;
}


Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;

int L, n, m, cnt;
int x[N], y[N], len[N], ext[N];

void dfs(int now, int L) {
	n = now;
	if (L == 1) return;
	if (L % 2 == 0) {
		x[++m] = now;
		y[m] = now + 1;
		len[m] = L / 2;
		x[++m] = now;
		y[m] = now + 1;
		len[m] = 0;
		dfs(now + 1, L - len[m - 1]);
	}
	else {
		x[++m] = now;
		y[m] = 0;
		len[m] = L - 1;
		L--;
		x[++m] = now;
		y[m] = now + 1;
		len[m] = L / 2;
		x[++m] = now;
		y[m] = now + 1;
		len[m] = 0;
		dfs(now + 1, L - len[m - 1]);
	}
}

int main() {
	cin >> L;
	dfs(1, L);
	cout << n << ' ' << m << endl;
	for (int i = 1; i <= m; ++i) {
		if (y[i] == 0) y[i] = n;
		cout << x[i] << ' ' << y[i] << ' ' << len[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

long long n, a[300][300];
struct Elem {
    int l;
    int u, v;
};
vector<Elem> v;
long long b[300][300];
long long ans = 0;
bool flag = true;
bool cc[300][300];

int main () {
    cin >> n;
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < n; j ++) {
            b[i][j] = 0x7fffffff;
            b[i][j] <<= 10; 
            if (i == j) b[i][j] = 0;
            cin >> a[i][j];
//          a[i][j] = (i + j) % 10 + 3;
            if (i < j) {
                Elem e;
                e.l = a[i][j];
                e.u = i;
                e.v = j;
                v.push_back(e);
            }   
        }   
    }   
    sort(v.begin(), v.end(), [](const Elem p, const Elem q) -> bool { return p.l < q.l; }); 
    for (Elem e : v) {
        if (b[e.u][e.v] < e.l) {
            flag = false;
            break;
        } else if (b[e.u][e.v] > e.l) {
            ans += e.l;
            for (int u = 0; u < n; u ++) {
                for (int v = 0; v < n; v ++) {
                    if (!cc[u][v] && b[u][v] > b[u][e.u] + e.l + b[v][e.v]) {
                        b[u][v] = b[v][u] = b[u][e.u] + e.l + b[v][e.v];
                    }   
                }   
            }   
            cc[e.u][e.v] = 1;
        }   
    }   
    if (!flag) cout << -1 << endl;
    else cout << ans << endl;

return 0;
}

Measured memory_bytes: 2424
n = int(input())
arr = list(map(int, input().split()))

count = 1
mode = None
for i in range(n):
    if i+1 == n or arr[i+1] - arr[i] == 0:
        continue
    elif mode is None:
        if arr[i+1] > arr[i]:
            mode = 'up'
        elif arr[i+1] < arr[i]:
            mode = 'down'
    elif mode == 'up':
        if arr[i+1] < arr[i]:
            count += 1
            mode = None
    elif mode == 'down':
        if arr[i+1] > arr[i]:
            count += 1
            mode = None

print(count)

Measured memory_bytes: 14436
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

struct UnionFind {
    vector<int> par; // 親を指すvector,-par[親]は木のサイズ
    UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
    int root(int x) { // 親をたどる&データの整理
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y) { // データの結合
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);} // 所属判定
    int size(int x) {return -par[root(x)];} // 木のサイズ
}uft(160000);

int main() {
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h) {
        cin >> s[i];
    }

    int di[4] = {0, 1, -1, 0};
    int dj[4] = {1, 0, 0, -1};

    ll ans = 0;
    rep(i, h) {
        rep(j, w) {
            int now = i*w+j;
            if(uft.size(now) != 1) continue;
            queue<int> que;
            que.push(now);
            int cou = 0;
            while(!que.empty()) {
                int nn = que.front();
                que.pop();
                if(s[nn/w][nn%w] == '.') cou++;
                rep(k, 4) {
                    int ni = nn/w+di[k];
                    int nj = nn%w+dj[k];
                    if(ni < 0 or nj < 0 or ni > h-1 or nj > w-1) continue;
                    if(s[ni][nj] == s[ni-di[k]][nj-dj[k]]) continue;
                    if(uft.same(now, ni*w+nj)) continue;
                    que.push(ni*w+nj);
                    uft.unite(now, ni*w+nj);
                }
            }
            ll aa = uft.size(now);
            ans += (aa-cou) * cou;
        }
    }

    cout << ans << endl;
}

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

int main(){
	int n,m,x;
	cin>>n>>m>>x;
	
	int a[100],b[100];
	for(int i=0;i<n;i++){
		a[i]=0;
	}
	for(int i=0;i<m;i++){
		cin>>b[i];
		a[b[i]]=1;
	}
	
	int l=0,r=0;
	for(int i=x-1;i>=0;i--){
		if(a[i]) l++;
	}
	for(int i=x+1;i<n;i++){
		if(a[i]) r++;
	}
	
	cout<<min(l,r)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        char[] s = nstr().toCharArray();
        int[] ans = new int[s.length];
        
        int i = 0;
        while(i < s.length) {
            int numR = 0;
            int numL = 0;
            while (s[i] == 'R') {
                i++;
                numR++;
            }
            while (i < s.length && s[i] == 'L') {
                i++;
                numL++;
            }
            
            int br = i-numL-1;
            int bl = br + 1;
            ans[br] = here(numR) + there(numL);
            ans[bl] = here(numL) + there(numR);
        }
        for (int i_ans = 0; i_ans < ans.length; i_ans++) {
            so.println(ans[i_ans]);
        }
    }

    private static int here(int i) {
        return (i+1)/2;
    }
    
    private static int there(int i) {
        return i/2;
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 45316
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return input().split()
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    i = 0
    while i != len(s):
        if s[i] == "h" and s[i + 1] == "i":
            i += 2
        else:
            print("No")
            return

        if len(s) == i + 1:
            print("No")
            return
        
    print("Yes")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    const double PI = acos(-1);
    int N;
    cin >> N;
    using arg_vec = pair<double, complex<double>>;
    vector<arg_vec> v(N);
    rep(i, 0, N) {
        int x, y;
        cin >> x >> y;
        v[i] = {atan2(y, x), complex<double>(x, y)};
    }
    sort(all(v), [](arg_vec &a, arg_vec &b) {
        return a.first < b.first;
    });

    double ans = 0;
    rep(i, 0, N) {
        rep(j, 0, N) {
            double r = v[j].first;
            double l = v[i].first;
            if (l > r) r += 2 * PI;
            if (r - l < PI) {
                complex<double> tmp;
                rep(k, 0, N) {
                    if ((l <= v[k].first and v[k].first <= r) ||
                        (l <= v[k].first + 2 * PI and v[k].first + 2 * PI <= r)) {
                        tmp += v[k].second;
                    }
                }
                chmax(ans, abs(tmp));
            }
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N; cin >> N;
    vector<Pi> Ai(N);
    rep(i,N){
        cin >> Ai[i].first;
        Ai[i].second = i;
    }
    sort(Ai.begin(),Ai.end(),greater<Pi>());
    int a = Ai[0].second;
    int b = Ai[1].second;
    rep(i,N){
        if(i != a) cout << Ai[0].first << endl;
        else cout << Ai[1].first << endl;
    }

}


Measured memory_bytes: 3200
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, accumulate
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

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

H, N = MAP()
A = LIST()

print("Yes" if sum(A) >= H else "No")


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

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

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

int main() {
    string s;
    cin>>s;
    ll a = 0;
    //ll bc = 0;
    ll p = 0;
    ll ans = 0;
    while(p<s.size()){
        if(s[p]=='A'){
            a++;
        }else if(p+1<s.size()&&s[p]=='B'&&s[p+1]=='C'){
            ans+=a;
            p++;
           // bc++;
        }else {
            a=0;
        }
        p++;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 640
m=int(input())
n=list(map(int,input().split()))
cnt=0
for i in range(m-1):
  minj=i
  irekae=0
  for j in range(i+1,m):
    if n[j]<n[minj]:
      minj=j
      irekae=1
  if irekae:
    n[i],n[minj]=n[minj],n[i]
    cnt+=1

print(' '.join(map(str, n)))
print(cnt)


Measured memory_bytes: 5600
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; ++i) {
            A[i] = sc.nextLong();
        }
        sc.close();

        int odd = 0;
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) {
                ++odd;
            }
        }

        if (odd % 2 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

n, k = map(int, input().split())

def border(n, k):
    cnt = 0
    while True:
        if n*2**cnt >= k:
            return cnt
        else:
            cnt += 1

ans = 0
for i in range(1, n+1):
    ans += 1/n * 0.5 ** border(i, k)

print(ans)


Measured memory_bytes: 39280
#include <ctype.h>
#include <cassert>
#include <cstdio>
#include <cstdlib>

using namespace std;

namespace {

int stackptr = -1;
int stack[100];

inline int Pop() {
  return stack[stackptr--];
}

inline void Push(int n) {
  stackptr++;
  stack[stackptr] = n;
}

}  // namespace

int main() {
  char buf[1000000];
  while (scanf("%s", buf) != EOF) {
    const char* p = buf;
    if (isspace(*p))
      continue;
    if (isdigit(*p)) {
      Push(atoi(p));
      continue;
    }

    switch (*p) {
      case '+':
        Push(Pop() + Pop());
        break;
      case '-': {
        const int b = Pop();
        const int a = Pop();
        Push(a - b);
      } break;
      case '*':
        Push(Pop() * Pop());
        break;
      default:
        assert(false);
    }
  }

  printf("%d\n", stack[0]);
  return 0;
}

Measured memory_bytes: 2652
def cc134
    n = gets.chomp.to_i#.map{|x| x.to_i}

    an_t = Struct.new("Arr", :index, :value)
    an = []
    for i in 1..n
        an.push(an_t.new(i, gets.chomp.to_i))
    end
    an = an.sort{|a, b| a.value <=> b.value}

    for i in 1..n
        m = an[-1]
        if m.index == i
            m = an[-2]
        end
        puts m.value
    end
end

cc134

Measured memory_bytes: 20840
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--)
using namespace std;
const int N = (int)1e5+5;
const int inf = (int)1e17+7;
void solve(){
	double r;
	cin >> r;
	printf("%0.15f",2*PI*r);
}
int32_t main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	FASTIO;
	solve();
    return 0;

}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 +7;
struct node{
	int parent;
	int left_child;
	int right_sibling;
};
struct node t[MAXN];
int d[MAXN];
int childrens[MAXN];
void setDepth(int i, int p){
	d[i] = p;
	if(t[i].left_child!=-1){
		setDepth(t[i].left_child, p+1);
	}
	if(t[i].right_sibling!=-1){
		setDepth(t[i].right_sibling, p);
	}
}
char* type(int i){
	if(t[i].parent == -1){
		return "root";
	}else if(t[i].left_child == -1){
		return "leaf"; 
	}else{
		return "internal node";
	}
}
int children(int i){
	int y = 0;
	int u = t[i].left_child;

	while(u!=-1){
		childrens[y++] = u;
		u = t[u].right_sibling;
	}

	
	return y;
} 
int main() {
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		t[i].parent = -1;
		t[i].left_child = -1;
		t[i].right_sibling = -1;
	}
	for(int i = 0; i < n; i++){
		int id;
		scanf("%d", &id);
		int k;
		scanf("%d", &k);
		int l;
		for(int j = 0; j < k; j++){
			int r;
			scanf("%d", &r);
			if(j == 0){
				t[id].left_child = r;
			}else{
				t[l].right_sibling = r;
			}
			l = r;
			t[r].parent = id;
		}
	}
	int root;
	for(int i = 0; i < n; i++){
		if(t[i].parent==-1){
			root = i;
		}
	}
	setDepth(root, 0);
	for(int i = 0; i < n; i++){
		printf("node %d:", i);
		printf(" parent = %d,", t[i].parent);
		printf(" depth = %d,", d[i]);
		printf(" %s,", type(i));
		printf(" [");
		int childs = children(i);
		for(int j = 0; j < childs; j++){
			if(j!=0) printf(" ");
			printf("%d", childrens[j]);
			if(j!=childs-1) printf(",");
		}
		printf("]");
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 5064
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      _a: [[u8; n]; n]
   }
   let mut a = vec![vec![true; n]; n];
   for i in 0..n {
      for j in 0..n {
         if _a[i][j] == 0 {
            a[i][j] = false;
         }
      }
   }
   let mut dp = vec![-1_i64; 1 << n];
   dp[0] = 1;
   let ans = rec((1 << n) - 1, 0, &a, &mut dp);
   println!("{}", ans);
}

const MOD: i64 = 1000000007;

fn rec(state: usize, c: usize, a: &Vec<Vec<bool>>, dp: &mut Vec<i64>) -> i64 {
   if dp[state] != -1 {
      dp[state]
   } else {
      let mut r = 0;
      for i in 0..a[0].len() {
         if (state >> i) & 1 == 1 && a[c][i] {
            r += rec(state ^ (1 << i), c + 1, a, dp);
         }
      }
      r %= MOD;
      dp[state] = r;
      r
   }
}


Measured memory_bytes: 20732
#template
def inputlist(): return [int(k) for k in input().split()]
import sys
sys.setrecursionlimit(10**8)
#template
N = int(input())
li = [0]*(N-1)
dic = {}
graph = [[]*(N+1) for _ in range(N+1)]
for i in range(N-1):
    a,b = inputlist()
    if a >= b:
        a,b = b,a
    graph[a].append(b)
    graph[b].append(a)
    k = tuple([a,b])
    dic[k] = i
ans = 0
indexa = -1
seen = [False]*(N+1)
for i in range(1,N+1):
    k = len(graph[i])
    if k > ans:
        indexa = i
    ans = max(ans,k)
def dfs(i,v):
    for v1 in graph[v]:
        if seen[v1]:
            continue
        seen[v1] = True
        i +=1
        i %= ans
        aa = min(v,v1)
        bb = max(v,v1)
        ka = tuple([aa,bb])
        li[dic[ka]] = i
        dfs(i,v1)
dfs(-1,indexa)
print(ans)
for i in range(N-1):
    print(li[i]+1)

Measured memory_bytes: 123416
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
int solve()
{
    int l;
    cin>>l;
    printf("%.12f",(l*l*l)/27.0);
}
int main()
{
    /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    #endif */
    solve();
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\n";
    #endif */
    return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int r = sc1.nextInt();

		if ( r < 1200) {
			System.out.println("ABC");
		}
		else if ( r < 2800) {
			System.out.println("ARC");
		}
		else {
			System.out.println("AGC");
		}

		sc1.close();

	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define lb(container, val)      lower_bound(all((container)), val) - (container).begin()
#define ub(container, val)      upper_bound(all((container)), val) - (container).begin()
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define sz(container)           ((int) (container).size())
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (long long) 1000000007

using namespace std;

#ifdef LOCAL_DEFINE
    #include "../../DEBUG.hpp"
#endif

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
long long MAX() {return LLONG_MIN;}
long long MIN() {return LLONG_MAX;}
template<typename T, typename... Args>
T MAX(T a, Args... args) {return max(a, MAX(args...));}
template<typename T, typename... Args>
T MIN(T a, Args... args) {return min(a, MIN(args...));}

typedef long long ll; 
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;
const ll inf = 1e9;
vvll dp;
vll we, v;
ll n;

ll solve(ll pos, ll w) {
    if (w < 0) return -inf;
    if (pos == n) return 0;
    if (dp[pos][w] != -1) return dp[pos][w];
    ll ans = 0;
    ans = max(v[pos] + solve(pos + 1, w - we[pos]), solve(pos + 1, w));
    return dp[pos][w] = ans;
}

int main(void) {    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in1", "r", stdin);
#endif
    
    ll w;
    cin >> n >> w;
    dp.resize(n, vll(w + 1, -1));
    we.resize(n);
    v.resize(n);
    forn(i, n) cin >> we[i] >> v[i];
    ll ans = solve(0LL, w);
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif
    return 0;
}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc= new Scanner(System.in);
		
		int N= sc.nextInt();
		
		int cnt= 0;
		for(int i=0;i<N;i++){
			
			int a= sc.nextInt();
			int b= sc.nextInt();
			
			if(a == b){
				cnt++;
				if(cnt == 3){
					System.out.println("Yes");
					break;
				}
			}
			else cnt=0;
			
			if(i == N-1)System.out.println("No");
			
		}
		
		
		sc.close();
	}
	
	
	

}


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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     int n;
     cin >> n;
     if(n%1000==0)cout << 0;
     else cout << 1000-n%1000;
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3800
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int answer = 0;
  rep(i, N){
    int l, r;
    cin >> l >> r;
    answer += (r - l + 1);
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <vector>

using namespace std;

struct Combination {
  std::vector<long long> fac, finv, inv;
  int mod;

  Combination(int max_n, int _mod) {
    fac = finv = inv = std::vector<long long>(max_n + 10, 0);
    mod = _mod;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max_n + 10; i++) {
      fac[i] = fac[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }

  long long mod_comb(int n, int k) {
    if (n < k || n < 0 || k < 0) {
      return 0;
    }
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
};

const int mod = 1000000007;

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

  Combination comb(n + 10, mod);

  int idx1, idx2;
  vector<int> a(n + 10, -1);
  for (int i = 0; i < n + 1; i++) {
    int t;
    std::cin >> t;
    if (a[t] != -1) {
      idx2 = i;
      idx1 = a[t];
    }
    a[t] = i;
  }

  int num1 = idx1;
  int num2 = n - idx2;

  for (int k = 1; k <= n + 1; k++) {
    long long ans = comb.mod_comb(n + 1, k);
    ans = (ans - comb.mod_comb(num1 + num2, k - 1) % mod + mod) % mod;

    std::cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 5868
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    if( N % 4 == 0 || N % 7 == 0){
    System.out.println("Yes");  
    } else{
    while(N > 0){
      N -= 7;
      if( N < 0) break;
    if(N % 4 == 0){
      System.out.println("Yes");
        break;
       }
    }
    if(N < 0)
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
n, m = map(int,input().split())
set1 = set([i for i in range(1,m+1)])
for i in range(n):
    k,a = input().split(None,1)
    a = list(map(int,a.split()))
    a = set(a)
    set1 = set1 & a
print(len(set1))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int num = X / (Y + Z);
  if (X % (Y + Z) < Z)
    num--;
  cout << num << endl;
}


Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)
	m := nextInt(sc)
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, m)
	}
	b := make([]int, m)

	for i := range a {
		for j := range a[i] {
			a[i][j] = nextInt(sc)
		}
	}
	for i := range b {
		b[i] = nextInt(sc)
	}

	for i := range a {
		v := 0
		for j := range a[i] {
			v += a[i][j] * b[j]
		}
		fmt.Println(v)
	}
}



Measured memory_bytes: 1220
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
	char s1,s2,s3;
	int s=0;
	scanf("%c%c%c",&s1,&s2,&s3);
	getchar();
	if(s1=='1')	s++;
	if(s2=='1')	s++;
	if(s3=='1')	s++;
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 128
package main

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

func main() {
	list := getStdinIntArr64()
	N := list[0]
	M := list[1]
	K := list[2]
	A := getStdinIntArr64()
	B := getStdinIntArr64()
	Asum := make([]int64, N+1)
	Bsum := make([]int64, M+1)

	var i int64 = 0
	var j int64 = 0

	for i = 0; i < N; i++ {
		Asum[i+1] = Asum[i] + A[i]
	}
	for i = 0; i < M; i++ {
		Bsum[i+1] = Bsum[i] + B[i]
	}

	var bmax int64 = M
	var ans int64 = 0
	for i = 0; i <= N; i++ {
		if Asum[i] > K {
			break
		}
		for j = bmax; j >= 0; j-- {
			if Asum[i]+Bsum[j] <= K {
				bmax = j
				break
			}
		}
		if i+bmax > ans {
			ans = i + bmax
		}
	}

	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func getStdinIntArru64() []uint64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]uint64, len(list))
	for idx, val := range list {
		var i int64
		i, _ = strconv.ParseInt(val, 10, 64)
		rtn[idx] = uint64(i)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll t;
	cin>>t;
	 map<string,ll>mp;
	while(t--){
	    
	   
	    
	        string s;
	        cin>>s;
	        mp[s]++;
	    
	   
	}
	 cout<<mp.size();
	return 0;
}

Measured memory_bytes: 19284
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;


int main(){
    int N;
    cin >> N;
    vector<long long> A(N,0);
    long long sum=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    int k=0;
    long long s=0;
    for(k=0;k<N;k++){
        s += A[k];
        if(s > sum/2){
            break;
        }
    }

    long long res = min(sum- 2LL* (s-A[k]), 2LL*s - sum);
    cout << res << endl;


    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
#define m int64_t
#define r(s,i,n) for(m i=s;i<n;i++)
m w[555][555],p[1234];
int main(){m n;cin>>n;m t=0,k=555;r(2,i,9999){bool a=true;r(2,j,i){if(i%j==0)a=false;}if(a)p[t]=i,t++;}r(0,i,k)r(0,j,k)if(i%2==j%2)w[i][j]=p[(i+j)/2]*p[(i+k*3-j)/2];r(0,i,k)r(0,j,k)if(w[i][j]==0&&i>0&&i<554)w[i][j]=w[i-1][j]*w[i+1][j]+1;r(0,i,n)r(0,j,n)cout<<w[i+1][j+1]<<" ";}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;
  std::vector<int> d(N);
  rep(i, N) {
    std::cin >> d[i];
  }

  ll ans = 0;
  for(int i = 0; i < N; ++i) {
    for(int j = i + 1; j < N; ++j) {
      ans += d[i] * d[j];
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    char s[100020];
    scanf("%s",s);
    int a=0,b=0,c=0;
    for (int i=0; i<strlen(s); i++){
        if (s[i]=='a'){
            a++;
        } else if (s[i]=='b'){
            b++;
        } else {
            c++;
        }
    }
    if (abs(a-b)<=1 && abs(b-c)<=1 && abs(c-a)<=1){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define inf 1e18
#define all(v) (v).begin(),(v).end()
using namespace std;

vector <int> dx = {-1,1,0,0};
vector <int> dy = {0,0,-1,1};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x;cin>>x;
	if(x){
		cout<<"0"<<"\n";
	}else{
		cout<<"1"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3612
n = int(input())
c,s,f = [0]*n,[0]*n,[0]*n
for i in range(n-1):
    c[i],s[i],f[i] = map(int,input().split())
for i in range(n):
    cnt = 0
    j = i
    while j < n-1:
        if cnt <= s[j]:
            cnt = s[j]+c[j]
        else:
            cnt = s[j]+f[j]*((cnt - s[j])//f[j])+\
            [f[j],0][((cnt - s[j])%f[j])==0]+c[j]
        j += 1
    print(cnt)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int a=scn.nextInt();
		int b=scn.nextInt();
		int c=scn.nextInt();
		if(b<a) {
			int t=b;
			b=a;
			a=t;
		}
		int cnt=0;
		for(int i=a;i>=1;i--) {
			if(b%i==0&&a%i==0) {
				cnt++;
			}
			if(cnt==c) {
				System.out.println(i);
				break;
			}
		}
	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)(n); ++i)
int par[100001];
int find(int x){
   if(par[x]==x)
     return x;
   else
     return par[x]=find(par[x]); 
}
int main() {
  int n,m,x,y,ans=0;
  cin >> n>>m;
  int p[n+1];
  rep(i,n){
    par[i]=i;
    cin>>p[i];
  }
  rep(i,m){
     cin>>x>>y;
     x=find(x);
     y=find(y);
     if(x==y)
       continue;
     par[y]=x;
  }
  rep(i,n){
     if(p[i]==i){
        ans++; 
     } else if(find(p[i])==find(p[p[i]])){
        ans++; 
     }
  }
  cout<<ans;
  return 0;
}


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

int main(){
    int N;
    scanf("%d",&N);
    int ans[N];
    for(int i=0;i<N;i++)
        ans[i] = 0;
    for(int i=0;i<N-1;i++){
        int buf;
        scanf("%d",&buf);
        ans[buf-1] += 1;
    }
    for(int i=0;i<N;i++){
        printf("%d",ans[i]);
        if(i!=N-1) printf("\n");
    }
}


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

int main() {
  string s_a, s_b, s_c;
  cin >> s_a >> s_b >> s_c;
  
  char next_card = 'a';
  bool b = true;
  while (b) {
    if (next_card == 'a'){
      if(s_a.empty() == true) {
        cout << "A" << endl;
        break;
      }
      next_card = s_a.at(0);
      s_a.erase(s_a.begin());

    }else if (next_card == 'b'){
      if(s_b.empty() == true) {
        cout << "B" << endl;
        break;
      }
      next_card = s_b.at(0);
      s_b.erase(s_b.begin());
      
    }else{
      if(s_c.empty() == true) {
        cout << "C" << endl;
        break;
      }
      next_card = s_c.at(0);
      s_c.erase(s_c.begin());
    
    }
  } 
  
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0147

"""
import sys
from sys import stdin
from heapq import heappop, heappush
from collections import deque
input = stdin.readline


class Seat():
    def __init__(self, n):
        self.seat = '_' * n

    def get(self, num):
        i = self.seat.find('_'*num)
        if i != -1:
            self.seat = self.seat[0:i] + 'o'*num + self.seat[i+num:]
            return i
        return None

    def release(self, i, num):
        self.seat = self.seat[0:i] + '_'*num + self.seat[i+num:]


def solve():
    waiting_time = [-1] * 100
    NUM_OF_SEAT = 17
    seat = Seat(NUM_OF_SEAT)
    LEAVE = 0
    COME = 1
    in_out = []                 #  ??\?????????????????????????????????
    Q = deque()                      #  ??§??????????????????
    # 100???????????\????????????????????????
    for group_id in range(100):
        if group_id % 5 == 1:
            num = 5
        else:
            num = 2
        heappush(in_out, (group_id * 5, COME, NUM_OF_SEAT+1, group_id, num))

    while in_out:
        time, event, start_seat, group_id, num = heappop(in_out)
        if event == COME:
            Q.append((time, group_id, num))
        else:
            seat.release(start_seat, num)
        while Q:
            res = seat.get(Q[0][2])
            if res is not None:
                arrive, group_id, num = Q.popleft()
                waiting_time[group_id] = time - arrive
                eating_time = 17 * (group_id % 2) + 3*(group_id % 3) + 19
                heappush(in_out, (time + eating_time, LEAVE, res, group_id, num))
            else:
                break
    return waiting_time


def main(args):
    waiting_time = solve()

    for line in sys.stdin:
        print(waiting_time[int(line)])


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 8148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if(a <= 0 && 0 <= b) cout << "Zero" << endl;
    else {
        if(a > 0) cout << "Positive" << endl;
        else if(b < 0) {
            if((a - b) & 1) cout << "Positive" << endl;
            else cout << "Negative" << endl;
        }
    }
}

Measured memory_bytes: 3620
#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()
{
	long long int m, n;
	cin >> m >> n;
	if (n > m) {
		swap(n, m);
	}

	if (m == 1){
		cout << 1 << endl;
		return 0;
	}
	if (n == 1) {
		cout << m - 2 << endl;
		return 0;
	}

	cout << (m - 2)*(n - 2) << endl;

	return 0;
}

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

int main(){
  int a, b;
  string s;
  cin >> a >> b;
  cin >> s;
  if(s[a] != '-'){
    cout << "No" << endl;
    return 0;
  }else{
    for(int i = 0; i < s.size(); i++){
      if(i == a) continue;
      if(s[i] == '-'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=100000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
ll n,k,a[maxn],b[maxn],ans;
void dfs(ll len,ll now,bool ok){
	if(ok && len>=0){
		if(k&(1LL<<len)){
			dfs(len-1,now^(1LL<<len),false);
			dfs(len-1,now,true);
		}
		else dfs(len-1,now^(1LL<<len),true);
	}
	else{
		ll res=0;
		for(ll i=1;i<=n;i++) if((a[i]&now)==a[i]) res+=b[i];
		ans=max(ans,res);
	}
}
int main(){
	read(n);read(k);
	for(int i=1;i<=n;i++) read(a[i]),read(b[i]);
	dfs(30,-1,true);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
import math

n = int(input())
a = list(map(int,input().split()))

MAX = 1000005

is_prime = [1]*MAX
D = [None]*MAX
is_prime[0],is_prime[1] = 0,0

for i in range(2,MAX):
  if is_prime[i]:
    D[i] = i
    for j in range(i*2,MAX,i):
      is_prime[j] = 0
      D[j] = i
      
counts = [0]*MAX
pair = True

for a_i in a:
  if a_i == 1:
    continue
  pf = {}
  while True:
    p = D[a_i]
    if counts[p]>0:
      pair = False
    pf[p] = pf.get(p,0)+1
    if p == a_i:
      break
    else:
      a_i //= p
      
  for p in pf.keys():
    counts[p] += 1

if pair:
  print('pairwise coprime')
else:
  g = a_i
  for a_i in a:
    g = math.gcd(a_i,g)
  if g == 1:
    print('setwise coprime')
  else:
    print('not coprime')

Measured memory_bytes: 213072
N=int(input())
a=list(map(int,input().split()))
count=0
for i in range(N):
  if a[i]%2==0 and (a[i]%3!=0 and a[i]%5!=0):
    count+=1
if count==0:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
	int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
	x=a;a=b;b=x;x=a;a=c;c=x;
	printf("%d %d %d",a,b,c);
	return 0;
} 

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

int main(){
  int N,mx=0,ans=0;
  cin>>N;
  int H[N];
  for(int i=0; i<N; ++i) cin>>H[i];
  for(int i=0; i<N; ++i){
    if(mx<=H[i]){
      mx=H[i];
      ans ++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(){
int X,A,B,C,D;
std::cin >> X >> A >> B;
if(X<A)
C=A-X;
else
C=X-A;
if(X<B)
D=B-X;
else
D=X-B;
if(C<D)
std::cout << "A" << std::endl;
else
std::cout << "B" << std::endl;
}

Measured memory_bytes: 256