akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

int main(){
    int H,W;
    cin >>H>>W;

    int x,y;

    rep(i,H) rep(j,W){
        string s;
        cin >> s;
        if(s=="snuke"){
            x=i;
            y=j;
        }
    }

    cout << (char)(y+'A') << x+1 << endl; 
}


Measured memory_bytes: 256
<?php
list($A,$B,$C,$K)=sscanf(trim(fgets(STDIN)),"%d %d %d %d");

$amari = $K - $A;
if($amari <= 0){
    print($K);
    exit;
}
$amari -= $B;
if($amari <= 0){
    print($A);
    exit;
}
print($A - $amari);


Measured memory_bytes: 16164
#include <bits/stdc++.h>
using namespace std;;
typedef long long ll;
int main()
{
    ll n,d;
    cin>>n>>d;
    ll count=0;
    ll x,y;
    for(ll i=0;i<n;i++)
    {
        cin>>x>>y;
        if(x*x + y*y <= d*d)
        count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 16;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int main() {
	ll N, K;
	scanf("%lld %lld", &N, &K);
	if (K == 0) return !printf("%lld\n", N*N);

	ll ans = 0;
	for (ll b = K + 1; b <= N; b++) {
		ll x = (N + 1) / b;
		ans += x * (b - K);

		ll t = (N + 1) % b;
		if (t >= K + 1) ans += t - K;
	}
	return !printf("%lld\n", ans);
}

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

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

int main() {
    int n,d;
    cin >> n >> d;
    int c = 2*d+1;
    cout << (n+c-1)/c << endl;
    return 0;
}


Measured memory_bytes: 3672
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        for(int i= 0; i < n; i++){
            String[] input = br.readLine().split(" ");
            int a = Integer.parseInt(input[0]);
            int b = Integer.parseInt(input[1]);
            int c = Integer.parseInt(input[2]);
            
            boolean isRight = false;
            if(a>=c && a>=b)        isRight = (a*a == b*b + c*c);
            else if(b>=c && b>=a)   isRight = (b*b == c*c + a*a);
            else if(c>=a && c>=b)   isRight = (c*c == a*a + b*b);

            if(isRight) System.out.println("YES");
            else        System.out.println("NO");
        }
    }
}

Measured memory_bytes: 25648
N, M = map(int, input().split())
# p = [int(i) for i in input().split()]
p = map(int,input().split())
# graph = [[]]*(N+1)
graph = [[] for _ in range(N+1)]
group = [0]*(N+1)
ans = 0
for _ in range(M):
    x, y = map(int, input().split())
    graph[x].append(y)
    graph[y].append(x)
for i, num in enumerate(p, 1):
    space = [i]
    for point in space:
        if group[point]:
            continue
        group[point] = i
        space.extend(graph[point])
    ans += (group[num] == group[i])
print(ans)

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

using namespace std;

int n;
long long ans = 0;
int h[200005];
long arr[200005];
long long score[200005];
int BIT[200005];

int query(int h) {
    int ret = BIT[h];
    //cout << "h: " << h << " ret: " << ret << " score[BIT[h]]: " << score[BIT[h]] << endl;
    while (h > 0) {
//		cout << h << " " << score[BIT[h]] << endl;
		if (score[BIT[h]] > score[ret]) ret = BIT[h];
		h -= h & (-h);
    }
    //cout << "returning " << ret << endl;
    return ret;
}

void update(int i, int curr) {
    int j = curr;
    while (j < n + 3) {
        if (score[BIT[j]] < score[i]) BIT[j] = i;
        if ((score[BIT[j]] == score[i]) && (h[i] < h[BIT[j]])) BIT[j] = i;
        j += j & (-j);
    }
}

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

	cin >> n;

	for (int i = 1; i < n+1; i++) cin >> h[i];
	for (int i = 1; i < n+1; i++) cin >> arr[i];

	score[0] = 0;
    for (int i = 0; i < n+5; i++) BIT[i] = 0;

    for (int i = 1; i < n+1; i++) {
        int b = query(h[i]);
        score[i] = arr[i];
        score[i] += score[b];
        update(i, h[i]);

        //for (int a = 0; a < 8; a++) {
		//	cout << "BIT[" << a << "]: " << BIT[a] << "  score[" << a << "]: " << score[a] << endl;
        //}
		//cout << "i: " << i << " b: " << b << " score: " << score[i] << endl;
		//cout << "--" << endl;

        ans = max(ans, score[i]);
    }

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4992
readlines.each do |l|
	c1,c2,c3 = l.split.map(&:to_i)
	a = (1..10).to_a - [c1,c2,c3]
	count = 0
	a.each {|x| count += 1 if (c1+c2)+x <= 20}
	puts (count.to_f/7 >= 0.5 ? "YES" : "NO")
end

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<long long> a(n, 0);
		for(int i=0; i<n; i++)cin >> a[i];
		long long s = 0;
		for(int i=0; i < n; i++)s += a[i];
		long long ret = 0x3f3f3f3f3f3f3f3f;
		long long s1 = 0;
		for(int i=0; i < n; i++){
			updmin(ret, abs(abs(s-s1) - s1));
			s1 += a[i];
		}
		cout << ret << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1792
// https://atcoder.jp/contests/dp/tasks/dp_a

#include <bits/stdc++.h>

using namespace std;

int main() {
    int N, K;
    cin >> N;
    vector<int> Arr(N);
    for(auto &x: Arr)
        cin >> x;
    vector<int> dp(N+1, 1e9+5);
    dp[0] = 0;
    for(int i = 0; i < N; ++i) {
        for(auto j: {i+1, i+2}) {
            dp[j] = min(dp[j], dp[i]+abs(Arr[i]-Arr[j]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
int main() {
	long long x,k,d;
	cin>>x>>k>>d;
	long long kaisuu=abs(x/d);
	long long kotae=0;
	long long amari=0;
	long long nokori=0;
	if(kaisuu>k)kotae=abs(x)-abs(k*d);
	else {
		amari=abs(x%d);
		nokori=(k-kaisuu)%2;
		if(nokori==1)kotae=(d-amari);
		else kotae=amari;
	}
	cout<<kotae<<endl;
	return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a + b == 15) System.out.println("+");
        else if (a * b == 15) System.out.println("*");
        else System.out.println("x");
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int n, a[3001];

int main() {
	cin >> n;
	int sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += (a[i] - 1);
	}
	cout << sum << endl;
	return 0;
}


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

int main(){
  int a,b;
  cin>>a>>b;
  if((a*b)%2!=0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3644
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long  t,r=1,r1=0,r2=0,k=0,a,b,c=0,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    vector<tuple<string,int,
           int>>mp;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>a>>b>>c>>d;
    //(n>0)?cout<<"0":cout<<"1"<<endl;
v.pb(a*c);
v.pb(a*d);
v.pb(b*c);
v.pb(b*d);
hi(v);
cout<<v[0]<<endl;







}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<limits.h>
using namespace std;
int main()
{
   int i,j,k=0,ar[100],first,second,third;
   first=INT_MIN;
   second=INT_MIN;
   third=INT_MIN;

   for(i=0;i<10;i++)
   {
     cin>>ar[i];
   }
   for(i=0;i<10;i++)
   {
     if(ar[i]>first)
     {
       third=second;
       second=first;
       first=ar[i];
     }
     else if(ar[i]>second){
      third=second;
      second=ar[i];
     }
     else if(ar[i]>third)
     {
       third=ar[i];
     }
   }
   cout<<first<<endl;
   cout<<second<<endl;
   cout<<third<<endl;



    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>

using namespace std;

string odd ( string s )
{
  string ans = "";

  for ( int i = 0; i < s.size(); i += 2 ) {
    ans += s[i];
  }

  return ans;
}

int main()
{
  string s;

  cin >> s;

  cout << odd(s) << "\n";
}


Measured memory_bytes: 704
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicLong;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();
        final int[] candies = new int[n];
        final Map<Integer, AtomicLong> countMap = new HashMap<>();

        int accum = 0;
        for (int i = 0; i < candies.length; i++) {
            final int mod = scanner.nextInt() % m;
            accum = (accum + mod) % m;
            candies[i] = accum;
            countMap.computeIfAbsent(accum, counter -> new AtomicLong()).incrementAndGet();
        }


        long answer = countMap.get(0) != null ? countMap.get(0).get() : 0;
        for (final int candy : candies) {
            answer += countMap.get(candy).decrementAndGet();
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 66920
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

d,t,s=MI()
if d<=t*s:print("Yes")
else:print("No")


Measured memory_bytes: 9128
#include <cstdio>

char s[2][2] = { 'R', 'Y', 'G', 'B' };

int main(){
  int H, W, D; scanf("%d%d%d", &H, &W, &D);

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int x = i + W - j, y = i + j;
      putchar(s[x / D & 1][y / D & 1]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 384
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> as(n); cin >> as;
    ll total = accumulate(as.begin(), as.end(), 0ll);
    ll acc = 0;
    ll ans = MLL;
    for(int i = 0; i < n - 1; i++){
        acc += as[i];
        ans = min(ans, abs(acc - (total - acc)));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int  INF = (1 << 30);

struct roadwork {
	int x, s, t;
	roadwork() : x(0), s(0), t(0) {}
	void read() { cin >> s >> t >> x; }
};

int main() {
	int N, Q; cin >> N >> Q;
	vector<roadwork> rw(N);
	for (int i = 0; i < N; ++i)
		rw[i].read();
	// 出発時間系の座圧
	map<int, int> mp;
	mp[-INF] = 0;
	mp[INF] = 0;
	for (auto& r : rw) {
		mp[r.s - r.x] = 0;
		mp[r.t - r.x] = 0;
		mp[r.s - r.x - 1] = 0;
	}
	int tmp = 0;
	vector<int> time;
	for (auto& e : mp) {
		e.second = tmp++;
		time.push_back(e.first);
	}

	int sz = mp.size();
	vector<int> res(sz, INF);
	vector<vector<pair<bool, int>>> imos(sz);
	for (auto& r : rw) {
		imos[mp[r.s - r.x]].emplace_back(true, r.x);
		imos[mp[r.t - r.x]].emplace_back(false, r.x);
	}
	map<int, int> cnt;
	for (int i = 0; i < sz; ++i) {
		for (auto& p : imos[i]) {
			if (p.first) {
				cnt[p.second]++;
			}
			else {
				if (cnt[p.second] > 1) --cnt[p.second];
				else cnt.erase(p.second);
			}
		}
		if (cnt.size())
			res[i] = (*(cnt.begin())).first;
	}

	/*
	for (auto i : time) cout << i << " ";
	cout << endl;
	for (auto i : res) cout << i << " ";
	cout << endl;
	*/

	while (Q--) {
		int d; cin >> d;
		auto iter = upper_bound(time.begin(), time.end(), d);
		int idx = iter - time.begin() - 1;
		//cout << "idx : " << idx << "  ";
		if (res[idx] != INF)
			cout << res[idx] << endl;
		else cout << -1 << endl;
	}
}

Measured memory_bytes: 74480
#pragma comment(linker, "/STACK: 16777216")

#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl


using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

template <typename T>
void freadT(T &x) {
    x = 0;
    char ch = _getchar_nolock();
    ll sign = 1;

    while (!isdigit(ch)) {
        if (ch == '-')
            sign *= -1;
        ch = _getchar_nolock();
    }

    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = _getchar_nolock();
    }

    x *= sign;
}

int fparse(string s, int start_indx) {
    int x = 0;

    while (isdigit(s[start_indx])) {
        x = x * 10 + s[start_indx] - '0';
        ++start_indx;
    }

    return x;
}

//#define solvsh
//#define multi

#ifdef solvsh
#else


ll mod = 998244353;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll mult(ll a, ll b) {
    return (a * b) % mod;
}

const int MAXN = 3e5 + 120;

void solve() {

    int n;
    cin >> n;
    ll answr = 0;
    ll pref = 0;
    for (int i = 0; i < n; ++i) {
        ll curr;
        cin >> curr;
        if (i == 0) pref = curr;
        else {
            answr += max(0ll,  pref - curr);
            pref = max(pref, curr);
        }
    }

    cout << answr << '\n';
}


#endif

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE

#else

#endif
#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin >> n;
    if (n < 1000){
        cout << "ABC" << endl;
    } else cout << "ABD" << endl;
}

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

def cal(h,n,w):
    return 4*h*n*w - N * (n*w + h*w + h*n)

w = -1

for h in range(1,3501):
    for n in range(h,3501):
        a = n
        b = 3501
        if cal(h,n,a) == 0:
            w = a
            break
        elif cal(h,n,b) == 0:
            w = b
            break
        while b - a > 1:
            c = (a+b)//2
            if cal(h,n,c) < 0:
                a = c
            elif cal(h,n,c) > 0:
                b = c
            else:
                w = c
                break
        if cal(h,n,a) == 0:
            w = a
        elif cal(h,n,b) == 0:
            w = b
        if w != -1:
          break
    if w != -1:
        break

print(" ".join(map(str,[h,n,w])))

        

Measured memory_bytes: 47068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//bit全探索
//引数は処理に応じて適宜追加
void bit_search(ll n, vll &a, vector<vector<vll>> &testimony, priority_queue<ll> &ans) {
  vll bits;
  for (ll i = 0; i < n; i++) bits.push_back(0);
  for (ll i = 0; i < pow(2, n); i++) {
    vector<vll> truth(0, vll(2));
    for (ll j = 0; j < n; j++) {
      if (bits[j] == 1) {
        for (ll k = 0; k < a[j]; k++) {
          truth.push_back(testimony[j][k]);
        }
      }
    }
    ll liar = 0;
    for (ll j = 0; j < truth.size(); j++) {
      if (bits[truth[j][0] - 1] != truth[j][1]) {
        liar = 1;
        break;
      }
    }
    if (liar == 0) {
      ll cnt = 0;
      for (ll j = 0; j < n; j++) {
        if (bits[j] == 1) cnt++;
      }
      ans.push(cnt);
    }
    if (i == pow(2, n) - 1) return;
    ll x = 0;
    while (bits[n - 1 - x] == 1) {
      bits[n - 1 - x] = 0;
      x++;
    }
    bits[n - 1 - x] = 1;
  }
}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  vector<vector<vll>> testimony(n, vector<vll>(0, vll(2)));
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    for (ll j = 0; j < a[i]; j++) {
      ll a, b;
      cin >> a >> b;
      testimony[i].push_back({a, b});
    }
  }
  priority_queue<ll> ans;
  bit_search(n, a, testimony, ans);
  cout << ans.top() << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod(a) (a % MOD + MOD) % MOD
const int N = 1e6 + 10, MOD = 1e9 + 7;
int a[N], fac[N], inv[N];
 
int mul(int a, int b) {return mod(a * b);}
 
int Pow(int a, int b)
{
    int res = 1;
    for (; b; b>>=1, a = mul(a, a)) if (b & 1) res = mul(res, a);
    return res;
}
 
int C(int n, int k)
{
    if (k < 0 || n < 0 || k > n) return 0;
    return mul(fac[n], mul(inv[k], inv[n - k]));
}
 
int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k; cin >> n >> k;
 
    fac[0] = 1;
    for (int i = 1; i <= n; i++) fac[i] = mul(fac[i - 1], i);
    inv[n] = Pow(fac[n], MOD - 2);
    for (int i = n - 1; i >= 0; i--) inv[i] = mul(inv[i + 1], i + 1);
  
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = (ans - mul(a[i], C(n - i - 1, k - 1)) + MOD) % MOD;
    for (int i = n - 1; i >= 0; i--)
        ans = (ans + mul(a[i], C(i, k - 1)) + MOD) % MOD;
    cout << ans << "\n";
}

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int[] intArray = new int[num];
		int k = 0;
		int res = 0;
		while (sc.hasNext()) {
			intArray[k] = sc.nextInt(); 
            k++;
		}

		boolean exist_odd = false;

		while (true) {
			for (int i = 0; i < intArray.length; i++) {
				if (intArray[i] % 2 != 0)
					exist_odd = true;
		}

			if (exist_odd) {
				break;
			}

			for (int i = 0; i < intArray.length; i++) {
				intArray[i] /= 2;
			}

			res++;
		}
		System.out.println(res);
	}
}


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

using namespace std;

const int INF = 1 << 30;

int N, M;
int g[17][17];
int lookup[1 << 17];
int dp[1 << 17][16][2];
vector< int > add[1 << 17];
bool isflip[1 << 17];

int rec(int mask, int pre, bool get)
{
  if(mask == 0) return (0);
  if(~dp[mask][pre][get]) return (dp[mask][pre][get]);
  int ret = -INF;
  for(int i = mask; i > 0; i = (i - 1) & mask) {
    for(auto &j : add[i]) {
      if(g[pre][j] == 0 && get) continue;
      ret = max(ret, rec(mask ^ i, j, get ^ isflip[i]) + lookup[i] + g[pre][j]);
    }
  }
  return (dp[mask][pre][get] = ret);
}

signed main()
{
  memset(dp, -1, sizeof(dp));

  cin >> N >> M;
  int all = 0;

  for(int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    g[a][b] = c;
    g[b][a] = c;
    all += c;
  }

  for(int i = 0; i < 1 << N; i++) {
    if(i & 1 && (i >> (N - 1)) & 1) continue;
    for(int j = 0; j < N; j++) {
      if((i >> j) & 1) {
        if(i & 1) {
          isflip[i] = true;
          if(j == 0) add[i].push_back(j);
        } else if((i >> (N - 1)) & 1) {
          isflip[i] = true;
          if(j == N - 1) add[i].push_back(j);
        } else {
          add[i].push_back(j);
        }
        for(int k = j + 1; k < N; k++) {
          if((i >> k) & 1) lookup[i] += g[j][k];
        }
      }
    }
  }
  cout << all - rec((1 << N) - 1, 15, 0) << endl;
}

Measured memory_bytes: 20736
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    size_t N;
    scanf("%zu", &N);
    char buf[128];
    scanf("%s", buf);
    string s(buf);

    scanf("%s", buf);
    string t(buf);

    if (s.length()+t.length() <= N)
        return !printf("%zu\n", N);

    for (size_t i=0; i<s.length(); ++i)
        if (s.substr(i) == t.substr(0, s.substr(i).length()))
            return !printf("%zu\n", i+t.length());

    printf("%zu\n", s.length()+t.length());
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define maxn 100000
vector< pair<int,int> > v[maxn+10];
LL dis[maxn+10];
void dfs(int k,int fa,LL d)
{
    int i;
    dis[k]=d;
    for(i=0;i<v[k].size();i++)
    {
        if (v[k][i].first==fa) continue;
        dfs(v[k][i].first,k,d+v[k][i].second);
    }
}
int main()
{
    int N,K,Q,a,b,c,i;
    LL ans;
    cin>>N;
    for(i=1;i<=N-1;i++)
    {
        scanf("%d%d%d",&a,&b,&c);
        v[a].push_back(make_pair(b,c));
        v[b].push_back(make_pair(a,c));
    }
    cin>>Q>>K;
    dfs(K,0,0);
    for(i=1;i<=Q;i++)
    {
        scanf("%d%d",&a,&b);
        ans=dis[a]+dis[b];
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 14336
def calc(n):
    a_list = []
    a = 0
    for i in range(0, n+1):
        a += 10**i
        a_list.append(a)
    return a_list
n = int(input())
N = len(list(str(n)))
a_list = calc(N+1)
b_list = []
for i in range(1, 10):
    for a in a_list:
        b_list.append(a * i)
b_list = sorted(b_list)
print([b for b in b_list if b >= n][0])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  
  vector<int> s, ord(n+1, -1);
  int c, l;
  int v = 1;
  while(ord[v] == -1){
    ord[v] = s.size();
    s.push_back(v);
    v = a[v-1];
  }
  c = s.size() - ord[v];
  l = ord[v];
  if (k < l) cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 6568
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int64_t> lyuca(N+1, 0);
  for (int i = 0; i <= N; i++){  
    if (i == 0){
    lyuca.at(0) = 2;
    }
    if(i == 1){
    lyuca.at(1) = 1;
    }
    if(i >= 2){ 
      lyuca.at(i) = lyuca.at(i-2)+lyuca.at(i-1);
     }
    }

  cout << lyuca.at(N) << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

typedef long long lint;

using namespace std;

int main(){
  int N,A;
  cin>>N>>A;
  int x[N];
  for(int i=0;i<N;i++){
    cin>>x[i];
    x[i]-=A;
  }
  int T=N*25;
  lint dp[N+1][T*2];
  for(int i=0;i<=N;i++){
    for(int j=0;j<T*2;j++)dp[i][j]=0;
  }
  dp[0][T]=1;
  for(int i=1;i<=N;i++){
    for(int j=0;j<T*2;j++){
      dp[i][j]=dp[i-1][j]+dp[i-1][j-x[i-1]];
    }
  }
  // for(int i=0;i<=N;i++){
  //   for(int j=T-5;j<=T+5;j++)cout<<dp[i][j];
  //   cout<<endl;
  // }
  cout<<dp[N][T]-1<<endl;
  return 0;
}


Measured memory_bytes: 1280
from collections import deque
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
ca = Counter(a)
ca_va = list(ca.values())
c_sum = sum([(i*(i-1))//2 for i in ca_va])
ans = 1
for j in range(n):
    x = ca[a[j]]
    ans += c_sum + ((ca[a[j]]-1)*ca[a[j]])//2 - (ca[a[j]]*(ca[a[j]]+1))//2
    print(ans)
    ans = 1

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

int main() {
  int n,k;
  cin >> n >> k;
  int i = 0;
  int sum = 1;
  while(i < n){
    if ((sum + k) <= (sum * 2)){
       sum += k;
    }
    
    else{
      sum *= 2;
    }
    i++;
  }
    cout << sum << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
a = []
b = []
c = []
for _ in range(N):
    a_val , b_val , c_val = map(int , input().split())
    a.append(a_val)
    b.append(b_val)
    c.append(c_val)

for i in range(N - 2, -1, -1):
    a[i] += max(b[i + 1], c[i + 1])
    b[i] += max(a[i + 1], c[i + 1])
    c[i] += max(a[i + 1], b[i + 1])
print(max(a[0],b[0],c[0]))



Measured memory_bytes: 15024
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")
#define y1 hoainambimaysolokill
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,pair<int,int> >
#define PII3 pair<pair<int,int>,int >
void solve()
{
   int a,b,c;
   cin>>a>>b>>c;
   int kc=a-b;
   c-=kc;
   cout<<max(0,c);
}
main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);cout.tie(0);

    //freopen("TBC.inp", "r", stdin);
    //freopen("FORMMAU.out", "w", stdout);

    //int t;cin>>t;while(t--)

    solve();
}


Measured memory_bytes: 256
<?php
$s = str_split(trim(fgets(STDIN)));
$t = str_split(trim(fgets(STDIN)));
sort($s);
rsort($t);
$s_a= implode("", $s);
$t_a = implode("", $t);
$ans =  $s_a < $t_a ? "Yes" : "No";
echo $ans . "\n"; 
?>

Measured memory_bytes: 4604
#include<stdio.h>
int main()
{
    int n,h[20],i,s=0;

    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        scanf("%d",&h[i]);

    }

    int max;
    max = h[0];

    for(i=0;i<n;i++)
    {
        if(h[i]>=max)
    {
        max = h[i];
        s++;
    }

    else continue;

    }

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

return 0;
}

Measured memory_bytes: 1732
# 31年5月1日以降なら年号をマイナス60する
for _ in range(102):
    input_str = str(input())
    if (input_str[0] == '#'):
        exit()
    today = input_str.split()
    if int(today[1]) > 31:
        print(f'? {int(today[1])-30} {int(today[2])} {today[3]}')
        continue

    if int(today[1]) == 31 and int(today[2]) >= 5:
        print(f'? {int(today[1])-30} {int(today[2])} {today[3]}')
        continue
    print(' '.join(today))



Measured memory_bytes: 5612
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define P pair<ll,ll>
using namespace std;
ll mul(ll int a,ll int b){
	return (a*b)%mod;
}
P dfs(int u,int parent,vector<vector<int>>&arr){
	ll int all_white=1;
	ll int some_black=0;
	for(int v:arr[u]){
		if(v!=parent){
		 	P temp = dfs(v,u,arr);
			ll memo_all_white=all_white;
			all_white=(all_white*temp.second)%mod;
			some_black=(mul(memo_all_white,temp.first)+mul(some_black,temp.first+temp.second))%mod;
		}
	}
	return {all_white,(all_white+some_black)%mod};
}
int main(){
	int n;
	cin>>n;
	vector<vector<int>>arr(n+1);
	int x,y;
	for(int i=0;i<n-1;i++){
		cin>>x>>y;
		arr[x].push_back(y);
		arr[y].push_back(x);
	}
	P result=dfs(1,-1,arr);
	ll res=(result.first+result.second)%mod;
	cout<<res;
	return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;
  vi a(n);
  vvi occ(n+1);
  rep(i,0,n) cin >> a[i];
  rep(i,0,n) {
    occ[a[i]].pb(i);
  }

  ll ans = n;
  int idx = 0;
  rep(i,1,n+1) {
    auto it = lower_bound(all(occ[i]), idx);
    if (it==occ[i].end()) break;
    idx = occ[i][it-occ[i].begin()];
    --ans;
  }

  if(ans==n)ans=-1;
  cout << ans << endl;

}

Measured memory_bytes: 12800
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;

string strMax(string str1, string str2)
{
  if(str1.size() != str2.size())
    return str1.size() > str2.size() ? str1 : str2;
  string res = str1;
  for(int i = 0; i < str1.size(); i++){
    if(str1[i]-'0' == str2[i]-'0') continue;
    res = str1[i]-'0' > str2[i]-'0' ? str1 : str2;
    break;
  }
  return res;
}

bool comp(const string &a, const string &b)
{
  if(a.size() != b.size())
    return a.size() > b.size();
  for(int i = 0; i < a.size(); i++){
    if(a[i]-'0' == b[i]-'0') continue;
    return a[i]-'0' > b[i]-'0';
  }
}

int main()
{
  while(1){
    int W, H;
    cin >> W >> H;
    if(W == 0 && H == 0) break;
    string C[H];
    for(int i = 0; i < H; i++)
      cin >> C[i];
    
    string dp[H+1][W+1];
    for(int i = 0; i < H; i++)
      for(int j = 0; j < W; j++)
        dp[i][j] = C[i][j];
    
    for(int i = 1; i < W; i++)
      if(isdigit(C[0][i-1]) && isdigit(C[0][i])){
        dp[0][i] = dp[0][i-1] + dp[0][i];
        if(dp[0][i][0] == '0') dp[0][i] = dp[0][i].substr(1);
      }
    
    for(int i = 1; i < H; i++)
      if(isdigit(C[i-1][0]) && isdigit(C[i][0])){
        dp[i][0] = dp[i-1][0] + dp[i][0];
        if(dp[i][0][0] == '0') dp[i][0] = dp[i][0].substr(1);
      }
    
    for(int i = 1; i < H; i++){
      for(int j = 1; j < W; j++){
        if((!isdigit(C[i-1][j]) && !isdigit(C[i][j-1])) || !isdigit(C[i][j])) continue;
        if(!isdigit(C[i-1][j]) && isdigit(C[i][j-1]))
          dp[i][j] = dp[i][j-1] + dp[i][j];
        else if(isdigit(C[i-1][j]) && !isdigit(C[i][j-1]))
          dp[i][j] = dp[i-1][j] + dp[i][j];
        else
          dp[i][j] = strMax(dp[i-1][j] + dp[i][j], dp[i][j-1] + dp[i][j]);
        if(dp[i][j][0] == '0') dp[i][j] = dp[i][j].substr(1);
      }
    }

    /*
    cout << "-----------------------------" << endl;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        cout << dp[i][j] << "  ";
      }
      cout << endl;
    }
    cout << "-----------------------------" << endl;
    */
    
    vector<string> v;
    
    if(isdigit(C[H-1][W-1])) v.push_back(dp[H-1][W-1]);
    
    for(int i = 0; i < H-1; i++)
      if(!isdigit(C[i+1][W-1]) && isdigit(C[i][W-1])) v.push_back(dp[i][W-1]);
    
    for(int i = 0; i < W-1; i++)
      if(!isdigit(C[H-1][i+1]) && isdigit(C[H-1][i])) v.push_back(dp[H-1][i]);
    
    for(int i = 0; i < H-1; i++)
      for(int j = 0; j < W-1; j++)
        if(!isdigit(C[i+1][j]) && !isdigit(C[i][j+1]) && isdigit(C[i][j]))
          v.push_back(dp[i][j]);
    
    sort(v.begin(),v.end(),comp);
    cout << v[0] << endl;
  }
}

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

int main(void){
    int S,h,m,s;
    cin >> S;
    cout << S/3600;
    cout << ":";
    cout << (S%3600)/60;
    cout << ":";
    cout << (S%3600)%60;
    cout << endl;
    
}



Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<pair<int, int>> primeFact(int n) {
  vector<pair<int, int>> res;
  for (int i = 2; i * i <= n; i++) {
    int divcnt = 0;
    if (n % i == 0) {
      do {
        divcnt++;
        n /= i;
      } while (n % i == 0);
      res.emplace_back(i, divcnt);
    }
  }
  if (n != 1)
    res.emplace_back(n, 1);
  return res;
}

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

  auto prime = primeFact(N);

  int ans = 0;
  for(auto p: prime){
    int now = 1;
    while(p.second >= 1){
      if(p.second-now < 0) break;
      p.second -= now;
      now++;
      ans++;
    }
  }

  cout << ans << "\n";


  return 0;
}

Measured memory_bytes: 3656
/*****And nothing else matters!******/

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define setbits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define sp(x) fixed << setprecision(10) << x
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 3e5 + 10;

int main()
{
    fast;
    int d, t, s;
    cin >> d >> t >> s;
    if(t*s >= d)
        cout << "Yes";
    else
        cout << "No";
}


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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif

int bad(string S) {
    for (int i = 0; i + 1 < S.size(); i++)
        if (S[i] == S[i + 1]) return 1;
    return 0;
}

map<string, int> dp;

int game(string S) {
    if (S.size() == 2) return 0;
    if (dp.count(S)) return dp[S];
    for (int i = 1; i + 1 < S.size(); i++) {
        string T = S.substr(0, i) + S.substr(i + 1);
        if (bad(T)) continue;
        if (!game(T)) {
            return dp[S] = 1;
        }
    }
    return dp[S] = 0;
}

void solve(string s) {
    if ((s.size() % 2) ^ (s.front() == s.back())) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}


void main_(istream &cin) {
    string s;
    cin >> s;
    solve(s);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
long long vis[200];
char s[200010],t[200010];
long long id[27][200010];
int main()
{
	long long lens,lent,i,j;
	scanf("%s",s),lens=strlen(s);
	scanf("%s",t),lent=strlen(t);
	for(i=0;i<lens;i++){
		id[s[i]-'a'][++id[s[i]-'a'][0]]=i;
		vis[s[i]]=1;
	}
	for(i=0;i<lent;i++)
		if(!vis[t[i]]){
			printf("-1\n");
			return 0;
		}
	long long tem=-1;
	long long ans=0;
	for(i=0;i<lent;i++){
		if(id[t[i]-'a'][id[t[i]-'a'][0]]<=tem){
			ans+=1ll*(lens-tem+id[t[i]-'a'][1]);
			tem=id[t[i]-'a'][1];
		}
		else{
			long long l=1,r=id[t[i]-'a'][0],mid;
			mid=(l+r)>>1;
			while(r-l>=2){
				if(id[t[i]-'a'][mid]>tem)	r=mid;
				else	l=mid+1;
				mid=(l+r)>>1;
			}
			for(mid=l;mid<=r;mid++)
				if(id[t[i]-'a'][mid]>tem)
					break;
			ans+=1ll*(id[t[i]-'a'][mid]-tem);
			tem=id[t[i]-'a'][mid];
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 39424
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m;
struct node{int l,r;}a[300010];
bool cmp(node x,node y){return x.r-x.l<y.r-y.l;}

int tree[100010];
void add(int id,int x){for(;id<=m;id+=id&-id) tree[id]+=x;}
int query(int id){int re=0;for(;id;id-=id&-id) re+=tree[id];return re;}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+n+1,cmp);
	for (int i=1,j=1;i<=m;i++)
	{
		int cnt=0;
		for (int t=i;t<=m;t+=i) cnt+=query(t);
		printf("%d\n",cnt+n-j+1);
		while (j<=n&&a[j].r-a[j].l<=i)
		{
			add(a[j].l,1);
			add(a[j].r+1,-1);
			j++;
		}
	}
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    string s;cin>>s;
    int n =s.length();
    reverse(been(s));
    vi cnt(2019,0),sum(n+1,0);
    int p =1;
    sum[0]=0;
    rep(i,n){
        int a =s[i]-'0';
        a*=p;
        a%=2019;
        sum[i+1]=sum[i]+a;
        sum[i+1]%=2019;
        p*=10;
        p%=2019;
    }
    rep(i,n+1){
        cnt[sum[i]]++;
    }
    int ans =0;
    rep(i,2019){
        ans+=(cnt[i]*(cnt[i]-1))/2;
    }
    cout<<ans<<endl;
    }

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

const int maxn = 1e5+10;

ll dp[maxn][2];

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vi vs(n);
	dp[0][0] = 0;
	dp[0][1] = -(1LL<<60);
	for(int i=0;i<n;++i){
		int x;cin>>x;
		dp[i+1][0] = max(dp[i][0]+x,dp[i][1]-x);
		dp[i+1][1] = max(dp[i][0]-x,dp[i][1]+x);
	}
	cout<<dp[n][0]<<endl;
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    double a,b,c,d;
    scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
    double ans=sqrt((a-c)*(a-c)+(b-d)*(b-d));
    printf("%.10lf\n", ans);

    return 0;
}



Measured memory_bytes: 2664
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Feb 22 21:00:00 JST 2020
 **/

signed main() {
    Int n, r;
    cin >> n >> r;
    cout << r + 100 * max(0LL, (10 - n)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef TOPOLOGY
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
using namespace std;

char a[200003];
vector<int> idx[200003];

int main() {
	int n;
	scanf("%s", a);
	n = (int)strlen(a);
	for (int i = 0; i < n; i++) {
		idx[a[i] - 'a'].push_back(i);
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		vector<int> &v = idx[a[i] - 'a'];
		int same = (int)(v.end() - upper_bound(v.begin(), v.end(), i));
		ans += n - 1 - i - same;
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 6640
M, K = map(int, input().split())
MAX_A = 2 ** M

# never exist condition
if 2 ** M <= K or K == 1 and M == 1:
    print(-1)
elif K == 0:
    ary = [i//2 for i in range(MAX_A*2)]
    print(' '.join(map(str, ary)))
else:
    # solution by wrap K
    ary = []
    
    ary_asc = [i for i in range(MAX_A) if i != K]
    ary_dec = [i for i in range(MAX_A-1,-1,-1) if i != K]
    ary.extend(ary_dec)
    ary.extend([K])
    ary.extend(ary_asc)
    ary.extend([K])

    print(' '.join(map(str, ary)))



Measured memory_bytes: 33752
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		
		if(s.charAt(0)!='A') {
			System.out.println("WA");
			return;
		}
		
		int cnt=0;
		for(int i=2;i<=s.length()-2;i++) {
			if(s.charAt(i)=='C')cnt++;
		}
		if(cnt!=1) {
			System.out.println("WA");
			return;
		}
		
		cnt=0;
		for(int i=0;i<s.length();i++) {
			if(Character.isUpperCase(s.charAt(i)))cnt++;
		}
		if(cnt!=2) {
			System.out.println("WA");
			return;
		}
		
		System.out.println("AC");
	}
}

Measured memory_bytes: 23636
#include <iostream>

using namespace std;

int main()
{
    long long h,w;
    cin>>h>>w;
    char graph[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>graph[i][j];
        }
    }
    long long dp[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(graph[i][j]!='#'&&(!((i==0)&&(j==0))))
            {
                if(j>=1)
                {
                    dp[i][j]=(dp[i][j]+dp[i][j-1])%1000000007;
                }
                if(i>=1)
                {
                    dp[i][j]=(dp[i][j]+dp[i-1][j])%1000000007;
                }

            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}


Measured memory_bytes: 9088
def t(a, b, k):
    a -= k
    b = b + a if a < 0 else b
    a = 0 if a < 0 else a
    b = 0 if b < 0 else b
    return a, b


if __name__ == '__main__':
    a, b, k = map(int, input().split())
    print('%d %d' % t(a, b, k))


Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
    int a,b;
    char op;
    int ans;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
            ans=a+b;
        else if(op=='-')
            ans=a-b;
        else if(op=='*')
            ans=a*b;
        else if(op=='/')
            ans=a/b;
        else if(op=='?')
            break;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 600