akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define int long long
#define ll unsigned long long
#define ld long double
#define mx 100005
#define mod 1000000007
#define fr first
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }

int tc=1;

void solve(int kk)
{
     int n,five=0,three=0;
     cin >> n;
     int t = n/3; /// 5

     three = (t*(t+1))/2; /// 15
     three*=3; /// 45

     t = n/5; /// 3

     five = (t*(t+1))/2; /// 6
     five*=5; /// 30

     t = n/15; /// 1
     t = (t*(t+1))/2;
     t*=15;

     int sum;
     sum = (n*(n+1))/2; /// 120-45-30
     cout << sum-three-five+t << "\n";

    
}

signed main()
{
   //freopen("text.txt", "r", stdin);
   //freopen("text2.txt", "w", stdout);
   fast;
   int kk=0;
   //cin >> tc;
   //scanf("%d", &tc);

   while(++kk<=tc) solve(kk);

   return 0;
}


Measured memory_bytes: 3696
#define P(x) cout << #x" = " << x << endl
#define PP(x, y) cout << "("#x", "#y") = (" << x << ", " << y << ")" << endl
#define PPP(x, y, z) cout << "("#x", "#y", "#z") = (" << x << ", " << y << ", " << z << ")" << endl

#include <iostream>
#include <vector>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;

using ll = long long;

const ll mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll cnt(int h, int w) {
    return COM(w + h - 2, w - 1);
}

int h, w, a, b;
int main() {
    cin >> h >> w >> a >> b;
    COMinit();
    // cout << COM(100000, 50000) << endl;
    // cout << cnt(3, 5) << endl;
    // return 0;
    ll total = cnt(h, w);
    for (int i = 1; i <= b; ++i) {
        total = (total + mod - (cnt(h - a, i) * cnt(a, w - i + 1)) % mod) % mod;
    }
    cout << total << endl;
}

Measured memory_bytes: 12160
#include<iostream>

using namespace std;

int main(){
	int n,m;
	int masu[17][17];
	int ura[17][17];
	
	while( cin>>m>>n, n != 0 && m != 0 ){
		for(int i=0;i<17;i++){
			for(int j=0;j<17;j++){
				masu[i][j]=ura[i][j]=0;
			}
		}
		
		for(int i=0;i<n;i++){
			for(int j=1;j<=m;j++){
				cin>>masu[i][j];
			}
		}
		
		for(int j=1;j<=m;j++){
			if(masu[0][j]!=1){
				ura[0][j]=1;
			}
		}
		
		
		for(int i=0;i<n-1;i++){
			for(int j=1;j<=m;j++){
				if(masu[i][j]==0){
					if(masu[i+1][j-1]==0){
						ura[i+1][j-1]+=ura[i][j];
					}
					if(masu[i+1][j]!=1){
						ura[i+1][j]+=ura[i][j];
					}
					if(masu[i+1][j+1]==0){
						ura[i+1][j+1]+=ura[i][j];
					}
				}
				
				if(masu[i][j]==2){
					if(masu[i+2][j]!=1){
						ura[i+2][j]+=ura[i][j];
					}
				}
			}
		}
		int cont=0;
		for(int i=1;i<=m;i++){
			cont+=ura[n][i]+ura[n-1][i];
		}
		
		/*
		
		for(int i=0;i<17;i++){
			for(int j=0;j<17;j++){
				printf("%2d ",ura[i][j]);
			}
			puts("");
		}*/
		printf("%d\n",cont);
	}
	
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

class UnionFind {
  public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL); // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

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

    ll N, M;
    cin >> N >> M;
    vector<ll> A(M), B(M), res;

    ll ans = N * (N - 1) / 2;

    UnionFind tree(N);
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }

    for (int i = M - 1; i > -1; i--) {
        res.push_back(ans);
        if (!tree.issame(A[i], B[i])) {
            ans -= (ll)tree.size(A[i]) * (ll)tree.size(B[i]);
            tree.merge(A[i], B[i]);
        }
    }

    for (int i = res.size() - 1; i > -1; i--) {
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 7360
n, m = map(int, input().split())
Penalty = [0]*(n+1)
AC = [False]*(n+1)
correct = 0
penalty = 0
for i in range(m):
  ans = input().split()
  problem = int(ans[0])
  result = ans[1]
  if AC[problem] == False:
    if result == 'AC':
      AC[problem] = True
      correct += 1
      penalty += Penalty[problem]
    else:
      Penalty[problem] += 1
print(correct, penalty)

Measured memory_bytes: 10352
#include <cstdlib>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <map>
#include <iostream>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  int g[128][128];
  string str[128];
  map<string, int> m;

  string s; getline(cin, s);
  const int n = atoi(s.c_str());
  const int mx = 1000000;

  REP(i,n){
    getline(cin, str[i]);

    if(str[i].substr(0, 5) != "goto "){
      m[str[i]] = i;
    }
  }

  REP(i,n+1) REP(j,n+1)
    g[i][j] = mx;
  REP(i,n+1) g[i][i] = 0;
  REP(i,n) g[i][i + 1] = 0;

  REP(i,n){
    if(str[i].substr(0, 5) == "goto "){
      string tmp = str[i].substr(5);
      tmp[tmp.size() - 1] = ':';
      g[i][i + 1] = 1;
      g[i][m[tmp]] = 0;
    }
  }

  REP(k,n+1) REP(i,n+1) REP(j,n+1)
    g[i][j] = min(g[i][j], g[i][k] + g[k][j]);

  printf("%d\n", g[0][n]);

  return 0;
}

Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
sx,sy,tx,ty = map(int, input().split())

path = ''

#往１復１
for y in range(sy,ty):
    path += 'U'

for x in range(sx,tx):
    path += 'R'

for y in range(sy, ty):
    path += 'D'

for x in range(sx, tx):
    path += 'L'

#往２
path += 'L'
for y in range(sy, ty):
    path += 'U'

path += 'U'
path += 'R'
for x in range(sx, tx):
    path += 'R'
path += 'D'

#復２
path += 'R'
for y in range(sy, ty):
    path += 'D'
path += 'D'

for x in range(sx, tx):
    path += 'L'
path += 'L'
path += 'U'

print(path)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    long long int n, L0 = 2, L1 = 1, L[100];
    L[0] = 2; L[1] = 1;
    std::cin >> n;

    n++;
    for(int i = 2;i < n;i++){
        L[i] = L[i - 1] + L[i - 2];
    }

    std::cout << L[n - 1];

    return 0;
}

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

int main() {
    
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    
    int dp[n];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++){
        dp[i]=min((dp[i-1]+abs(arr[i]-arr[i-1])),(dp[i-2]+abs(arr[i]-arr[i-2])));
    }
    cout<<dp[n-1]<<endl;
    }

Measured memory_bytes: 1024
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    vector<pii>v(n);
    rep(i,n)cin>>v[i].second>>v[i].first;
    sort(all(v));
    cout<<v[0].first+v[n-1].second+(-v[n-1].second+v[0].second)<<endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

class Test
{

    public static void Main()
    {
        var ss = Console.ReadLine().Split(' ');
        var n = int.Parse(ss[0]);
        var d = int.Parse(ss[1]);
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            var ii = Console.ReadLine().Split(' ');
            var x1 = long.Parse(ii[0]);
            var x2 = long.Parse(ii[1]);

            var dd = Math.Sqrt((x1 * x1) + (x2 * x2));
            if (dd <= d)
                ans++;

        }

        Console.Write(ans);


    }
}





Measured memory_bytes: 21856
#include<cstdio>
int main(){
	long int debt = 100000;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		debt *= 1.05;
		int mod = debt % 1000;
		if(mod != 0){
			debt += (1000-mod);
		}
		//printf("%ld\n",debt);
	}
	printf("%d\n",debt);
	return 0;
}

Measured memory_bytes: 2608
s = input()
t = input()

a = [[] for i in range(26)]

for i in range(len(s)):
	a[ord(s[i]) - ord('a')].append(i)

cnt = 1

prev = -1
i = 0 
while(i < len(t)):
	l = t[i]
	indi = ord(l) - ord('a')
	li = a[indi]

	if(li == []):
		print(-1)
		exit(0)

	if li[-1] <= prev:
		prev = -1
		cnt += 1

	start = 0
	end = len(li) - 1
	ans = -1
	while(start <= end):
		mid = (start + end)//2
		if li[mid] > prev:
			ans = mid
			end = mid - 1
		else:
			start = mid + 1
	# print(l,ans,li)
	prev = li[ans]

	i += 1

# print(cnt,prev)
final = cnt*len(s) - (len(s) - prev - 1)
print(final)

Measured memory_bytes: 46704
from collections import deque
n = int(input())
l = []
ans = [-1 for i in range(n+1)]

adj = [[] for i in range(n+1)]
for i in range(n-1):
    a, b, c = map(int, input().split())
    adj[a].append([b, c])
    adj[b].append([a, c])

deq = deque()
deq.appendleft(1)

while len(deq) > 0:
    v = deq.pop()
    for u, w in adj[v]:
        if ans[u] == -1:
            deq.appendleft(u)
        if ans[v] == -1 and ans[u] == -1:
            if w %2 == 0:
                ans[v] = 0
                ans[u] = 0
            else:
                ans[v] = 0
                ans[u] = 1
        elif ans[v] == 0:
            if w % 2 == 0:
                ans[u] = 0
            else:
                ans[u] = 1
        else:
            if w % 2 == 0:
                ans[u] = 1
            else:
                ans[u] = 0
        #print(ans)

if(n == 1): 
    print(0)
else:
    for i in range(1, n+1):
        print(ans[i])


Measured memory_bytes: 45352
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
	if (N % 10 == 3) printf("bon");
	else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) printf("pon");
	else printf("hon");
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
struct node {
    int l, r;
    int cnt[26];
};
node tree[500000 * 4 + 5];
string s;
void build(int cur, int l, int r) {
    tree[cur].l = l;
    tree[cur].r = r;
    if (l == r) {
        for (int i = 0; i < 26; i++) {
            tree[cur].cnt[i] = 0;
        }
        tree[cur].cnt[s[l - 1] - 'a'] = 1;
    } else {
        int mid = (l + r) / 2;
        build(cur * 2, l, mid);
        build(cur * 2 + 1, mid + 1, r);
        for (int i = 0; i < 26; i++) {
            tree[cur].cnt[i] = tree[cur * 2].cnt[i] + tree[cur * 2 + 1].cnt[i];
        }
    }
}
void update(int cur, int goal) {
    if (tree[cur].l == tree[cur].r && tree[cur].l == goal) {
        for (int i = 0; i < 26; i++) {
            tree[cur].cnt[i] = 0;
        }
        tree[cur].cnt[s[goal - 1] - 'a'] = 1;
    } else {
        int mid = (tree[cur].l + tree[cur].r) / 2;
        if (goal <= mid) {
            update(cur * 2, goal);
        } else {
            update(cur * 2 + 1, goal);
        }
        for (int i = 0; i < 26; i++) {
            tree[cur].cnt[i] = tree[cur * 2].cnt[i] + tree[cur * 2 + 1].cnt[i];
        }
    }
}
int ans[26];
void cnt(int cur, int l, int r){
    if(tree[cur].l >= l &&tree[cur].r <= r){
        for(int i = 0; i < 26; i++){
            ans[i]+=tree[cur].cnt[i];
        }
    }
    else{
        int mid = (tree[cur].l + tree[cur].r) / 2;
        if(l <= mid){
            cnt(cur*2,l,r);
        }
        if(r >= mid+1){
            cnt(cur*2+1,l,r);
        }
    }
}
int main(void) {
    ios_base::sync_with_stdio(false);
    int n, q;
    while (cin >> n >> s >> q) {
        build(1, 1, n);
        for (int i = 0; i < q; i++) {
            int type;
            cin >> type;
            if (type == 1) {
                int ind;
                char c;
                cin >> ind >> c;
                s[ind - 1] = c;
                update(1, ind);
            }
            else{
                int l,r;
                cin>>l>>r;
                memset(ans,0,sizeof(ans));
                cnt(1,l,r);
                int total = 0;
                for(int j= 0; j < 26; j++){
                    if(ans[j]!=0)total++;
                }
                cout<<total<<'\n';
            }
        }
    }
}

Measured memory_bytes: 117660
#include <iostream>
#include <stdlib.h>
#include <algorithm>
 
 
using namespace std;
 
int main(void){
    int N;
    cin >> N;
    int A[N+5];
    for (int i=0;i<N+5;i++){A[i]=0;}
    for (int i=1;i<=N;i++){
        cin >> A[i];
    }

    int next_botton = A[1];
    int count = 1;
    for(int i=2;i<=N;i++){
        if(next_botton == 2){
            cout << count << endl;
            return 0;
        }
        else{
            next_botton = A[next_botton];
            count++;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define int long long
const int N=1e6+5;
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
int n;
double a[N];
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	double ans=a[1];
	for(int i=2;i<=n;i++)
		ans=(ans+a[i])/2;
	printf("%.5lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

const double EPS = 1e-10;

struct Point {
	double x, y;
	Point(double x = 0, double y = 0) : x(x), y(y){}
	Point operator - (Point p) {return (Point(x - p.x, y - p.y));}
};

typedef Point Vector;

double dot(Vector a, Vector b)
{
	return (a.x * b.x + a.y * b.y);
}

double cross(Vector a, Vector b)
{
	return (a.x * b.y - a.y * b.x);
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

//3点の位置関係を求める
int ccw( Point p0, Point p1, Point p2 ){
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
	if (cross(a, b) < -EPS) return CLOCKWISE;
	if (dot(a, b) < -EPS) return ONLINE_BACK;
	if (dot(a, a) < dot(b, b)) return ONLINE_FRONT;
	return ON_SEGMENT;
}

double area(Vector a, Vector b)
{
	return (fabs(cross(a, b)) * 0.5);
}

int main()
{
	int r, x, y, n;
	
	scanf("%d %d %d %d", &r, &x, &y, &n);
	
	vector<Point> v;
	v.push_back(Point(0, 100));
	int sum = 0;
	int p[10];
	for (int i = 0; i < n; i++){
		scanf("%d", &p[i]);
		sum += p[i];
		if (sum != 100) v.push_back(Point(100 * sin(sum / 100.0 * 2 * M_PI), 100 * cos(sum / 100.0 * 2 * M_PI)));
	}
	
	double prev[10], diff[10];
	for (int i = 0; i < n; i++){
		prev[i] = 0.5 * 100 * 100 * (p[i] / 100.0 * 2 * M_PI);
		diff[i] = prev[i];
		double S = area(v[i], v[(i + 1) % n]);
		if (ccw(v[i], Point(0, 0), v[(i + 1) % n]) >= 0) diff[i] -= S;
		else diff[i] += S;
	}
	
	double now[10];
	for (int i = 0; i < n; i++){
		now[i] = diff[i];
		double S = area(v[i] - Point(x, y), v[(i + 1) % n] - Point(x, y));
		if (ccw(v[i], Point(x, y), v[(i + 1) % n]) >= 0) now[i] += S;
		else now[i] -= S;
	}
	
	for (int i = 0; i < n; i++) printf("%d%c", (int)(now[i] * 100 / prev[i]), " \n"[i == n - 1]);
	
	return (0);
}

Measured memory_bytes: 1040
#include <iostream>
#include <stdio.h>
#include <string.h>

int main() {
  std::string o, t;
  std::cin >> o >> t;
  int c = 0;
  for(int i = 0; i < 3; i++) {
    if(o.at(i) == t.at(i)) {
      ++c;
    }
  }
  std::cout << c;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  double m,n;

  int aleft=0,aright=0,bleft=0,bright=0;
  int cleft=0,cright=0,dleft=0,dright=0;


  while( scanf("%lf %lf",&m,&n) != EOF ){
    if(m>=1.1){
      aleft++;
    }else if(m>=0.6){
      bleft++;
    }else if(m>=0.2){
      cleft++;
    }else{
      dleft++;
    }
    if(n>=1.1){
      aright++;
    }else if(n>=0.6){
      bright++;
    }else if(n>=0.2){
      cright++;
    }else{
      dright++;
    }
  }

  printf("%d %d\n",aleft, aright);
  printf("%d %d\n",bleft, bright);
  printf("%d %d\n",cleft, cright);
  printf("%d %d\n",dleft, dright);
}

Measured memory_bytes: 1056
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair

int main() {
	bool s[10] = {};
	int n, k;
	cin >> n >> k;
	REP(i, k) {
		int a;
		cin >> a;
		s[a] = true;
	}
	FOR(i, n, INF) {
		int b = i;
		bool a = {};
		REP(j, INF) {
			if (s[b % 10]) a = true;
			b /= 10;
			if (b == 0) break;
		}
		if (!a) {
			cout << i << 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++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m,k;
	bool b=false;
	cin >> n >> m >> k;
	rep(i,n+1){
		rep(j,m+1){
			if(i*(m-j)+j*(n-i)==k) b=true;
		}
	}
	Yes(b);
	return 0;
}


Measured memory_bytes: 256
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim n As Integer = NextInt()
        Dim way, pre As Integer
        Dim ans As Integer = 1

        For i As Integer = 0 To n - 1
            Dim now As Integer = NextInt()
            If i = 0 OrElse now - pre = 0 Then
            ElseIf way = 0 Then
                way = Math.Sign(now - pre)
            ElseIf Math.Sign(now - pre) <> way Then
                ans += 1
                way = 0
            End If
            pre = now
        Next
        WriteLine(ans)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


Measured memory_bytes: 26692
#include <stdio.h>
void CountingSort(int *,int *,int );

int n;
int tA[10000000],tB[10000000];

int main(){
  int i,max=0;

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

    if(max<tA[i])max=tA[i];

  }

  for(i=1;i<=n;i++){
    tB[i]=0;
  }
  CountingSort(tA,tB,max);


  return 0;
}


void CountingSort(int A[],int B[],int k){
  int i,j;
  int C[100000];

  for (i = 0 ;i<=k;i++){
    C[i] = 0;
  }

  /* C[i] �� i �̏o������L�^���� */
  for( j = 1 ;j<= n;j++){

    C[A[j]]++;
  }


    /* C[i] �� i �ȉ��̐��̏o������L�^����*/
  for (i = 1 ;i<= k;i++){

    C[i] = C[i] + C[i-1];
  }

  for( j = n ;j>= 1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1){
      printf(" ");
    }
    
    printf("%d",B[i]);
  }
  printf("\n");
}



Measured memory_bytes: 17448
#include<bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define mem(x,i) memset(x,i,sizeof(x)) 
#define mec(x,y) memcpy(x,y,sizeof(y))
#define eps 1e-8 
#define ull unsigned long long
#define cps CLOCKS_PER_SEC
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
void exgcd(ll a, ll b, ll &x, ll &y, ll &d){if(!b) d=a,x=1,y=0;else exgcd(b,a%b,y,x,d),y-=a/b*x;}
ll inv(ll a, ll p){ll x,y,d;exgcd(a,p,x,y,d);x=(x%p+p)%p;return x;}
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=1e5+100;
int n,m,k,t;
ll l,r,d;
int main()
{
	cin>>l>>r>>d;
	ll ans=r/d-(l-1)/d;
	cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
long long n;
int q[100005];
//map<long long,long long>q;
//map<long long,long long>::iterator it;
long long  modl(long long a, long long b, long long c)        //快速幂取余a^b%c
{
	long long res=1;
	for(int i=0;i<b;i++)
	{
		res=res*a%c;
	}
	return res;
//    long long res, t;
//    res = 1 % c;
//    t = a % c;
//    while (b)
//    {
//        if (b & 1)
//        {
//            res = res * t % c;
//        }
//        t = t * t % c;
//        b >>= 1;
//    }
//    return res;
}
long long mod=1e9+7;
int main()
{
    memset(q,0,sizeof(q));
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        long long num;
        cin>>num;
        q[num]++;
    }
    if(q[0]>1)
    {
        cout<<"0"<<endl;
    }
    else if(q[0]==1||q[0]==0)
    {
        int num=0;
        for(int i=0;i<n;i++)
        {
            if(q[i]==2)
            {
                num++;
            }
            else if(q[i]>2)
            {
                cout<<"0"<<endl;
                return 0;
            }
        }
        num%=mod;
        cout<<modl(2,num,mod)%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if(s == "Sunny") cout << "Cloudy" << endl;
  else if(s == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		var s = Input().ToInt();
		int p = s[0] / s[1];
		int q = s[0] - p * s[1];
		if(q > 0)
			p++;
		Console.WriteLine(p);
	}


	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
int a[N];

int main()

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

    int a, b, c, x, ans = 0;

    cin >> a >> b >> c >> x;

    for (int i = 0; i <= a; i++) {

        for (int j = 0; j <= b; j++) {

            for (int k = 0; k <= c; k++) {

                if (i*500 + j*100 + k*50 == x) ans++;
            }
        }
    }

    cout << ans;

    return 0;
}


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


void solve(long long N){
    

    cout << round((float(N)+0.5)/2) << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n, ans, w[210];
int main(){
	scanf("%d", &n);
	for(int i=1; i<=n*2; i++)scanf("%d", &w[i]); sort(w+1, w+1+n*2);
	ans=0; for(int i=1; i<=n; i++)ans+=w[i*2-1]; printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
#define ll long long

int main () {
  ll n, K;
  cin >> n >> K;
  ll a[n];
  ll sum[n + 1];
  sum[0] = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  vector<ll> ans;
  for (ll i = 0; i < n + 1; i++) {
    for (ll j = i + 1; j < n + 1; j++) {
      ans.push_back(sum[j] - sum[i]);  
    }  
  }
  ll sub = 1;
  ll itr = 0;
  ll dp[40][ans.size()];
  for (ll i = 0; i < 40; i++) {
    for (ll j = 0; j < ans.size(); j++) {
      dp[i][j] = 0;  
    }  
  }
  for (ll i = 0; i < ans.size(); i++) {
    itr = 0;
    while (ans[i] != 0) {
      if ((ans[i] & 1) == 1) {
        dp[itr][i] = 1;
      }    
      else {
        dp[itr][i] = 0;  
      }
      ans[i] >>= 1;  
      itr++;
    }
  }
  sub = 1;
  for (int i = 0; i < 40; i++) {
    sub = sub * 2;  
  }
  ll answer = 0;
  bool ok = false;
  ll count[40];
  ll num = 0;
  for (ll i = 0; i < 40; i++) {
    num = 0;
    for (ll j = 0; j < ans.size(); j++) {
      // cout << dp[i][j] << " ";
      if (dp[i][j] == 1) {
        num++;  
      }  
    }  
    // cout << endl;
    count[i] = num;
  }
  for (ll i = 0; i < 40; i++) {
    sub = sub / 2;
    if (ok == false) {
      if (count[39 - i] >= K) {
        answer = answer + sub;
        ok = true;
        itr = 39 - i;
      }
    }
    else {
      num = 0;
      if (count[39 - i] >= K) {
        for (ll j = 0; j < ans.size(); j++) {
          if (dp[39 - i][j] == 1) {
            if (dp[itr][j] == 1) {  
              num++;
            }  
            else {
              dp[39 - i][j] = 0;  
            }
          }
        }  
        if (num >= K) {
          answer = answer + sub;  
          itr = 39 - i;
        }
      }     
    }
  }
  cout << answer << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<string> v;
    rep(i, n) {
        string tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    std::sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int cnt = 0;
    for (int i = 0; i < v.size(); i++) {
        if (v[i].length() != 0) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 11612
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include<unordered_map>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n;
	scanf("%d",&n);
	unordered_map<int, int>a;
	rep(i, n) {
		int m;
		cin >> m;
		if (a.count(m)) {
			a.erase(m);
		}
		else {
			a[m] = 1;
		}
	}
	cout << a.size() << endl;
}


Measured memory_bytes: 4388
N = int(input())
alphas = map(int, input().split())
alphas = list(alphas)

res =[]

r = None

for i in range(len(alphas)):
	if r is None:
		r = alphas[i]
	else:
		r ^= alphas[i]

for i in range(len(alphas)):
	res.append(r^alphas[i])
print(*res)

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

using namespace std;
int main()
{
    long long int x,y,z,ans,baki;
    scanf("%lld",&x);
    y = x/500;
    baki = x-(500*y);
    z = baki/5;
    ans = (1000*y)+(5*z);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int digit(int x, int n){
	REP(i,n){
		x/=10;
	}
	x%=10;
	return x;
}

int main(){
	int n;
	string s;
	cin>>n>>s;
	int left[10];
	int right[10];
	REP(i,10)left[i] = right[i] = -1;
	REP(i,n){
		char d=s[i];
		int num = d-'0';
		if(left[num] == -1){
			left[num] = right[num] = i;
		}else{
			right[num]=i;
		}
	}
	int ans=0;
	REP(i,10){
		int ansi=0;
		if(left[i]==-1)continue;
		REP(j,10){
			if(left[j]==-1)continue;
			if(left[i]<right[j]){
				REP(k,10){
					if(left[k]==-1)continue;
					if(left[j]<right[k]){
						if(right[j]<right[k]){
							ansi++;
							//cout<<i<<" "<<j<<" "<<k<<endl;
						}else{
							int leftj=n;
							for(int jj=left[i]+1;jj<right[k];jj++){
								char d=s[jj];
								int num=d-'0';
								if(num==j){
									leftj=jj;
									break;
								}
							}
							if(leftj<right[k]){
								ansi++;
								//cout<<i<<" "<<j<<" "<<k<<endl;
							}
						}
					}
				}
			}
		}
		ans+=ansi;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
ans = [0,0,0,0]
while True:
    tri = list(map(int,input().split()))
    tri.sort()
    a = tri[0]
    b = tri[1]
    c = tri[2]
    if a + b <= c:
        break
    ans[0] += 1
    if a**2+b**2 == c**2:
        ans[1] += 1
    elif a**2+b**2 < c**2:
        ans[3] += 1
    else:
        ans[2] += 1
print(ans[0],ans[1],ans[2],ans[3])
    
    


Measured memory_bytes: 5600
while True:

    n, a, b, c, x = map(int, input().split(" "))

    if n == 0 and a == 0 and b == 0 and c == 0 and x == 0:
        break

    y = list(map(int, input().split(" ")))

    ans = 0
    i = 0
    
    while ans <= 10000:
        if x == y[i]:
            i += 1

        if i == n:
            break
        x = (a * x + b) % c
        ans += 1
    if ans >= 10001:
        ans = -1
    print(ans)



Measured memory_bytes: 5608
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

using PI = P<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t; cin >> n >> t;
    V<PI> ab(n);
    for (int i = 0; i < n; i++) cin >> ab[i].first >> ab[i].second;
    sort(ALL(ab), [&](PI &i, PI &j){
        return i.first < j.first;
    });

    V< V<int> > dp(n + 1, V<int>(t + 1, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= t; j++) {
            chmax(dp[i + 1][j], dp[i][j]);
            if (j < t) chmax(dp[i + 1][min(j + ab[i].first, t)], dp[i][j] + ab[i].second);
        }
    }
    cout << *max_element(ALL(dp[n])) << '\n';
    return 0;
}


Measured memory_bytes: 38572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

char m(char c)
{
    if(c=='i' || c=='w') return c;
    if(c=='(') return ')';
    if(c==')') return '(';
}

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

    int S = s.size();
    int ans = 0;

    rep(i,S)
    {
        char f = m(s[i]);
        if(i == S-1-i)
        {
            if(s[i]!='i' && s[i]!='w')
            {
                s[i] = 'i';
                ++ans;
            }
        }
        else
        {
            if(s[S-1-i] != f)
            {
                s[S-1-i]=f;
                ++ans;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 5;
const int inf = 0x3f3f3f3f;

int main(){
	int N, D;
	while (cin >> N >> D){
		int ans = 0, x = 1;
		while (x <= N){
			x += D * 2;
			ans++;
			x += 1;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (int)N; i++)

const int UNVISITED = -1;
vector<int> low;
vector<int> dist;
vector<int> component;
vector<vector<int>> adjacentList;
stack<int> path;

int cid = 1;
int t = 0;
int dfs(int i) {
  t++;
  low[i] = t;
  dist[i] = t;
  path.push(i);

  for(auto n: adjacentList[i]) {
    if(dist[n] == UNVISITED) {
      low[i] = min(low[i], dfs(n));
    } else if(component[n] == -1){
      low[i] = min(low[i], dist[n]);
    }
  }

  if(dist[i] == low[i]) {
    while(!path.empty()) {
      int v = path.top(); path.pop();
      component[v] = cid;
      if(v == i)break;
    }
    cid++;
  }
  return low[i];
}

int main () {
  int V, E, Q;
  cin >> V >> E;
  low = vector<int>(V, 0);
  dist = vector<int>(V, UNVISITED);
  component = vector<int>(V, -1);
  adjacentList = vector<vector<int>>(V);

  for(int i = 0; i < E; i++) {
    int s, t;
    cin >> s >> t;
    adjacentList[s].push_back(t);
  }

  for (int i = 0; i < V; i++) {
    if(dist[i] == UNVISITED)dfs(i);
   }

  cin >> Q;
  for(int i = 0; i < Q; i++) {
    int u, v;
    cin >> u >> v;
    cout << (component[u] == component[v]) << endl;
  }

  return 0;
}

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

int main(){

    ll x;
    cin>>x;
    for(ll i=0;;i++){
        float num = pow(x+pow(i,5),0.2);
        //ll res = pow(x-pow(i,5),0.2)/1;
        if(floor(num) == num){
            cout<<num<<" "<<i;
            break;
        }
        float num2 = pow(x+pow(-i,5),0.2);
        //ll res2 = pow(x-pow(-i,5),(1/5))/1;
        if(floor(num2) == num2){
            cout<<num2<<" "<<-i;
            break;
        }
    }
    return 0;

}


Measured memory_bytes: 4216
def main():
    N = int(input())
    C = list(input())
    ans = 0
    w, r = 0, N - 1
    while True:
        while w < N and C[w] != 'W':
            w += 1
        if w == N:
            break
        while r >= 0 and C[r] != 'R':
            r -= 1
        if r == -1:
            break
        if r < w:
            break
        C[w] = 'R'
        C[r] = 'W'
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 10700
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N = 1e3 + 5;
const int M = 1e9 + 7;
int a[27];

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n;
    cin >> n;
    for(int i = 0; i < 26; i++) a[i] = M;
    while(n--) {
        string s;
        cin >> s;
        int temp[27];
        memset(temp, 0, sizeof(temp));
        for(int i = 0; i < s.size(); i++) {
            temp[s[i] - 'a']++;
        }
        for(int i = 0; i < 26; i++) {
            a[i] = min(a[i], temp[i]);
        }
    }
    for(int i = 0; i < 26; i++) {
        for(int j = 0; j < a[i]; j++)
            cout << (char)('a' + i);
    }
    cout << "\n";
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>	
#define inf ll(1e18)
using namespace std;
typedef long long ll;
int a[10000];
int main()
{
    int x;
    scanf("%d", &x);
    for (int i = 1; i <= x; i++) {
        scanf("%d", &a[i]);
    }
    int sum = 0,w=1;
    for (int i = w; i <= x; i++) {
        for (int j = i + 1; j <= x; j++) {
            for (int k = j + 1; k <= x; k++) {
                if (a[i] == a[k] || a[i] == a[j] || a[j] == a[k])continue;
                if (a[i] + a[j] > a[k] && a[j] + a[k] >a[i] && a[i] + a[k] > a[j])sum++;
            }
        }
    }
    printf("%d", sum);
    return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 100005, P = 998244353, V = 716070898;

int n, m, pw[N];

struct Graph {
	std::vector<int> E[N];

	void addEdge(int u, int v) {
		if (u > v) {
			std::swap(u, v);
		}
		E[u].push_back(v);
	}

	int vis[N], sg[N], mx, sum[N];

	void getSG() {
		for (int i = 0; i <= n; ++i) {
			vis[i] = 0, sum[i] = 0;
		}
		for (int u = n; u; --u) {
			for (int v : E[u]) {
				vis[sg[v]] = u;
			}
			sg[u] = 0;
			while (vis[sg[u]] == u) {
				++sg[u];
			}
			sum[sg[u]] = (sum[sg[u]] + pw[u]) % P;
		}
		mx = n;
		while (mx >= 0 && !sum[mx]) {
			--mx;
		}
	}
} G[3];

void solve() {
	read(n);
	pw[0] = 1;
	for (int i = 1; i <= n; ++i) {
		pw[i] = 1ll * pw[i - 1] * V % P;
	}
	for (int k = 0; k < 3; ++k) {
		read(m);
		for (int i = 0; i < m; ++i) {
			int u, v;
			read(u), read(v);
			G[k].addEdge(u, v);
		}
		G[k].getSG();
	}
	int ans = 0;
	for (int x = 0; x <= G[0].mx; ++x) {
		for (int y = 0; y <= G[1].mx; ++y) {
			int z = x ^ y;
			if (z <= G[2].mx) {
				ans = (ans + 1ll * G[0].sum[x] * G[1].sum[y] % P * G[2].sum[z]) % P;
			}
		}
	}
	print(ans);
}

int main() {
	int T = 1;
	// read(T);
	while (T--) {
		solve();
	}
}


Measured memory_bytes: 23300
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	ll N;
	cin>>N;
	ll ans=0;
	
	ll s=sqrt(N);
	
	rep1(i,s){
		ll z=(ll)i;
		if(N%z==0 && N/z-1>z)ans+=(N/z-1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int H, W, i, j;

    while (1) {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0) {
            break;
        }
        for (i = 0; i < H; i++) {
            for (j = 0; j < W; j++) {
                if ((i + j) % 2 == 0) {
                    fputc('#', stdout);
                } else {
                    fputc('.', stdout);
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 576
//メモリ数確認したか?
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long int ll;

int main()
{
	while(true){
    string s[10];
	int n,a;
	scanf("%d",&n);
	if(n==0)return 0;
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		s[a]+="*";
	}
	for(int i=0;i<10;i++){
		if(s[i].length()==0)printf("-\n");
		else cout << s[i] << "\n";
	}
	}
    return 0;
}
//メモリ数確認したか?

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b;
    Scd2(a,b);

    printf ("%d\n", (a+b) % 24);

    return 0;
}



Measured memory_bytes: 256