akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

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


class DFriendSuggestions {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, M, K;
        cin >> N >> M >> K;

        UnionFind uf(N);
        map<int, set<int>> fr, br;
        REP(i, M) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            fr[a].insert(b);
            fr[b].insert(a);
            uf.unite(a, b);
        }
        vector<int> minus(N);
        REP(i, K) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            br[a].insert(b);
            br[b].insert(a);
            if (uf.same(a, b)) {
                minus[a]++;
                minus[b]++;
            }
        }
        REP(i, N) {
            int res = uf.size(i);
            cout << res - fr[i].size() - minus[i] - 1 << " ";
        }
        cout << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DFriendSuggestions solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 40192
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
 
long double pi = 3.141592653589793238462643;
vector<pair<int, int>>p;
long double len(vector<int>num){
	ll x = 0;
	ll y = 0;
	fore(z, num) {
		x += p[z].first;
		y += p[z].second;
	}
	return sqrt(x*x + y*y);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
 
	int N;
	cin >> N;
	p.resize(N);
	for (int i = 0; i < N; i++)cin >> p[i].first >> p[i].second;
 
	long double ans = 0.0;
	for (int i = 0; i < 100000; i++) {
		long double c = cos((2.0*(long double)i*pi)/(long double)10000);
		long double s = sin((2.0*(long double)i*pi)/(long double)10000);
		vector<int>temp;
		for (int j = 0; j < N; j++) {
			long double x = p[j].first;
			long double y = p[j].second;
			if (x*c + y*s >= 0.0)temp.pb(j);
		}
		ans = max(ans, len(temp));
	}
	cout << setprecision(20) << ans << endl;
	return 0;
}

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

int main()
{
    long long n,m,d;
    cin >> n >> m >> d;
    double ans = 0.0;
    if(d == 0){
        ans = (double)(m-1)/(double)n;
        cout << ans << endl;
        return 0;
    }
    double a = (n-d)*2.0/pow(n,2);
    cout << fixed << setprecision(10) << a * (double)(m-1) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int quant = sc.nextInt();

        Queue<TimeTask> que = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            que.add(new TimeTask(sc.next(), sc.nextInt()));
        }
        
        int timePoint = 0;
        while (!que.isEmpty()) {
            TimeTask head = que.poll();

            if (head.time > quant) {
                timePoint += quant;
                head.addTime(-quant);
                que.add(head);
                
            } else {
                timePoint += head.time;
                System.out.println(head.task + " " + timePoint);
            }
        }
    }
    
    static class TimeTask {
        String task;
        int time;
        TimeTask (String task, int time) {
            this.task = task;
            this.time = time;
        }
        
        void addTime(int add) {
            time += add;
        }
    }
}


Measured memory_bytes: 78984
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int[] lastCounts = new int[1001];
        while (true) {
            String line = reader.readLine();
            if (line.isEmpty()) {
                break;
            }
            String[] values = line.split(",");
            int number = Integer.parseInt(values[0]);
            lastCounts[number]++;
        }
        int[] thisCounts = new int[1001];
        while (true) {
            String line = reader.readLine();
            if (line == null) {
                break;
            }
            String[] values = line.split(",");
            int number = Integer.parseInt(values[0]);
            thisCounts[number]++;
        }
        for (int i = 1; i <= 1000; i++) {
            if (lastCounts[i] > 0 && thisCounts[i] > 0) {
                out.println(i + " " + (lastCounts[i] + thisCounts[i]));
            }
        }
    }
}

Measured memory_bytes: 9224
"use strict";
    
const main = arg => {
    const S  = arg.split("\n")[0].split("");
    let answer = [];
    
    for(let i in S) {
        if(i % 2 === 0) answer.push(S[i]);
    }
    
    console.log(answer.join(""));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 18632
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

const int MAX_LIMIT = 100005;
long long N;
long long arr[MAX_LIMIT];

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

	long long cnt = 0;
	for(int i = 0; i < N; i++) {	 
		while(arr[i] % 2 == 0) {
			arr[i] = arr[i] / 2;
			cnt++;
		}
	
	}
	printf("%lld\n", cnt);
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 5e5 + 5;
int BIT[MAX], ind[MAX], arr[MAX], ans[MAX];
vector <int> ql[MAX], qid[MAX];
void upd(int i, int val)
{
	for(; i < MAX; i += i&-i)
	BIT[i] += val;
}
int qry(int i)
{
	int sum = 0;
	for(; i; i -= i&-i)
	sum += BIT[i];
	return sum;
}
int main()
{
	boost;
	int n, q, i, l, r;
	cin >> n >> q;
	foe(i, 1, n)
	cin >> arr[i];
	
	fo(i, 0, q) {
		cin >> l >> r;
		ql[r].pb(l);
		qid[r].pb(i);
	}
	
	foe(i, 1, n) {
		if(ind[arr[i]] > 0) upd(ind[arr[i]], -1);
		upd(i, 1);
		ind[arr[i]] = i;
		for(int j = 0; j < ql[i].size(); j++)
		ans[qid[i][j]] += qry(i) - qry(ql[i][j] - 1);
	}
	fo(i, 0, q)
	cout << ans[i] << '\n';
}


Measured memory_bytes: 52984
let rec gcd n m =
  if m = 0 then n
  else gcd m (n mod m)

let () = Scanf.scanf "%d %d\n" @@ fun n x ->
  let xs = Array.init n @@ fun _ ->
    Scanf.scanf "%d " @@ fun x -> x in
  Printf.printf "%d\n" @@ Array.fold_right (fun x' -> gcd @@ abs @@ x' - x) xs 0


Measured memory_bytes: 3456
n = int(input())
x = [int(_) for _ in input().split()]

y = range(n)

z = [[x[i],y[i],0] for i in range(n)]

z.sort(key = lambda t:t[0])
for i in range(n):
    if i < int(n/2):
        z[i][2] = z[int(n/2)][0]
    else:
        z[i][2] = z[int(n/2)-1][0]
z.sort(key = lambda t:t[1])
for i in range(n):
    print(z[i][2])

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

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

    int n;
    cin >> n;
    int a = 0; // ooooA
    int b = 0; // Boooo
    int c = 0; // BoooA

    int ans = 0;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        int ss = s.size() - 1;
        if(s[0] == 'B' and s[ss] == 'A') c++;
        else if(s[0] == 'B') b++;
        else if(s[ss] == 'A') a++;
        for(int j = 0; j < ss - 1; j++){
            if(s[j] == 'A' and s[j + 1] == 'B'){
                ans++;
            }
        }
    }

    if(c == 0) ans += min(a, b);
    else if(a == 0 and b == 0 and c > 0) ans += c - 1;
    else ans += c + min(a, b);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int x;
  scanf("%d", &x);
  int i, j, flag;
  i = x;
  if(x == 2){
    printf("%d", 2);
    return 0;
  }
  while(1){
    flag = 0;
    for(j=2; j<x; j++){
      if(i%j == 0){
        flag = 1;
      }
    }
    if(flag == 0){
      printf("%d", i);
      return 0;
    }
    i++;
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x[10]={inf,2,5,5,4,5,6,3,7,6};
    int n,m;cin >> n >> m;
    vector<bool> b(10);
    rep(i,0,m){
        int a;cin >> a;
        b[a]=true;
    }
    vector<vector<bool>> dp(n+1,vector<bool>(n/2+1));
    dp[0][0]=true;
    rep(i,0,n){
        rep(j,0,n/2+1){
            if(!dp[i][j]){
                continue;
            }
            rep(k,1,10){
                if(i+x[k]<=n&&b[k]){
                    dp[i+x[k]][j+1]=true;
                }
            }
        }
    }
    int t=0;
    rep(i,0,n/2+1){
        if(dp[n][i]){
            chmax(t,i);
        }
    }
    vector<int> ans;
    int now=n;
    rrep(i,t-1,0){
        rrep(j,9,1){
            if(b[j]&&now-x[j]>=0&&dp[now-x[j]][i]){
                ans.push_back(j);
                now-=x[j];
                break;
            }
        }
    }
    for(int v:ans){
        cout << v;
    }
    cout << endl;
}

Measured memory_bytes: 10012
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
#include <fstream>
using namespace std;

int main()
{
    //  freopen("timber_input.txt", "r", stdin);
   // freopen("out3_test.txt", "w", stdout);
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--) {
    ll n,i,j,w;
    cin>>n>>w;
    ll arr[n+1],brr[n+1],crr[n+1],dp[n+5][w+5];

    for(i=0;i<n;i++)
        cin>>arr[i]>>brr[i];
    for(i=0;i<=n;i++)
        dp[i][0]=0;
    for(i=0;i<=w;i++)
        dp[0][i]=0;

    for(j=1;j<=w;j++)
    {
         for(i=1;i<=n;i++)
        {
            if(arr[i-1]>j)
                dp[i][j]=dp[i-1][j];
                else
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-arr[i-1]]+brr[i-1]);
        }
    }
    cout<<dp[n][w];
    }

}


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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  vector<int> vec(5);
  for(int i=0;i<5;i++)cin >> vec.at(i);

  int min_sup=10;
  for(int i:vec)if(i%10)min_sup = min(min_sup,i%10);

  int ans=0;
  for(int i:vec)ans += ((i+9)/10)*10;
  cout << ans+min_sup-10 << endl;
}

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

int main() {
  int n,c,k;
  cin >> n >> c >> k;
  vector<int>t(n);
  rep(i,0,n) cin >> t[i];
  sort(t.begin(),t.end());
  int cnt = 0,s = t[0],cn = 0;
  rep(i,0,n){
    if(t[i] > s+k || cn >= c){
      cnt++;
      cn = 0;
      s = t[i];
    }
    cn++;
  }
  if(cn != 0)cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))

if n > 0 and a[0] != 0: print(-1); exit()

s = [0] * (n+2)
for i in range(n+1)[::-1]:
    s[i] = s[i+1]+a[i]

x = 1
ans = 0
for i in range(n+1):
    ans += x
    if x == s[i]:
        x -= a[i]
        continue
    x -= a[i]
    if (x <= 0 and i != n) or x < 0: print(-1); exit()
    if x*2 >= s[i+1]: x = s[i+1]
    else: x *= 2

print(ans)


Measured memory_bytes: 20100
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll a, b; string op;
    cin >> a >> op >> b;
    ll ans = (op == "+") ? (a + b) : (a - b);
    cout << ans<< endl;
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;

int main(){
    int a; cin >> a;
    string ans; cin >> ans;

    if(a>=3200){
        cout << ans;
    }else{
        cout << "red";
    }
    return 0;


}




Measured memory_bytes: 256
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
const long long MOD = 2;

int main(){
  ll N,M;
  cin >> N >> M;
  vector<vector<ll>>s(M);
  for (int i = 0; i < M; i++) {
    ll k;
    cin >> k;
    for (int l = 0; l < k; l++) {
      ll x;
      cin >> x;
      s[i].pb(x);
    }
  }
  vector<int>p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  ll ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    ll light=0;
    for (int i = 0; i < M; i++) {
      ll c = 0;
      for(auto x : s[i]){
        if(bit & (1 << x-1))c++;
      }
      if(c%2 == p[i])light++;
    } 
    if(light == M)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
int main(){
  ll n;
  cin >>n;

  ll ans = 20000000000000;
  for(ll i = 1; i*i <= n;i++){
    ll a = i;
    ll b = 0;
    if(n%a != 0){
      continue;
    }else{
      b = n/a;
      ll tmp = a + b -2;
      ans = min(ans, tmp);
    }
  }

  cout << ans << endl;
}

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

int main() {
    long long int k, a, b, biscuit, n;
    cin >> k >> a >> b;
    k+=1;
    if((a+2)>=b || k<a+2){
        biscuit=k;
    }else{
        n = (k-a)/2;
        biscuit = n*(b-a)+(k-a)%2+a;
    }
    cout << biscuit << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_picture_frame(void) {
	int h, w;
	char a[110][110];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	
	for (int i = 0; i < (h + 2); i++) {
		for (int j = 0; j < (w + 2); j++) {
			if ((i == 0) || (i == h + 1)) cout << "#";
			else if ((j == 0) || (j == w + 1)) cout << "#";
			else cout << a[i - 1][j - 1];
		}
		cout << endl;
	}
}


int main()
{
	b_picture_frame();
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi   = vector<int>;
using vll  = vector<ll>;
using vc   = vector<char>;
using vvll  = vector<vll>;
using vvi  = vector<vi>;
using vvc  = vector<vc>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;


int main() {
    string S, T; cin >> S >> T;
    int ans = S.length();

    for (int i = 0; i < S.length(); i++) {
        if (S.at(i) == T.at(i)) ans--;
    }    
    cout << ans << endl;
}

Measured memory_bytes: 3836
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'
using ll = long long;
#define int ll
using db = long double;
using ii = pair<int, int>;

const int N = 1e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
ll a[100005];
ll b[100005];
ll c[100005];
int A,B,C,X,Y;
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  cin >> X >> Y >> A >> B >> C;
  f(i,1,A+1)cin>>a[i];  sort(a+1,a+A+1);  reverse(a+1,a+A+1);
  f(i,1,B+1)cin>>b[i];  sort(b+1,b+B+1);  reverse(b+1,b+B+1);
  f(i,1,C+1)cin>>c[i];  sort(c+1,c+C+1);  reverse(c+1,c+C+1);
  vector<pair<int,int>> vp;
  f(i,1,C+1)c[i]+=c[i-1];
  f(i,1,A+1)vp.push_back({a[i],0});
  f(i,1,B+1)vp.push_back({b[i],1});
  sort(vp.rbegin(),vp.rend());
  int CntA = 0,cntB = 0;
  ll ans = 0;
  if(X+Y<=C)ans=c[X+Y];
  ll curSum = 0;
  for(auto x:vp){
    if(x.S==0){
      if(CntA!=X)CntA++,curSum+=x.F;
    } else {
      if(cntB!=Y)cntB++,curSum+=x.F;
    }
    if(X+Y-CntA-cntB<=C)
    ans=max(ans,curSum+c[X+Y-CntA-cntB]);
  }
  cout<<ans<<"\n";


  return 0;
}


Measured memory_bytes: 8904
// ctrl+shift+b
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    rep(i, 9){
        if (i * 111 < N && N <= (i + 1) * 111){
            cout << (i + 1) * 111 << endl; exit(0);
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main(void){
    int a[3],tmp;
    cin >> a[0] >> a[1] >> a[2];
    for (int i=0; i<2; i++){
        for (int j=i+1; j<3; j++){
            if(a[i]>a[j]){
                tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
    return 0;
}

Measured memory_bytes: 3088
# -*- coding: utf-8 -*-
n = int(input())
al = list(map(int, input().split()))

bl = [0]*n
for i in range(n,0,-1):
    if i*2>n:
        if al[i-1]>0:
            bl[i-1] = 1
        continue

    c = 2
    s = 0
    while i*c<=n:
        s += bl[i*c-1]
        c += 1
    if al[i-1]==1:
        bl[i-1] = 1 if s%2==0 else 0
    else:
        bl[i-1] = 0 if s%2==0 else 1

res = []
for i in range(1,n+1):
    if bl[i-1]>0:
        res.append(i)

print(len(res))
if len(res)>0:
    print(*res)

Measured memory_bytes: 14196
"use strict"
function Main(stdin){
stdin = stdin.trim().split("\n").reverse();
let stdout = [];
function input(){return stdin.pop()};
function maput(){return input().split(" ").map(n=>parseInt(n))};
function print(x){stdout.push(x)};
function exist(x, xs){return new Set(xs).has(x)}
/*START*/


let a1 = maput()
let a2 = maput()
let a3 = maput()
let n = parseInt(input())
let b = [];
for (let i = 0; i < n; i++){ 
    b.push(parseInt(input()))
}
for (let i = 0; i < 3; i++){ 
    if (exist(a1[i], b)){ a1[i] = 1 }else{ a1[i] = 0 }
}
for (let i = 0; i < 3; i++){ 
    if (exist(a2[i], b)){ a2[i] = 1 }else{ a2[i] = 0 }
}
for (let i = 0; i < 3; i++){ 
    if (exist(a3[i], b)){ a3[i] = 1 }else{ a3[i] = 0 }
}
let ans = 0
if (a1[0]+a1[1]+a1[2] == 3){ ans++ }
if (a2[0]+a2[1]+a2[2] == 3){ ans++ }
if (a3[0]+a3[1]+a3[2] == 3){ ans++ }
if (a1[0]+a2[0]+a3[0] == 3){ ans++ }
if (a1[1]+a2[1]+a3[1] == 3){ ans++ }
if (a1[2]+a2[2]+a3[2] == 3){ ans++ }
if (a1[0]+a2[1]+a3[2] == 3){ ans++ }
if (a1[2]+a2[1]+a3[0] == 3){ ans++ }
if (ans > 0){print("Yes")}else(print("No"))


/*END*/
stdout = stdout.join("\n");
console.log(stdout);
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int h,a;
    cin>>h>>a;
    cout << (h+a-1)/a << endl;
    return 0;
}

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

#define int long long
#define ld long double

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>b;i--)

#define pb push_back
#define mp make_pair
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define precise(i) fixed << setprecision(i)
#define fi first
#define se second

#define err() cout<<"\n==================================\n";
#define errA(A) for(auto i:A) cout<<i<<" "; cout<<"\n";
#define err1(a) cout<<#a<<" "<<a<<"\n";
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n";
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<"\n";

const int logN = 20;
const int M = 1000000007;
const int INF = 1e12;
#define PI 3.14159265;
const int N = 200005;

#define Pii pair<int,int>
#define Vi vector<int>
#define Vpii vector<Pii>

void solve()
{
       int n,ans=0;
       cin>>n;
       Vi a(n);
       rep(c,0,n)
       {
              cin>>a[c];
       }
       rep(c,1,n)
       {
              if(a[c]<a[c-1])
              {
                     ans+=(a[c-1]-a[c]);
                     a[c]=a[c-1];
              }
       }
       cout<<ans;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)
    {
           solve();
    }
    return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  if (A+B > C+D) {
  	cout << "Left" << endl;
  }
   else if (A+B < C+D) {
   	cout << "Right" << endl;
   }
   else {
   	cout << "Balanced" << endl;
   }
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007 
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN


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

void solve(){
    ll n,m;
    cin>>n>>m;
    cout<< (( n )*( n-1 ))/2 + (( m )*( m-1 ))/2<<endl; 
    return;
}

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

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

void solve(string s, string t){
    int m = s.size(), n = t.size();
    // string res = "";
    vector<vector<int>> dp(m+1, vector<int>(n+1, 0));
    
    // Filling the dp table
    for(int i = m-1 ; i >= 0 ; i--){
        for(int j = n-1 ; j >= 0 ; j--){
            if(s[i] == t[j]){
                dp[i][j] = 1 + dp[i+1][j+1];
            }
            else{
                dp[i][j] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }
    
    char res[dp[0][0]+1];
    res[dp[0][0]] = '\0';
    int i = 0, j = 0, idx = 0;
    while(i < m && j < n){
        if(s[i] == t[j]){
            res[idx] = s[i];
            i++; j++; idx++;
        }
        else if(dp[i+1][j] > dp[i][j+1]){
            i++;
        }
        else{
            j++;
        }
    }
    
    for(int i = 0 ; i < dp[0][0] ; i++){
        cout << res[i];
    }
}

int main(){
    // INPUT
    string s, t;
    cin >> s;
    cin >> t;
    
    // OUTPUT
    solve(s, t);
}

Measured memory_bytes: 38600
# -*- coding: utf-8 -*-
N, M, X = map(int, input().split())

A, C = [], []
for _ in range(N):
    tokens = list(map(int, input().split()))
    C.append(tokens[0])
    A.append(tokens[1:])

for i in range(M):
    x = sum([a[i] for a in A])
    if x < X:
        print(-1)
        exit()


ans = float('inf')
def solve(buf):
    global ans

    if len(buf) == N:
        can_solve = True
        for i in range(M):
            x = sum([A[j][i] for j in range(N) if buf[j]])
            if x < X:
                can_solve = False
                break

        if can_solve:
            c =  sum([C[j] for j in range(N) if buf[j]])
            ans = min(ans, c)

    else:
        solve(buf + [0])
        solve(buf + [1])

#
solve([])
print(ans)

Measured memory_bytes: 71608
#include<stdio.h>
#include<string.h>
int main(){
	int N,i;
	char s[10000+10];
	scanf("%d",&N);
	scanf("%s",s);
	int len = strlen(s);
    for(i = 0;i < len;i++){
    	s[i] = (s[i]+N-'A')%26+'A';
	}
	printf("%s",s);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

template<class T>
ostream& operator<<(ostream& os, const vector<T>& vs) {
    if (vs.empty()) return os << "[]";
    os << "[" << vs[0];
    for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
    return os << "]";
}
 
const double EPS = 1e-7;

struct Point {
    double x, y;
    Point() {}
    Point(double x, double y) : x(x), y(y) {}
    Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
    Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
    Point operator*(double k) const { return Point(k * x, k * y); }
    Point operator/(double k) const { return Point(x / k, y / k); }
};
double dot(const Point& a, const Point& b) { return a.x * b.x + a.y * b.y; }
double cross(const Point& a, const Point& b) { return a.x * b.y - a.y * b.x; }
double norm(const Point& a) { return sqrt(dot(a, a)); }
Point rot90(const Point& p) { return Point(p.y, -p.x); } // 時計回りに90度回転 
ostream& operator<<(ostream& os, const Point& p) { return os << "(" << p.x << "," << p.y << ")"; }
istream& operator>>(istream& is, Point& p) { return is >> p.x >> p.y; }

typedef vector<Point> Polygon;
double area(const Polygon& vs) {
    assert(vs.size() >= 3);
    double r = 0;
    for (int i = 0; i < vs.size(); i++) {
        const Point& a = vs[i];
        const Point& b = vs[(i + 1) % vs.size()];
        r += cross(a, b);
    }
    return r / 2;
}

int main() {
    int N; cin >> N;
    Polygon P(N);
    for (int i = 0; i < N; i++) cin >> P[i];
    cout << fixed << setprecision(1) << area(P) << endl;
    return 0;
}

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

#define N_MAX 100000

using namespace std;

int main(){
    int n;
    int odd[N_MAX+1] = {0};
    int even[N_MAX+1] = {0};
    int max_even = 2;
    int max_odd = 1;
    cin >> n;
    for(int i = 0; i < n; i++){
        int v;
        cin >> v;
        if(i%2 == 0)odd[v]++;
        else even[v]++;
    }
    for(int i = 1; i <= N_MAX; i++){
        if(even[i] > even[max_even]) max_even = i;
        if(odd[i] > odd[max_odd]) max_odd = i;
    }
    if(max_even != max_odd){
        cout << n - even[max_even] - odd[max_odd] << endl;
    }else{
        sort(odd, odd+N_MAX+1, greater<int>());
        sort(even, even+N_MAX+1, greater<int>());
        int tmp = max(even[0]+odd[1], even[1]+odd[0]);
        cout << n - tmp << endl;
    }
}

Measured memory_bytes: 1024
//============================================================================
// Name        : test1.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int n;

	cin >> n;

	int h[100];
	for(int i=0;i<n;++i) cin >> h[i];

	int count = 1;
	int max = h[0];
	for(int i=1;i<n;++i){
		if(h[i]-max>=0){
			count += 1;
			max = h[i];
		}
	}

	cout << count << endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   string s;
   cin >> s;
   if (s <= "2019/04/30") cout << "Heisei" << endl;
   else cout << "TBD" << endl;

   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve(){
	int n, a; cin >> n >> a;
	cout << n * n - a << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

n, k = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)

mod = 10**9+7
N = 2*10**5
fac = [1]*(N+1)
finv = [1]*(N+1)
for i in range(N):
    fac[i+1] = fac[i] * (i+1) % mod
finv[-1] = pow(fac[-1], mod-2, mod)
for i in reversed(range(N)):
    finv[i] = finv[i+1] * (i+1) % mod

def prm(n, r, mod):
    if r <0 or r > n:
        return 0
    if r == 0:
        return 1
    return fac[n] * finv[n-r] % mod

s = [0]
visit = [-1]*n
visit[0] = 0
ans = 1
while s:
    v = s.pop()
    if v != 0:
        c = len(g[v])-1
        K = k-2
    else:
        c = len(g[v])+1
        K = k
    ans *= prm(K, c, mod)
    ans %= mod
    for u in g[v]:
        if visit[u] == -1:
            visit[u] = 0
            s.append(u)
print(ans)


Measured memory_bytes: 97864
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define p(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}
int n,m,l,r;

void input(){
	cin>>n;
}
ll dp[101];
ll ryuka(int i){
	if(i>n){
		return 0;
	}
	dp[i]=dp[i-1]+dp[i-2];
	ryuka(i+1);
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	dp[0]=2;
	dp[1]=1;
	ryuka(2);
	P(dp[n])
	return 0;
}



Measured memory_bytes: 256
import math


def main():
    depth = int(input())
    leaves = [int(x) for x in input().split()]

    nodes_range = [None] * (depth + 1)
    for i in range(depth, -1, -1):
        if i == depth:
            nodes_range[i] = (leaves[i], leaves[i])
            continue
        min_nodes = math.ceil(nodes_range[i + 1][0] / 2) + leaves[i]
        max_nodes = nodes_range[i + 1][1] + leaves[i]
        nodes_range[i] = (min_nodes, max_nodes)

    if not (nodes_range[0][0] <= 1 <= nodes_range[0][1]):
        # 根が1を取り得ない場合は実現不可能。
        print(-1)
        return

    max_noded_tree = [0] * (depth + 1)
    for i in range(depth + 1):
        if i == 0:
            max_noded_tree[i] = 1
            continue
        max_noded_tree[i] = min(
            (max_noded_tree[i - 1] - leaves[i - 1]) * 2,
            nodes_range[i][1])
    print(sum(max_noded_tree))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 31840
#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int N = 1e5 + 5;
int a[N];
int main()
{
	int n;
	cin>>n;
	for(int i= 0; i < n; i++)
		cin>>a[i];
	int asr = 1;
	int tp = 0;
	for(int i = 1; i < n ; i++)
	{
		if(a[i] > a[i -1])
		{
			if(tp == -1)
			{
				tp = 0;
				asr++;
				continue;
			}
			else if(tp == 0)
			{
				tp = 1;
			}
		}
		else if(a[i] < a[i-1])
		{
			if(tp == 1)
			{
				tp = 0;
				asr++;
				continue;
			}
			else if(tp == 0)
			{
				tp = -1;
			}
		}
	}
	cout<<asr<<endl;
	//system("pause");
}

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

int main() {
  int i, j;
  char prev[3];
  char after[3];
  int prev_num, after_num;

  scanf("%c", &prev[0]);
  scanf("%c", &prev[1]);
  scanf("%c", &after[0]);
  scanf("%c", &after[1]);
  prev[2] = '\0';
  after[2] = '\0';

  prev_num = atoi(prev);
  after_num = atoi(after);

  int p_f, a_f;

  if(prev_num <= 12 && prev_num >= 1){
    p_f = 1;
  }
  else{
    p_f = 0;
  }
  if(after_num <= 12 && after_num >= 1){
    a_f = 1;
  }
  else{
    a_f = 0;
  }

  if (a_f && p_f){
    printf("AMBIGUOUS");
  }
  else if (p_f){
    printf("MMYY");
  }
  else if (a_f) {
    printf("YYMM");
  }
  else{
    printf("NA");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
const double PI = 3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = 1LL << 50;
typedef pair<int, int> P;
const int mod = 1e9 + 7;

struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint &operator+=(const mint a)
    {
        (x += a.x) %= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        (x -= mod - a.x) %= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t % 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        fact[0] = 1;
        for (int i = 1; i < n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] + ifact[n - k];
    }
};

ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

ll gcd(vector<ll> a)
{
    ll ans = 0;
    for (ll i = 0; i < a.size(); ++i)
    {
        ans = gcd(ans, a[i]);
    }
    return ans;
}

int main(){
    int x;
    cin >> x;
    if(x)cout<<0 << endl;
    else cout <<1 << endl;
    return 0;
}

Measured memory_bytes: 3612
import Foundation

extension String {
    
    func toStrList() -> [String] {
        return self.map{String($0)}
    }
    
    func toIntList() -> [Int] {
        return self.map{Int(String($0))!}
    }
    
    func toSepDoubleList() -> [Double]{
        return self.split(separator: " ").map{Double($0)!}
    }

    func toSepIntList() -> [Int] {
        return self.split(separator: " ").map{Int($0)!}
    }

    func toSepStrList() -> [String] {
        return self.split(separator: " ").map{String($0)}
    }
    
    func zFill(n:Int) -> String {
        return String(format: "%0\(n)d", Int(self)!)
    }
    
    func count(c:Character) -> Int{
        var result = 0

        for e in self{
            if e == c{
                result += 1
            }
        }
        return result
    }

    func counter() -> Dictionary<Character, Int>{
        var result:[Character:Int] = [:]
        
        for c in self{
            guard let _ = result.index(forKey: c) else {
                result[c] = 1
                continue
            }
            result[c]! += 1
        }
        return result
    }
}

extension Int {
    func toBin() -> String {
        return String(self, radix: 2)
    }
    
    func toNBin(_ radix:Int) -> String{
        return String(self, radix: radix)
    }
    
    func toD() -> Double {
        return Double(self)
    }
}

extension Double {
    func toI() -> Int {
        return Int(self)
    }
}

extension Array where Element: Equatable{
    func count(n:Self.Element) -> Int{
        var result = 0
        for e in self{
            if e == n{
                result += 1
            }
        }
        return result
    }
}

func pow(_ base:Int,_ exp:Int) -> Int{
    let d = pow(base.toD(), exp.toD())
    return Int(d)
}

func hitachi2020b() -> Int{
    let ABM = readLine()!.toSepIntList()
    let A = readLine()!.toSepIntList()
    let B = readLine()!.toSepIntList()
    
    var sum = A.min()! + B.min()!
    for _ in 1...ABM[2]{
        let xyc = readLine()!.toSepIntList()
        sum = min(A[xyc[0]-1] + B[xyc[1]-1] - xyc[2], sum)
    }
    return sum
}

print(hitachi2020b())


Measured memory_bytes: 21756
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    for (int i = 0; i < A; i++) {
        if (!('0' <= S[i] && S[i] <= '9')) {
            cout << "No";
            return 0;
        }
    }
    if (S[A] != '-') {
        cout << "No";
        return 0;
    }
    for (int i = A+1; i < A+1+B; i++) {
        if (!('0' <= S[i] && S[i] <= '9')) {
            cout << "No";
            return 0;
        }
    }
    if (S.size() != A + 1 + B) {
        cout << "No";
        return 0;
    }
    cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

uintmax_t combination(unsigned int n, unsigned int r)
{
    if (r * 2 > n)
        r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor = 1;
    for (unsigned int i = 1; i <= r; ++i)
    {
        dividend *= (n - i + 1);
        divisor *= i;
    }
    return dividend / divisor;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int N, x;
    cin >> N >> x;
    if(N < x){
        cout << 0 << endl;
    }
    else{
        cout << N - x << endl;
    }
}


Measured memory_bytes: 3612
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m,k=LI()
  _a=LI()
  _b=LI()
  la=copy.deepcopy(_a)
  lb=copy.deepcopy(_b)

  for i in range(n-1):
    la[i+1]+=la[i]

  for i in range(m-1):
    lb[i+1]+=lb[i]

  # print(la)
  # print(lb)

  cntA=cntB=0
  for i,x in enumerate(la):
    if x>k:
      cntA=i
      break
  if la[-1]<=k:
    cntA=n
  for i,x in enumerate(lb):
    if x>k:
      cntB=i
      break
  if lb[-1]<=k:
    cntB=m

  # print(cntA,cntB)

  mx=max(cntA,cntB)
  # print(mx)

  i=-1
  j=cntB-1
  sm=lb[j]

  while True:

    if sm<=k:
      i+=1
      if i>=n:
        break
      sm+=_a[i]

    else:
      sm-=_b[j]
      j-=1
      if j<0:
        break

    if sm<=k:
      mx=max(mx,i+j+2)
  # print(mx)

  i=-1
  j=cntA-1
  sm=la[j]

  while True:
    if i>=m-1 or j<=0:
      break

    if sm<=k:
      i+=1
      if i>=n:
        break
      sm+=_b[i]

    else:
      sm-=_a[j]
      j-=1
      if j<0:
        break

    if sm<=k:
      mx=max(mx,i+j+2)

  return mx

# main()
print(main())


Measured memory_bytes: 50604
using System;

namespace AOJ.Volume1
{
    public class EuclideanAlgorithm
    {
        public static int Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                long a = long.Parse(input[0]);
                long b = long.Parse(input[1]);

                if(a == 0 && b == 0) { break; }

                long x = Math.Max(a, b);
                long y = Math.Min(a, b);

                int step = 0;
                while (y > 0)
                {
                    long mod = x % y;
                    x = y;
                    y = mod;
                    step++;
                }

                Console.WriteLine(string.Format("{0} {1}", x, step));
            }

            return 0;
        }
    }
}

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

int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double ans = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
  printf("%0.8f\n", ans);
  return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll>mon(n+1);
    vector<ll>hero(n);
    for(int i=0;i<=n;i++) cin >> mon[i] ;
    for(int i=0;i<n;i++) cin >> hero[i];

    ll sum = 0;
    for(int i=0;i<n;i++){
        if(hero[i]>mon[i]){
            if((hero[i] - mon[i])>mon[i+1]){
                sum += mon[i] + mon[i+1];
                mon[i+1] = 0;
            }else {
                mon[i+1] = mon[i+1] - (hero[i] - mon[i]);
                sum += hero[i] ;
            }
        }else sum += hero[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792