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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
	InitIO() {
		cin.tie(nullptr);
		ios_base::sync_with_stdio(false);
		cout << fixed << setprecision(30);
	}
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
	for(T& x: vec) is >> x;
	return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
	for(int i=0; i<vec.size(); i++){
		os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
	}
	return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//main code

int main(int argc, char const* argv[])
{
	int n,k;
	cin >> n >> k;
	VL v(n);
	cin >> v;
	VL vv = v;
	vv.insert(vv.end(), v.begin(), v.end());
	LL ans = 0;
	for (int get = 0; get <= min(k,n); get++) { // 取る数
		for (int ret = 0; ret <= min(k-get,get); ret++) { // 返す数
			for(int s = n - get;s <= n;s++) {
				LL ans_t = 0;
				priority_queue<LL,VL,greater<LL>> pq;
				for (int i = 0; i < get; i++) {
					pq.push(vv[s+i]);
					ans_t += vv[s+i];
				}
				for (int i = 0; i < ret; i++) {
					ans_t -= pq.top();
					pq.pop();
				}
				ans = max(ans_t,ans);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

D = INT()
c = LIST()
s = [LIST() for _ in range(D)]

def decrease(d, j):  # d:日にち, j:開催するコンテスト
    tmp = 0
    for i in range(26):
        if i == j: continue
        tmp += c[i]*(d-last[i])
    return tmp 

ans = [0]*D

last = [0]*26
now = 0
for i in range(D):  # i+1日目
    ma = -INF
    ma_idx = None
    for j in range(26):  # 開催するコンテスト
        tmp = now
        tmp += s[i][j]
        tmp -= decrease(i+1, j)
        if tmp > ma:
            ma = tmp
            ma_idx = j
    now = ma
    last[ma_idx] = i+1
    ans[i] = ma_idx+1

print(*ans, sep="\n")


Measured memory_bytes: 10332
n,m=map(int,input().split())
hoge=[0 for i in range(n)]
huga=[0 for i in range(n)]
for i in range(m):
  a,b=map(str,input().split())
  if(hoge[int(a)-1]==0 and b=="AC"):
    hoge[int(a)-1]=1
  if(hoge[int(a)-1]==0 and b=="WA"):
    huga[int(a)-1]+=1
    
for i in range(n):
  if(hoge[i]==0):
    huga[i]=0
    
print(sum(hoge),sum(huga))

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	int a,b,c;
	cin>>a>>b>>c;

	swap(a,b);
	swap(a,c);

	cout<<a<<" "<<b<<" "<<c;
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve(
    left: usize,
    right: usize,
    n: usize,
    a: &Vec<usize>,
    dp: &mut Vec<Vec<Option<i64>>>,
) -> i64 {
    if left > right {
        return 0;
    }
    if dp[left][right].is_some() {
        return dp[left][right].unwrap();
    }
    if (left + right) & 1 != n & 1 {
        let mut res = solve(left + 1, right, n, a, dp) + a[left] as i64;
        if right > 0 {
            res = std::cmp::max(res, solve(left, right - 1, n, a, dp) + a[right] as i64);
        }
        dp[left][right] = Some(res);
        return res;
    } else {
        let mut res = solve(left + 1, right, n, a, dp) - a[left] as i64;
        if right > 0 {
            res = std::cmp::min(res, solve(left, right - 1, n, a, dp) - a[right] as i64);
        }
        dp[left][right] = Some(res);
        return res;
    }
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut dp: Vec<Vec<Option<i64>>> = vec![vec![None; n]; n];
    println!("{}", solve(0, n - 1, n, &a, &mut dp));
}


Measured memory_bytes: 166396
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,n;cin>>n;
	a=n/100;b=n%100;
	if(1<=a&&a<=12)
	{
		if(1<=b&&b<=12)
		{
			cout<<"AMBIGUOUS"<<endl;
		}
		else
		{
			cout<<"MMYY"<<endl;
		}
	}
	else
	{
		if(1<=b&&b<=12)
		{
			cout<<"YYMM"<<endl;
		}
		else
		{
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    int k;
    string s;
    cin >> k >> s;
    if(k>=s.size()) {
        cout << s << endl;
    }else{
        for(int i=0;i<k;i++) cout << s.at(i);
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n,total=0;
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	sort(a+1,a+n+1);
	for (int i=1;i<=n-2;i++)
	{
		for (int j=i+1;j<=n-1;j++)
		{
			for (int k=j+1;k<=n;k++)
			{
				if ((a[i]+a[j])>a[k])  total++;
				else break;
			}
		}
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
const int D=1<<21, C=22, M=1000000007;

int nob[D], ij[C];
vector <vector <int> > opt(C);
ll pw[C], dp[D];

int main(){
	int n, i, j, a, jj;
	
	opt[0].push_back(0), ij[0]++;
	for (i=1;i<D;i++){
		nob[i]=((i%2==0)?nob[i/2]:(nob[i/2]+1));
		opt[nob[i]].push_back(i), ij[nob[i]]++;
	}
	pw[0]=1;
	for (i=1;i<C;i++)	pw[i]=pw[i-1]*2;
	
	scanf ("%d", &n);
	
	dp[0]=1;
	for (i=0;i<n;i++){
		for (j=0;j<n;j++){
			scanf ("%d", &a);
			if (a==0)	continue;
			for (jj=0;jj<ij[i];jj++){
				a=opt[i][jj];
				if ((a&pw[j])==0)	dp[a|pw[j]]=(dp[a|pw[j]]+dp[a])%M;
			}
		}
	}
	
	printf ("%lld", dp[pw[n]-1]);
	
return 0;}

Measured memory_bytes: 35516
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
int a,b;
  scanf("%d%d",&a,&b);
  int countp=0,countt=1;
  while(1)
  {
    if(countt>=b)
      break;
    countp++;
    countt+=a;
    countt--;
  }
  cout<<countp;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e5+7;
const int n_max = 1e9;



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

    ll x2 = 1e9, y2 = 1;
    ll y3,x3;
    // y3 = (s / x2) + 1;
    // if(1e9 < y3)y3= 1e9;
    y3 = ceil(ld(s) / ld(x2)); 
    x3 = y3 * x2 - s;
    cout << "0 0 1000000000 1 " << x3  << ' ' << y3 << endl;
    // cout << endl;
    return 0;

}

Measured memory_bytes: 256
input_array = gets.chomp.split("")
anser = []
input_array.each.with_index(1){|name,index|
  if index.odd?
   anser << (name =~ /R|U|D/)
  else
    anser << (name =~ /L|U|D/)
  end
  }

if anser.all?
	puts "Yes"
else
  	puts "No"
end

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>
#include<map>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
  int n, a, b;cin>>n>>a>>b;
  string s;cin>>s;
  int count=0, count2=0;
  for(int i=0;i<n;i++){
  	if(s[i]=='a'){
      if(count<a+b){cout<<"Yes"<<endl;count++;}
      else cout<<"No"<<endl;
    }else if(s[i]=='b'){
      if(count<a+b&&count2<b){cout<<"Yes"<<endl;count++;count2++;}
      else cout<<"No"<<endl; 
    }else{
      cout<<"No"<<endl;
    }
  }
}


Measured memory_bytes: 896
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

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



#X = str(input()).split()
#a = [int(x) for x in input().split()]


NM = str(input()).split()
N = int(NM[0])
M = int(NM[1])


for i in reversed(range(math.floor(M/N)+1)):
  f = M/i
  if(f.is_integer() == True):
    if(N*i<=M):
      ans = i
      break


print(ans)


Measured memory_bytes: 40424
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N;
	vector<long double>x(N);
	vector<long double>y(N);
	for(int i=0;i<N;i++){
		cin>>x[i]>>y[i];
	}
	vector<int>p(N);
	for(int i=0;i<N;i++)p[i]=i;
	long double sum=0;
	int num=0;
	do{
		for(int i=1;i<N;i++){
			sum+=sqrt((x[p[i]]-x[p[i-1]])*(x[p[i]]-x[p[i-1]])+(y[p[i]]-y[p[i-1]])*(y[p[i]]-y[p[i-1]]));
		}
		num++;
	}while(next_permutation(p.begin(),p.end()));
	cout<<setprecision(20)<<sum/num<<endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())

cnt=0
mini,maxim=list(map(int,input().split()))
for _ in range(M-1):
    a,b=list(map(int,input().split()))
    if a>maxim:
        cnt=1
    else:
        mini=max(a,mini)
        maxim=min(b,maxim)

if cnt==0:
    print(maxim-mini+1)
else:
    print("0")


Measured memory_bytes: 3060
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Edge{
	bool operator<(const struct Edge &arg) const{
		return diff < arg.diff;
	}
	int from,to;
	double length,cost,diff;
};


int N,M;
int boss[10000],height[10000];
Edge edge[10000];

int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

int IS_SAME(int x,int y){
	return get_boss(x) == get_boss(y);
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

void init(){

	for(int i = 0; i < N; i++){
		boss[i] = i;
		height[i] = i;
	}
}

bool check(double per_length){

	init();

	for(int i = 0; i < M; i++){
		edge[i].diff = edge[i].length*per_length-edge[i].cost;
	}

	sort(edge,edge+M);

	double sum = 0.0;

	for(int i = 0; i < M; i++){
		if(!IS_SAME(edge[i].from,edge[i].to)){
			unite(edge[i].from,edge[i].to);
		}else{
			sum += edge[i].diff;
		}
	}

	return sum >= 0.0;
}

int main(){

	scanf("%d %d",&N,&M);

	for(int i = 0; i < M; i++){
		scanf("%d %d %lf %lf",&edge[i].from,&edge[i].to,&edge[i].length,&edge[i].cost);
	}

	double left = 0.0,right = 9999999.0,m = (left+right)/2;

	for(int loop = 0; loop < 100; loop++){
		if(check(m)){
			right = m-EPS;
		}else{
			left = m+EPS;
		}
		m = (left+right)/2;
	}

	printf("%.10lf\n",m);

	return 0;
}



Measured memory_bytes: 3644
#include <iostream>

#define MX 1000000000

using namespace std;
int M[100][100],N; //M[i][j]:i©çjÜÅÌRXg

int dijkstra(int s , int g){
  bool visited[100];
  int d[100];
  for(int i=0;i < N;i++) d[i] = MX , visited[i] = false;
  d[s] = 0;
  while(1){
    int u;
    int mincost = MX;
    for(int i=0;i<N;i++)if(!visited[i] && d[i] < mincost) mincost = d[i] , u = i;
    if(mincost == MX) break;
    visited[u] = true;
    for(int v=0;v<N;v++){
      if(visited[v] || M[u][v] == MX) continue;
      if(d[v] > d[u] + M[u][v]) d[v] = d[u] + M[u][v];
    }
  }
  return d[g];
}
    
int main(){
  int k;
  while(cin >> N >> k){
    for(int i=0;i<N;i++)for(int j=0;j<N;j++) M[i][j] = MX;
    while(k--){
      int x,a,b,c;
      cin >> x;
      if(!(x)){
        int cost;
        cin >> a >> b;
        cost = dijkstra(a-1,b-1);
        if(cost == MX) cout << "-1" << endl;
        else cout << cost << endl;
      }
      else {
        cin >> a >> b >> c;        
        if(M[a-1][b-1] > c && M[b-1][a-1] > c) M[a-1][b-1] = M[b-1][a-1] = c;
      }
    }
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int max = a[0], min = a[0];
  for(int i = 0; i < n; i++){
    if(max < a[i])
      max = a[i];
    if(min > a[i])
      min = a[i];
  }
  cout << max - min << endl;
  return 0;
}

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

int mod = 1000000007;
int mp[100005];
//---------------------------------------------------------------------------------------------------
int f[101010], rf[101010];
int inv(int x) {
    int res = 1;
    int k = mod - 2;
    int y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    FOR(i,1,101010-1) f[i] = (f[i - 1] * i) % mod;
    rep(i,101010) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
int nCk(int n, int k) {
    int a = f[n]; // = n!
    int b = rf[n-k]; // = (n-k)!
    int c = rf[k]; // = k!

    int bc = (b * c) % mod;

    return (a * bc) % mod;
}

signed main() {
    int n,m;cin>>n>>m;
    int orim = m;
    init();
    int cnt = 0;
    int idx = 0;
    bool tuika = false;
    FOR(i,2,sqrt(orim)+2)
    {
        while(m%i==0)
        {
            tuika = true;
            m/=i;
            mp[idx]++;
            cnt++;
        }
        if(tuika)idx++,tuika=false;
    }  

    if(m > 1) {
        mp[idx]++;
        cnt++;
        idx++;
    }

    int ans = 1;
    rep(i,idx)
    {
        (ans *= nCk(mp[i]+n-1,n-1)) %=mod;
    }

    cout << ans << endl;
}


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

using namespace std;
int main(){
    int A, B, C, D;
    int turn = 0;
    cin>>A;
    cin>>B;
    cin>>C;
    cin>>D;

    while(true){
        if(turn == 0){
            C = C-B;
            turn = 1;
        }
        else{
            A = A-D;
            turn = 0;
        }

        if(A<=0 || C<=0){
            break;
        }
    }

    if(A<=0){
        cout<<"No\n";
    }
    if(C<=0){
        cout<<"Yes\n";
    }

    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  ll Sum=0;
  rep(i, N){
    cin>>A[i];
    Sum+=A[i];
    Sum%=MOD;
  }
  ll Ans=0;
  rep(i, N){
    ll Rev=MOD+Sum-A[i];
    Rev%=MOD;
    Ans+=A[i]*Rev;
    Ans%=MOD;
  }
  if(Ans%2)Ans+=MOD;
  Ans/=2;
  cout<<Ans<<endl;
}

Measured memory_bytes: 4836
#include<iostream>
#include<stack>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	stack<int> st;
	cin>>n;
	st.push(n);
	while(cin>>n){
		if(!n){
			cout<<st.top()<<endl;
			st.pop();
		}else{
			st.push(n);
		}
	}
	return 0;
}

Measured memory_bytes: 1200
#include <cmath>
#include <climits> /* LLONG_MAX */

#include <string>
#include <vector>
#include <numeric> /* gcd, lcm, partial_sum, reduce*/
#include <iomanip> /* setprecision */
#include <iostream>
#include <algorithm>

using ll = long long; // c++11

const std::string ans[2] = { "No\n", "Yes\n" };

int main() {
    using namespace std;
    int n;
    cin >> n;
    vector<int> P;
    for (int i = 0; i < n; i++){
        int p;
        cin >> p;
        P.push_back(p);
    }

    int min_p = P[0];
    int ans = 1;
    for (int i = 1; i < n; i++)
    {
        if (P[i]<min_p) {
            min_p = P[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int N;
long long arr[20][20];
long long pre[1<<20];
long long dp[1<<20];

int main(){
    cin >> N;
    for(int i = 0; i<N; i++){
        for(int j = 0; j<N; j++){
            cin >> arr[i][j];
        }
    }
    for(int i = 0; i<(1<<N); i++){
        for(int j = 0; j<N; j++){
            if(i&(1<<j)){
                for(int k = 0; k<N; k++){
                    if(i&(1<<k)){
                        pre[i] += arr[j][k];
                    }
                }
            }
        }
    }
    for(int i = 0; i<1<<N; i++){
        dp[i] = pre[i];
        for(int j = ((j-1)&i); j>0; j = ((j-1)&i)){
            dp[i] = max(dp[i], dp[j]+dp[j^i]);
        }
    }
    cout << dp[(1<<N)-1]/2 << endl;
}


Measured memory_bytes: 2816
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        c: [Chars;h],
    }
    let mut ans = 0;
    for maskrow in 0..(1 << h) {
        for maskcol in 0..(1 << w) {
            let mut black = 0;
            for i in 0..h {
                for j in 0..w {
                    if ((maskrow >> i) & 1) == 0 && ((maskcol >> j) & 1) == 0 && c[i][j] == '#' {
                        black += 1;
                    }
                }
            }
            if black == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
def enq(a,x)
  b=a[i=-1] and b=a and until b.frozen?
    x < (a=b)[-1] or return a << x
    x > a[0] or return a.unshift x
    b = a[i = a.bsearch_index{|y| x < (y.frozen? ? y: y[0])}-1]
  end
  a[i+9] or return a.insert i+1, x
  i>0 ? a[i]=[b,x] : enq(a[i+=1].to_a,x)  rescue a[i]=[x,a[i]]
end
def deq(a) r=a.shift; a[0].frozen? or a.unshift *a.shift; r end
def poq(a) r=a.pop; a[-1].frozen? or a.push *a.pop; r end

Q,E,N = [],{},{}
F =->(e,n) { if !N[n]; enq Q, e; (E[e]||={})[n] = 0 end }
gets.to_i.times {
  n,a,b,c,d = gets.split.map &:to_i
  Q.replace [0]
  E.replace({0=>{n=>0}})
  N.clear
  p (catch(:e) { while 1
    E[e=deq(Q)].keys.each {|n|
      N[n] ? next : N[n]=e
      throw :e,e  if n == 0
      if n.even?
        q = n>>1
        x = a > q*d ? q*d : a
        F[e+x,q]
      else
        F[e+d,n+1]
        F[e+d,n-1]
      end
      q,m = n.divmod 3
      if 0 == m
        x = b > (y=q*d*2) ? y : b
        F[e+x,q]
      else
        F[e+d*m,n-m]
        F[e+d*(3-m),n-m+3]
      end
      q,m = n.divmod 5
      if 0 == m
        x = c > (y=q*d*4) ? y : c
        F[e+x,q]
      else
        F[e+d*m,n-m]
        F[e+d*(5-m),n-m+5]
      end
    }
    E.delete e
    deq Q  while Q[0] == e
  end })
}

Measured memory_bytes: 22656
S = gets.chomp
len = S.length

# conditions 1
# puts "con 1 is ok " if S == S.reverse
# # conditions 2
# puts "con 1 is ok " if S[0,(len-1)/2] == S[0,(len-1)/2].reverse
# # conditions 3
# puts "con 2 is ok " if S[(len+3)/2-1, len] == S[(len+3)/2-1, len].reverse
puts S == S.reverse && S[0,(len-1)/2] == S[0,(len-1)/2].reverse && S[(len+3)/2-1, len] == S[(len+3)/2-1, len].reverse ? "Yes" : "No"





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

struct edge{
  int to, cap, rev;
  edge(int to=0, int cap=0, int rev=0):to(to),cap(cap),rev(rev){}
};

typedef pair<int,int> P;
typedef pair<int,P> P2;

const int MAX = 300;
const int INF = 1 << 29;
vector<edge> G[MAX];
bool used[MAX];

void add_edge(int from, int to, int cap){
  G[from].push_back(edge(to, cap, G[to].size()));
  G[to].push_back(edge(from, 0, G[from].size()-1));
}

int dfs(int v, int t, int f){
  if(v == t) return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to, t, min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t){
  int flow = 0;
  while(1){
    fill(used,used+MAX,false);
    int f = dfs(s, t, INF);
    if(f == 0) return flow;
    flow += f;
  }
}

int main(){
  int n,m,s,t;
  while(cin >> n >> m){
    vector<P2> v;
    for(int i=0;i<m;i++){
      int a,b;
      cin >> a >> b;
      add_edge(a,b,1);
      add_edge(b,a,1);
      v.push_back(P2(i+1, P(b,G[b].size()-1)));
    }
    cin >> s >> t;

    cout << max_flow(s,t) << endl;
    for(int i=0;i<v.size();i++){
      if(G[v[i].second.first][v[i].second.second].cap == 1){
        v.erase(v.begin()+i);
        i--;
      }
    }
    cout << v.size() << endl;
    for(int i=0;i<v.size();i++) cout << v[i].first << endl;
  }
}

Measured memory_bytes: 1312
h,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(h)]

ct=0
ans=[]

for i in range(h):
  for j in range(w-1):
    if l[i][j]%2==1:
      ans.append([i+1,j+1,i+1,j+2])
      ct+=1
      l[i][j+1]+=1
for k in range(h-1):
  if l[k][w-1]%2==1:
    ans.append([k+1,w,k+2,w])
    ct+=1
    l[k+1][w-1]+=1

print(ct)
for i in range(ct):
  print(ans[i][0],ans[i][1],ans[i][2],ans[i][3])

Measured memory_bytes: 30256
/*
ID: jerrywcy
LINK:
LANG: C++
STATUS:
*/
#include <bits/stdc++.h>

#define init(array,x) memset(array,x,sizeof(array))

using namespace std;

typedef long long ll;

const int inf=0x3f3f3f3f;

int m,d;
int ans;

int read(){
    int f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}

int main()
{
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
    m=read();d=read();
    for (int x=4;x<=min(m,81);x++){
        for (int i=2;i<=9;i++){
            for (int j=2;j<=9;j++){
                if (i*j==x && i*10+j<=d)ans++;
            }
        }
    }
    printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int main(){
    int n;
    cin >> n;
    if(n == 0) cout << 1 << endl;
    else if (n == 1) cout << 2 << endl;
    else if (n == 2) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  int n = s.size();
  if(n!=a+b+1){
    cout << "No" << endl;
    return 0;
  }
  if(s[a]!='-'){
    cout << "No" << endl;
    return 0;
  }
  int cnt =0;
  for(int i=0; i<n; ++i){
    if(s[i]=='-') cnt++;
    if(cnt>1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string ans;
    int a,b,c;
    vector<int> vec(3);
    for (int i = 0; i < 3; i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    for (int i = 0; i < 2; i++){
        cout << vec.at(i) << " ";
    }
    cout << vec.at(2) << endl;
}


Measured memory_bytes: 3076
N, M = map(int, input().split())
ans = [None] * N
for _ in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] in [None, c]:
        ans[s - 1] = c
    else:
        print(-1)
        quit()

ans = "".join(map(lambda pair :str(pair[1]) if pair[1] != None else "0" if pair[0] or N == 1 else "1", enumerate(ans)))
if N > 1 and ans[0] == "0":
    print(-1)
    quit()

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstring>
#include <map>
#include<cmath>
#include <algorithm>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n;
    cout << "ABC" << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sum[100007],q,l,r;
int check[100007];
int main(){
	ios_base::sync_with_stdio(0);
	check[0]=check[1]=1;
	sum[0]=sum[1]=1;
	for(int i=2;i<=100000;i++){
		sum[i]=sum[i-1]+(check[i]==0 && check[(i+1)/2]==0);
		if(check[i]) continue;
		for(int j=2*i;j<=100000;j+=i){
			check[j]=1;
		}
	}
	cin>>q;
	while(q--){
		cin>>l>>r;
		cout<<sum[r]-sum[l-1]<<"\n";
	}
}


Measured memory_bytes: 1408
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
ll n,m,r,a,b,c,dp[100000],INF=(1LL<<60);
vector<PP> v;
bool Bell(void){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(dp[v[j].F.F]!=INF&&dp[v[j].F.S]>dp[v[j].F.F]+v[j].S){
                dp[v[j].F.S]=dp[v[j].F.F]+v[j].S;
                if(i==n-1)return false;
            }
        }
    }
    return true;
}
int main(void){
    cin>>n>>m>>r;
    for(int i=0;i<100000;i++)dp[i]=INF;
    dp[r]=0;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        v.push_back({{a,b},c});
    }
    if(!Bell()){
        cout<<"NEGATIVE CYCLE"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(dp[i]==INF)cout<<"INF"<<endl;
        else cout<<dp[i]<<endl;
    }
}



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

int main()
{
    long long a, b, v, w, t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;

    if(a < b) {
        if (a + v * t >= b + w * t) 
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    } else {
        if (a - v * t <= b - w * t)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

    return 0;
} 

Measured memory_bytes: 3624
N, X, M = map(int, input().split())

existence = [False] * M
a = []
A = X
for i in range(N):
    if existence[A]:
        break
    existence[A] = True
    a.append(A)
    A = A * A % M

for i in range(len(a)):
    if a[i] == A:
        break
loop_start = i

result = sum(a[:loop_start])
a = a[loop_start:]
N -= loop_start
loops = N // len(a)
remainder = N % len(a)
result += sum(a) * loops + sum(a[:remainder])
print(result)


Measured memory_bytes: 12056
N, Y = map(int, input().split())

a = 0

for i in range(N+1):
    for ii in range(N+1):
        iii = N - i - ii
        if iii < 0:
            break
        ans = 10000 * i + 5000 * ii + 1000 * iii
        if ans == Y:
                print(i,ii,iii)
                a += 1
                break

        #for iii in range(N):
        #    ans = 10000 * i + 5000 * ii + 1000 * iii
        #    J = i + ii + iii
        #    if ans == Y and J == N:
        #        print(i,ii,iii)
        #        a += 1
        #        break
        #if a != 0:
        #    break
    if a != 0:
        break

if a == 0:
    print(-1,-1,-1)


Measured memory_bytes: 3060
import sys

def all_lighted(input, mod, pattern):
    for i, bulb in enumerate(input):
        if bin(bulb & pattern).count('1') % 2 == mod[i]:
            next
        else:
            return False
    
    return True


def main():
    num_switch, num_bulb = [int(x) for x in sys.stdin.readline().split()]
    input = [0] * num_bulb

    for i in range(num_bulb):
        for x in sys.stdin.readline().split()[1:]:
            input[i] += 2**(int(x) - 1)

    mod = [int(x) for x in sys.stdin.readline().split()]

    count = 0

    for pattern in range(2 ** num_switch):
        if all_lighted(input, mod, pattern): count += 1

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#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(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n,m;
  cin >> n >> m;
  int cnt = 0;
  int L = 0;
  int R = 1000000007;
  for(int i=0;i<m;i++){
    int l,r;
    cin >> l >> r;
    L = max(L,l);
    R = min(R,r);
  }
  cout<< max(0,R-L+1) <<endl;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

int main()
{
    int N, i, first, second, third;
    string buf;
    long long nums[5];

    REP(i, 5)
    {
        nums[i] = 0;
    }

    scanf("%d\n", &N);

    REP(i, N)
    {
        getline(cin, buf);

        switch (buf[0])
        {
        case 'M':
            (nums[0])++;
            break;
        case 'A':
            (nums[1])++;
            break;
        case 'R':
            (nums[2])++;
            break;
        case 'C':
            (nums[3])++;
            break;
        case 'H':
            (nums[4])++;
            break;
        }
    }

    printf("%lld\n",
           nums[0] * nums[1] * nums[2]
           + nums[0] * nums[1] * nums[3]
           + nums[0] * nums[1] * nums[4]
           + nums[0] * nums[2] * nums[3]
           + nums[0] * nums[2] * nums[4]
           + nums[0] * nums[3] * nums[4]
           + nums[1] * nums[2] * nums[3]
           + nums[1] * nums[2] * nums[4]
           + nums[1] * nums[3] * nums[4]
           + nums[2] * nums[3] * nums[4] );

    return 0;
}


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

int main(){
	int n;
  	cin >> n;
  
  	int ans = 0;
  	for(int i = 1; i < n; i++){
    	int ab = n - i;
      	for(int j = 1; j*j <= ab; j++){
        	if(ab % j == 0){
            	if(ab == j*j) ans++;
              	else ans += 2;
            }
        }
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))
sm = sum(a)
tmp = a[0]
for i in range(1, n):
  if tmp > sm / 2:
    print(min(tmp * 2 - sm, sm - (tmp - a[i-1]) * 2))
    break
  tmp += a[i]
else:
  print(sm - (tmp - a[i]) * 2)

Measured memory_bytes: 26224
N, K = map(int, input().split())
m = 1000000007

dp = [[[0] * (K+2*N+1) for _ in range(N+1)] for _ in range(N+1)]

dp[0][0][0] = 1
for i in range(0, N):
  for j in range(0, i+1):
    for k in range(0, K+1):
      dp[i+1][j+1][k+2*(j+1)] += dp[i][j][k]
      dp[i+1][j+1][k+2*(j+1)] %= m
      dp[i+1][j][k+2*j] += dp[i][j][k]
      dp[i+1][j][k+2*j] %= m
      dp[i+1][j][k+2*j] += 2*j * dp[i][j][k]
      dp[i+1][j][k+2*j] %= m
      if j != 0:
        dp[i+1][j-1][k+2*(j-1)] += j*j * dp[i][j][k]
        dp[i+1][j-1][k+2*(j-1)] %= m
print(dp[N][0][K])


Measured memory_bytes: 96220
#include<bits/stdc++.h>
using namespace std;
const int M=100001;
int n,a[M][3],dp[M][3];
int solve(int st,int fl){
	fl%=3;
	if(st==n) return 0;
	int &ret=dp[st][fl];
	if(ret) return ret;
	ret=a[st][fl]+max(solve(st+1,fl+1),solve(st+1,fl+2));
	return ret;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
	int ans=0;
	for(int i=0;i<3;i++)
		ans=max(ans,solve(0,i));
	cout<<ans;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
int main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n,m;
  cin>>n>>m;
  int a[m+1];
  memset(a,0,sizeof(a));
  for (int i = 0; i < n; ++i)
  {
    /* code */
    int k;
    cin>>k;
    for(int j=0;j<k;j++)
    {
      int b;
      cin>>b;
      a[b]++;
    }
  }
  int ans=0;
  for(int i=1;i<=m;i++)
  {
    if(a[i]==n)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#abc149c

def is_prime(n):
 if n < 2: 
  return False;
 if n % 2 == 0:             
  return n == 2
 k = 3
 while k*k <= n:
   if n % k == 0:
    return False
   k += 2
 return True

x=int(raw_input())
while not is_prime(x):
 x+=1
print x


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
const ll INF=1e9+7;
const ll N = 1002;
const ll M = 21;
ll n,a[N],q,m,dp[21*2001];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	FOR(i,0,21*2001)dp[i]=0;
	cin>>n;
	FOR(i,0,n)cin>>a[i];
	dp[0]=1;
	FOR(i,0,n){
		for(ll j=n*2000;j>=0;j--){
				if(dp[j]==1)dp[j+a[i]]=1;
		}
	}
	cin>>q;
	FOR(p,0,q){
		cin>>m;
		if(dp[m]==1)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3492
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] ary = new Integer[n+1];
		Arrays.fill(ary, 0);
		Map<List<Integer>, Integer> anss = new LinkedHashMap<>();
		TreeMap<Integer, List<Integer>> map = new TreeMap<>();
		for(int i=0; i<n-1; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			ary[a]++;
			ary[b]++;
			List<Integer> pair = new ArrayList<>();
			pair.add(a);
			pair.add(b);
			anss.put(pair, -1);
			List<Integer> list = map.get(a);
			if(list == null) {
				list = new ArrayList<Integer>();
				list.add(b);
				map.put(a, list);
			} else {
				list.add(b);
				map.put(a, list);
			}
		}
		Arrays.sort(ary, Comparator.reverseOrder());
		System.out.println(ary[0]);

		//色付け処理
		// スタックを用意(どの頂点からきたのか、その頂点とその上の頂点は辺に何色を使っているのかの情報を盛り込む)
		Stack<List<Integer>> stack = new Stack<>();
		List<Integer> from = new ArrayList<>();
		from.add(map.firstKey());
		from.add(0);
		stack.push(from);
		while (!stack.empty()) {
			from = stack.pop();
			Integer tyouten = from.get(0);
			Integer color = from.get(1);
			List<Integer> l = map.get(tyouten);
			if(l == null) continue;
			int k = 1;
			for (Integer t: l) {
				if(color == k) k++;
				List<Integer> ans = new ArrayList<>();
				ans.add(tyouten);
				ans.add(t);
				anss.put(ans, k);
				List<Integer> ll = new ArrayList<>();
				ll.add(t);
				ll.add(k);
				k++;
				stack.push(ll);
			}
		}
		for (Integer ans : anss.values()) {
			System.out.println(ans);
		}
	}
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int di_sum = 0; 
  while (N > 0) {
    int X;
    cin >> X;
    if (X <= K - X) {
      di_sum += X * 2;
    }
    else {
      di_sum += (K - X) * 2;
    }
    N--;
  }
  cout << di_sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  char brock[100];
  int H, W, i, j, k, flag;

  scanf("%d %d", &H, &W);
  
  for(i = 0; i < H; i++){
    flag = -1;
    scanf("%s", brock);
    for(j = 0; j < W; j++){
      if(brock[j] == 'c')
	flag = 0;
      else if(flag > -1)
	flag++;
   
      printf("%d", flag);
      if(j == W-1)
	printf("\n");
	else
	  printf(" ");   
    }
  }
  return 0;
}

Measured memory_bytes: 604
import numpy as np

N = int(input())

A, B = [int(i) for i in input().split()]

P = [int(i) for i in input().split()]



def Three_Categorize(P,A,B):
    count_1 = 0
    count_2 = 0
    count_3 = 0
    for i in P:
        if i <= A:
            count_1 +=1
        elif (i > A) & (i <= B):
            count_2 +=1
        elif i > B:
            count_3 +=1
    
    return [count_1, count_2, count_3]
            
    
count = Three_Categorize(P,A,B)
ans=min(count)
print(ans)


Measured memory_bytes: 12428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define FIR first
#define SEC second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll DP[2001][2001];




int main() {
  IN(string,S);
  REP(i,S.size())
    cout << "x";
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    char c1[4];
    scanf("%s", c1);

    char c2[4];
    scanf("%s", c2);

    char c3[4];
    scanf("%s", c3);

    printf("%c%c%c\n", c1[0], c2[1], c3[2]);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int x;
    cin>>x;
    long long int hoge=100;
    long long int count=0;
    while (1) {
        hoge*=1.01;
        count++;
        if (hoge>=x) {
            cout<<count<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

const int MAX_LEN = 10;
char S[MAX_LEN+1];

void _main() {
  cin >> S;
  int s_len = strlen(S);

  if (S[0] != 'A') {
    cout << "WA" << "\n";
    return;
  }

  int c_count = 0;
  rep(i, 2, s_len-1) {
    if (S[i] == 'C') S[i] = 'c', c_count++;
  }
  if (c_count != 1) {
    cout << "WA" << "\n";
    return;
  }

  rep(i, 1, s_len) {
    if (S[i] < 'a' ||  S[i] > 'z') {
      cout << "WA" << "\n";
      return;
    }
  }
  cout << "AC" << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<vector<int>> A(N, vector<int>(N-1));
  for(int i=0; i<N; i++){
    for(int j=0; j<N-1; j++){
      cin >> A[i][j];
      A[i][j]--;
    }
  }
  vector<set<int>> update(2);
  vector<int> done(N, 0);
  vector<int> red;
  for(int i=0; i<N; i++)
    update[0].insert(i);
  
  int cnt = 0;
  int ans = -1;
  while(true){
    if(update[cnt%2].empty()){
      ans = cnt;
      for(int i=0; i<N; i++){
        if(done[i] != N-2) {
          ans = -1;
          break;
        }
      }
      break;
    }
    for(auto i: update[cnt%2]){
      int aite = A[i][done[i]];
      if(A[aite][done[aite]] == i) {
        update[(cnt+1)%2].insert(aite);
        update[(cnt+1)%2].insert(i);
      }
    }
    for(auto i: update[(cnt+1)%2]){
      if(done[i] == N-2) red.push_back(i);
      else done[i]++;
    }
    for(auto i: red){
      update[(cnt+1)%2].erase(i);
    }
    update[cnt%2].clear();
    cnt++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

int main() {
  string S;
  cin >> S;
  
  bool isgood = true;
  
  if(S[0] == S[1]) isgood = false;
  if(S[1] == S[2]) isgood = false;
  if(S[2] == S[3]) isgood = false;
  
  if(isgood)
    cout << "Good" << endl;
  else
    cout << "Bad" << endl;
}




Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int n;
    cin>>n;
    string s;
    while(n!=0){
        if(n%(-2)==0){s.pb('0');}
        else {s.pb('1');n--;}

        n/=-2;
    }
    reverse(s.begin(),s.end());
    if(s=="")cout<<0<<endl;
    else cout<<s<<endl;

    
    
}



    

Measured memory_bytes: 256