akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	auto start = high_resolution_clock::now(); 

	int n, k;
	cin >> n >> k;

	if (n >= 2*k - 1)
		cout << "YES";
	else
		cout << "NO";

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 256
//NAME-DEEPESH BHATT
//Institute-IIT Dhanbad
//MOTTO-THINK FIRST,CODE LATER
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007  ;
#define pb push_back
#define mp make_pair
#define pi 3.14159265359
#define fill(a,b) memset(a, b, sizeof(a))
#define endl '\n'
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
ll power(ll a,ll n)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p);
    if (n % 2)
        return (p * a);
    else
        return p;
}
struct compare{
    bool operator()(pair<int,int>p1,pair<int,int>p2){
        int l1=p1.second-p1.first+1;
        int l2=p2.second-p2.first+1;
        if(l1==l2){
            return p1.first<p2.first;
        } else
            return l1>l2;
    }
};
int main()
{
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
    int test=1;
    /*cin>>test;*/
    while(test--) {
        int n,k;
        cin>>n>>k;
        vector<int>h(n);
        for(int i=0;i<n;i++){
            cin>>h[i];
        }
        vector<int>dp(n,INT_MAX);
        dp[0]=0;
        dp[1]=abs(h[1]-h[0]);
        for(int i=2;i<n;i++){
            for(int j=1;j<=k;j++){
                if(i-j<0){
                    break;
                }
                dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
            }
        }
        cout<<dp[n-1];
    }
    return 0;
}




Measured memory_bytes: 1024
fun main() {
    val input = readLine()!!.split(" ").map { it.toInt() }
    val w = input[0]
    val h = input[1]
    val n = input[2]

    var xMin = 0
    var xMax = w
    var yMin = 0
    var yMax = h

    for (i in 0 until n) {
        val input2 = readLine()!!.split(" ").map { it.toInt() }
        val tmpX = input2[0]
        val tmpY = input2[1]

        when (input2[2]) {
            (1) -> xMin = if ( xMin < tmpX) tmpX else xMin
            (2) -> xMax = if ( tmpX < xMax) tmpX else xMax
            (3) -> yMin = if ( yMin < tmpY) tmpY else yMin
            (4) -> yMax = if ( tmpY < yMax) tmpY else yMax
        }
    }

    if (xMax <= xMin || yMax <= yMin) {
        print(0)
        return
    }

    print((xMax - xMin) * (yMax - yMin))
}

Measured memory_bytes: 37896
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll MOD = 1000000007;

int main() {
    ll x;
    cin >> x;
    if (x == 1) {
        cout << 1 << endl;
        return 0;
    }
    vll a;
    REP(i, x) {
        ll ans = (i+2)*(i+2);
        REP(j, x) {
            ans *= i+2;
            if (ans > x && ans/(i+2) <= x) {
                a.push_back(ans/(i+2));
                break;
            }
        }
    }
    cout << *max_element(ALL(a)) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int i = 1;
        while(true){
            int x = sc.nextInt();

            if(x==0) {
                break;
            }else{
                System.out.println("Case " + i++ + ": " + x);
            }
        }
    }
}



Measured memory_bytes: 41096
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],cnt[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long int n,x,y,z,i,j,k;
    x=0;y=0;
    cin>>n;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
    	cnt[arr[i]]++;
	}
	for (i=0;i<200000;i++)
	{
		if (cnt[i]>=1)
		{
			x++;
			if (cnt[i]%2==0)
			{
				y++;
			}
		}
	}
	if (y%2==1)
	{
		x--;
	}
	cout<<x<<endl;
}

Measured memory_bytes: 5120
<?php
// D
fscanf(STDIN, '%d %d %d', $n, $x, $y);
for ($i  = 0; $i < $n - 1; $i++) {
    $g[$i][] = $i + 1;
    $g[$i + 1][] = $i; // 無向グラフの場合
}
$x--;
$y--;
$g[$x][] = $y;
$g[$y][] = $x; // 無向グラフの場合

for ($i = 0; $i < $n - 1; $i++) {
    $dist = bfs($i);
    for ($j = $i + 1; $j < $n; $j++) {
        if (isset($ans[$dist[$j]])) {
            $ans[$dist[$j]]++;
        } else {
            $ans[$dist[$j]] = 1;
        }
    }
}
for ($i = 1; $i < $n; $i++) {
    echo ($ans[$i] ?? 0) . PHP_EOL;
}

function bfs($x)
{
    global $g, $n;
    // BFS（幅優先探索）：最短経路アルゴリズムとして活用
    $q = new SplQueue(); // キューを用意
    $dist = array_fill(0, $n, -1); // 距離を格納する配列（-1の場合はその頂点が未発見）

    $dist[$x] = 0; // 頂点0からの距離格納配列
    $q->enqueue($x); // キューに0を追加

    while (!$q->isEmpty()) {
        $v = $q->dequeue();

        foreach ($g[$v] as $next_v) {
            if ($dist[$next_v] !== -1) continue; // 発見済み

            $dist[$next_v] = $dist[$v] + 1;
            $q->enqueue($next_v);
        }
    }
    return $dist;
}

Measured memory_bytes: 4856
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Boat Travel
 * JOI 7th, Pre 6
 */
public class Main {

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

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n, k;
			n = parseInt(line.substring(0, line.indexOf(' ')));
			k = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | k) == 0) break;

			//
			DijkstraA D = new DijkstraA(n);
			UnionFind U = new UnionFind(n);

			//
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < k; i++) {
				words = br.readLine().split(" ");
				if (words[0].equals("0")) {
					int a, b;
					a = parseInt(words[1]);
					b = parseInt(words[2]);
					//
					if (U.same(a, b)) {
						sb.append(D.solve(a, b)).append('\n');
					} else {
						sb.append(-1).append('\n');
					}
				} else {
					int c, d, e;
					c = parseInt(words[1]);
					d = parseInt(words[2]);
					e = parseInt(words[3]);
					//
					D.update(c, d, e);
					U.unite(c, d);
				}
			}

			System.out.print(sb.toString());
		}
	}
}

class DijkstraA {

	static final int INF = 1 << 29;

	int N;
	int[][] adj;
	int[] min;
	boolean[] used;

	DijkstraA(int n) {
		N = n;
		adj = new int[N + 1][N + 1];
		for (int i = 0; i < adj.length; i++) {
			Arrays.fill(adj[i], INF);
		}
		min = new int[N + 1];
		used = new boolean[N + 1];
	}

	void update(int c, int d, int e) {
		if (e < adj[c][d]) {
			adj[c][d] = adj[d][c] = e;
		}
	}

	int solve(int a, int b) {

		Arrays.fill(min, INF);
		Arrays.fill(used, false);

		min[a] = 0;

		while (true) {
			int v = -1;
			for (int u = 1; u <= N; u++) {
				if (!used[u] && (v == -1 || min[u] < min[v])) v = u;
			}
			if (v == -1) break;
			//
			used[v] = true;
			for (int u = 1; u <= N; u++) {
				min[u] = Math.min(min[u], min[v] + adj[v][u]);
			}
		}

		return min[b];
	}
}


class UnionFind {

	int[] par;
	int[] rank;

	UnionFind(int n) {
		par = new int[n + 1];
		for (int i = 0; i < par.length; i++) par[i] = i;
		rank = new int[n + 1];
	}

	int find(int a) {
		if (par[a] == a) {
			return a;
		} else {
			return par[a] = find(par[a]);
		}
	}

	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;

		if (rank[a] < rank[b]) {
			par[a] = b;
		} else {
			par[b] = a;
			if (rank[a] == rank[b]) rank[a]++;
		}
	}

	boolean same(int a, int b) {
		return find(a) == find(b);
	}
}

Measured memory_bytes: 33196
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    print(min(abs(N//K*K-N),abs((N//K+1)*K-N)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.util.*;
import java.util.ArrayList;
public class Main{
    public static void main(String[]args){  
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int A=sc.nextInt();
    int B=sc.nextInt();
    int sum=0;
    for(int i=0;i<N;i++){
        String a=String.valueOf(N-i);
        char[]aa=a.toCharArray();
        int[]aaa=new int[a.length()];
        for(int j=0;j<a.length();j++){
            aaa[j]=Integer.parseInt(""+aa[j]);
        }
        int summ=0;
        for(int k=0;k<a.length();k++){
            summ=summ+aaa[k];
        }
        if((summ>=A)&&(summ<=B)){
            sum=sum+(N-i);
        }


    }
    System.out.println(sum);
    
    }
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;



int main(){
    ll x,y,a,b,c; cin>>x>>y>>a>>b>>c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a) cin>>p[i];
    rep(i,b) cin>>q[i];
    rep(i,c) cin>>r[i];
    sort(p.begin(),p.end(),greater<ll>()); 
    sort(q.begin(),q.end(),greater<ll>());
    sort(r.begin(),r.end(),greater<ll>());
    ll ans = 0;
    rep(i,x) ans += p[i];
    rep(i,y) ans += q[i];
    ll i = x-1, j = y-1, k = 0;
    while(1){
        int d = 0;
        if(k<c){
            if(i<0){
                if(j>=0&&r[k]>q[j]) d = 2;
            }else{
                if(p[i]>=r[k]) {
                    if(j>=0&&r[k]>q[j])d = 2;
                }else{
                    if(j>=0&&r[k]>q[j]){
                        if(p[i]>=q[j])d = 2;
                        else d = 1;
                    }else d = 1;
                }
            }
        }
        if(d == 1){
            ans += r[k]-p[i];
            i--; k++;
        }else if(d==2){
            ans+=r[k]-q[j];
            j--; k++;
        }else break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

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

int main(void) {
	int N;
	cin >> N;
	vector<int> a(N+1);
	for(int i=1; i<=N; i++) cin >> a[i];

	int ans = 0;
	for(int i=1; i<=N; i++){
		if(i % 2 == 1){
			if(a[i] % 2 == 1){
				ans++;
			}
		}
	}


	cout << ans << endl;

}


Measured memory_bytes: 3620
program line
implicit none

integer :: n, x, y, i, j, k
integer, allocatable :: a(:)

read *, n, x, y
allocate(a(n-1)) 
a = 0

do i = 1, n-1
   do j = i+1, n
      k = min(j-i, abs(x-i)+1+abs(y-j))
      a(k) = a(k) + 1
   end do
end do

do k = 1, n-1
   print *, a(k)
end do

deallocate(a)

stop
end program line
      

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//ll lcm(ll x, ll y){ return x*y/__gcd(x, y);}
int main(){
    ll N, M; cin >> N >> M;
    bool ac[N+1];
    int wa[N+1];
    for(ll i=1; i<=N; i++){
        ac[i] =false;
        wa[i]=0;
    }
    ll n_ac = 0;
    ll n_wa = 0;
    for(ll i=0; i<M; i++){
        ll p; string s;
        cin >> p >> s;
        if(ac[p]){continue;}
        if(!ac[p]&&s=="AC"){n_ac++; ac[p]=true;continue;}
        if(!ac[p]&&s=="WA"){wa[p]++;continue;}
    }
      for(ll i=1; i<=N; i++){
        if(ac[i]){
      n_wa+=wa[i];}
    }
    cout << n_ac << ' ' << n_wa;

    //for(ll i=0; i<n; i++){}
    

}


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

using namespace std;
int main(){
    string s;
    cin >> s;
    if(s == "RRR") cout << '3' << endl;
    if(s == "RRS") cout << '2' << endl;
    if(s == "RSR") cout << '1' << endl;
    if(s == "RSS") cout << '1' << endl;
    if(s == "SRS") cout << '1' << endl;
    if(s == "SRR") cout << '2' << endl;
    if(s == "SSS") cout << '0' << endl;
    if(s == "SSR") cout << '1' << endl;
    return 0;
}



Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

ll solve()
{
    ll a, b, c, k;

    std::cin >> a >> b >> c >> k;

    if (k <= a)
        return k;

    k -= a;

    if (k <= b)
        return a;

    k -= b;

    return a - k;
}

int main()
{
    std::cout << solve() << std::endl;
//    solve();

    return 0;
}

Measured memory_bytes: 3640
n,k = map(int,input().split())
num = [0] * k
ans = 0
for i in range(1,n + 1):
  num[i%k] += 1
for a in range(k):
  b = (k - a) % k
  c = (k - a) % k
  if (b + c) % k != 0:
    continue
  ans += num[a] * num[b] * num[c]
print(ans)

Measured memory_bytes: 4596
import queue

k = int(input())
li = [1,2,3,4,5,6,7,8,9]
a = queue.Queue()
for l in li:
  a.put(l)

if k <= 9:
  print(li[k-1])
else:
  n = 9
  f=False
  while True:
    x = a.get()
    for i in [-1, 0, 1]:
      if x%10+i==10 or x%10+i==-1:
        continue
      d = (x+i)%10
      t=x*10+d
      a.put(t)
      n+=1
      if n==k:
        print(t)
        f=True
        break
    if f:
      break

Measured memory_bytes: 6744
import sys

def solve():
    N = int(input())
    A = [int(a) for a in input().split()]
    lengthD = dict()
    for a in A:
        if a in lengthD: lengthD[a] += 1
        else: lengthD[a] = 1
    moreThanTwo = []
    count = 0
    for key in lengthD:
        if lengthD[key] > 1: 
            moreThanTwo.append(key)
            count += 1
    
    if count == 0: print(0)
    else:
        ans = 0
        moreThanTwo.sort()
        if lengthD[moreThanTwo[-1]] > 3: ans = moreThanTwo[-1] ** 2
        if count < 2: print(ans)
        else:
            ans = max(ans, moreThanTwo[-1] * moreThanTwo[-2])
            print(ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 18060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << fixed<<setprecision(9)<<(double)(w*h)/2.0 << "\n";
  if(w==2*x&&h==2*y)cout << 1 << "\n";
  else cout << 0 << "\n";
  return 0;
}


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

int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ll n,k;
  cin>>n>>k;
  ll i;
  ll a[n+1];
  a[0]=0;
  for(i=1;i<=n;i++)
  cin>>a[i];
  vector<ll>ans;
  ans.push_back(1);
  ll b[n+1];b[0]=0;b[1]=1;
  for(i=2;i<=n;i++)
  b[i]=0;
   ll x=1;
  while(1)
  {
  	ll k1=a[x];
  	if(b[k1]==1)
  	{
  		ans.push_back(k1);
  		break;
	  }
	  else
	  {
	  	ans.push_back(k1);
	  	b[k1]=1;
	  	x=k1;
	  }
	  
  }
  
  int l=ans.size();
  /*for(i=0;i<l;i++)
  cout<<ans[i]<<" ";
  cout<<endl;*/
  if(k<l)
  {
  	cout<<ans[k]<<endl;
  }
  else
  {
  	ll c=ans[l-1];
  	ll y=0;
  	for(i=0;i<l;i++)
  	{
  	if(ans[i]==c)
	  {
	  	y=i;
	  	break;
		  }	
	  }
	  ll diff=l-1-y;
	  //cout<<"DIFF="<<diff<<endl;
	  //cout<<"LENGHT="<<l-1<<endl;
	  
	   ll j=k-l+1;
	   //cout<<"j="<<j<<endl;
	  ll r=j%(diff);
	  //cout<<"Remainder="<<r<<endl;
	  cout<<ans[y+r]<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 8448
#include<iostream>

using namespace std;

int main(){

   string s;
   cin>> s;

   int c=0, f=0;
   for(int i=0; i<s.size(); i++){
      if(s[i]=='C') c++;
      if(s[i]=='F'&&c!=0){
         cout<< "Yes"<< endl;
         return 0;
      }
   }

   cout<< "No"<< endl;

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  int n = 10*g + b;
  if(n % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <cmath>
#include<iomanip>
#include <unordered_map>
#include <map>
using namespace std;
static const long long MOD = 1000000007LL;
typedef long long ll;
unordered_map <string,int> ump;
 
 
int main()
{
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<3;i++)
    {
    	if(s[i]==t[i])
    		cnt++;
    }
    cout<<cnt<<endl;
 
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
 
namespace Aizu
{
    public class OnlineJudge
    {
        public static void Main()
        {
            int count = 0;
            for(int i = int.Parse(Console.ReadLine()); i > 0; --i) {
                var input = Console.ReadLine();
                if(count >= 0) {
                    var data = input.Split();
                    count = count + (int.Parse(data[1]) * (data[0][0] == '(' ? 1 : -1));
                }
            }
            Console.WriteLine(count == 0 ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 9356
N = int(input())
S = [input() for _ in range(N)]

abc = 'abcdefghijklmnopqrstuvwxyz'

ans = ''
cnt = 0

for a in abc:
    cnt = 100
    for s in S:
        cnt = min(cnt, s.count(a))

    ans += a*cnt
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		String numberArray = "";
		for(int i = 1; i <= n; i++) {
			numberArray += String.valueOf(i);
		}

		permutation(numberArray, "");
	}

	public static void permutation(String s, String ans) {
		if(s.length() <= 1) {
			if(ans.length() != 0) ans += " ";
			System.out.println(ans + s);
		}
		else {
			for(int i = 0; i < s.length(); i++) {
				if(ans.length() == 0) permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
				else permutation(s.substring(0, i) + s.substring(i + 1), ans + " " + s.charAt(i));
			}
		}
	}
}



Measured memory_bytes: 90604
n = int(input())
d = {}
for i in range(n):
    s ,p = input().split()
    p = int(p)
    if not(s in d):
        d[s] = {}
    d[s][p*-1] = i+1
for i in sorted(d.keys()):
    for j in sorted(d[i].keys()):
        print(d[i][j])


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
const int N=109;

int n,a[N];

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            ans+=a[i]*a[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String S = sc.next();
    long K = sc.nextLong();
    long answer = 0;

    // 全部同じ
    if(S.matches("^" + S.charAt(0) + "+$")) {
      answer = S.length() * K / 2;
    }
    else {

      long count = 0;
      String bef = null;

      for(String s : S.split("")) {
        if(s.equals(bef)) {
          count++;
          bef = null;
        }
        else {
          bef = s;
        }
      }

      if(S.charAt(0) == S.charAt(S.length() - 1)) {
        int length = S.length();
        long a = length - S.replaceAll("^" + S.charAt(0) + "+", "").length();
        long b = length - S.replaceAll(S.charAt(length - 1) + "+$", "").length();
        answer = count * K - (a/2 + b/2 - (a+b)/2) * (K - 1);
      }
      else {
        answer = count * K;
      }

    }

    System.out.println(answer);


  }

}


Measured memory_bytes: 24148
#include <stdio.h>
#include <algorithm>
int a[200005];
int b[200005];
int main(){
    int n,v,mid;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&v);
        a[i]=v;
        b[i]=v;
    }
    std::sort(b,b+n);
    mid = b[n/2-1];
    for(int i=0;i<n;i++){
        if(a[i]>mid){
          printf("%d\n",mid);
        }else{
            printf("%d\n",b[n/2]);
        }

    }
}


Measured memory_bytes: 3712
A, B = map(int, input().split())

from fractions import gcd

def divisors(num):
    """
    約数全列挙
    """
    divisors = []
    for i in range(1, int(num ** 0.5) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num // i)

    return divisors

a_d = set(divisors(A))
b_d = set(divisors(B))

c_set = a_d & b_d
c_list = sorted(list(c_set))
used = []
for k in c_list:
    if len(used) != 0:
        f = False
        for u in used:
            if gcd(u, k) != 1:
                f = True
                break
        if not f:
            used.append(k)
    else:
        used.append(k)
print(len(used))


Measured memory_bytes: 7168
#include<iostream>

using namespace std;

int main(void)

{
    long long int a, b, c, k, total = 0, q;
    cin>>a>>b>>c>>k;
    q = min(a, k);
    k -= q;
    total += q;
    q = min(b, k);
    k -= q;
    q = min(c, k);
    total -= q;
    cout<<total<<endl;
    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
int H, W;

struct point{
    int x;
    int y;
    point() : x(0), y(0) {}
    point(int _x, int _y) : x(_x), y(_y) {}
    point(point const& p, point const& q) : x(p.x + q.x), y(p.y + q.y) {}

    bool valid(char c) {
        if (x == 0 || y == 0) return false;
        if (W < x || H < y) return false;        
        return c == '.';
    }

};


int main() {

    cin >> H >> W;
    char board[H + 2][W + 2];
    for (int i = 0; i <= H + 1; i++) {
        for (int j = 0; j <= W + 1 ;j++) {
            board[i][j] = '#';
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W ;j++) {
            cin >> board[i][j];
        }
    }       

    int ans = 0;
    int score[H + 2][W + 2];

    int maximum = 0;
    for (int i = 1; i < H + 1;i++) {
        for (int j = 1; j < W + 1;j++) {

            if (board[i][j] == '#') continue;
            // Reset Score
            for (int i1 = 0; i1 < H + 2; i1++) {
                for (int j1 = 0; j1 < W + 2; j1++) {
                    score[i1][j1] = board[i1][j1] == '#' ?
                                    0 :
                                    H * W;
                }
            }

            score[i][j] = 0;
            point p;
            p.y = i;
            p.x = j;
            queue<point> qp;
            qp.push(p);                              

            point ways[4];
            ways[0] = point(-1, 0);
            ways[1] = point(0, -1);
            ways[2] = point(1, 0);
            ways[3] = point(0, 1);

            do {
                p = qp.front();
                int const val = score[p.y][p.x] + 1;
                
                qp.pop();

                if (!p.valid(board[p.y][p.x])) {
                    continue;
                }

                for (int i1 = 0; i1 < 4; i1++) {

                    point temp(p, ways[i1]);                   
                    if (val < score[temp.y][temp.x]) {
                       

                        qp.push(temp);
                        score[temp.y][temp.x] = val;                        
                    }
                }

            } while(0 < qp.size());

            for (int i1 = 1; i1 <= H; i1++) {
                for (int j1 = 1; j1 <= W; j1++) {

                    maximum = max(maximum, score[i1][j1]);
    //                cout << score[i1][j1] << ' ';
                }
  //              cout << endl;
            }

//             cout << endl;
//            minimum = min(maximum, minimum);
        }
    }

    cout << maximum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define ll long long

const int MAXN = (int)1e5 + 10;
char A[MAXN];
char B[MAXN];

ll gcd(ll a,ll b){
	if(!b) return a;
	else return gcd(b,a % b);
}
int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	scanf("%s",A + 1);
	scanf("%s",B + 1);
	/*if(n % m == 0 || m % n == 0){
		ll flag = 1;
		if(n >= m){
			ll c = n / m;
			for(ll i = 1;i <= m;i++){
				if(A[i * c] != B[i]) flag = 0;
			}
		}
		else{
			ll c = m / n;
			for(ll i = 1;i <= n;i++){
				if(B[i * c] != A[i]) flag = 0;
			}
		}
		if(!flag){
			printf("-1");
			return 0;
		}
		else printf("%lld",(n > m) ? n : m);
	}
	else{*/
		ll len = n * m / gcd(n,m);
		ll c2 = len / n;
		ll c1 = len / m; //beizengshu
		int flag = 1;
		
		int p1 = 1;
		int p2 = 1;
		 
		while((p1 <= n) && (p2 <= m)){
			if(A[p1] != B[p2]) flag = 0;
			p1 += c1;
			p2 += c2;
		}
		if(!flag){
			printf("-1");
			return 0;
		}
		else printf("%lld",len);

	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    string a, b;
    cin >> a >> b;
    if (a.size() == b.size()){
        if (a > b) {
            cout << "GREATER" <<endl;
            return 0;
        } 
        else if (b > a) {
            cout << "LESS" << endl;
            return 0;
        }
        else {
            cout << "EQUAL" << endl;
            return 0;
        }
    }
    else if (a.size() > b.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    else {
        cout << "LESS" << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int const N = 1000 * 1000 + 16;

// int n, m, k;
ll s, c;
bool chk(ll m) {
  return (c >= 2*m) && (s + (c-2*m)/2 >= m);
}

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cin >> s >> c;

  ll l = 0;
  ll r = 1000LL * 1000LL; r*=r;
  ll ans = 0;

  while(l <= r) {
    ll m = (r+l) >> 1;
    if(chk(m))
      l = m+1, ans = m;
    else
      r = m-1;
  }

  cout << ans;
}

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_right
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
sum_a = [0]+list(accumulate(a))
b = list(map(int,input().split()))
sum_b = list(accumulate(b))
ma = 0
#print(sum_a,sum_b)
for i in range(len(sum_a)):
    x = sum_a[i]
    if k<x:
      index = bisect_right(sum_b,k)
      ma = max(index,ma)
    else:
      k -= x
      index = bisect_right(sum_b,k)
      ma = max(i+index,ma)
      k += x
    #  print(x,k,index,ma)
print(ma)
    

Measured memory_bytes: 52224
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b,c,d,e,f;
    cin >> a >> b >> c >> d;
    e=a+b;
    f=c+d;
    if(e>f){
        cout << "Left" << endl;
    }else if (e<f){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }
}



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

tree_info = {}
for i in range(n):
    row = input().split()
    tree_info[int(row[0])] = (int(row[1]), list(map(int, row[2:])))
tree_info

Nodes = [None] * n

class Node:
    
    def __init__(self, id, parent, depth, child):
        self.id = id
        self.parent = parent
        self.depth = depth
        if (parent == -1):
            self.tree_type = "root"
        elif(len(child) == 0):
            self.tree_type = "leaf"
        else:
            self.tree_type = "internal node"
            
        self.child = child
        
        if(self.tree_type != "leaf"):
            self.make_child()
    
    def make_child(self):
        for ch_id in self.child:
            Nodes[ch_id] = Node(ch_id, self.id, self.depth + 1, tree_info[ch_id][1])
        
    
    def __str__(self):
        return "node {}: parent = {}, depth = {}, {}, {}".format(self.id, self.parent, self.depth, self.tree_type, self.child)


for i in range(n):
    if(Nodes[i] == None):
        Nodes[i] = Node(i, -1, 0, tree_info[i][1])
        Nodes[i].make_child()

for root in Nodes:
    print(root)


Measured memory_bytes: 53080
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b,c=map(int,input().split())
    k=int(input())
    print((2**k-1)*max(a,b,c)+a+b+c)
resolve()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
    #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 = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;

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

    int main()
    {
       vector<int> a(5,0);
        vector<int> b(5,0);
        vector<int> d(5,0);
        int ans=0;

       for(int i=0; i<5; i++)
       {
           cin>>a[i];

           if(a[i]%10!=0)
           {
               b[i]=(a[i]/10+1)*10;
           }
           else {b[i]=a[i];}
           d[i]=b[i]-a[i];
           ans+=b[i];
       }
       sort(d.begin(),d.end(),greater<int>());
       cout<<ans-d[0]<<endl;
    }


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  V<ll> r(n+1,0),b(n+1,0),g(n+1,0);
  for(int i=0;i<n;i++){
    if(s[i]=='R')r[i+1]++;
    else if(s[i]=='B')b[i+1]++;
    else g[i+1]++;
  }
  for(int i=0;i<n;i++){
    r[i+1]+=r[i];
    b[i+1]+=b[i];
    g[i+1]+=g[i];
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+2;j<n;j++){
      if(s[i]==s[j])continue;
      if((s[i]=='R'&&s[j]=='G')||(s[i]=='G'&&s[j]=='R')){
        ans+=b[j+1]-b[i];
        if((j+i)%2==0&&s[(i+j)/2]=='B')ans--;
      }
      if((s[i]=='R'&&s[j]=='B')||(s[i]=='B'&&s[j]=='R')){
        ans+=g[j+1]-g[i];
        if((j+i)%2==0&&s[(i+j)/2]=='G')ans--;
      }
      if((s[i]=='B'&&s[j]=='G')||(s[i]=='G'&&s[j]=='B')){
        ans+=r[j+1]-r[i];
        if((j+i)%2==0&&s[(i+j)/2]=='R')ans--;
      }
    }
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 3760
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
 
    int[] numlist = new int[n];
 
    for(int i = 0; i < n; i++){
      numlist[i] = sc.nextInt();
    }
 
    Arrays.sort(numlist);
 
    int halfnum = (numlist[n - 1] + 1) / 2;
    int sa = numlist[n - 1];
    int bestnum = 0;
 
    for(int i = 0; i < n - 1; i++){
      if(Math.abs(numlist[i] - halfnum) < sa){
        sa = Math.abs(numlist[i] - halfnum);
        bestnum = numlist[i];
      }
    }
    System.out.print(numlist[n - 1]); 
    System.out.print(" ");
    System.out.println(bestnum);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 26744
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int ans = 0;
	int L, R;
	cin >> L >> R;
	if (R - L + 1 >= 2019) {
		ans = 0;
	}
	else {
		ans = 2019;
		for (int i = L; i < R; i++) {
			for (int j = i + 1; j <= R; j++) {
				ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int h, a;
    cin >> h >> a;
    if (h % a == 0)
        cout << h / a << endl;
    else
        cout << h / a + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int p=1e9+7;
using namespace std;
#define ll long long
const int N=2e5+20;
const ll mod=1e9+7;
ll f[N],n,m,a,b;
ll powmod(ll x,ll n)
{
    ll s=1;
    while(n)
    {
        if(n&1)
            s=(s*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return s;
}
ll C(ll n,ll m)
{
    ll aa=f[n];
    ll bb=(f[m]*f[n-m])%mod;
    return (aa*powmod(bb,mod-2))%mod;
}
int main()
{
    ll i,j;
    f[0]=1;
    for(i=1; i<N; i++)
        f[i]=(f[i-1]*i)%mod;
    ll ans=0,cnt=0;
    while(cin>>n>>m>>a>>b)
    {
        ans=0;
        for(i=1; i<=n-a; i++)
        {
            ans+=(C(b+i-2,i-1)*C(m+n-b-i-1,n-i))%mod;
            ans%=mod;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    VVI Fr(n+1);
    VI Ca(n+1, -1), Fn(n+1, 0);
    vector<P> Bl(k);

    rep(i,m){
        int a,b;
        cin >> a >> b;
        Fr[a].push_back(b);
        Fr[b].push_back(a);
        Fn[a]++; Fn[b]++;
    }
    rep(i,k){
        int c,d;
        cin >> c >> d;
        Bl[i].first = c;
        Bl[i].second = d;
    }

    vector<set<int>> groups;
    VI done(n+1, 0);

    rep(i,n){
        int p = i+1;
        if(done[p] == 1) continue;

        int cand = 0;
        set<int> seen;
        VI todo = {};
        seen.insert(p);
        for(auto x : Fr[p]){
            seen.insert(x);
            todo.push_back(x);
            done[x] = 1;
        }
        while(!todo.empty()){
            int v = todo.back();
            todo.pop_back();
            for(auto x : Fr[v]){
                if(seen.count(x)) continue;
                seen.insert(x);
                todo.push_back(x);
                done[x] = 1;
            }
        }
        groups.push_back(seen);
    }

    VI gid(n+1, 0);
    int id = 0;
    for(auto s : groups){
        id++;
        int S = s.size();
        for(auto x : s){
            Ca[x] = S;
            gid[x] = id;
        }
    }

    for(auto q : Bl){
        int q1 = q.first, q2 = q.second;
        if(gid[q1] == gid[q2]){
            Ca[q1]--;
            Ca[q2]--;
        }
    }

    rep(i,n){
        int p = i+1;
        cout << (Ca[p] - Fn[p] - 1) << " ";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 18416
#include<bits/stdc++.h>
using namespace std;
long long n,m;
string s1,s2,s3;
int main()
{
    cin>>s1>>s2;
    cin>>n>>m;
    cin>>s3;
    if(s1==s3) 
    cout<<n-1<<' '<<m;
    else 
    cout<<n<<' '<<m-1;
    return 0;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int BIT[6] = {1,2,4,8,16,32};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int H, W, K,ans=0;
    cin >> H >> W >> K;
    char C[H][W], COPY[H][W];
    REP(h,H){
        REP(w,W){
            cin >> C[h][w];
        }
    }
    int hbitMax = 1<<H;
    int wbitMax = 1<<W;

    for(int hbit = 0; hbit < hbitMax; hbit++){
        for(int wbit = 0; wbit < wbitMax; wbit++){
            // 初期化
            int KCNT = 0;
            REP(h,H){
                REP(w,W){
                    COPY[h][w] = C[h][w];
                }
            }

            REP(h,H){
                REP(w,W){
                    if(((hbit&BIT[h])==0) && ((wbit&BIT[w])==0) && (COPY[h][w] == '#')){
                        KCNT++;
                    }
                }
            }
            if(K == KCNT) ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){ 
 int N; cin >> N;
  
  vector<pair<ll,ll>> arr(N);
  
  for(int i = 0; i < N; i++){
    
    ll X,L; cin >> X >> L;
  
    arr[i] = {X+L,X-L};
    
  }
  
  sort(arr.begin(),arr.end()); // 終端ソートする
  
  ll anchor = -2e9;
  
  int cnt = 0;
  
  for(int i = 0; i < N; i++){ 
    
    if( anchor <= arr[i].second ){ anchor = arr[i].first; cnt++;}
    //端点含まない→被っていてもいいver
    
  }
  
  cout << cnt << endl;
  
  return 0;
} 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long llong;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  llong h,n,m,to;
  to=0;
  cin>>h>>n;
  for(llong i=0;i<n;i++){
    cin>>m;
    to+=m;
  }
  cout<<(to>=h?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> Aapple(a);
  vector<int> Bapple(b);
  vector<int> Capple(c);
  priority_queue<int> possible;
  for(int i = 0; i < a; ++i) cin >> Aapple[i];
  for(int i = 0; i < b; ++i) cin >> Bapple[i];
  for(int i = 0; i < c; ++i) cin >> Capple[i];
  sort(Aapple.begin(), Aapple.end(), greater<int>());
  sort(Bapple.begin(), Bapple.end(), greater<int>());
  for(int i = 0; i < x; ++i)possible.push(Aapple[i]);
  for(int i = 0; i < y; ++i)possible.push(Bapple[i]);
  for(int i = 0; i < c; ++i)possible.push(Capple[i]);
  long long int ans = 0;
  /*
  while(!possible.empty()){
    cout << possible.top() << endl;
    possible.pop();
  }
  */
  for(int i = 0; i < x + y; ++i){
    ans += possible.top();
    possible.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572