akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}


void solve(long long n, long long a, long long b){

    ll ret = (modpow(2,n,MOD)-1);
    ll nca_denom = 1;
    ll nca_num = 1;
    ll ncb_denom = 1;
    ll ncb_num = 1;

    for (ll i=0;i<a;i++){
        nca_denom = nca_denom * (n-i) %MOD;
        nca_num = nca_num *  modinv(i+1,MOD) %MOD;
    }
    for (ll i=0;i<b;i++){
        ncb_denom = ncb_denom * (n-i) %MOD;
        ncb_num = ncb_num *  modinv(i+1,MOD) %MOD;
    }
    ll nca = nca_denom * nca_num %MOD;
    ll ncb = ncb_denom * ncb_num %MOD;
    ret = ((ret -nca)%MOD - ncb) %MOD;
    if (ret<0){
        ret +=MOD;
    }
    printf("%lld\n",ret);

}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>PP;
const ll MOD = 1000000007;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int k=a/d;
  if(a%d>0)k++;
  int j=c/b;
  if(c%b>0)j++;
  if(k>=j)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve()
{ 
    ll n,k,i,j;
    cin >> n >> k;
    ll h[n],dp[n];
    for(i=0;i<n;i++) cin >> h[i];
    dp[0]=0; dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++) dp[i]=1e+18;
    for(i=2;i<n;i++)
    {
        for(j=0;j<min(k,i);j++) dp[i]=min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]));
    }
    cout << dp[n-1] << "\n";
}

 
int main()
{
    opt;
    solve();
    return 0;
}       

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int a[210000];
signed main(){
  int n;cin>>n;
  rep(i,n-1){
    int x;cin>>x;
    a[x]++;
  }
  repd(i,1,n+1)cout << a[i] << endl;
}


Measured memory_bytes: 5084
word_counts = Hash.new(0)
max = ""
words = gets.chomp.split(nil)
words.each do |word|
  word_counts[word] += 1

  max = word if (word.length > max.length)
end
puts "#{word_counts.max{|a,b|a[1]<=>b[1]}[0]} #{max}"

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

int main()
{
    long long mod = 1000000000 + 7;
    int N, K;
    cin >> N >> K;
    long long sum[N + 1];
    long long sum_inv[N + 1];
    for (int i = 0; i < N + 1; i++)
    {
        sum[i] = 0;
        sum_inv[i] = 0;
    }
    sum_inv[0] = N;
    for (int i = 1; i < N + 1; i++)
    {
        sum[i] = sum[i - 1] + i;
        sum_inv[i] = sum_inv[i - 1] + (N - i);
    }
    long long ans = 0;
    for (int i = K; i < N + 1; i++)
    {
        ans = (ans + (sum_inv[i - 1] - sum[i - 1] + 1)%mod) % mod;
    }
    cout << (ans + 1) % mod << endl;
}


Measured memory_bytes: 6696
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		//キーボード入力メソッド
		Scanner sc = new Scanner(System.in);

		//入力
		int S = sc.nextInt();

		//処理
		int h = 0;
		int m = 0;
		int s = 0;
		int amr = 0;

		h = S / (60 * 60);
		amr = S % (60 * 60);
		m = amr / 60;
		s = amr % 60;

		//出力
		System.out.println(h + ":" + m + ":" + s);

	}

}



Measured memory_bytes: 26228
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;


int Pow(int x , int y , int mod){
  int res = 1;
  while(y>0){
      if(y&1)
          res = (res*x) % mod;
      y=y>>1;
      x = (x*x) % mod;
  }
  return res % mod;
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  
  int n , k;
  cin >> n >> k;
  vector<int>dp(k+1,0);
  for(int i = k; i >= 1; i--) {
    int ans = 0;
    int N = k / i;
    ans += Pow(N , n , Mod);
    ans = ans % Mod;

    for(int j = i * 2; j <= k; j += i) {
      ans = (ans + Mod - dp[j]) % Mod;
    }
    dp[i] = ans;
  }
  int ans = 0;
  for(int i = 1; i<= k; i++) {
    ans += (dp[i] * i) % Mod;
    ans = ans % Mod;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3556
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		PrintWriter out=new PrintWriter(System.out);
		long S = sc.nextLong();
		long X1=0;
		long Y1=0;
		long X2=0;
		long Y2=0;
		long X3=0;
		long Y3=0;
		
		if(S<=1000*1000*1000) {
			Y2=S;
			X3=1;
			out.print(X1+" "+Y1+" "+X2+" "+Y2+" "+X3+" "+Y3);
			out.flush();
			return;
		}
		
		
		long N=(long) Math.sqrt(S)+1;
		
		if(S==(N-1)*(N-1)) {
			N=N-1;
		}
		
		if(S-N*N<S-(N-1)*N) {
			long M=N*N-S;
			X2=N;
			Y3=N;
			X3=1;
			Y2=M;
		}else {
			long M=N*(N-1)-S;
			X2=N;
			Y3=N-1;
			X3=1;
			Y2=M;
		}
		out.print(X1+" "+Y1+" "+X2+" "+Y2+" "+X3+" "+Y3);
	
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public char[][] nextCharsHW(int H, int W) {
		char[][] chars = new char[H][W];
		for (int i = 0; i < H; i++) {
			String str = next();
			for (int j = 0; j < W; j++) {
				chars[i][j] = str.charAt(j);
			}
		}
		return chars;
	}

	public int[][] nextIntsNM(int N, int M) {
		int[][] ints = new int[N][M];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				ints[i][j] = nextInt();
			}
		}
		return ints;
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
    int n, m , q;
    cin >> n >> m >>q;
    vector<vector<int>> a(q, vector<int>(4));
    rep(i,q){
        rep(j,4){
            cin >> a.at(i).at(j);
        }
    }
    int max=0;
    vector<int> p(n+m);
    rep(i,n+1){
        p.at(i)=1;
    }
    rep(i,m-1){
        p.at(n+i+1)=0;
    }
    sort(p.begin(), p.end());
    do{
        int sum=0;
        int d;
        int k;
        rep(i,q){
            d =0;
            k= -1;
            rep(j,p.size()){
                if(k < a.at(i).at(0)){
                    if(p.at(j) == 1){
                        k++;
                    }
                }
                else{
                    if(p.at(j) ==0){
                        d++;
                    }
                    if(p.at(j) ==1){
                        k++;
                    }
                }
                if(k== a.at(i).at(1)){
                    break;
                }
            }
            if(a.at(i).at(2)==d){
                sum += a.at(i).at(3);
            }
        }
        if(sum > max){
            max= sum;
        }
    } while (next_permutation(p.begin(), p.end()));
    cout << max  << endl;
}

Measured memory_bytes: 3608
n=int(input())
a=[]
x=[[-1]*n for _ in range(n)]
y=[[-1]*n for _ in range(n)]
ans=0
for i in range(n):
  a.append(int(input()))
  for j in range(a[-1]):
    x[i][j],y[i][j]=map(int,input().split())
for i in range(2**n):
  for j in range(n):
    if (i>>j)&1:
      for k in range(a[j]):
        if not (i>>(x[j][k]-1))&1==y[j][k]:
          break
      else:
        continue
      break
  else:
    ans=max(ans,sum([(i>>j)&1 for j in range(n)]))
print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 0;
    String first = "1",second = "2";
    int harf = 0;
    while(s.length() > 0){
      s = s.substring(0,s.length()-2);
      harf = s.length()/2;
      first = s.substring(0,harf);
      second = s.substring(harf,s.length());
      if(first.equals(second)){
        break;
      }
    }
    System.out.println(s.length());
  }
}


Measured memory_bytes: 21844
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	int d = max(a, b);
	if (c % d == 0) {
		cout << c / d << endl;
	}
	else {
		cout << c / d + 1 << endl;
	}
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()] # 村
B = [int(x) for x in input().split()] # 勇者

B.append(0)
rest = 0
score = 0
for a,b in zip(A,B):
  x = min(a,rest)
  score += x
  a -= x
  if b < a:
    score += b
    rest = 0
    continue
  score += a
  rest = b - a
print(score)

Measured memory_bytes: 19648
#include<stdio.h>
#include<limits.h>

long compTimes = 0;

void merge(int A[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1], R[n2+1];
	int i, j, k;
	for( i = 0; i < n1; i++ ){ L[i] = A[left+i]; }
	for( i = 0; i < n2; i++ ){ R[i] = A[mid+i]; }
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	i = 0;
	j = 0;
	int c = 0;
	for( k = left; k < right; k++ ){
		if( L[i] <= R[j] ){
			A[k] = L[i++];
			c++;
		}else{
			if( c < n1 ){ compTimes += n1 - c; }
			A[k] = R[j++];
		}
	}
	return;
}

void mergeSort(int A[], int left, int right){
	if( left+1 <  right ){
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
	return;
}

int main(){
	int A[200000], S[200000];
	int n, i, j, count = 0;
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){
		scanf("%d", &A[i]);
		S[i] = A[i];
	}
	mergeSort(S, 0, n);
	printf("%ld\n", compTimes);
	return 0;
}

Measured memory_bytes: 2936
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

m = set(i * j for i in range(1, 10) for j in range(1, 10))
if input() in m:
    print "Yes"
else:
    print "No"

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

#define ll long long
using namespace std;

int main() {
ll n;
cin>>n;
string s,t;
cin>>s>>t;
string a="";
for(ll i=0;i<n;i++)
{
    a+=s[i];
    a+=t[i];
}
cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
char s[5005];
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    scanf("%d%s",&len,s+1);
    int ans=0;
    FOR(i,1,len){
    	int t=0,maxi=0;
    	FOR(j,1,len-i){
    		if(s[j]==s[j+i]){
    			t++;
    		}else{
    			maxi=max(t,maxi);t=0;
    		}
    	}
    	maxi=max(maxi,t);
    	ans=max(ans,min(i,maxi));
    }
    cout<<ans;
	RE 0;
}




Measured memory_bytes: 384
# -*- coding: utf-8 -*-
from queue import Queue

q = Queue()
N, M = [int(n) for n in input().split()]
graph = {n:[] for n in range(1, N+1)}

for m in range(M):
    a, b = [int(n) for n in input().split()]
    graph[a].append(b)
    graph[b].append(a)

end = 0
for n in range(2, N+1):
    if len(graph[n]) == 1:
        end = n

ok = []
q.put([1, []])

while not q.empty():
    point, past = q.get()
    for d in graph[point]:
        if not d in past:
            if len(past + [point, d]) == N:
                ok.append(past + [point, d])
            else:
                q.put([d, past+[point]])

print(len(ok))            

Measured memory_bytes: 5232
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int a,b;scanf("%d%d",&a,&b);
    double ret=0;
    for(int i=1;i<=a;i++){
        double tmp=1.0/a;
        int now=i;
        while(now<b){
            now*=2;
            tmp/=2;
        }
        ret+=tmp;
    }
    printf("%.12f\n",ret);
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const int MAXN = 200000;

/*
int N, M;

struct Edge {
    int to;
    int weight;
    int next;
};

vector<Edge> edges(MAXN);
vector<int> head(MAXN, -1);
vector<int> matchingx(MAXN, -1);
vector<int> matchingy(MAXN, -1);
vector<bool> check(MAXN);
vector<int> dis(MAXN);
vector<bool> vis(MAXN, false);

int cnt = 1;

void addEdge(int from, int to, int weight) {
    edges[cnt].to = to;
    edges[cnt].weight = weight;
    edges[cnt].next = head[from];
    head[from] = cnt++;
}

bool dfs(int u) {
    for (int i = head[u]; i != -1; i = edges[i].next) {
        int v = edges[i].to;
        if (!check[v]) {
            check[v] = true;
            if (matchingy[v] == -1 || dfs(matchingy[v])) {
                matchingy[v] = u;
                matchingx[u] = v;
                return true;
            }
        }
    }
    return false;
}

int hungarian() {
    int ans = 0;
    fill(matchingx.begin(), matchingx.end(), -1);
    fill(matchingy.begin(), matchingy.end(), -1);
    for (int u = 1; u <= N; ++u) {
//        if (matchingx[u] == -1) {
        {
            fill(check.begin(), check.end(), false);
            if (dfs(u)) {
                ++ans;
            }
        }
    }
    return ans;
}

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<>> que;
    fill(dis.begin(), dis.end(), INF);
    dis[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int u = p.second;
        if (vis[u]) continue;
        vis[u] = true;
        for (int i = head[u]; i != -1; i = edges[i].next) {
            int v = edges[i].to;
            if (dis[v] > dis[u] + edges[i].weight && !vis[v]) {
                dis[v] = dis[u] + edges[i].weight;
                que.push(P(dis[v], v));
            }
        }
    }
}

struct TreeNode {
    int val;
    TreeNode* left = nullptr;
    TreeNode* right = nullptr;
    TreeNode(int val_) : val(val_) {}
};
 */

int main() {
    ll A, B, Q;
    cin >> A >> B >> Q;
    vll numsA(A);
    vll numsB(B);
    for (int i = 0; i < A; ++i) {
        cin >> numsA[i];
    }
    numsA.push_back(-100000000000LL);
    numsA.push_back(100000000000LL);
    for (int i = 0; i < B; ++i) {
        cin >> numsB[i];
    }
    numsB.push_back(-100000000000LL);
    numsB.push_back(100000000000LL);
    sort(numsA.begin(), numsA.end());
    sort(numsB.begin(), numsB.end());
    ll x;
    for (int i = 0; i < Q; ++i) {
        cin >> x;
        auto uba = upper_bound(numsA.begin(), numsA.end(), x);
        auto ubb = upper_bound(numsB.begin(), numsB.end(), x);
        auto lba = uba - 1;
        auto lbb = ubb - 1;
        vll tmpA = {*lba, *uba};
        vll tmpB = {*lbb, *ubb};

        ll ans = 0;

        ans = tmpA[1] - tmpB[0] + min(tmpA[1] - x, x - tmpB[0]);
        ans = min(ans, tmpB[1] - tmpA[0] + min(tmpB[1] - x, x - tmpA[0]));
        ans = min(ans, x - min(tmpA[0], tmpB[0]));
        ans = min(ans, max(tmpA[1], tmpB[1]) - x);

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

Measured memory_bytes: 2912
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var R = long.Parse(Console.ReadLine());

            if (R < 1200)
            {
                Console.WriteLine("ABC");
            }else if (R < 2800)
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("AGC");
            }
        }
    }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const int MOD = (int)1e9+7;
int dy[4] = {-1, 0, 1, 1};
int dx[4] = {0, 1, 0, 1};

int main(void) {
	//freopen("in.txt", "r", stdin);
	ll n;
	scanf("%lld", &n);
	ll ret = n-1;
	for(ll i=1; i<=sqrt(n); ++i) {
		if(n % i == 0) {
			ret = min(ret, (i-1)+(n/i)-1);
		}
	}
	printf("%lld", ret);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
template <class T> bool inline chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
int main() {
int n;
cin>>n;
string s;
cin>>s;
int ans=0,cnt=0;
for(int i=1;i<n;i++){
        cnt=0;
        for(char c='a';c<='z';c++){
                bool left=false,right=false;
                for(int j=0;j<i;j++){
                        if(s.at(j)==c)left=true;
                }
                        for(int j=i;j<n;j++){
                                if(s.at(j)==c)right=true;

                        }
                if(left&&right)cnt++;
        }
chmax(ans,cnt);
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  //  vector<string> pict;
  int H, W;
  cin >> H >> W;
  string header = string(W+2, '#');
  cout << header << endl;
  for (int i=0;i<H;i++) {
    string s;
    cout << '#';
    cin >> s;
    cout << s;
    cout << '#';
    cout << endl;
  }
  cout << header << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var nm string
	var a string

	if sc.Scan() {
		nm = sc.Text()
	}

	if sc.Scan() {
		a = sc.Text()
	}

	nmArr := strings.Split(nm, " ")
	intN, _ := strconv.Atoi(nmArr[0])

	for _, v := range strings.Split(a, " ") {
		intV, _ := strconv.Atoi(v)
		intN -= intV
	}

	if intN < 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(intN)
	}
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int M = 100000;
LL n, a[M], b[M], x[M];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	inc(i, n) { cin >> b[i]; }
	
	inc(i, n) { x[i] = a[i] - b[i]; }
	
	LL s = 0;
	inc(i, n) { s += x[i]; }
	
	if(s < 0) { cout << -1 << endl; return 0; }
	
	sort(x, x + n);
	
	LL ans = 0, m = 0;
	inc(i, n) { if(x[i] < 0) { m -= x[i]; ans++; } }
	dec(i, n) {
		if(m > 0) {
			m -= min(m, x[i]);
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2560
stack = []
for i in input().split():
  if i in ['+', '-', '*']:
    b, a = stack.pop(), stack.pop()
    if i == '+': stack.append(a + b)
    if i == '-': stack.append(a - b)
    if i == '*': stack.append(a * b)
  else:
    stack.append(int(i))
print(stack.pop())

Measured memory_bytes: 7612
#include <stdio.h>

int main(){
    int a, b, c, n, m, l;
    scanf("%d%d%d", &a, &b, &c);
    n = a + b;
    m = b + c;
    l = c + a;
    printf("%d\n", n > m ? (m > l ? l : m) : (n > l ? l : n));

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	string str;
	while(true){
		cin >> str;
		int sz = str.size();
		long sum = 0;
		if(atoi(str.c_str())==0) break;
		for (int i = 0; i < sz; ++i) {
			sum += (str[i]-'0');
		}
		println(sum);
	}

	return 0;
}



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

int main() {
	int n; cin >> n;
	int a[n], b[n];
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n);
	set<int> even;
	for(int i = 0; i < n; ++i) {
		if(i % 2 == 0) even.insert(b[i]);
	}
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if(i % 2 == 0) {
			if(even.find(a[i]) == even.end()) {
				++ans;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;

int M = 10000001;


int main()
{
	int n, m;
	cin >> n >> m;
	int minn = M;
	int maxx = 0;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		minn = min(minn, r);
		maxx = max(maxx, l);
	}
	if (maxx > minn)
		cout << 0;
	else
		cout << minn - maxx + 1;

}


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

int main(){
	int H,W;
	cin >> H >> W;
	vector<string> A(H);
	int m[H][W];
	for(int i=0;i<H;i++)cin >> A[i];
	queue<int> que;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++){
		if(A[i][j]=='#'){
			que.push(i*W+j);
			m[i][j]=0;
		}else m[i][j]=9999999;
	}
	
	int dx[4]={0,1,0,-1};
	int dy[4]={1,0,-1,0};
	while(!que.empty()){
		int a=que.front();
		que.pop();
		int h=a/W;
		int w=a%W;
		for(int i=0;i<4;i++){
			int hh=h+dx[i];
			int ww=w+dy[i];
			if(0<=hh && hh<H && 0<=ww && ww<W && (m[hh][ww]>m[h][w]+1)){
				m[hh][ww]=m[h][w]+1;
				que.push(hh*W+ww);
			}
		}
	}
	int maxi=0;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)maxi=max(maxi,m[i][j]);
	cout << maxi << endl;
	return 0;
}

Measured memory_bytes: 9344
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int N;
	scanf("%d", &N);
	long long L[100];
	L[0] = 2, L[1] = 1;
	for (int i = 2; i <= N; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}
	printf("%lld", L[N]);
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str, T: str):
    SS = S + S
    for i in range(len(S)):
        if SS[i:i+len(S)] == T:
            return YES
    return NO


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    result = solve(S, T)
    print(result)

if __name__ == '__main__':
    main()


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

template<long long mod>
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x((mod+x)%mod) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= mod;
        }
        this->x = z;
    }
    mint& operator+=(const mint &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint &a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint& operator/=(const mint &a) {
        long long n = mod - 2;
        mint<mod> u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
};

//powMod
ll powMod(ll k, ll n, ll mod) {
    ll x = 1;
    while (n > 0) {
        if (n & 1) {
            x = x * k % mod;
        }
        k = k * k % mod;
        n >>= 1;
    }
    return x;
}

// comb (一つのみ) O(r)
ll comb(ll n, ll r, ll mod) {
    ll ret = 1;
    while (true) {
        if (r == 0) break;
        ll N = n % mod;
        ll R = r % mod;
        if (N < R) return 0;
        for (int i = 0; i < R; i++)
        {
            ret = ret * (N - i) % mod;
        }
        ll imul = 1;
        for (int i = 0; i < R; i++)
        {
            imul = imul * (i + 1) % mod;
        }
        ret = ret * powMod(imul, mod - 2, mod) % mod;
        n /= mod; r /= mod;
    }
    return ret;
}

int main() {
    constexpr int MOD = 1e9 + 7;
    int n, k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (k == 1) {
        cout << 0 << endl;
        return 0;
    }
    sort(a.begin(), a.end());
    vector<mint<MOD>> t(n + 1);
    t[k - 1] = 1;
    for (int i = k; i <= n; i++) {
        t[i] = t[i - 1] * (i) / (i - k + 1);
    }
    mint<MOD> ans = 0;
    for (int i = 0; i < n; i++) {
        if (i <= n - k + 1) {
            ans -= t[n - 1 - i] * a[i];
        }
        if (i >= k - 1) {
            ans += t[i] * a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
// Aizu 0288: Knocker of the Gigas Cedar
// 2017.9.10 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int a, e, r; } T;
T tbl[102];
char dp[210][102][102];

int main()
{
	int d, n, i, j, k, r, f, k1, k2;

	while (scanf("%d%d", &d, &n) && d) {
		for (f = i = 0; i < n; i++) {
			scanf("%d%d%d", &tbl[i].a, &tbl[i].e, &tbl[i].r);
			if (tbl[i].a > 0) f = 1;
		}
		if (!f) { puts("NA"); continue; } 
		memset(dp, 0, sizeof(dp));
		dp[0][0][0] = 1;
		for (i = 1; ; i++) {
			f = 0;
			for (j = 0; j < d; j++) for (r = 0; r <= 100; r++) {
				if (!dp[i-1][j][r]) continue;
				for (k = 0; k < n; k++) {
					if (tbl[k].r > r) continue;
					if ((k1 = r+tbl[k].e) > 100) k1 = 100;
					if ((k2 = j+tbl[k].a) > 100) k2 = 100;
					dp[i][k2][k1] = 1;
					if (tbl[k].e > 0 || tbl[k].a > 0) f = 1;
					if (j+tbl[k].a >= d) { printf("%d\n", i); goto Done; }
				}
			}
			if (!f) { puts("NA"); goto Done; }
		}
		Done:;
	}
	return 0;
}

Measured memory_bytes: 3936
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


class UnionFind:
    # Reference: https://note.nkmk.me/python-union-find/
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, *AB = map(int, read().split())
A = AB[::2]
B = AB[1::2]

ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j, (a, b) in enumerate(zip(A, B)):
        if i != j:
            uf.union(a - 1, b - 1)
    if uf.group_count() > 1:
        ans += 1

print(ans)


Measured memory_bytes: 3188
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Author: z0marlin
Title: B.cpp
Time: 16-08-2019T22:25:39+0530 
I suck at CP T_T
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
#include <bits/stdc++.h>
#if DEBUG
#define dprintf(...) printf(__VA_ARGS__)
#else
#define dprintf(...)
#endif
#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define FORE(a, v) for(auto a:v)
#define MAX(a, b) ((a>b)?a:b)
#define MIN(a, b) ((a<b)?a:b)
#define MP(i, j) make_pair(i, j)
#define PB(a) push_back(a)
#define PPB(a) pop_back(a)
#define all(a) a.begin(), a.end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii_t;
typedef pair<ll,ll> pll_t;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;

const int MAX_SZ=1e6+2;
const int MOD=1e9+7;
int t = 1, n, m, q, ql, qr;
char ch;

int solve(){

    return ceil((n+.0)/((m<<1)+1));
}

int main(){
    // scanf("%d", &t);
    while(t--){
        scanf("%d%d", &n, &m);
        printf("%d\n", solve());
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] b = new int[n-1];
        for (int i=0;i<n-1;i++)b[i]=sc.nextInt();
        int ans = b[0];
        for (int i=1;i<n-1;i++){
            ans+=Math.min(b[i],b[i-1]);
        }
        ans+=b[n-2];
        System.out.println(ans);
    }
}


Measured memory_bytes: 35956
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;

int main() {
    int n;
    int m;
    int l;
   cin >> n >> m >> l;
  
  // cout << n << endl;
  // cout << m << endl;
  // cout << l << endl;
  
  int sum = 0;
  
for(int i = n;i<=m;i++){
     
   if(l%i==0){
     
     sum++;
     
   }

  
}
  
  cout << sum << endl;
  
  return 0;
}


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

// ------ graph ------ //
using Weight = long long;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) { }
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // pqが降順のため
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
using Edges = vector<Edge>;
struct Graph {
    vector<Edges> adj;
    Graph(int n) : adj(n) { }
    int size() { return adj.size(); }
    Edges operator [] (int v) { return adj[v]; }
    void add_edge(int a, int b, Weight w = 1) { // graph
        adj[a].emplace_back(a, b, w);
        adj[b].emplace_back(b, a, w);
    }
    void add_arc(int a, int b, Weight w = 1) {  // digraph
        adj[a].emplace_back(a, b, w);
    }
};
using Array = vector<Weight>;
using Matrix = vector<Array>;
using UnweightedGraph = vector<vector<int>>;

// ------ Low-Link ------ //
struct LowLink {
    vector<int> aps;                // articulation points
    vector<pair<int, int>> brs;     // brides
    vector<int> seen, ord, low;
    int dfs(const UnweightedGraph &G, int u, int p = -1, int time = 0) {
        seen[u] = true;
        ord[u] = low[u] = time++;
        bool exists = false;
        int cnt_ch = 0;
        for (auto v : G[u]) {
            if (!seen[v]) {
                ++cnt_ch;
                time = dfs(G, v, u, time);
                low[u] = min(low[u], low[v]);   // forward edge
                if (ord[u] < low[v]) brs.emplace_back(u, v);
                if (ord[u] <= low[v]) exists = true;
            } else if (v != p) {
                low[u] = min(low[u], ord[v]);   // back edge
            }
        }
        if ((p == -1 && cnt_ch > 1) || (p != -1 && exists)) {
            aps.emplace_back(u);
        }
        return time;
    }
    void solve(const UnweightedGraph &G) {
        int N = G.size();
        seen.assign(N, 0); ord.resize(N); low.resize(N);
        aps.clear(); brs.clear();
        for (int v = 0; v < N; ++v) if (!seen[v]) dfs(G, v);
        for (auto &br: brs) if (br.first > br.second) swap(br.first, br.second);
        sort(brs.begin(), brs.end());
        sort(aps.begin(), aps.end());
    }
};

int main() {
    int V, E; cin >> V >> E;
    UnweightedGraph G(V);
    while (E--) {
        int s, t; cin >> s >> t;
        G[s].emplace_back(t);
        G[t].emplace_back(s);
    }
    LowLink ll;
    ll.solve(G);

    for (auto v: ll.aps) cout << v << endl;
    return 0;
}


Measured memory_bytes: 4520
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  if(n == 1) printf("Hello World\n");
  else{
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    printf("%d\n", a + b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
   
    //変数：暦の種類「 E 」,その暦での年「 Y 」と置く
    int E, Y;
    
    //入力：暦の種類「 E 」,その暦での年「 Y 」を入力ずる
    cin >> E >> Y;
    
    //条件：switch文から暦の種類「 E 」を探す
    switch(E){
        case 0:{
            //条件：西暦を求める
            if(Y <= 1911) cout << "M" << Y - 1867  << endl;
            else if(Y <= 1925) cout << "T" << Y - 1911<< endl;
            else if(Y <= 1988) cout << "S" << Y - 1925<< endl;
            else cout << "H" << Y - 1988 << endl;
            break;
        }

        case 1:{
            //ポイント：数字の所を１引いている和暦の元年は１年だから
            cout << 1867 + Y << endl;
            break;
        }

        case 2:{
            cout << 1911 + Y << endl;
            break;
        }

        case 3:{
            cout << 1925 + Y << endl;
            break;
        }
        case 4:{
            cout << 1988+ Y << endl;
            break;
        }
        default:{
            break;
        }
    }
    
    return 0;
}


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

int main() {
    int y, m, d;
    char a, b;
    cin >> y >> a >> m >> b >> d;

    if (y >= 2019 && m > 4) cout << "TBD" << endl;
    else cout << "Heisei" << endl;

    return 0;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "YES" : "NO");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string c1, c2;
  cin >> c1 >> c2;
  reverse(c2.begin(), c2.end());
  bool is_ok = true;
  if (c1 != c2)
    is_ok = false;
  printYesNo(is_ok);
  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 ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  ll a, b, c, d, A, B;
  cin >> a >> b >> c >> d;
  B = b-b/c-b/d+b/lcm(c,d);
  A = a-a/c-a/d+a/lcm(c,d);
  if(a%c==0||a%d==0) cout << B-A << endl;
  else cout << B-A+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(void){
    int N;
    long long K;
    vector <int> a, b;
    int sub;
    map <int, long long> cnt;
    int ans;
    
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> sub;
        a.push_back(sub);
        cin >> sub;
        b.push_back(sub);
    }
    
    for(int i = 0; i < N; i++){
        cnt[a[i]] += b[i];
    }
    
    for(int i = 1; i <= 100000; i++){
        if(K > cnt[i]){
            K -= cnt[i];
        }
        else{
            ans = i;
            break;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 7284
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  string s; cin >> s;
  int n = s.size();
  if (s.at(0) != '1' || s.at(n-2) != '1' || s.at(n-1) != '0') {
    cout << -1 << endl;
    return 0;
  }

  for(int i=1; i<n-1; i++) {
    if (s.at(i) != s.at(n-i-2)) {
      cout << -1 << endl;
      return 0;
    }
  }

  int pos = 2;
  for(int i=1; i<n; i++) {
    if (i==1) {
      cout << "1 2" << '\n';
      continue;
    }
    cout << pos << ' ' << i+1 << '\n';
    if (s.at(i-1) == '1' && i <= n/2) {
      pos = i+1;
    }
  }
}

Measured memory_bytes: 1616
import Control.Applicative

solver a b c d = max 0 $ (min b d) - (max a c)

main :: IO ()
main = do
    -- 整数の入力
    [a,b,c,d] <- map read . words <$> getLine :: IO [Int]
    -- 出力
    putStrLn $ show $ solver a b c d



Measured memory_bytes: 508
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const int N = 2e5 + 7;
int a[N];
int main(void){
    IOS;
    int n; cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    ll ans = 0;
    for (int i = 1; i <= n; ++i){
        if (a[i] < a[i-1]) ans += a[i-1]-a[i], a[i] = a[i-1];
    }
    cout << ans << endl;
    return 0;
}

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

map<string, int> memo;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		memo[s] += 1;
	}

    int mx = 0;
	for (const auto& x : memo) {
        int v = x.second;
        if (mx < v) {
        	mx = v;
        }
	}

	for (auto it = memo.begin(); it != memo.end(); it++) {
		if (it->second == mx) {
			cout << it->first << "\n";
		}
	}
	return 0;
}

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

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int maximum = max(max(a,b),c);
  int maximun = max(max(a,b),c);
  for(int i=0;i<k;i++) {
    maximum*=2;
  }
  cout<<a+b+c+maximum-maximun<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	int[][] ab;
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) h[i] = scan.nextInt();
		int[][] ab = new int[m][2];
		int out = n;
		boolean[] isDeleted = new boolean[n];
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < 2; j++) {
				ab[i][j] = scan.nextInt() - 1;
			}
			if(h[ab[i][0]] > h[ab[i][1]]) {
				if(!isDeleted[ab[i][1]]) {
					out--;
					isDeleted[ab[i][1]] = true;
				}
			} else if(h[ab[i][0]] < h[ab[i][1]]) {
				if(!isDeleted[ab[i][0]]) {
					out--;
					isDeleted[ab[i][0]] = true;
				}
			} else {
				if(!isDeleted[ab[i][0]]) {
					out--;
					isDeleted[ab[i][0]] = true;
				}
				if(!isDeleted[ab[i][1]]) {
					out--;
					isDeleted[ab[i][1]] = true;
				}
			}
		}
		System.out.println(out);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 64676