akhauriyash/Code-Regression huggingface dataset:
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　RedcoderになるためAtCoderを巡る旅をしてます。

　　　 　＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897

ll M;

ll dfs_tree(ll idx, ll par, vector<vector<pll>> &adj) {
        
    ll res = 1;
    for(auto &i:adj[idx]) {
        if(i.fi!=par) {
            i.se = dfs_tree(i.fi,idx,adj);
            res = (res * i.se)%M;
        }
    }

    return (1+res)%M;
}

void dfs_tree2(ll idx, ll par, vector<vector<pll>> &adj, vector<ll> &res, ll par_value) {

    ll s = adj[idx].size();
    vector<ll> right(s,1), left(s,1);

    for(auto &i:adj[idx])
        if(i.fi==par)
            i.se = par_value;

    rep2(i,1,s)
        left[i] = (adj[idx][i-1].se * left[i-1])%M;

    repr2(i,s-2,0)
        right[i] = (adj[idx][i+1].se * right[i+1])%M;

    rep(i,s) {
        if(adj[idx][i].fi!=par) {
            dfs_tree2(adj[idx][i].fi, idx, adj, res, (left[i]*right[i]+1)%M);
        }
        res[idx] = (res[idx]*adj[idx][i].se)%M;
    }
}

int main() {

    get2(n,m);
    M = m;

    vector<vector<pll>> adj(n);
    rep(i,n-1) {
        get2(a,b); --a; --b;
        adj[a].pb({b,1});
        adj[b].pb({a,1});
    }

    dfs_tree(0,-1,adj);

    vector<ll> res(n,1);
    dfs_tree2(0,-1,adj,res,1);

    rep(i,n) {
        printf("%lld\n", (res[i]+M)%M);
    }

    return 0;  
}

Measured memory_bytes: 21760
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;

int main(){
    int n;
    std::cin >> n;
    std::vector<ll> a(n),b(n);
    rep(i,n)std::cin >> a[i]>>b[i];
    ll c=0;
    irep(i,n){
        a[i]+=c;
        if(a[i]%b[i]!=0)c+=b[i]-a[i]%b[i];
        //std::cout << a[i]<<b[i] << std::endl;
    }
    std::cout << c << std::endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#define N (200000+100)
#define MOD (1000000007)
using namespace std;
long long n,a[N],b[N],f[5005][5005],ans;
long long Inv[N],Fac[N],FacInv[N];

void Init()
{
	Fac[0]=1; Inv[1]=1; FacInv[0]=1;
	for (int i=1; i<=10000; ++i)
	{
		if (i!=1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
		Fac[i]=Fac[i-1]*i%MOD; FacInv[i]=FacInv[i-1]*Inv[i]%MOD;
	}
}

long long C(long long n,long long m)
{
	if (m>n) return 0;
	return Fac[n]*FacInv[m]%MOD*FacInv[n-m]%MOD;
}

int main()
{
	Init();
	scanf("%lld",&n);
	for (int i=1; i<=n; ++i)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		f[-a[i]+2000][-b[i]+2000]++;
	}
	for (int i=0; i<=4000; ++i)
		for (int j=0; j<=4000; ++j)
		{
			if (i) (f[i][j]+=f[i-1][j])%=MOD;
			if (j) (f[i][j]+=f[i][j-1])%=MOD;
		}
	for (int i=1; i<=n; ++i)
		(ans+=f[a[i]+2000][b[i]+2000])%=MOD;
	for (int i=1; i<=n; ++i)
		ans=((ans-C(2*a[i]+2*b[i],2*b[i]))%MOD+MOD)%MOD;
	printf("%lld",(ans*Inv[2])%MOD);
}

Measured memory_bytes: 164992
import math
import sys
import os

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
MOD = 998244353    

# もらうDP(forcus on destination), 区間の和を足しこむ=累積和
N,K = LI()
LRs = [LI() for _ in range(K)]

dp = [0]*(N+1)
cum = [0]*(N+1)
dp[1] = 1
cum[1] = 1
for i in range(2, N+1):
    for j in range(K):
        l, r = LRs[j]
        start = max(0,i-r-1)
        end = max(0,i-l)
        dp[i] += cum[end] - cum[start]
        dp[i] %= MOD
    # 累積和を更新
    cum[i] = (cum[i-1] + dp[i]) % MOD
ans = dp[N]
print(ans)

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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

#define PII pair<ll,ll>
#define X first
#define Y second
#define mp make_pair

const int N=2e5+7;
const ll mod=1e9+7;

ll fac[N],inv[N];

void pre(){
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(int i=2;i<N;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<N;i++) inv[i]=inv[i-1]*inv[i]%mod,fac[i]=fac[i-1]*i%mod;
}

ll C(int m,int n){
	return fac[m]*inv[m-n]%mod*inv[n]%mod;
}

int n,m,k,dp[3007];
PII a[3007];

int main(){
	pre();
	n=input(),m=input(),k=input();

	for(int i=1;i<=k;i++){
		a[i].X=input(),a[i].Y=input();
		if((a[i].X==1&&a[i].Y==1)||(a[i].X==n&&a[i].Y==m)) printf("0\n"),exit(0);
	}

	a[++k].X=n,a[k].Y=m;
	sort(a+1,a+1+k);

	for(int i=1;i<=k;i++){
		dp[i]=C(a[i].X+a[i].Y-2,a[i].X-1);
		for(int j=1;j<i;j++){
			if(a[j].X<=a[i].X&&a[j].Y<=a[i].Y){
				ll x=a[i].X-a[j].X,y=a[i].Y-a[j].Y;
				dp[i]=(dp[i]-dp[j]*C(x+y,x)%mod+mod)%mod;
			}
		}
	}
	printf("%lld\n",dp[k]);
}

Measured memory_bytes: 3456
#include <string>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(void) {
	int buf;
	vector<int> v(10);
	for(int i = 0; i < 10; i++){
		cin >> buf;
		v[i] = buf;
	}
	sort(v.begin(), v.end());
	cout << v[9] << endl;
	cout << v[8] << endl;
	cout << v[7] << endl;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
	int A, B, C, tmp[3], count = 0;
	scanf("%d%d%d", &A, &B, &C);
	if (A == B && B == C && A % 2 == 0) {
		printf("-1\n");
		return 0;
	} 

	while (1) {
		if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1)
			break;
		tmp[0] = (B + C) / 2;
		tmp[1] = (C + A) / 2;
		tmp[2] = (A + B) / 2;
		A = tmp[0];
		B = tmp[1];
		C = tmp[2];
		count++;
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())

mod = 10**9+7
dp = [-1]*(n+1)
dp[0]= 0
dp[1] = 1
for i in range(m):
    a = int(input())
    dp[a] = 0

for i in range(2,n+1):
    if dp[i] == -1:
        if i <= 2:
            dp[i] = dp[i-1]+1
        elif i>=3 :
            dp[i] = (dp[i-1]+ dp[i-2])%mod

print(dp[n])

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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;
	int n = (int)S.length();
	rep (i, n){
		if (S[i] == '/') S[i] = ' ';
	} // end rep

	stringstream ss(S);
	int y, m, d;
	ss >> y >> m >> d;
	bool ans = false;
	if (y >= 2019 && m >= 5){
		ans |= true;
	} // end if

	cout << (ans ? "TBD" : "Heisei") << endl;
 
	return 0;
}

Measured memory_bytes: 256
// 2018, Sayutin Dmitry.

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int n = input<int>();
    int m = input<int>();
    string s = input<string>();

    vector<vector<int>> graph(n);
    vector<int> deg[2] = {vector<int>(n), vector<int>(n)};
    
    for (int i = 0; i != m; ++i) {
        int v = input<int>() - 1;
        int u = input<int>() - 1;
        
        graph[v].push_back(u);
        graph[u].push_back(v);

        deg[s[v] - 'A'][u] += 1;
        deg[s[u] - 'A'][v] += 1;
    }

    int alive = n;
    std::queue<int> destroy;

    for (int i = 0; i != n; ++i)
        if (deg[0][i] == 0 or deg[1][i] == 0)
            destroy.push(i), --alive;

    while (not destroy.empty()) {
        int v = destroy.front();
        destroy.pop();
        
        for (int u: graph[v])
            if (deg[0][u] > 0 and deg[1][u] > 0) {
                deg[s[v] - 'A'][u] -= 1;

                if (deg[0][u] == 0 or deg[1][u] == 0)
                    destroy.push(u), --alive;
            }
    }
    
    cout << (alive == 0 ? "No\n" : "Yes\n");
    
    return 0;
}


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



int main(){
    string S;
    cin >> S;
    int index;
    index = S.size() - 1;

    if (S[index] == 's'){
        S += "es";
    } else{
        S += 's';
    }

    cout << S << endl;

}


Measured memory_bytes: 3600
package main

import "fmt"

func nextInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func main() {
	n := nextInt()
	_ = nextInt()

	dic := map[int]int{}

	for range make([]struct{}, n) {
		k := nextInt()
		for range make([]struct{}, k) {
			dic[nextInt()]++
		}
	}

	ans := 0
	for _, val := range dic {
		if val == n {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import Data.List

main :: IO ()
main = do
  [h,w] <- map read . words <$> getLine :: IO [Int]
  l <- lines <$> getContents 
  let bs = concat $ map (\g -> boms (fst g) (snd g)) $ zip [1..h] l 
  let grid =  [c |i <- [1..h], 
                  j <- [1..w], 
                  let v = (l !! (i-1)) !! (j-1),
                  let c = if v == '#' then v else head $ show $ length $ filter (`elem` bs) $ around (i,j)]
  putStr $ aligne grid w
    where around (i,j) = [(i-1,j-1), (i-1,j), (i-1,j+1), (i,j-1), (i,j+1), (i+1,j-1), (i+1,j), (i+1,j+1)] 
          boms h l = map (\i -> (h,i+1)) $ elemIndices '#' l
 
aligne :: String -> Int -> String
aligne [] _ = ""
aligne xs w = take w xs ++ "\n" ++ aligne (drop w xs) w


Measured memory_bytes: 1276
import Foundation

var s = readLine()!
if s[s.startIndex] != "A" { print("WA"); exit(0) }
let start = s.index(s.startIndex, offsetBy: 2)
let end = s.index(s.endIndex, offsetBy: -2)
var count = 0
var index: String.Index!
for (i, c) in s[start...end].enumerated() {
  if c == "C" {
    count += 1
    index = s.index(s.startIndex, offsetBy: i + 2)
  }
}
if count != 1 { print("WA"); exit(0) }
else { s.remove(at: index) }
s.removeFirst()
if s.lowercased() != s { print("WA"); exit(0) }
print("AC")

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



int main() {
  int n,m;
  cin >> n >> m;
  vector<int> student_x(n),student_y(n);
  vector<int> point_x(m),point_y(m);
  
  for(int i=0;i<n;i++){
    cin >> student_x.at(i) >> student_y.at(i);
  }
  for(int i=0;i<m;i++){
    cin >> point_x.at(i) >> point_y.at(i);
  }
  
  for(int i=0;i<n;i++){
   int ans = 900000000;
   int answer = 0;
    for(int j=0;j<m;j++){
      int x = student_x.at(i)-point_x.at(j);
      if(x<0)
        x*=-1;
      int y = student_y.at(i)-point_y.at(j);
      if(y<0)
        y*=-1;
     if(ans > x+y){
       ans = x+y;
       answer = j+1;
     }
   
    }
     cout <<  answer << endl;
  }
  
  
}


Measured memory_bytes: 256
def solve(a,M):
	for x,y in xy:
		if x in a and (y not in a or a.index(x) > a.index(y)): break
	else:
		if len(a) == m: return a
		for i in range(len(M)):
			r =  solve([M[i]] + a,M[:i]+M[i+1:])
			if r: return r
m = input()
xy = [map(int,raw_input().split()) for i in range(input())]
for i in solve([],range(1,m+1)): print i

Measured memory_bytes: 4232
n,y = map(int, input().split())

y //= 1000

for i in range(0,y+1,5):
    for j in range(0,i+1,10):
        a,b,c = j,i-j,y-i
        a //= 10
        b //= 5
        if a+b+c == n:
            print(a,b,c)
            exit()
print(-1,-1,-1)

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

#define DBG(a)	cerr << #a << " = " << a << endl;

int main(){
	char s[110];
	scanf("%s", s);
	for (int i = 0; s[i]; ++i){
		cout << 'x';
	}
	cout << endl;
	return 0;
}

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

typedef long long ll;
typedef int keytype;

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

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int main(){
    char s[11];

    scanf("%s", s);

    int min = abs_val(753, (s[0] - '0') * 100 + (s[1] - '0') * 10 + (s[2] - '0'));
    for(int i = 1; i + 2 < strlen(s); ++i){
        if(min > abs_val(753, (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0'))){
            min = abs_val(753, (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0'));
        }
    }

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

    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define bet(a,x,b)  (a)<(x)&&(x)<(b)
#define beta(a,x,b)  (a)<=(x)&&(x)<(b)
#define betb(a,x,b)  (a)<(x)&&(x)<=(b)
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  
  if(B<=C)
    cout << 0 << endl;
  else if(beta(A,C,B) && B<=D)
    cout << B-C << endl;
  else if(bet(C,A,B) && B<=D)
    cout << B-A << endl;
  else if(betb(C,A,D) && D<B)
    cout << D-A << endl;
  else if(beta(A,C,D) && D<B)
    cout << D-C << endl;
  else
    cout << 0 << endl;  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long

using namespace std;

const int MOD = 1000000007;
int modpow(int a, int p){
    if(p == 0){
        return 1;
    }
    int t = modpow(a, p / 2);
    if(p % 2 == 0){
        return t * t % MOD;
    }
    return t * t % MOD * a % MOD;
}
int modinv(int a) { return modpow(a, MOD - 2); }

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x, int y) {
        x = root(x);
        y = root(y);
        if(x != y) {
            if(data[y] < data[x])
                swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
};

signed main() {
    int N, M;
    cin >> N >> M;
    cout << N * (N-1)/2 + M * (M-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
 
int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> roads(50), x(50), y(50);
  rep(i,N){roads.at(i)=0;}
  rep(i,M)
  {
    cin >> x.at(i) >> y.at(i);
    roads.at(x.at(i)-1)++;
    roads.at(y.at(i)-1)++;
  }
  rep(i,N){cout << roads.at(i) << endl;}
  //return 0;
}

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

int main() {
    int n = 0;
    int fmax = 0;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        fmax += a[i] - 1;
    }
    std::cout << fmax << std::endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll N;
	cin>>N;
	if(N==1){
		cout<<"Hello World"<<endl;
	}else{
		ll A,B;
		cin>>A>>B;
		cout<<A+B<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
 public static void main(String args[]){
   Scanner sc=new Scanner(System.in);

   int N=sc.nextInt();
   int A[][]=new int[2][N];
   int sum[]= new int[N];
   int x=0,y=0,collect=0,max=0;

    for (int i=0;i<2;i++)
   {
        for (int j=0; j<N;j++)
        {
       A[i][j]=sc.nextInt();
        }

   }
  /* for (int i=1;i<N;i++)
   {
       sum[i]=A[0][i]+A[1][i];
       if(sum[i]>(A[0][i-1]+A[1][i-1]))
           max=i;
   }
   */
   for(int j=0;j<N;j++)
   {
       for(int i=0; i<N;i++)
       {
       if(i<=j)
           collect+=A[0][i];
       if(i>=j)
           collect+=A[1][i];
       }
       if(collect>max)
           max=collect;
       collect=0;
   }



           System.out.println(max);


   sc.close();
 }
}


Measured memory_bytes: 21972
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
void swap(int idx1, int idx2, int *node)
{
	int f = node[idx1];
	node[idx1] = node[idx2];
	node[idx2] = f;
}
//nlogn
void quickSort(int left, int right, int *node)
{
	int pl = left;
	int pr = right;
	int pivot_f = node[(pl + pr) / 2];
	do
	{
		while (node[pl] < pivot_f)
		{
			pl++;
		}
		while (node[pr]> pivot_f)
		{
			pr--;
		}
		if (pl <= pr)
		{
			swap(pl++, pr--, node);
		}
	} while (pl <= pr);
	if (left < pr) quickSort(left, pr, node);
	if (pl <= right) quickSort(pl, right, node);
}

bool compare(int a, int b)
{
	if (a == b)
	{
		return true;
	}
	else {
		return false;
	}
}
int main()
{
	string max;
	getline(cin, max);
	string ans[1000];
	int count = 0;
	for (int num = 0; num < stoi(max); num++)
	{
		string str;
		string item;
		vector<string> list;
		getline(cin, str);
		int edge[3];
		stringstream ss(str);
		while (getline(ss, item, ' ') && !item.empty()) {
			list.push_back(item);
		}
		
		edge[0] = stoi(list[0].c_str());
		edge[1] = stoi(list[1].c_str());
		edge[2] = stoi(list[2].c_str());
		quickSort(0, 2, edge);

		int edge1 = edge[2] * edge[2];
		int edge2 = edge[0] * edge[0] + edge[1] * edge[1];
		if (compare(edge1, edge2))
		{
			ans[count] = "YES";
			count++;
		}
		else {
			ans[count] = "NO";
			count++;
		}
	}
	for (int i = 0; i < count;i++)
	{
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
import bisect
A, B, Q = map(int, input().split())
INF = 10**18
S = [-INF] + [int(input()) for i in range(A)] + [INF]
T = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b = bisect.bisect_right(S, x)
  d = bisect.bisect_right(T, x)
  res = INF
  
  for s in [S[b-1], S[b]]:
    for t in [T[d-1], T[d]]:
      d1 = abs(s-x) + abs(t-s)
      d2 = abs(t-x) + abs(s-t)
      res = min(res, d1, d2)
  print(res)
    
  

Measured memory_bytes: 13968
N,M=map(int,input().split())
keta=[]
for i in range(N):
    keta.append('x')
ans=-1
for _ in range(M):
    si,ci=input().split()
    si=int(si)
    if keta[si-1]=='x':#sm
        keta[si-1]=ci
    else:
        if keta[si-1]!=ci:#sm
            break
else:
    if keta[0]=='0' and N!=1:#先頭要素が０かつ2桁以上の数なら
        print(-1)
        exit()
    
    if keta[0]=='x' and N==1:
        print(0)
        exit()
    
    if keta[0]=='x' and N>=2:
        keta[0]='1'
    for i in range(1,N):
        if keta[i]=='x':
            keta[i]='0'

    ans=int(''.join(keta))

print(ans)



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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

ll n;
string s;
ll mod = 1000000007;
vector<ll> v;
vector<ll> v2;
ll dp[3002][3002];

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

    cin >> n;
    cin >> s;

    dp[1][0] = 1;
    v.pb(0);
    v.pb(1);
    v.pb(1);

    fr(i,2,n)
    {
        v2.pb(0);
        fr(j,0,i-1)
        {
            if(s[i-2]=='<' && j==0)
            {
                v2.pb(0);
                continue;
            }

            if(s[i-2]=='>')
            {
                dp[i][j] = ((v[i-1]%mod)-(v[j]%mod) + mod)%mod;
                v2.pb(dp[i][j]);
            }
            else
            {
                dp[i][j] = ((v[j]%mod)-(v[0]%mod) + mod)%mod;
                v2.pb(dp[i][j]);
            }
        }

        v = v2;
        v2.clear();
        fr(j,1,v.size()-1)
        {
            v[j] = (v[j]%mod + v[j-1]%mod)%mod;
        }
    }

    ll ans = 0;

    fr(i,0,n)
    {
        ans = (ans + (dp[n][i]%mod))%mod;
    }

    cout << ans << endl;
}


Measured memory_bytes: 69120
import std.stdio,
       std.string,
       std.conv,
       std.algorithm;

void main() {
  int N = readln.chomp.to!(int);
  int[] A = readln.chomp.split.to!(int[]);

  if (N == 1) {
    writeln(1);
    return;
  }

  int ans;
  for (int i = 1; i < N; ) {
    i += max(plus(A, i), minus(A, i)) + 1;
    ans++;
    if (N == i) {
      ans++;
    }
  }

  writeln(ans);
}

int plus(int[] A, int index) {
  int ret;
  for (int i = index; i < A.length; i++) {
    if (A[i - 1] <= A[i]) {
      ret++;
    }
    else {
      break;
    }
  }
  return ret;
}

int minus(int[] A, int index) {
  int ret;
  for (int i = index; i < A.length; i++) {
    if (A[i - 1] >= A[i]) {
      ret++;
    }
    else {
      break;
    }
  }
  return ret;
}


Measured memory_bytes: 4532
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int A,B,C;
int main(){
	scanf("%d%d%d",&A,&B,&C);
	if(C-(A-B)>=0) printf("%d\n",C-(A-B));
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string w;
    getline(cin,w);
    int len=w.size();
    int a[26]={0};
    int raf=0;
    for(int i=0;i<len;i++)
        a[w[i]-97]++;
    for(int i=0;i<25;i++)
        if(a[i]%2!=0){
           raf=1;
         break;
        }
    if(raf==0)
        printf("Yes\n");
    else
        printf("No\n");

}



Measured memory_bytes: 384
"""
ALDS1_10_A
簡単な動的計画法を使ってフィボナッチ数列を計算する
"""
def Fibo(num):
    List = [None]*45
    for i in range(num+1):
        if i == 0:
            List[0] = 1
        elif i == 1:
            List[1] = 1
        else:
            List[i] = List[i-1]+List[i-2]
    return List

n = int(input())

print(Fibo(n)[n])



Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    b+=a*3;
    cout << b/2 << endl;;

    return 0;
}

Measured memory_bytes: 256
def is_even(num):
    if num == 0:
        return True
    return num % 2 == 0


height, width = list(map(int, input().split()))
coin_table = [list(map(is_even, map(int, input().split()))) for i in range(height)]

move_list = list()

for h in range(height):
    for w in range(width):
        if not(coin_table[h][w]):
            coin_table[h][w] = True
            if w == width-1:
                if h == height-1:
                    break
                coin_table[h + 1][w] = not coin_table[h + 1][w]
                move_list.append([h + 1, w + 1, h + 2, w + 1])
            else:
                coin_table[h][w+1] = not coin_table[h][w+1]
                move_list.append([h + 1, w + 1, h + 1, w + 2])

print(len(move_list))
for i in range(len(move_list)):
    print("{0} {1} {2} {3}".format(move_list[i][0], move_list[i][1], move_list[i][2], move_list[i][3]))


Measured memory_bytes: 29880
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int ans=0,max=0,N;cin>>N;
    REP(i,N){
        int H;
        cin>>H;
        if(max<=H){
            max=H;
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int x=b-a;
    ll num;
    num=x*(x+1)/2;
   int ans=num-b;
    cout<<ans<<endl;
}

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

#define M 1046257
#define NIL (-1)
#define L 14

char H[M][L];

/* 文字から数値に変換 */
int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}

/* 文字列から数値へ変換して key を生成する */
long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ;i++) {
    h = (h1(key) + i*h2(key)) % M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str);
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 16036
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

Measured memory_bytes: 3620
n = int(input())
A = list(map(int, input().split()))

ans = 0
r = 0
bit_check = 0
for l in range(n):
    while r <= n-1:
        num = A[r]
        if num & bit_check == 0:
            bit_check |= num
            r += 1
        else:
            bit_check -= A[l]
            break
    ans += r - l

print(ans)

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

using namespace std;

typedef long long int LLI;

// #define debug

bool check(LLI k, LLI a, LLI b, LLI x, LLI y) {
    return k*x >= a && k*y >= b;
}


int main() { 
    int n, x, y;
    while (cin >> n) {
        LLI a = 0, b = 0, lo, hi, mi;
        cin >> a >> b;
        for (int i = 1; i < n; ++i) {
            cin >> x >> y;
            lo = 1, hi = min(1e18/x, 1e18/y);
            while (lo < hi) {
                mi = (lo+hi)>>1;
                if (check(mi, a, b, x, y)) hi = mi;
                else lo = mi+1;
            }
            a = x*lo;
            b = y*lo;
#ifdef debug
            cout << a << " " << b << "\n";
#endif
        }
        cout << a+b << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <iomanip>

using namespace std;

int const N = 55;
int const M = 1e9;

long long n,i,ne,po,res,f,s;
vector<pair<long,long>> ans;

int main() {
	
	cin>>n;
	long long a[n];
	for(i=0;i<n;i++) {
		cin>>a[i];
		if(a[i]<0) ne++;
		else po++;
	}
	
	sort(a,a+n);
	
	if(ne==0){
		
		f = a[0];
		for(i=1;i<n-1;i++){
			ans.push_back({f,a[i]});
			f = f-a[i];
		}
		ans.push_back({a[n-1],f});
		cout<<a[n-1]-f<<endl;
	}
	else {
		f = a[n-1];
		for(i=0;i<ne-1;i++) { ans.push_back({f,a[i]});; f = f-a[i]; }
		
		if(ne!=n){
			s = a[ne-1];
			for(i=ne;i<n-1 ;i++) { ans.push_back({s,a[i]});; s = s-a[i]; }
			ans.push_back({f,s});
		}
		cout<<f-s<<endl;
	}
	
	for(i=0;i<ans.size();i++) cout<<ans[i].first<<" "<<ans[i].second<<endl;
	return 0;
}

Measured memory_bytes: 4336
import java.util.*;

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

		PriorityQueue<Double> q = new PriorityQueue<>();
		for(int i=0; i<N; i++)
			q.add((double)sc.nextInt());
		
		while(q.size()>1) {
			double v1 = q.poll();
			double v2 = q.poll();
			q.add((v1+v2)/2);
		}

		System.out.println(q.poll());
		sc.close();
	}
}


Measured memory_bytes: 23892
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderTemplate {
    class Program {
        static void Main (string[] args) {
            var N = ReadInt ();
            var b = ReadInts ();
            var js = new List<int> ();
            foreach (var i in Enumerable.Range (0, N + 1).Reverse ()) {
                if (i == 0) {
                    PrintList (Enumerable.Reverse (js));
                    return;
                }

                // foreach (var m in Enumerable.Range (0, i)) {
                //     Console.Write ($"{b[m]} ");
                // }
                // Console.Write ("\n");
                foreach (var j in Enumerable.Range (0, i + 1).Reverse ()) {
                    // Console.WriteLine ("ok");
                    if (j == 0) {
                        // aに一つも一致するものが含まれない
                        Console.WriteLine (-1);
                        return;
                    }
                    if (b[j - 1] == j) {
                        // Console.WriteLine (j);
                        js.Add (j);
                        b.RemoveAt (j - 1);
                        break;
                    }
                }
            }
        }
        static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }
        static List<int> ReadInts () {
            return Console.ReadLine ().Split (' ').Select (c => int.Parse (c)).ToList ();
        }
        static List<List<int>> ReadSequence (int n) {
            /*
            入力例
            A1 B1
            A2 B2
            ...
            An Bn

            出力例
            [[A1,A2,...,An], [B1,B2,...,Bn]]
            */
            var seq = Enumerable.Range (0, n).Select (i => ReadInts ()).ToList ();
            return Enumerable.Range (0, seq.First ().Count ()).Select (i => seq.Select (items => items[i]).ToList ()).ToList ();
        }
        static void PrintList<T> (IEnumerable<T> list) {
            foreach (var item in list) {
                Console.WriteLine (item);
            }
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;
int main(){
    int K;
    cin >> K;
    ll sum1=0;
    for(int a=1; a<=K; a++){
        for(int b=1; b<=K; b++){
            for(int c=1; c<=K; c++){
                ll d=gcd(a,b);
              	ll e=gcd(c,d);
                sum1+=e;
              	
            }
        }
    }
    
    cout << sum1 << endl;
    return 0;
}

Measured memory_bytes: 3636
using System;

class A{
	public static void Main(){

//		int x = int.Parse (Console.ReadLine ());
		const string EV = "a == b";
		const string A = "a > b";
		const string B = "a < b";

		string[] x = Console.ReadLine ().Split (' ');
		int a = int.Parse(x[0]);
		int b = int.Parse (x [1]);

		if (a == b) {
			Console.WriteLine (EV);
		} else if (a > b) {
			Console.WriteLine (A);
		} else {
			Console.WriteLine (B);
		}

	
	}
}

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

int main() {
    int n, v[101], r[4];

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

    int counter = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            for (int k = j + 1; k <= n; k++)
                if (v[i] != v[j] && v[i] != v[k] && v[k] != v[j])
                    if (v[i] + v[j] > v[k] && v[j] + v[k] > v[i] && v[i] + v[k] > v[j])
                        counter++;

    cout << counter;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    int a,b;
    cin>>a>>b;
    int ans=a+b;
    if(ans>=24) cout<<ans-24<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    vec<vec<int> > bng(3, vec<int>(3));
    vec<int> mp(101, -1);
    REP(i, 3){
        REP(j, 3){
            cin >> bng[i][j];
            mp[bng[i][j]] = i*3+j;
        }
    }
    ll N;
    cin >> N;
    
    int bits = 0;
    REP(i, N){
        int b;
        cin >> b;
        if(mp[b] != -1){
            bits |= 1<<mp[b];
        }
    }
    vec<int> tmp{
        0b000000111,
        0b000111000,
        0b111000000,
        0b100100100,
        0b010010010,
        0b001001001,
        0b100010001,
        0b001010100
    };
    //cout << std::bitset<9>(bits) << el;
    REP(i, tmp.size()){
        if(__builtin_popcount(bits&tmp[i]) == 3){
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    int N;
    cin>>N;
    vector<ll> A(N),B(N);
    priority_queue<P> PQ;
    rep(i,N)cin>>A[i];
    rep(i,N){
        cin>>B[i];
        PQ.push({B[i],i});
    }
    ll ans = 0;
    while(!PQ.empty()){
        auto maxx = PQ.top();
        PQ.pop();
        int b = maxx.first;
        int i_m = maxx.second;
        int i_r = i_m + 1;
        int i_l = i_m -1; 
        if(b == A[i_m]){
            continue;
        }
        if(i_m == N-1){
            i_r = 0;
        }
        else if(i_m == 0){
            i_l = N-1;
        }
        ll a = B[i_l];
        ll c = B[i_r];
        if(b<=a+c){
            cout<<-1<<endl;
            return 0;
        }
        if((b-A[i_m])%(a+c)==0){
            ans+=(b-A[i_m])/(a+c);
            B[i_m] = A[i_m];
        }
        else{
            ans += b/(a+c);
            b %= (a+c);
            B[i_m] = b;
        }
        if(A[i_m] == B[i_m]){
            continue;
        }
        PQ.push({b,i_m});
    }
    if(A!=B){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
vector<int> G[N];
int C[N], num[N], sum[N];
ll ans[N];
ll cal(int x) {
    return 1LL * x * (x + 1) / 2;
}
void dfs(int u, int fa) {
    int c = C[u], save = sum[c];
    num[u] = 1;
    for(auto v : G[u]) {
        if(v == fa) continue;
        int t = sum[c];
        dfs(v, u);
        int dt = sum[c] - t;
        ans[c] -= cal(num[v] - dt);
        num[u] += num[v];
    }
    sum[c] = save + num[u];
}
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &C[i]);
    }
    for(int i = 1, u, v; i < n; i++) {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(int i = 1; i <= n; i++) {
        ans[i] = cal(n);
    }
    dfs(1, -1);
    for(int i = 1; i <= n; i++) {
        int t = n - sum[i];
        ans[i] -= cal(t);
        printf("%lld\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 37176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))

ll n,m,ans=0;
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
void work(int x){
	if(n%x==0)ans++;
	while(n%x==0)n/=x;
}
int main(){
	//ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n>>m;
	n=gcd(n,m);
	repeat(i,2,int(sqrt(n)+2))work(i);
	if(n!=1)ans++;
	cout<<(ans+1)<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;

class Abc{
  static void Main(){
    int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int A = Ar[0];
    int B = Ar[1];
    int C = Ar[2];
    if (C - (A - B) > 0) Console.WriteLine(C - (A - B));
    else Console.WriteLine("0");
  }
}

Measured memory_bytes: 13140
class Tree
    attr_accessor :key, :left, :right
    def initialize(k, l, r)
        @key   = k
        @left  = l
        @right = r
    end
end

def insert(x, tree)
    if tree == nil
        Tree.new(x, nil, nil)
    elsif x < tree.key
        Tree.new(tree.key, insert(x, tree.left), tree.right)
    elsif x > tree.key
        Tree.new(tree.key, tree.left, insert(x, tree.right))
    else
        tree
    end
end

def goleft(tree, directions, breadcrambs)
    rt = tree.left
    tree.left = nil
    directions << 'L'
    breadcrambs << tree
    [rt, directions, breadcrambs]
end

def goright(tree, directions, breadcrambs)
    rt = tree.right
    tree.right = nil
    directions << 'R'
    breadcrambs << tree
    [rt, directions, breadcrambs]
end

def goup(tree, directions, breadcrambs)
    d = directions[-1]
    xtree = breadcrambs[-1]
    if d == 'L' then xtree.left = tree
    else xtree.right = tree end
    [xtree, directions[0..-2], breadcrambs[0..-2]]
end

def preorder(tree)
    if tree != nil
        print " #{tree.key}"
        preorder(tree.left)
        preorder(tree.right)
    end
end

def inorder(tree)
    if tree != nil
        inorder(tree.left)
        print " #{tree.key}"
        inorder(tree.right)
    end
end

def postorder(tree)
    if tree != nil
        postorder(tree.left)
        postorder(tree.right)
        print " #{tree.key}"
    end
end

#-- main
#------------------------------------------
tree = nil
paths = []
breads = []

x = gets.chomp.to_i
x.times {
    cmd, n = gets.chomp.split
    case cmd
    when "insert"
        tree = insert(n.to_i, tree)
    when "find"
        if find(n.to_i, tree)
            puts "yes"
        else
            puts "no"
        end
    when "delete"
        tree = delete(n.to_i, tree)
    when "print"
        inorder(tree); puts
        preorder(tree); puts
    end
}


Measured memory_bytes: 50560
#include<stdio.h>

int b[15][15];

void reset(){
    int i,j;
    for(i=0;i<15;i++){
        for(j=0;j<15;j++){
            b[i][j]=0;
        }
    }
}

void magic_square(int x,int y,int n,int c){
    if(c==n*n)return;
    if(b[x][y]==0){
        b[x][y]=++c;
        if(++x==n)x=0;
        if(++y==n)y=0;
        magic_square(x,y,n,c);
    }else{
        if(++x==n)x=0;
        if(--y==-1)y=n-1;
        magic_square(x,y,n,c);
    }
}

int main(){
    int n,i,j;
    while(scanf("%d",&n),n){
        reset();
        magic_square(n/2+1,n/2,n,0);
        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                printf("%4d",b[i][j]);
            }
            puts("");
        }
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a,b,c;
    a = n%10;
    b = (n%100-a)/10;
    c = n/100;
    if(a==7 or b==7 or c==7) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

using ll = long long;
using namespace std;

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


int main()
{
   int p[30][214514] = {};
  int N, C;
  cin >> N >> C;
  rep(i, N) {
    // cout << "i : "<< i << "now " << endl;
    int s, t, c;
    cin >> s >> t >> c;
    p[c-1][2*s] ++ ;
    p[c-1][2*t + 2] --;
  }

  int ans = 0;
  rep2(i,1, 200050) {
    int count = 0;
    rep(j, C) {
      p[j][i] += p[j][i-1];
      if (p[j][i] )
        count++;
    }
    if (i == 1) 
      ans = count; else 
    ans = max(ans,count);
    
  }

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

Measured memory_bytes: 25344
import java.io.*;
 
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        for(char c: str.toCharArray()){
            if(Character.isUpperCase(c)){
            System.out.print(Character.toLowerCase(c));
            }else{
            System.out.print(Character.toUpperCase(c));
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 25332
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=n1;i<(int)(n2);i++)
using namespace std;

signed main()
{
	vector<char> s;
	int N = 0;
	while(1){
		char x;
		cin >> x;
		if(cin.eof()){
			break;
		}

		N++;
		s.push_back(x);
	}

	int f = 1;
	Rep(i, N){
		if((i+1) % 2 == 1){
			if(s[i] == 'L'){
				f = 0;
			}
		}
		if((i+1) % 2 == 0){
			if(s[i] == 'R'){
				f = 0;
			}
		}
	}

	std::string y, n;
	y = "Yes";
	n = "No";

	if(f == 1){
		cout << y << endl;
	}else{
		cout << n << endl;
	}
	return 0;
}


Measured memory_bytes: 256