akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;
 
int main(){
  using namespace std;
  int x, y, z;
  cin>>x>>y>>z;
  swap(x, y);
  swap(x, z);
  cout<<x<<' '<<y<<' '<<z<<endl;
  return 0;
}



Measured memory_bytes: 256
[n,k,q] = [int(i) for i in input().split()]
a = []
for i in range(q):
  a.append(int(input())-1)
ls = [k-q for i in range(n)]
for i in range(q):
  ls[a[i]] += 1
for i in range(n):
  if ls[i] > 0:
    print("Yes")
  else:
    print("No")
    

Measured memory_bytes: 11784
#include<iostream>

using namespace std;

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

	if (X < A) {
		cout << "NO" << endl;
	}
	else if (A + B < X) {
		cout << "NO" << endl;
	}
	else cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    lli a, b, n;
    cin >> a >> b >> n;
    lli x;
    x = b - 1;
    if (x > n) x = n;
    int ans = floor((a*x)/b) - a * floor(x/b);
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;

const int MOD = 998244353;
const int MX = 300 * 1000 + 7;

int fc[MX], rfc[MX];

void add(int& x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

int mul(int x, int y) {
    return (1ll * x * y) % MOD;
}

int pw(int x, int y) {
    if (y == 0) {
        return 1;
    } else if (y % 2 == 0) {
        return pw(mul(x, x), y / 2);
    } else {
        return mul(pw(x, y - 1), x);
    }
}

int inv(int x) {
    return pw(x, MOD - 2);
}

int cnk(int n, int k) {
    return mul(fc[n], mul(rfc[k], rfc[n - k]));
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    fc[0] = 1;
    for (int i = 1; i < MX; i++) {
        fc[i] = mul(fc[i - 1], i);
    }
    rfc[MX - 1] = inv(fc[MX - 1]);
    for (int i = MX - 2; i >= 0; i--) {
        rfc[i] = mul(rfc[i + 1], i + 1);
    }
    int n, a, b;
    ll k;
    cin >> n >> a >> b >> k;
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        ll more = k - 1ll * i * a;
        if (more < 0 || more % b != 0) {
            continue;
        }
        more /= b;
        if (more <= n) {
            add(ans, mul(cnk(n, i), cnk(n, more)));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
int main()
{long int n;
 std::cin>>n;
 int a[n];
 for(long int i=0;i<n;i++)
  std::cin>>a[i] ;
 int dp[n];
 dp[0]=0;
 dp[1]=std::abs(a[1]-a[0]);
 for(long int i=2;i<n;i++)
 {dp[i]=std::min(dp[i-1]+std::abs(a[i]-a[i-1]),dp[i-2]+std::abs(a[i]-a[i-2]));
 }
 std::cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;

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

	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	ll ans = 0;
	for(int i = 0;i < n;i++){
		ans += (ll)(lower_bound(a.begin(),a.end(),b[i]) - a.begin()) * (ll)(c.end() - upper_bound(c.begin(),c.end(),b[i]));
	}

	cout << ans << endl;
}


Measured memory_bytes: 1408
# coding: utf-8
import itertools
def main():
    n, m, q = map(int, input().split())
    matrix = []
    for _ in range(q):
        row = list(map(int, input().split()))
        matrix.append(row)
    # print(matrix)
    A = list(range(1, m+1))
    ans = 0
    for tmp_A in itertools.combinations_with_replacement(A, n):
        tmp_A = sorted(list(tmp_A))
        tmp_ans = 0
        for row in matrix:
            # print("row", row)
            # print("tmp_A", tmp_A)
            tmp = tmp_A[row[1] - 1] - tmp_A[row[0]- 1]
            if row[2] == tmp:
                tmp_ans += row[3]
        if tmp_ans >= ans:
            ans = tmp_ans
            
    print(ans)
    
main()

Measured memory_bytes: 9124
#!/usr/bin/env python3
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

(n, m), *d = [[*map(int, o.split())] for o in open(0)]
UF = UnionFind(n)
for a, b in d:
    UF.union(a-1, b-1)
print(UF.group_count()-1)

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll s;
  cin >> s;
  ll ans = s;
  while(s >= 100)
  {
    ans = min(ans, abs((s % 1000) - 753));
    s /= 10;
  }
  cout << ans;
  
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;


int main(){
    int n;
    while(cin>>n){
        int  odds=0;
        while(n--){
            long long a;
            scanf("%lld", &a)==1;
            if(a%2==1) odds++;
            //else odds++;
        }
        if(odds%2==0){
           /* odds>>=1;
            evens+=odds;
            evens%=2;
            if(evens==0 || odds==0) */ printf("YES\n");
           // else printf("NO\n");
        }
        else{
            /*odds>>=1;
            evens+=odds;
            odds=1;
            if(evens%2==0)  printf("YES\n");*/
            printf("NO\n");
        }
    }
return 0;
}

Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Thu Mar 12 07:52:52 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N, M, X = na()
X -= 1
a = na()
b = [0] * N
for i in range(M):
    b[a[i] - 1] = 1

l, r = 0, 0
for i in range(N):
    if i < X:
        l += b[i]
    else:
        r += b[i]

print(min(l, r))

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

int main(){
    string T;
    cin >> T;
    for(int64_t i = 0; i < T.size(); i++){
        if(T.at(i) == '?'){
            T.at(i) = 'D';
        }
    }
    cout << T << endl;
}


Measured memory_bytes: 3756
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL K;
	in >> K;

	std::vector<LL>ans;
	if (K == 0) ans.resize(2, 1);
	else if (K == 1)
	{
		ans.push_back(0);
		ans.push_back(3);
	}
	else if (K <= 50) ans.resize(K, K);
	else
	{
		LL def = 49 + K / 50;
		ans.resize(50, def);
		rep(i, K % 50) ans[i] += 51 - K % 50;
		rep(i, 50 - K % 50) ans[(K % 50) + i] -= K % 50;
	}

	out << ans.size() << std::endl;
	rep(i, ans.size()) out << ans[i] << (i < ans.size() - 1 ? " " : "\n");
	return 0;
}


Measured memory_bytes: 256
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.14159265358979323846
#define setprc(x) setprecision(x)
void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld a,lld b){//return (x%mod+mod)%mod;
long long int r = a % b;
    return r < 0 ? r + b : r;
}
// cout<<fixed<<setprecision(20)
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
const int maxi = 1e6+10;
vector<lld> v[maxi];
vector<lld> h(maxi);
vector<long long> a(maxi,0);
lld res=0;
void dfs(int x){
    if(a[x]){
        return;
    }
    a[x]=1;
    int flag=1;
    for(int i:v[x]){
        if(h[x]<=h[i]){
            flag=0;
            break;
        }
    }
    if(flag){
        ++res;
    }
}

void test_case(){
    lld x;
    cin>>x;
    for(int i=-150;i<151;++i){
        for(int j=-150;j<151;++j){
            if(pow(i,5)-pow(j,5) == x){
                cout<<i<<" "<<j;
                return;
            }
        }
    }
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}


Measured memory_bytes: 42136
import sys

def main():
    input = sys.stdin.readline
    A, B = map(int, input().split())
    
    if A == B:
        return 'Draw'
    elif A == 1:
        return 'Alice'
    elif B == 1:
        return 'Bob'
    elif A > B:
        return 'Alice'
    else:
        return 'Bob'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
import collections
H,W=map(int,input().split())
went=[[False]*W for i in range(H)]
queue=collections.deque()
for hoge in range(H):
    for huga,t in enumerate(input()):
        if t=="#":
            went[hoge][huga]=True
            queue.append([hoge,huga,0])
while queue:
    curx,cury,ct=queue.popleft()
    for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
        newx,newy=curx+dx,cury+dy
        newct=ct+1
        if 0<=newx<H and 0<=newy<W and (not went[newx][newy]):
            went[newx][newy]=True
            queue.append([newx,newy,newct])
print(ct)

Measured memory_bytes: 147420
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;
int main(){
    fastio
    int x ; 
    cin >> x ; 
    cout << x * x << endl;
    return 0 ; 
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, x;
    cin >> N >> x;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    sort(all(A));
    int ans = 0;
    rep(i, N) {
        if(A[i] <= x) {
            ans++;
            x -= A[i];
        }
        else {
            break;
        }
    }
    if(ans == N && x > 0) {
        ans--;
    }
    output(ans);
    
    return 0;
}


Measured memory_bytes: 256
def main():
    S_p = input()
    T = input()
    N = len(T)

    str_list = [S_p[i:i+N] for i in range(len(S_p)-N+1)]
    str_candidate = []
    # itemはstr_listの中の一つ
    for i, item in enumerate(str_list):
        # Tとの比較を行い，等しければその部分を使った文字列をcandidateに入れる．
        for j, check_str in enumerate(item):
            if check_str == "?" or check_str == T[j]:
                pass
            else:
                break
            # 次の等式が満たせれば全ての文字が等しかったと判断
            if j+1 == N:
                str_candidate.append(S_p[:i]+T+S_p[i+N:])
    if len(str_candidate) == 0:
        print("UNRESTORABLE")
        return None
    str_result = []
    for item in str_candidate:
        str_result.append(item.replace("?", "a"))
    str_result.sort()
    print(str_result[0])
    return None

if __name__ == "__main__":
    main()

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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 1) cout << "IMPOSSIBLE\n";
	else cout << (a + b) / 2 << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



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

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int N;
    cin >> N;
    bool b = false;
    int count=0;
    for(int i=0;i<N;i++){
        int D1,D2;
        cin >>D1 >> D2;
        if(D1==D2){
            count++;
        }else{
            count = 0;
        }
        if(count>=3){
            b=true;
        }
    }
    if(b==false){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int N;
    cin >> N;
    cout << (N+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    print(max(a*b,a+b,a-b))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3316
n = input()
a = map(int, raw_input().split())


z = []
if max(a) > -min(a):
	r = a.index(max(a))
	for i in range(n):
		if i != r:
			a[i] += a[r]
			z.append((r, i))
	for i in range(n - 1):
		z.append((i, i + 1))
else:
	r = a.index(min(a))
	for i in range(n):
		if i != r:
			a[i] += a[r]
			z.append((r, i))
	for i in range(n - 1)[::-1]:
		z.append((i + 1, i))

print len(z)
for x, y in z:
	print x + 1, y + 1

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

public class Main {
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		while(true)
		{
			int n = sc.nextInt();
			if(n == 0)break;
			int seiseki[][] = new int[n][5];
			int sum[] = new int[n];
			for(int i = 0; i < n; i++)
			{
				sum[i] = 0;
				for(int j = 0; j < 5; j++)
				{
					seiseki[i][j] = sc.nextInt();
					sum[i] += seiseki[i][j];
				}
			}
			Arrays.sort(sum);
			System.out.println(sum[n-1] + " " + sum[0]);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=2e5+10;

int N,pos=-1;
vector<int> G[MAX_N];
bool seen[MAX_N],finished[MAX_N];
stack<int> hist;
set<int> cycle;
int par[MAX_N],grundy[MAX_N][2];

void dfs1(int v){
    seen[v]=true; hist.emplace(v);
    for (int u:G[v]){
        if (finished[u]) continue;
        if (seen[u]&&!finished[u]){
            pos=u; return;
        }
        dfs1(u);
        if (~pos) return;
    }
    finished[v]=true; hist.pop();
}

void dfs2(int v,int p){
    set<int> mex;
    for (int u:G[v]){
        if (u==p) continue;
        if (p<0&&cycle.count(u)) continue;
        dfs2(u,v);
        mex.emplace(grundy[u][0]);
    }
    if (~p){
        for (int i=0;;++i){
            if (!mex.count(i)){
                grundy[v][0]=i;
                break;
            }
        }
    } else {
        int ok=0;
        for (int i=0;;++i){
            if (!mex.count(i)){
                if (ok){grundy[v][1]=i; break;}
                else {grundy[v][0]=i; ok=1;}
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    for (int i=0;i<N;++i){
        cin >> par[i];
        G[--par[i]].emplace_back(i);
    }
    for (int i=0;i<N;++i){
        if (!seen[i]) dfs1(i);
        if (~pos) break;
    }
    while(!hist.empty()){
        int t=hist.top(); hist.pop();
        cycle.emplace(t);
        if (t==pos) break;
    }
    for (int v:cycle) dfs2(v,-1);
    int s=*cycle.begin();
    for (int i=0;i<2;++i){
        vector<int> res(N);
        int now=s; res[s]=grundy[s][i];
        while(par[now]!=s){
            int p=par[now];
            res[p]=(res[now]==grundy[p][0]?grundy[p][1]:grundy[p][0]);
            now=p;
        }
        if ((res[now]==grundy[s][0])==i){
            cout << "POSSIBLE" << '\n';
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << '\n';
}

Measured memory_bytes: 31872
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n, t; cin >> n >> t;

  int ans = 0;
  int before = INT_MIN/2;
  rep(i, n) {
    int x; cin >> x;
    ans += min(x - before, t);
    before = x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import sys

read = sys.stdin.readline

N = int(read())
A = list(map(int, read().split()))
B = list(map(int, read().split()))

d = [i - j for i, j in zip(A, B)]
d.sort()
if d[0] >= 0:
    print(0)
    exit()

n = 0
below = 0
for i in d:
    if i < 0:
        below += i
        n += 1
    else:
        break

for i in d[::-1]:
    below += i
    n += 1
    if below > 0:
        print(n)
        exit()
else:
    print(-1)

Measured memory_bytes: 18652
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int a, b, c, k;
	cin >> a >> b >> c >> k;
	if(a >= k){
		cout << k << endl;
	}else if((k - a) <= b){
		cout << a << endl;
	}else{
		cout << 2 * a + b - k << endl;
	}
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
	 
	static String str;
	
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int n=cin.nextInt();double D=0;
		List<Integer> xa=new ArrayList<>(),ya=new ArrayList<>();
		
		for(int i=0;i<n;i++) xa.add(cin.nextInt());
		for(int i=0;i<n;i++) ya.add(cin.nextInt());
		
		for(int i=0;i<n;i++) D+=Math.abs(xa.get(i)-ya.get(i));
		System.out.println(D);
		D=0;
		
		for(int i=0;i<n;i++) D+=Math.pow(xa.get(i)-ya.get(i),2);
		System.out.println(Math.sqrt(D));
		D=0;
		
		for(int i=0;i<n;i++) D+=Math.pow(Math.abs(xa.get(i)-ya.get(i)),3);
		System.out.println(Math.cbrt(D));
		D=0;
		
		for(int i=0;i<n;i++) D=Math.max(Math.abs(xa.get(i)-ya.get(i)), D);
		System.out.println(D);
	}
	
	
	
}


Measured memory_bytes: 26580
#include<iostream>
#include<string>
#include<cmath>
using namespace std;

int main() {
  string s;
  cin >> s;

  int minval = 1e9;
  for (int i = 0; i < s.length() - 2; ++i) {
    int val = abs(753 - stoi(s.substr(i, 3)));
    if (val < minval) minval = val;
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    char s[11];
    int sn,sum;
    int i=0;
    int result=1000;
    cin>>s;
    sn=strlen(s);
    while(sn-i>=3){
        sum=0;
        sum=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        result=min(abs(753-sum),result);
        i++;
    }
    cout<<result<<"\n";
    return 0;
}


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

int f(int m, int a) {
	return m % a;
}

int main() {
	int n; cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		res += a[i] - 1;
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define INFTY 1000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim();


int n,M[MAX][MAX];

int main(){
  int a,e,i,j;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

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

  return 0;
}

int prim(){
  int i,u,v,minv;
  int sum=0;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
      for(v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum += M[i][p[i]];
  }
  return sum;
}




Measured memory_bytes: 2080
#include <iostream>

using namespace std;

int main(){
    int result;
    int book;
    for(int i = 0; i < 5; i++){
    cin >> result; //総額
    for(int i = 0; i < 9; i++){
        cin >> book;
        result = result - book;
    }
    cout << result << endl;
    }
}


Measured memory_bytes: 3076
N=int(input())
wlist=list(map(int,input().split()))

diff_min = 99999
for i in range(0,N-1):
  sum1 = sum(wlist[:i+1])
  sum2 = sum(wlist[i+1:])
  diff = abs(sum1-sum2)
  #print(diff)
  if diff < diff_min:
    diff_min = diff
    
print(diff_min)

Measured memory_bytes: 3060
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let n = input!(usize);
    let a_list = input!(i64; n);
    let mut b_list = a_list
        .iter()
        .enumerate()
        .map(|(i, x)| x - (i as i64 + 1))
        .collect::<Vec<i64>>();
    b_list.sort();

    let median = if n % 2 == 0 {
        (b_list[n/2-1] + b_list[n/2]) / 2
    } else {
        b_list[n/2]
    };

    let result = b_list
        .iter()
        .map(|x| (x - median).abs())
        .fold(0, |acc, x| acc + x);
    println!("{}", result);
}

Measured memory_bytes: 10492
n=int(input())-1

k=1

while n-26**k>=0:
    n=n-26**k
    k+=1

seq=[]
for i in range(k):
    seq.append(chr(ord("a")+n%26))
    n=n//26

seq.reverse()
s=""


for i in range(k):
    s+=seq[i]

print(s)

Measured memory_bytes: 9160
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n;
    cin >> n;
    VL a(n);
    REP(i,n) a[i] = in();
    REP(i,n){
        if (a[i] % 2){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}


Measured memory_bytes: 1152
import math

a,b,C = (int(x) for x in input().split())

S = a * b * math.sin(math.radians(C)) / 2
L = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(C))) + a + b
h = b * math.sin(math.radians(C))

print(round(S,8),round(L,8),round(h,8))


Measured memory_bytes: 5724
#include <bits/stdc++.h>
#define ri register int
using namespace std;
const int rlen = 1 << 20 | 5;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin))), ib == ob ? -1 : *ib++)
#define pb push_back
#define rez resize
#define fi first
#define se second
typedef long long ll;
typedef pair <int, int> pii;
inline int read() {
  static int ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return ans;
}
inline ll readl() {
  static ll ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return ans;
}
const int N = 2e5 + 5;
int n, ft[N];
ll m;
inline int find(int x) { return x ^ ft[x] ? ft[x] = find(ft[x]) : x; }
vector <pii> e;
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  n = read(), m = readl();
  for (ri i = 1; i <= n; ++i) ft[i] = i;
  for (ri tt = read(), u, v, c; tt; --tt) {
    u = read() + 1, v = read() + 1, c = read();
    if(!c) {
      u = find(u), v = find(v);
      if (u ^ v) ft[v] = u;
    }
    else e.pb(pii(u, v));
  }
  int ct = 0;
  for (ri i = 1; i <= n; ++i) if (find(i) == i) ++ct;
  for (ri i = 0; i < e.size(); ++i) if (find(e[i].fi) == find(e[i].se)) return cout << "No", 0;
  ll L, R;
  if (e.size()) L = max(3ll, (ll) ct);
  else L = ct - 1;
  R = (ll) ct * (ct - 1) / 2;
  m -= (n - ct);
  if (L <= m && m <= R) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 5508
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
	double x = 0, y = 0;
	int d = 90;
	int a, b;

	while (true)
	{
		scanf("%d,%d", &a, &b);
		if (a + b == 0) break;
		x += a * cos(d * 3.14159 / 180);
		y += a * sin(d * 3.14159 / 180);
		d -= b;
	}
	printf("%d\n", (int)x);
	printf("%d\n", (int)y);

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans;
  if(s=="SUN") ans = 7;
  if(s=="MON") ans = 6;
  if(s=="TUE") ans = 5;
  if(s=="WED") ans = 4;
  if(s=="THU") ans = 3;
  if(s=="FRI") ans = 2;
  if(s=="SAT") ans = 1;

  cout << ans << endl;
}

Measured memory_bytes: 256
#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 clr cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container) (container).begin(), (container).end()
#define rall(container) (container).rbegin(), (container).rend()
#define FILL(x, val) memset(x, val, sizeof(x))
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

using namespace std;

typedef long long i64; 
typedef vector<int> vi;
typedef vector<i64> vi64;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

int main(void) {
	string str; cin >> str;
	stack<int> s; vi ans;
	for (char x: str) {
		if (x == '1') s.push(1);
		else if (x == '0') s.push(0);
		else if (!s.empty()) s.pop();
	}
	while (!s.empty()) {
		ans.emplace_back(s.top());
		s.pop();
	} reverse(all(ans));
	for (int x : ans) cout << x;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n; cin >> n;

  for(int i=1;i<=9;i++){
    if(n%i==0){
      int q = n/i;
      int d = i;
      if(q>=1&&q<=9&&i>=1&&i<=9){
        cout << "Yes\n";
        return 0;
      }
    }
  }

  cout << "No\n";
  


  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var S, T, U string
	fmt.Scan(&S, &T)
	var A, B int
	fmt.Scan(&A, &B)
	fmt.Scan(&U)
	if U == S {
		fmt.Println(A-1, B)
	} else {
		fmt.Println(A, B-1)
	}

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

llong dp[102][100005];
int main() {
   int N, W;
   cin >> N >> W;
   vector<int> w(N), v(N);
   rep(i, N) cin >> w[i] >> v[i];

   rep(i, N) {
      rep(j, W + 1) {
         if (j - w[i] >= 0)
            dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
         else
            dp[i + 1][j] = dp[i][j];
      }
   }
   cout << dp[N][W] << endl;
   return 0;
}

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

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

  int s = N - N / 1000 * 1000;

  if(s %111 == 0 || N / 10 % 111 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    cout << N / 3 << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

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

    rep(i,m)n-=a[i];
    cout<<max(-1,n)<<endl;

    return 0;
}


Measured memory_bytes: 3676
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a1 = int.Parse(str[0]);
            int a2 = int.Parse(str[1]);
            int a3 = int.Parse(str[2]);
            int num = a1 + a2 + a3;
            if (num >= 22) Console.WriteLine("bust");
            else Console.WriteLine("win");
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

struct UnionFind {
	vector<int> par, rank, siz;
	UnionFind(int n): par(n), rank(n,0), siz(n,1) {
		rep(i,n) par[i] = i;
	}
	int find(int x) {
		return par[x] == x? x: par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		else {
			if (siz[x] < siz[y]) swap(x, y);
			siz[x] += siz[y];
			par[y] = x;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return siz[find(x)];
	}
};

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<set<int>> v(n);
	UnionFind uf(n);
	rep(i,m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		uf.unite(a, b);
		v[a].insert(b);
		v[b].insert(a);
	}
	rep(i,k) {
		int c, d;
		cin >> c >> d;
		c--, d--;
		if (!uf.same(c, d)) continue;
		v[c].insert(d);
		v[d].insert(c);
	}
	rep(i,n) {
		if (i != 0) cout << " ";
		cout << uf.size(i) - v[i].size() - 1;
	}
	cout << endl;
}

Measured memory_bytes: 27800
#include <stdio.h>
#define maxn 105
int a[5][5],b[maxn],c[5][5];
int main()
{
    int i,j,n,k,flag=0;
    for(i=1; i<=3; i++)
        for(j=1; j<=3; j++)
            scanf("%d",&a[i][j]);
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        scanf("%d",&b[i]);
    for(i=1; i<=n; i++)
        for(j=1; j<=3; j++)
            for(k=1; k<=3; k++)
                if(b[i]==a[j][k])
                    c[j][k]=1;
    for(i=1; i<=3; i++)
        if(c[i][1]==1&&c[i][2]==1&&c[i][3]==1)
            flag=1;
    for(j=1; j<=3; j++)
        if(c[1][j]==1&&c[2][j]==1&&c[3][j]==1)
            flag=1;
    if(c[1][1]==1&&c[2][2]==1&&c[3][3]==1)
        flag=1;
    if(c[1][3]==1&&c[2][2]==1&&c[3][1]==1)
        flag=1;
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 128
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  a, b, c, d = input_list()
  dc = b // c
  dd = b // d
  dcd = b // (lcm_base(c,d))
  bb = b - dc - dd + dcd
  
  ac = (a-1)//c
  ad = (a-1)//d
  acd = (a-1)//(lcm_base(c,d))
  aa = (a-1) - ac - ad + acd
  
  print(bb-aa)
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

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

const int MAX_V = 1000000;
int ranks[MAX_V];
int parents[MAX_V];
int num[MAX_V];

// 初期化
void init(int n){
    for (int i = 0; i < n; i++){
        parents[i] = i;
        ranks[i] = 0;
        num[i] = 1;
    }
}

// 探索
int root(int x){
    if(parents[x] == x) return x;
    else{
        parents[x] = root(parents[x]);
        return parents[x];
    }
}

// 木の統合
void unite(int x, int y){
    // xとyの親を探索し，親レベルでの統合を考える
    x = root(x);
    y = root(y);
    if(x == y) return;
    num[x] += num[y];
    num[y] = num[x];

    if(ranks[x] > ranks[y]){
        parents[y] = parents[x];
    }else{
        parents[x] = parents[y];
        if(ranks[x] == ranks[y]) ranks[x]++;
    }
}

// 同一の木かどうか
bool same(int x, int y){
    return root(x) == root(y);
}

int get_num(int x) {
    return num[root(x)];
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> a.at(i) >> b.at(i);
        a.at(i)--;
        b.at(i)--;
    }
 
    init(n);
 
    vector<long long> ans(m);
    long long cnt = (long long)n * (n - 1) / 2;
    ans.at(m - 1) = cnt;
    for (int i = m - 1; i >= 1; i--) {
        if (!same(a.at(i), b.at(i))) {
            cnt -= (long long)get_num(a.at(i)) * get_num(b.at(i));
            unite(a.at(i), b.at(i));
        }
        ans.at(i - 1) = cnt;
    }
 
    for (int i = 0; i < m; i++) {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 11520
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();
    for num in a {
        if num % 2 == 0 {
            if num % 3 != 0 && num % 5 != 0 {
                println!("DENIED");
                return;
            }
        }
    }
    println!("APPROVED");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<vector>
#include<iostream>
#include <string>

using namespace std;

int s(string n){
  int ret = 0;
  for (auto it = n.begin(); it != n.end(); ++it){
    ret += *it - '0';
  }
  return ret;
}


bool test(string n, int keta){
  int intn = stoi(n.substr(0,n.size()-keta));
  int sint = s(n);
  if (keta!=0) ++intn;
  return sint >= intn;
}

int main(){
  int K;
  cin >> K;
  string bgn = "";
  int counter = 1;
  int keta = 0;
  int cnt =0;
  
  while(cnt < K){
    
    string res = to_string(counter)+bgn;
    if (test(res, keta)){
      cout << res << endl;
      ++counter;
      ++cnt;
    }else{
      ++keta;
      bgn+='9';
      counter /= 10;
    }
  }
  return 0;
}

Measured memory_bytes: 256