akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define NIL -1
#define MAX 25

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

vector<Node> t(MAX, {NIL, NIL, NIL});
vector<int> d(MAX);
vector<int> h(MAX);

int get_sibling(int u) {
    int p = t[u].parent;
    if (p == NIL) return NIL;
    if (t[p].left != NIL && t[p].left != u) return t[p].left;
    if (t[p].right != NIL && t[p].right != u) return t[p].right;
    return NIL;
}

int get_degree(int u) {
    int m = 0;
    if (t[u].left != NIL) m++;
    if (t[u].right != NIL) m++;
    return m;
}

void set_depth(int u, int p) {
    if (u == NIL) return;
    d[u] = p;
    set_depth(t[u].left, p+1);
    set_depth(t[u].right, p+1);
}

int set_height(int u) {
    int h1 = 0, h2 = 0;
    if (t[u].left == NIL && t[u].right == NIL) return 0;
    if (t[u].left != NIL) h1 = set_height(t[u].left) + 1;
    if (t[u].right != NIL) h2 = set_height(t[u].right) + 1;
    return h[u] = max(h1, h2);
}

int main() {
    int n;
    scanf("%d", &n);
    rep(i, n) {
        int id, l, r;
        scanf("%d %d %d", &id, &l, &r);
        if (l != NIL) t[l].parent = id;
        if (r != NIL) t[r].parent = id;
        t[id].left = l;
        t[id].right = r;
    }

    int r;
    rep(i, n) {
        if (t[i].parent == NIL) {
            r = i;
            break;
        }
    }
    set_depth(r, 0);
    set_height(r);

    rep(i, n) {
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, t[i].parent, get_sibling(i), get_degree(i), d[i], h[i]);
        if (t[i].parent == NIL) printf("root\n");
        else if (t[i].left == NIL && t[i].right == NIL) printf("leaf\n");
        else printf("internal node\n") ;
    }
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
    int n,m,l;
    cin>>n>>m>>l;
    vector<vector<ll>> A(n,vector<ll>(m));
    vector<vector<ll>> B(m,vector<ll>(l));
    vector<vector<ll>> C(n,vector<ll>(l));
    REP(i,n) REP(j,m) cin>>A.at(i).at(j);
    REP(i,m) REP(j,l) cin>>B.at(i).at(j);
    REP(i,n) {
        REP(j,l) {
            REP(k,m) {
                C.at(i).at(j) += A.at(i).at(k)*B.at(k).at(j);
            }
        }
    }
    REP(i,n) {
        REP(j,l-1) cout<<C.at(i).at(j)<<' ';
        cout<<C.at(i).at(l-1);
        cout<<endl;
    }
}



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

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

    queue<pair<vector<int>, int>> q;
    q.push(make_pair(vector<int>{0}, 0));
    for (int i = 0; i < N - 1; i++)
    {
        queue<pair<vector<int>, int>> tmp;
        while (!q.empty())
        {
            vector<int> str = q.front().first;
            int m = q.front().second;
            q.pop();
            for (int j = 0; j <= m + 1; j++)
            {
                vector<int> n = str;
                n.push_back(j);
                tmp.push(make_pair(n, max(m, j)));
            }
        }
        q = tmp;
    }
    set<string> ans;
    while (!q.empty())
    {
        string a;
        for (int front : q.front().first)
        {
            a.push_back('a' + front);
        }
        q.pop();
        ans.insert(a);
    }
    for (string a : ans)
    {
        cout << a << endl;
    }
}


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

using namespace std;

typedef long long ll;
const int maxn = (int)1e5 + 1;

string s;

int ok(int a, int b){
    return (b <= 12 && b > 0);
}

bool good(int a, int b){
    return (ok(a, b) && ok(b, a));
}

int main(){
    cin >> s ;
    int a = (s[0] - '0') * 10 + (s[1] - '0'), b = (s[2] - '0') * 10 + (s[3] - '0');
    if(good(a, b)){
        cout << "AMBIGUOUS";
        return 0;
    }
    if(ok(a, b)){
        cout << "YYMM";
        return 0;
    }
    if(ok(b, a)){
        cout << "MMYY";
        return 0;
    }
    cout << "NA";
}


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

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans=max(a*c,b*d);
  if(a>=0 and d<=0) ans=a*d;
  if(b<=0 and c>=0) ans=b*c;
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n,k,d,a,flg[101],cnt;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)	flg[i]=0;
	for(i=0;i<k;i++)	{
		scanf("%d",&d);
		for(j=0;j<d;j++)	{
			scanf("%d",&a);
			flg[a]=1;
		}
	}
	cnt=0;
	for(i=1;i<=n;i++)	{
		cnt+=flg[i];
	}
	printf("%d\n",n-cnt);
	return 0;
}

Measured memory_bytes: 1736
//MD. HASNAIN ALI (UNSOLVED)
#include <bits/stdc++.h>

#define ll long long
#define pii pair<int,int>

#define distance(a,b) (sq(a.x-b.x) + sq(a.y-b.y))
#define MAX3(a,b,c) max(a,max(b,c))
#define SQ(x) ((x) * (x))
#define SWAP(a,b) {        \
                    a=a+b; \
                    b=a-b; \
                    a=a-b; }

using namespace std;

int main()
{
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    d=(c-(a-b));
    if(d>=0) printf("%d\n",d);
    else printf("%d\n",0);

    return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;
    
    if(1 <= A && A <= 9 && 1 <= B && B <= 9) {
        cout << A * B << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

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

int main(void){
  int n,m;
  cin>>n>>m;
  
  vector<vector<int>>pos(2,vector<int>(n));
  vector<vector<int>>check(2,vector<int>(m));
  
  for(int i=0;i<n;i++){
   cin>>pos.at(0).at(i)>>pos.at(1).at(i); 
  }
  for(int i=0;i<m;i++){
   cin>>check.at(0).at(i)>>check.at(1).at(i); 
  }
  
  for(int i=0;i<n;i++){
    int x,y;
    int ans=0;
    x=fabs(pos.at(0).at(i)-check.at(0).at(0))+fabs(pos.at(1).at(i)-check.at(1).at(0));
     for(int j=1;j<m;j++){
       y=fabs(pos.at(0).at(i)-check.at(0).at(j))+fabs(pos.at(1).at(i)-check.at(1).at(j));
       if(y<x){
         x=y;
         ans=j;
       }
     }
    cout<<ans+1<<endl;
  }
  return 0;
}

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

// グローバル変数
ll h1, m1, h2, m2, k;
//vector<ll> c;
//vector<pair<ll, ll>> a; // No.16

// 関数プロトタイプ
void input();
void solve();

int main(void)
{
    input();
    solve();  
}

// 標準入力
void input() {
    cin >> h1 >> m1 >> h2 >> m2 >> k;
}

void solve() {
    ll ans = (h2 * 60 + m2) - (h1 * 60 + m1) - k;
    cout << ans << endl;
}

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

int main(){
    int n;
    cin>>n;
    
    for(int i=1;i<=9;i++){
        int b=n/i;
        int rem=n%i;
        
        if(b>=1 and b<=9 and rem==0){
            cout<<"Yes";
            return 0;
        }
    }
    
    cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;
using pis = std::pair<int, std::string>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n;
	cin >> n;
	ll* a = new ll[n];
	rep(i, n) cin >> a[i];

	ll sum = 0;
	rep(i, n) {
		sum += a[i];
		sum %= _MOD;
	}

	ll ans = 0;
	rep(i, n-1) {
		sum -= a[i];
		sum = (sum + _MOD) % _MOD;
		ans += (a[i] * sum)%_MOD;
		ans %= _MOD;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 5212
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while(1) {
        if (x > y) break;
        x *= 2LL;
        ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

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


int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  s[k-1] = s[k-1] - ('A'-'a');
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3608
import sys
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
N,W = LI()
dp = [0 for _ in range(W+1)]
for i in range(1,N+1):
    w,v = LI()
    for j in range(W,0,-1):
        if j < w: continue
        dp[j] = max(dp[j],dp[j-w]+v)
print(dp[-1])

Measured memory_bytes: 44912
N, Q = map(int, input().split())
S = input()
t = [0] * N
for i in range(N-1):
    t[i+1] = t[i] + (1 if S[i : i+2] == "AC" else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
_input = input
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

import queue

#データ読み込み
n,m=map(int, input().split())
s=[list(map(int, input().split())) for i in range(m)]

t=[[] for i in range(n+1)]

#マップ作成
for route in s:
	t[route[0]].append(route[1])
	t[route[1]].append(route[0])

#ルート作成
saitan = [n+10 for i in range(n+1)]
shirube=[[] for i in range(n+1)]
itta=[0 for i in range(n+1)]


q = queue.Queue()
q.put(1)
saitan[1]=0
while not q.empty():
	i=q.get()
	for j in t[i]:
		itta[j]=1
		if saitan[i]+1 < saitan[j]:
			saitan[j] = saitan[i]+1
			q.put(j)
			shirube[j] = i

if sum(itta) == n:
	print("Yes")
	for i in shirube[2:n+1]:
		print(i)
else:
	print("No")
	
input = _input


Measured memory_bytes: 68708
N = int(input())
ws = [int(ele) for ele in input().split()]
min_diff = 100 * 100
for T in range(1, N):
  s1, s2 = ws[:T], ws[T:]
  diff = abs(sum(s1) - sum(s2))
  min_diff = min(min_diff, diff)
print(min_diff)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <random>

#define ll long long

using namespace std;

int main() {
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    char buffer[3000 + 1];
    scanf("%3000s", buffer);
    string s1(buffer);
    scanf("%3000s", buffer);
    string s2(buffer);
    vector<vector<int>> a((int)s1.size() + 1, vector<int>((int)s2.size() + 1, 0));
    for (int i = 1; i <= (int)s1.size(); i++) {
        for (int j = 1; j <= (int)s2.size(); j++) {
            if (s1[i - 1] == s2[j - 1]) {
                a[i][j] = a[i - 1][j - 1] + 1;

            } else {
                a[i][j] = max(a[i - 1][j], a[i][j - 1]);
            }
        }
    }
    int i = (int)s1.size();
    int j = (int)s2.size();
    string ans = "";
    while (i > 0 && j > 0) {
        if (s1[i - 1] == s2[j - 1]) {
            ans.push_back(s1[i - 1]);
            i--;
            j--;
        } else {
            if (a[i - 1][j] == a[i][j]) {
                i--;
            } else {
                j--;
            }
        }
    }
    //printf("%d\n", a[(int)s1.size()][(int)s2.size()]);
    reverse(ans.begin(), ans.end());
    printf("%s", ans.c_str());
    return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <utility>

std::vector<int> GetInput() {
    int n = 0;
    std::vector<int> values;
    std::cin >> n;
    values.resize(n, 0.0);

    for (auto it = values.begin(); it < values.end(); it++) {
        std::cin >> *it;
    }
    return values;
}

void Display(std::vector<int> value) {
    int n = value.size();
    for (int i = 0; i < n; i++) {
        std::cout << value[i];
        if(i == n-1) {
            std::cout << std::endl;
        }
        else {
            std::cout << " ";
        }
    }
}

void InsertionSort(std::vector<int>& values) {
    for (int i = 1; i < values.size(); i++) {
        Display(values);
        int j = i - 1;
        int target_value = values[i];
        while(j >= 0 && target_value < values[j]) {
            values[j+1] = values[j];
            j--;
        }
        values[j+1] = target_value;
    }
    Display(values);
}

void BubbleSort(std::vector<int>& values) {
    int flag = 1;
    int change_count = 0;
    while (flag) {
        flag = 0;
        for (int i = 0; i < values.size(); i++) {
            if (values[i] < values[i-1]) {
                std::swap(values[i], values[i-1]);
                flag = 1;
                change_count++;
            }
        }
    }
    Display(values);
    std::cout << change_count << std::endl;
}

void SelectionSort(std::vector<int>& values) {
    int change_count = 0;
    for (int i = 0; i < values.size(); i++) {
        int min_ix = i;
        for (int j = i; j <values.size(); j++) {
            if (values[j] < values[min_ix]) {
                min_ix = j;
            }
        }
        if (i != min_ix) {
            std::swap(values[i], values[min_ix]);
            change_count++;
        }
    }
    Display(values);
    std::cout << change_count << std::endl;
}

int main(int argc, char const* argv[])
{
    std::vector<int> values = GetInput();
    SelectionSort(values);

    return 0;
}

Measured memory_bytes: 3152
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    k0 = 0
    kh = 0
    if K % 2 == 1:
        k0 = N // K
    else:
        k0 = N // K
        kh = (N+(K//2)) // K

    print(k0**3 + kh ** 3)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    solve(N, K)

if __name__ == '__main__':
    main()


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

int main(){
	int x,n,flag=1;
	cin>>x>>n;
	if(n==0){
		cout<<x<<"\n";
		flag=0;
	}
	else{
		bitset<101> b;
		for(int i=0;i<n;i++){
			int d;
			cin>>d;
			b[d] = 1;
		}
		for(int i=0;;i++){
			if(x-i > -1 && b[x-i]!=1){
				cout<<(x-i)<<"\n";
				flag=0;
				break;
			}
			else if(x+i<101 && b[x+i]!=1){
				cout<<(x+i)<<"\n";
				flag=0;
				break;
			}
			else if(x+i>100){
				cout<<(x+i)<<"\n";
				flag=0;
				break;
			}
		}
	}
	if(flag==1){
		cout<<-1<<"\n";
	}
}

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

int N,K,X,Y,sum;

int main(){

	cin>>N>>K>>X>>Y;
	if(N>K){
		sum=K*X+(N-K)*Y;
	}
	else{sum=X*N;}
	

	cout<< sum<<endl;
	return 0;

	}

Measured memory_bytes: 3572
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	string S=in<string>();
	deque<char> A;
	int right=0;
	for(int i=N-1;i>=0;i--){
		if(S[i]==')'){
			right++;
		}
		else{
			if(!right){
				A.push_back(')');
			}
			else{
				right--;
			}
		}
		A.push_front(S[i]);
	}
	LOOP(right){
		A.push_front('(');
	}

	for(auto& x:A) cout << x;
	out();

	return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]
ans = 0
for i in range(2 ** H):
    for j in range(2 ** W):
        tmp = 0
        for h in range(H):
            if i & (1 << h):
                continue
            for w in range(W):
                if j & (1 << w):
                    continue
                if c[h][w] == "#":
                    tmp += 1
        if tmp == K:
            ans += 1
print(ans)



Measured memory_bytes: 68324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  vector<vector<ll>> dp(n+1,vector<ll>(k+1,0));
  dp.at(0).at(0) = 1;
  for(int i=1;i<=n;i++){
    rep(j,k+1){
      if(j-a.at(i-1)>0) dp.at(i).at(j) = ((dp.at(i-1).at(j) + dp.at(i).at(j-1))%MOD - dp.at(i-1).at(j-a.at(i-1)-1)+MOD)%MOD;
      else{
        if(j>0) dp.at(i).at(j) = (dp.at(i-1).at(j) + dp.at(i).at(j-1))%MOD;
        else dp.at(i).at(j) = dp.at(i-1).at(j);
      }
    }
  }
  cout << dp.at(n).at(k) << endl;    
  //rep(i,n+1)rep(j,k+1) cout << dp.at(i).at(j) << endl;
  return 0;
}



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

int main(){
  ll n; cin >> n;
  ll c=(int)sqrt(n); ll ans=0;
  for(ll j=1; j<=c+1; j++){
    if(n%j==0) ans=j;
  }

  cout << ans+(n/ans)-2 << endl;

 return 0;
}


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


int main(){
    string s,t;
    cin >> s >> t;
    vector<int> from(26,-1),to(26,-1);
    rep(i,int(s.size())){
        int a = s[i]-'a';
        int b = t[i]-'a';

        if(from[a]!=-1 || to[b]!=-1){
            if(from[a] != b || to[b] != a){
                cout << "No" << endl;
                return 0;
            }
        }else{
            from[a] = b;
            to[b] = a;
        }
    }   
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3900
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        x:usize,y:usize,
    }
    let mut v = vec![0, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0];
    yn(v[x] == v[y]);
}
pub fn yn(ans: bool) {
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2136
#include<stdio.h>
#define MAX 100000
#define NUMBER 2000000000

typedef struct
{
  char mark;
  int num;
}cards;

cards c1[MAX/2+2],c2[MAX/2+2];

void merg(cards M[],int n,int left, int middle, int right)
{
  int i,j,l;
  int a,b;
  a=middle-left;
  b=right-middle;
  for(i=0;i<a;i++)c1[i]=M[left+i];
  for(i=0;i<b;i++)c2[i]=M[middle+i];
  c1[a].num=NUMBER;
  c2[b].num=NUMBER;
  i=0;
  j=0;
  for(l=left;l<right;l++)
    {
      if(c1[i].num<=c2[j].num)
        {
          M[l]=c1[i++];
        }
      else
        {
          M[l]=c2[j++];
        }
    }
}

void mergS(cards M[],int n, int left, int right)
{
  int middle;
  if(left+1<right)
    {
      middle=(left+right)/2;
      mergS(M,n,left,middle);
      mergS(M,n,middle,right);
      merg(M,n,left,middle,right);
    }
}int part(cards M[], int n,int posi,int las)
{
  int i,j;
  cards A,B;
  B=M[las];
  i=posi-1;
  for(j=posi;j<las;j++)
    {
      if(M[j].num<=B.num)
        {
          i++;
          A=M[i];
          M[i]=M[j];
          M[j]=A;
        }
    }
  A=M[i+1];
  M[i+1]=M[las];
  M[las]=A;
  return i+1;
}

void quickS(cards M[],int n, int posi,int las)
{
  int k;
  if(posi<las)
    {
      k=part(M,n,posi,las);
      quickS(M,n,posi,k-1);
      quickS(M,n,k+1,las);
    }
}
int main()
{
  int i,cnt,va;
  cards S[MAX],T[MAX];
  char MR[10];
  int t=1;
  scanf("%d",&cnt);
  for(i=0;i<cnt;i++)
    {
      scanf("%s %d",MR,&va);
      S[i].mark=MR[0];
      T[i].mark=MR[0];
      S[i].num=va;
      T[i].num=va;
    }
  mergS(S,cnt,0,cnt);
  quickS(T,cnt,0,cnt-1);

  for(i=0;i<cnt;i++)
    {
      if(S[i].mark!=T[i].mark)t=0;
    }
  if(t==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<cnt;i++)
    {
      printf("%c %d\n",T[i].mark,T[i].num);
    }
  return 0;
}

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

using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()

ll weight[110],val[110];
ll dp[110][100010];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,W;
	cin>>n>>W;
	for(ll i=0;i<n;i++)cin>>weight[i]>>val[i];
	for(ll i=0;i<=n;i++)
		for(ll cur_w=0;cur_w<=W;cur_w++)
			if(!i or !cur_w)dp[i][cur_w]=0;
			else if(weight[i-1]<=cur_w)dp[i][cur_w]=max(dp[i-1][cur_w],val[i-1]+dp[i-1][cur_w-weight[i-1]]);
			else dp[i][cur_w]=dp[i-1][cur_w];
	cout<<dp[n][W]<<"\n";
	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	string s;
	cin >> s;
	string weather[] = {"Sunny", "Cloudy", "Rainy"};
	rep(i,2){
		if(weather[i] == s){
			cout << weather[i + 1] << endl;
			return 0;
		}
	}
	cout << weather[0] << endl;
	
}


Measured memory_bytes: 384
package main

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

func main() {
	a := readInt64()
	b := readInt64()
	c := gcd(a, b)
	fmt.Println(a * b / c)
}

func gcd(x, y int64) int64 {
	if y == 0 {
		return x
	}

	if x > y {
		return gcd(y, x%y)
	} else {
		return gcd(y, x)
	}
}

var stdin *bufio.Scanner

func read() string {
	if stdin == nil {
		stdin = bufio.NewScanner(os.Stdin)
		stdin.Split(bufio.ScanWords)
		stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	}
	stdin.Scan()
	return stdin.Text()
}

func readInt() int {
	n, _ := strconv.Atoi(read())
	return n
}

func readInt64() int64 {
	n, _ := strconv.ParseInt(read(), 10, 64)
	return n
}

func readFloat64() float64 {
	n, _ := strconv.ParseFloat(read(), 64)
	return n
}


Measured memory_bytes: 640
N,C=map(int,input().split())
xc=[tuple(map(int,input().split())) for i in range(N)]
xc.sort()
ans=0
p=0
#右を取る範囲と左を取る範囲を決めればいい
s=[0]*(N+1)#時計回り
ss=[0]*(N+1)#反時計回り
for i in range(N):
  s[i+1]=s[i]+xc[i][1]

for i in range(N):
  ss[i+1]=ss[i]+xc[N-1-i][1]
maxs=[0]*(N+1)
maxss=[0]*(N+1)
for i in range(N):
  s[i+1]=s[i+1]-xc[i][0]
  ss[i+1]=ss[i+1]-(C-xc[N-1-i][0])
  maxs[i+1]=max(maxs[i],s[i+1])
  maxss[i+1]=max(maxss[i],ss[i+1])
ans=max(0,maxs[-1])
ans=max(ans,maxss[-1])
for i in range(N):
  if s[i+1]>xc[i][0]:
    ans=max(ans,maxss[N-i-1]+(s[i+1]-xc[i][0]))
  if ss[i+1]>(C-xc[N-1-i][0]):
    ans=max(ans,maxs[N-i-1]+(ss[i+1]-(C-xc[N-1-i][0])))
print(ans)

Measured memory_bytes: 29704
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
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=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



P func(int n){
  int a=n%10,b;
  while(n){
    b = n;
    n/=10;
  }
  return P(a,b);
}


int main(){
  int N,D,X;
  cin >> N >> D >> X;
  int ans = N;
  D--;
  rep(i,N){
    int a;
    cin >> a;
    ans += (D/a);
  }
  ans += X;
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
vector<int>p[100005];
int n,m,h[100005];
bool ok(int w){
    for(int i=0;i<p[w].size();i++){
        if(h[p[w][i]]>=h[w]){
            return 0;
        }
    }
    return 1;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
	    cin>>h[i];
	}
	int x,y;
	for(int i=1;i<=m;i++){
	    cin>>x>>y;
	    p[x].push_back(y);
	    p[y].push_back(x);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
	    ans+=ok(i);
	}
	cout<<ans;
}


Measured memory_bytes: 9156
N,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(1,N):
    s = a[i-1]+a[i]
    if s > x:
        ans += s-x
        a[i] = max(0,x-a[i-1])
print(ans)

Measured memory_bytes: 85796
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=500050;
//↑templete
const double EPS=1e-7;
struct Pos{
	double x, y;
};
struct Circ{
	double x, y, c;
};
pair<Pos, Pos> kouten(Circ alpha, Circ beta){
	double x=beta.x-alpha.x, y=beta.y-alpha.y;
	double ra=alpha.c, rb=beta.c;
	double a=(x*x+y*y+ra*ra-rb*rb)/2;

	Pos fir={
		(a*x + y*sqrt( (x*x+y*y)*ra*ra - a*a ))/(x*x+y*y)+alpha.x,
		(a*y - x*sqrt( (x*x+y*y)*ra*ra - a*a ))/(x*x+y*y)+alpha.y,
	};
	Pos sec={
		(a*x - y*sqrt( (x*x+y*y)*ra*ra - a*a ))/(x*x+y*y)+alpha.x,
		(a*y + x*sqrt( (x*x+y*y)*ra*ra - a*a ))/(x*x+y*y)+alpha.y,
	};

	return mp(fir, sec);
}
bool kousa(Circ alpha, Circ beta){
	double dd=(alpha.x-beta.x)*(alpha.x-beta.x)+(alpha.y-beta.y)*(alpha.y-beta.y);
	double d=sqrt(dd);
	if(alpha.c+beta.c<d)	//無関係
		return 0;
	if((d+beta.c<alpha.c) || (d+alpha.c<beta.c))	//内包
		return 0;
	
	return 1;
}
bool naihou(Pos A, Circ alpha){
	double dd=(A.x-alpha.x)*(A.x-alpha.x)+(A.y-alpha.y)*(A.y-alpha.y);
	double d=sqrt(dd);
	
	return (d<alpha.c+EPS);
}
signed main(){
	cout<<setprecision(20)<<fixed;

	int N, K;
	cin>>N>>K;

	vtint A;
	for(int i=0;i<N;i++){
		int x, y, c;
		cin>>x>>y>>c;
		A.eb(x, y, c);
	}

	//K枚焼く時間を二分探索
	double ng=0., ok=1e9;
	int unchi=100;
	while(unchi--){
		double T=(ng+ok)/2;

		vector<Pos> v;
		for(int i=0;i<N;i++){
			double x1, y1, c1;
			tie(x1, y1, c1)=A[i];
			v.pb(Pos{x1, y1});
			Circ alpha{x1, y1, T/c1};

			for(int j=i+1;j<N;j++){
				double x2, y2, c2;
				tie(x2, y2, c2)=A[j];
				Circ beta{x2, y2, T/c2};

				if(!kousa(alpha, beta))
					continue;
				
				Pos fir, sec;
				tie(fir, sec)=kouten(alpha, beta);
				v.pb(fir);
				v.pb(sec);
			}
		}

		int maxi=0;

		//各点で内包判定
		for(Pos p:v){
			double X=p.x, Y=p.y;
			int cnt=0;
			for(tint t:A){
				double x, y, c;
				tie(x, y, c)=t;
				cnt+=naihou(Pos{X, Y}, Circ{x, y, T/c});
			}
			maxi=max(maxi, cnt);
		}

		//cout<<T<<" "<<maxi<<endl;

		if(maxi>=K)
			ok=T;
		else
			ng=T;
	}

	cout<<ok<<endl;

	return 0;
}

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

int main(){
    int n;
    cin >>n;
    vector<pair<int,int>> p(n);
    rep(i,n) cin >> p[i].second >> p[i].first;
    sort(p.begin(),p.end());
    long long t = 0;
    rep(i,n){
        t += p[i].second;
        if(t>p[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string[] strArray = new string[a.Length];
            for (var i = 0; i < a.Length; i++)
            {
                strArray[i] = a.Substring(i, 1);
            }
            if (strArray[0] == "R" && strArray[1] == "R" && strArray[2] == "R") Console.WriteLine("3");
            else if (strArray[0] == "R" && strArray[1] == "R" || strArray[1] == "R" && strArray[2] == "R") Console.WriteLine("2");
            else if (strArray[0] == "R" || strArray[1] == "R" || strArray[2] == "R") Console.WriteLine("1");
            else Console.WriteLine("0");
        }
    }
}

Measured memory_bytes: 25788
#include<iostream>

double cross( double x1, double y1, double x2, double y2 )
{
	return x1 * y2 - x2 * y1;
}

int main()
{
	double x[3], y[3], xp, yp;

	while( std::cin >> x[0] >> y[0] )
	{
		for( int i = 1; i != 3; ++i )
			std::cin >> x[i] >> y[i];
		std::cin >> xp >> yp;

		bool s, f = true;
		for( int i = 0; i != 3; ++i )
		{
			double t = cross( x[( i + 1 ) % 3] - x[i], y[( i + 1 ) % 3] - y[i], xp - x[i], yp - y[i] );

			if( !i )
			{
				if( t > 0 )
					s = true;
				else
					s = false;
			}

			f &= ( t < 0 ) ^ s;
		}

		if( f )
			std::cout << "YES" << std::endl;
		else
			std::cout << "NO" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 200010;
const double eps = 1e-6;
const ll mod = 1000000007;
const ll inf = 1LL << 59;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

////////////////////////////////////////////////////////////////////////

int N, P;
ll dp[51][2];
int A[51];

void solve() {
	cin >> N >> P;
	rep(i, 0, N) {
		cin >> A[i];
		A[i] = A[i] % 2;
	}
	dp[0][0] = 1;
	rep(i, 0, N) {
		rep(j, 0, 2) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j] += dp[i][(j - A[i] + 2) % 2];
		}
	}
	cout << dp[N][P] << "\n";
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

static const int INF = 2147483647;
static const int NIL = -1;
static const int MOD = 1000000007;
typedef long long ll;
typedef pair<int,int> P;
struct edge {int to,cost;};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define itn int
#define scnaf scanf
#define int ll

static const int MAX_N = 200;

int d[MAX_N][MAX_N];
int N;

void warshall_floyd(){
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++) d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
        }
    }
}

signed main(){
    int m,r;
    scanf("%lld %lld %lld",&N,&m,&r);

    vector<int> disti;

    for(int i=0;i<r;i++){
        int tmp;
        scanf("%lld",&tmp);
        disti.pb (tmp-1);
    }

    sort(all(disti));

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            d[i][j] = INF;
        }
    }

    for(int i=0;i<m;i++){
        int s,t,l;
        scanf("%lld %lld %lld",&s,&t,&l);
        d[s-1][t-1] = d[t-1][s-1] = l;
    }

    warshall_floyd();

    int ans=INF;

    while(np(all(disti))){
        int kyori=0;
        for(int i=0;i<disti.size()-1;i++){
            kyori += d[disti[i]][disti[i+1]];
        }
        if(kyori<ans) ans = kyori;
    }

    printf("%lld\n",ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define endk '\n'

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int k, x;
  cin >> k >> x;
  for (int i = x - k + 1; i < x + k - 1; i++)
    cout << i << ' ';
  cout << x + k - 1 << endk;
  
  return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <vector>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;



int main(){
    ll D,G,ptm,ctm,ans,pct,tmp;
    vector<ll> p,c;
    cin>>D>>G;
    for(ll i=0;i<D;i++){
        cin>>ptm>>ctm;
        p.push_back(ptm);
        c.push_back(ctm);
    }
    ans=inf;
    for(ll i=0;i<(1<<D);i++){
        pct=0;
        tmp=0;
        for(ll j=0;j<D;j++){
            if(i&(1<<j)){
                tmp+=(p[D-j-1]*100*(D-j))+c[D-j-1];
                pct+=p[D-j-1];
            }
        }
        if(tmp>=G){
            ans=min(ans,pct);
        }
        else{
            for(ll j=0;j<D;j++){
                if(!(i&(1<<j))){
                    if(p[D-j-1]>(G-tmp+(100*(D-j)-1))/(100*(D-j))){
                        pct+=(G-tmp+(100*(D-j)-1))/(100*(D-j));
                        ans=min(pct,ans);
                    }
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;
const double PI = 3.1415926535;


//D
int main() {
	ll a;
	scanf("%lld", &a);
	ll b;
	scanf("%lld", &b);
	ll x;
	scanf("%lld", &x);

	ll area = a * a;
	ll allCap = a * a * b;

	double theta = 0.0;

	if (x * 2ll >= allCap) {
		double c = 2.0 / (double)area * ((double)area * (double)b - (double)x);
		theta = atan2(c, a);
	}
	else {
		double c = 2.0 * (double)x / (double)a / (double)b;
		theta = atan2(b, c);
	}


	double result = 0;

	result = theta * 180.0 / PI;

	printf("%0.10f\n", result);
}


//C
/*
int main() {
	ll N;
	scanf("%lld", &N);

	ll result = INF;

	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ll move = (i - 1) + (N / i - 1);
			result = min(result, move);
		}
	}

	printf("%lld\n", result);
}
*/

//B
/*
int main() {
	ll N;
	scanf("%lld", &N);

	bool result = false;

	for (ll i = 1; i <= 9; i++) {
		if (N % i == 0 && N / i <= 9) {
			result = true;
			break;
		}
	}

	if (result == true) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}
*/

//A
/*
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	ll result = 0;

	if (A <= 9 && B <= 9) {
		result = A * B;
	}
	else {
		result = -1;
	}

	printf("%lld\n", result);
}
*/


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#include <assert.h>
#define ff first
#define ss second
#define ll long long
#define mod 998244353
using namespace std;
//ll bp(ll x, ll p){
//    ll res = 1;
//    while(p){
//        if(p & 1)
//            res = res * x % mod;
//        x = x * x % mod;
//        p >>= 1;
//    }
//    return res;
//}
//ll C(ll n, ll k){
//    if(k == 0)
//        return 1;
//    if(k < 0 || k > n)
//        return 0;
//    return f[n] * rf[k] % mod * rf[n - k] % mod;
//}
//f[0] = rf[0] = 1;
//    for(int i = 1; i < 500009; i++)
//        f[i] = f[i - 1] * i % mod, rf[i] = bp(f[i], mod - 2);
long double a, b;
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>a>>b;
    a *= b;
    cout<<(long long)a;
}
/*
 2
 ((
 )))(
 */


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  string S, T;
  int A, B;
  string U;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if (U == S) {
    A--;
  } else {
    B--;
  }
  cout << A << " " << B;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(c, i, n) for (int i = c; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    if ((S == "AAA") || (S == "BBB"))
    {
        cout << " No" << endl;
        return 0;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

char S[100010];

int main()
{
	int i;
	scanf("%s", &S);
	int len = strlen(S);
	int res = 0;
	for(i=1; i<len; i++){
		if(S[i] != S[i-1])
			res ++;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long h, w; cin >> h >> w;
  if(h == 1) {
    cout << 1 << endl;
  }
  else if(w == 1) {
    cout << 1 << endl;
  }
  else if(h % 2 == 0) {
    cout << h * w /2 << endl;
  }
  else {
    if(w % 2 == 0) {
      cout << h * w /2 << endl;
    }
    else {
      cout << (h * w +1) /2 << endl;
    }
  }
}

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;

        for(ll i=1000;i<=10000;i+=1000)
        {
            if(i>=n)
            {
                cout<<i-n;
                break;
            }
        }
    }
}

Measured memory_bytes: 3640
import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1): #木グラフの隣接リストを作成
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
for _ in range(q): #各頂点についてcount[v]を計算
 v,val=map(int,input().split())
 cnt[v]+=val
q=collections.deque()
q.append(1) #DFSのスタックによる実装、まずスタックに始点1を積む
checked=[0]*(n+1) #各頂点を見たかどうかのフラグを持っておく
while q:
 v=q.pop()
 checked[v]=1 #頂点を見たかどうかのフラグを更新する
 for u in g[v]:
   if checked[u]==1: #vの子ノードuについて、まだ見ていない頂点であればcount[u]をcount[u]+=count[v]として更新する
     continue
   cnt[u]+=cnt[v]
   q.append(u) #スタックに子ノードuを積む
print(*cnt[1:]) #各頂点のcountが答えとなる

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

int main() {
  int A, P;
  cin >> A >> P;
  
  if (A == 0 && P < 2) {
    cout << 0 << endl;
  } else {
    cout << (A * 3 + P) / 2 << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,i,arr[1000];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        arr[i]=a;
    }
    for(i=0;;i++)
    {
        if(i<n)
        {
            if(arr[i]%2==0)
            {
                if(arr[i]%3==0 || arr[i]%5==0)
                    continue;
                else
                {
                    printf("DENIED");
                    break;
                }
            }
            else
                continue;
        }
        else
        {
            printf("APPROVED");
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define time ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main()
{
	int arr[5];
	for(int i=0;i<5;i++)
		cin>>arr[i];
		
	for(int i=0;i<5;i++)
	{
		if(arr[i] == 0)
		{
			cout<<i+1<<"\n";
		}
	}
	
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
typedef long long LL;

LL S;

int main() {
	
	std::ios::sync_with_stdio(false);
	std::cin >> S;
	LL r = S <= 1000000000LL ? S : 1000000000LL;
	std::cout << "0 1 " << r << " 0 ";
	LL x = S % r, y = S / r + 1;
	if (x == 0) x = r, y--;
	std::cout << x << " " << y << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
N = long(input())
W = map(long, raw_input().split())

sum = sum(W)
x = sum
left = 0
for i in range(0, N):
  left += W[i]
  p_x = abs(sum - 2 * left)
  if x < p_x :
      break
  x = p_x

print(x)

Measured memory_bytes: 2572
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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



int D, G;
int p[12];
int c[12];

int main () {
  cin >> D >> G;

  vector<int> dp;
  dp.assign(1200, INF);

  Rep(i, D) {
    cin >> p[i] >> c[i];
  }

  Rep(i, 1 << D) {
    int tmp = 0;
    int tmp_score = 0;

    //cout << i << "\n";

    Rep(j, D) {
      int mask = 1 << j;

      if (mask & i) {
        tmp += p[j];
        tmp_score += ((p[j] * (j+1) * 100) + c[j]);
      }
    }

    //cout << tmp << "\n";
    //cout << tmp_score << "\n";

    if (tmp_score >= G) {
      dp[i] = tmp;
      //cout << dp[i] << "\n";
      continue;
    }

    int cri = 0;

    for (int j=D-1;j>=0;--j) {
      int mask = 1 << j;

      if (!(mask & i)) {
        cri = j;
        break;
      }
    }

    //cout << "cri" << cri << "\n";

    int plus;
    if ((G - tmp_score) % ((cri+1) * 100) == 0) {
      plus = (G - tmp_score) / ((cri+1) * 100);
    } else {
      plus = (G - tmp_score) / ((cri+1) * 100) + 1;
    }

    if (plus < p[cri]) {
      dp[i] = tmp + plus;
    }

    //cout << dp[i] << "\n";
  }  

  sort(All(dp));
  cout << dp[0] << "\n";
}

Measured memory_bytes: 256
N, M = map(int, input().split())


class DisjointSet():
    def __init__(self, n):
        self.parent = list(range(n))
        self.rank = [0] * n

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def count_groups(self):
        return len([i for i, x in enumerate(self.parent) if i == x])


d = DisjointSet(N)
for i in range(M):
    xi, yi, zi = map(int, input().split())
    d.unite(xi - 1, yi - 1)
print(d.count_groups())


Measured memory_bytes: 11800