akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := nextInt()
	g := make([][]Edge, n+1)
	for i := 0; i < m; i++ {
		l := nextInt()
		r := nextInt()
		d := nextInt()
		g[l] = append(g[l], Edge{r, d})
		g[r] = append(g[r], Edge{l, -d})
	}

	done := make(map[int]bool)
	ds := make([]int, n+1)
	var dfs func(i, dist int) bool
	dfs = func(u, dist int) bool {
		if done[u] {
			return ds[u] == dist
		}
		done[u] = true
		ds[u] = dist
		for _, e := range g[u] {
			v := e.index
			d := e.dist
			if !dfs(v, ds[u]+d) {
				return false
			}
		}
		return true
	}

	for i := 1; i <= n; i++ {
		if !done[i] {
			if !dfs(i, 0) {
				fmt.Println("No")
				return
			}
		}
	}

	fmt.Println("Yes")
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// Edge .
type Edge struct {
	index, dist int
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 37168
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;//1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class Rng>
void in(Rng& x) {
	cin >> x;
}

template<class T1, class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class Rng>
void in(vector<Rng>& v, LL st = -1, LL en = -1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	cin >> N;
	if (N == 1) {
		cout << "Hello World\n";
	}
	else {
		LL A, B;
		cin >> A >> B;
		cout << A + B << "\n";
	}
	return 0;
}

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

alis=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(alis[N-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, a[101010];

void solve() {
    int z = 0;
    while (z < N - 1 && z + 1 < a[z + 1])
        z++;
    int dy = a[z] - z + 1;
    int dx = 0;
    while (z + dx + 1 < N && a[z + dx + 1] > z)
        dx++;
    bool flag = (dy % 2) || (dx % 2);
    cout << (flag ? "First" : "Second") << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a, a + N, greater<int>());

    solve();
    return 0;
}


Measured memory_bytes: 4412
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const MOD: usize = 1e+9 as usize + 7;
fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let sqn = ((n as f64).sqrt().floor()) as usize;
    let mut kinds = vec![];
    for i in 1..sqn + 1 {
        kinds.push((i, n / i));
    }
    for i in (1..sqn + 1).rev() {
        let mut v = n / (i + 1) + 1;
        kinds.push((v, i));
    }
    kinds.sort();
    kinds.dedup();
    let m = kinds.len();
    let mut width = vec![0; m];
    let mut prev = n + 1;
    for i in (0..m).rev() {
        width[i] = prev - kinds[i].0;
        prev = kinds[i].0;
    }
    // println!("{:?}", kinds);
    let mut dp = vec![0; m];
    dp[0] = 1;
    for _iter in 0..k {
        let mut ndp = vec![0; m];
        let mut sum = 0;
        let mut pos = 0;
        for i in (0..m).rev() {
            while pos < kinds.len() && kinds[pos].0 <= kinds[i].1 {
                sum = (sum + width[pos] * dp[pos]) % MOD;
                pos += 1;
            }
            ndp[i] = sum;
        }
        dp = ndp;
        // println!("{:?}", dp);
    }
    let mut ans = 0;
    for i in 0..m {
        ans = (ans + width[i] * dp[i]) % MOD;
    }
    println!("{}", ans);
}


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

using namespace std;

bitset<100005> possible;
int number[100005];

int main()
{
  int n,m,x,y;

  scanf("%d%d",&n,&m);
  possible[1]=true;
  for(int c=1;c<=n;c++)
  number[c]=1;
  for(int c=0;c<m;c++)
  {
    scanf("%d%d",&x,&y);
    if (possible[x])
    {
      if (number[x]==1)
        possible[x]=false,possible[y]=true;
      else if (number[x]>1)
        possible[y]=true;
    }
    number[x]--;
    number[y]++;
  }
  printf("%d\n",possible.count());
}


Measured memory_bytes: 640
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n, ans = 0;
	string s;

	cin >> n;

	forll(i, 0, n)
	{
		if ((i + 1) % 3 != 0 && (i + 1) % 5 != 0)
		{
			ans += i + 1;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

static const double eps = 1e-8;

int main(){

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		double areaA=0,areaB=0;
		int remain=360;
		for(int i=0;i<n-1;i++){
			double rad;
			int angle;
			scanf("%d",&angle);
			remain-=angle;
			rad = (double)angle / 180.0 * M_PI;
			areaA += 0.5*sin(rad);
		}

		areaA += 0.5*sin((double)remain / 180.0 * M_PI);

		remain=360;
		scanf("%d",&n);
		for(int i=0;i<n-1;i++){
			double rad;
			int angle;
			scanf("%d",&angle);
			remain-=angle;
			rad = (double)angle / 180.0 * M_PI;
			areaB += 0.5*sin(rad);
		}

		areaB += 0.5*sin((double)remain / 180.0 * M_PI);

		printf("%d\n",abs(areaA - areaB) < eps ? 0 :
			areaA > areaB ? 1 : 2);
	}
}

Measured memory_bytes: 3388
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define int ll 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =1e5+2 ;
int n,p1,p2,p3;
vector<ar<int,3>>A ;
int dp[mxN][3] ;
void solve(){
  cin >> n  ;
  For(i,n){
    ar<int,3>p ;
    cin >> p[0] >> p[1] >> p[2]  ;
    A.pb(p) ;
  }
  // dp[i][j]--> maximum cost if we chose jth activity on ith day 
  For(i,3)
    dp[0][i]=A[0][i] ;
  for(int i=1;i<n;i++)
    for(int j=0;j<3;++j)
      dp[i][j]=max(dp[i-1][(j+1)%3]+A[i][j],dp[i-1][(j+2)%3]+A[i][j]) ;
  cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << endl ;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}
  

Measured memory_bytes: 5488
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
int a[6];
signed main() {
	for (int i = 0; i < 6; i++) {
		int p; cin >> p;
		a[p]++;
	}
	cout << ((a[1] < 3 && a[2] < 3 && a[3] < 3 && a[4] < 3) ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;

int N, M, Q;
vector<int> a;
vector<int> b;
vector<ll> c;
vector<ll> d;

ll score(vector<int> &A) {
    ll sum = 0;
    for (int i = 0; i < Q; i++) {
        if (A[b[i]] - A[a[i]] == c[i]) sum += d[i];
    }

    return sum;
}

ll dfs(vector<int> &A) {
    if (A.size() == N) {
        return score(A);
    }

    ll sum = 0;
    int prev = (A.empty() ? 1 : A.back());
    for (int i = prev; i <= M; i++) {
        A.push_back(i);
        chmax(sum, dfs(A));
        A.pop_back();
    }

    return sum;
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    vector<int> A;

    cout << dfs(A) << endl;
}

Measured memory_bytes: 3560
#include <iostream>

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

int m,nmin,nmax;
int p[1000];
signed main(void) {
    while(true) {
    cin >> m >> nmin >> nmax;
    if (m == 0) break;
    rep (i,m) cin >> p[i];

    int n;
    int mgap = 0;
    int ans = nmin;
    for (n = nmin; n <= nmax;n++) {
        int gap = p[n-1] - p[n];
        if (gap >= mgap) {
            mgap = gap;
            ans = n;
        }
    }
    cout << ans << endl;
    }
    return 0;
}


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

int     main() {
        int n;
        cin >>n;
        vector<long> a(n);
        long A=0;
        for (int i=0; i<n; i++) {
                cin >>a.at(i);
                A=max(A, a.at(i));
        }
        long AA=A;
        long AAA=A;
        for (int i=0; i<n; i++) {
                if (abs(a.at(i)*2-A)<=AAA) {
                        AA=a.at(i);
                        AAA=abs(AA*2-A);
                }
        }
        cout <<A <<' ' <<AA <<endl;
        return 0;
};

Measured memory_bytes: 1024
#!/usr/bin/env python3

from math import sqrt
from itertools import product

def prime(n):
    assert(n > 1)
    n = int(n)
    sq_n = int(sqrt(n)) + 1
    hurui = [False] * sq_n
    ret = []
    for i in range(2, sq_n):
        cnt = 0
        if hurui[i]:
            continue
        for ii in range(i, sq_n, i):
            hurui[ii] = True
        while n % i == 0:
            n = n // i
            cnt += 1
        if cnt > 0:
            ret.append((i, cnt))
    if n != 1:
        ret.append((n, 1))
    return ret

def pairs(N):
    N = int(N)
    nlist = prime(N)
    n, cnt = zip(*nlist)
    ret = []
    for _cnt in product(*(list(range(c + 1)) for c in cnt)):
        val = 1
        for _n, _c in zip(n, _cnt):
            val *= _n ** _c
        ret.append([val, N // val])
    ret.sort()
    return ret

#X = int(1)
X = int(input())

if X == 1:
    print(0, -1)
    exit(0)

for n, m in pairs(X):
    #print(n, m)
    if (n**4 - m**4) % 5 != 0:
        continue
    for B in range(-n // 2 - 1, int(m ** 0.25)):
        A = B + n
        if A ** 5 - B ** 5 == X:
            break
    if A ** 5 - B ** 5 == X:
        break
print(A, B)


Measured memory_bytes: 9436
fun main(args: Array<String>)
{
    val (a, b) = readNInts().sorted()

    val k = (a + b) / 2

    println(if ((a+b)%2 == 0) k else "IMPOSSIBLE")

}

// Read an integer
// Usage: val a = readInt()
private fun readInt() = readLine()!!.toInt()


// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
private fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
private fun readString() = readLine()!!


Measured memory_bytes: 37900
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int main(){
    vector<int> h(10);
    REP(i,10)cin>>h[i];
    sort(h.begin(),h.end());
    cout<<h[9]<<endl<<h[8]<<endl<<h[7]<<endl;
    return 0;
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define puts(s) cout<<(s)<<endl
#define inf (1000000007)
#define nil -1

int main() {
	int n; cin >> n;
	vs S(n);
	vvi alf(n,vi(26));
	rep(i, 0, n) {
		cin >> S[i];
	}
	string ans = "";
	rep(i, 0, n) {
		rep(j, 0, S[i].size()) {
			
			alf[i][S[i][j] - 'a']++;
		}
	}

	rep(i, 0, 26) {
		int min_=1000000000;
		rep(j, 0, n) {
			min_ = min(min_,alf[j][i]);
		}
		rep(j, 0, min_) {
			ans += ('a'+i);
		}
	}
	sort(all(ans));
	puts(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int n,x;
  scanf("%d %d",&n,&x);
  ll a[n],b[n];
  FOR(n){
    scanf("%lld",&a[i]);
    b[i]=abs(a[i]-x);
  }
  FOR(n-1)b[i+1]=gcd(b[i],b[i+1]);
  PRL(b[n-1]);
  return 0;
}


Measured memory_bytes: 1664
n,m=gets.split.map(&:to_i)
kss=m.times.map{gets.split.map(&:to_i)}
ps=gets.split.map(&:to_i)
ans=0
(2**n).times do |i|
  switch=i.to_s(2).split("").map(&:to_i)
  (n-switch.size).times{switch.insert(0,0)}
  check=true
  m.times do |j|
    sum=0
    1.upto(kss[j][0]){|k| sum+=switch[kss[j][k]-1]}
    if sum%2!=ps[j]
      check=false
      break
    end
  end
  ans+=1 if check
end
puts ans


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    int sum = 0;
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum+=A[i];
        if(i%2) {
            cnt+=A[i]*2;
        }
    }
    vector<int>ans(N,-1);
    ans[0] = sum-cnt;
    for(int i = 1; i < N; i++) {
        ans[i] = A[i-1]*2-ans[i-1];
    }
    for(int i = 0; i < N; i++) {
        if(i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 4808
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

// ?????§?????????P???k??°?????????????????§?????????????????????????????????
int check(llong P) {
    int i = 0;
    for (int j = 0; j < k; j++) {
        llong s = 0;
        while (s + T[i] <= P) {
            s += T[i];
            i++;
            if( i == n ) return n;
        }
    }
    return i;
}

int solve() {
    llong left = 0;
    llong right = 100000 * 10000; // ??????????????° * 1????????????????????§??????
    llong mid;
    while (right - left > 1) {
        mid = (right + left) / 2;
        int v  = check(mid); // mid == P ????±??????????????????????????????§??????
        if (v >= n) right = mid;
        else left = mid;
    }

    return right;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> T[i];
    }
    llong ans = solve();
    cout << ans << endl;
}

Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define SZ(x) ((int)(x).size())
#define prts(x) return puts(x),0
#define pirtf(x) return printf("%d\n",x),0
#define re return
typedef long long LL;
typedef double ld;
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline LL Gcd(LL X,LL Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int B,LL E,int M){if(!(B%=M))return 0;int A=1;for(;E;E>>=1,B=(LL)B*B%M)E&1?A=(LL)A*B%M:0;return A;}
inline LL Pow(LL B,LL E,LL M){if(!(B%=M))return 0;LL A=1;for(;E;E>>=1,B=B*B%M)E&1?A=A*B%M:0;return A;}
const int INF=0x3f3f3f3f;

map<int,int> mp;
set<int> st;

int n,q,m,k;
int a[300005],b[300005];
int f[300005],g[300005];
int M[3005][3005];
char str[300005];

int h[300005],nxt[600005],to[600005],tot;
inline void ins(int x,int y){nxt[++tot]=h[x];to[tot]=y;h[x]=tot;}

int main(){
	scanf("%d%d",&n,&q);printf("%d\n",n+q/2);
	return 0;
}


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

using namespace std;

int main() {
	long long int num,numa,numb;
	long long int loop,rem;
	long long int ans;

	cin >> num >> numa >> numb;

	loop = num / (numa + numb);
	rem = num % (numa + numb);
	if (rem >= numa) {
		rem = numa;
	}

	ans = loop * numa + rem;
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{ string s;
 cin>>s;

 int n=s.size();
 if(s.substr(0,(n-1)/2)==s.substr((n+3)/2-1))
    {
        cout<<"Yes"<<endl;
    }
    else
    {cout<<"No"<<endl;}
    return 0;
    }



Measured memory_bytes: 3648
#include <iostream>
#include <queue>
using namespace std;
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, -1, 0, 1 };

int main(){
	int W, H;
	while( cin >> W >> H, W, H ){
		char room[20][20];
		queue< pair<int, int> > xy;
		for( int i = 0; i < H; i++ ){
			for( int j = 0; j < W; j++ ){
				cin >> room[i][j];
				if( room[i][j] == '@' ){
					xy.push(pair<int, int>(i, j));
					room[i][j] = '#';
				}
			}
		}
		int sum = 1;
		while( !xy.empty() ){
			for( int i = 0; i < 4; i++ ){
				int x = xy.front().second + dx[i];
				int y = xy.front().first + dy[i];
				if( 0 <= x && x < W && 0 <= y && y < H && room[y][x] == '.' ){
					room[y][x] = '*';
					xy.push(pair<int, int>(y, x));
					sum++;
				}
			}
			xy.pop();
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1216
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
  map<string, int> mp;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    mp[s] = mp[s] + 1;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    string s;
    cin >> s;
    mp[s] = mp[s] - 1;
  }

  int ret = 0;
  for (auto& p : mp) {
    ret = max(ret, p.second);
  }
  cout << ret << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,k;
    cin>>n>>k;
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    ll dp[n+1];
    for(int i=0;i<=n;i++)
        dp[i]=INT_MAX;
    dp[1]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i+j<=n)
                dp[i+j]=min(dp[i+j],abs(h[i+j]-h[i])+dp[i]);
            else
                break;
        }
    }
    /*for(int i=1;i<=n;i++)
        cout<<dp[i]<<" ";
    cout<<endl;*/
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1408
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

d = float("inf")
ans = 0
for i in range(n):
    di = abs(a - (t - h[i]*0.006))
    if di < d:
        d = di
        ans = i+1
print(ans)

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

int main() {
  int N;
  cin >> N;

  int ans = 1 << 10;
  for (int i = 0; i < N; ++i) {
    int num;
    cin >> num;

    int count = 0;
    int r = 0;
    while (!r) {
      r = num % 2;
      if (!r) {
        ++count;
        num /= 2;
      }
    }
    ans = min(ans, count);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<pair<pair<string, int>, int> > vec(n);
  for (int i = 0; i < n; ++i) {
    cin >> vec[i].first.first >> vec[i].first.second;
    vec[i].second = i + 1;
    vec[i].first.second = -vec[i].first.second;
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < n; ++i) {
    cout << vec[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 256
s=list(input())
r=0
l=0
ans=[]
for i,x in enumerate(s):
  if s[i]=='R':
    if s[i-1]=='L'and i>0:
      migi=(r+1)//2+l//2
      hidari=r//2+(l+1)//2
      ans+=[0]*(r-1)+[migi,hidari]+[0]*(l-1)
      r=1
      l=0
    else:r+=1
  else:
    l+=1
migi=(r+1)//2+l//2
hidari=r//2+(l+1)//2
ans+=[0]*(r-1)+[migi,hidari]+[0]*(l-1)
    
print(*ans)

Measured memory_bytes: 7092
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>

int main(){
    int havePaul,connectPaul;
    std::cin >> havePaul >> connectPaul;
    std::vector<int> poulLength(havePaul);
    for(int i = 0; i < havePaul; i++){
        std::cin >> poulLength[i];
    }

    std::sort(poulLength.begin(),poulLength.end(),std::greater<int>());

    int sum = 0;
    for(int i = 0; i < connectPaul; i++){
        sum += poulLength[i];
    }
    std::cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   map<ll,ll> ma;
   string s;
   cin>>s;
   
   ll n = s.length();
   ma[0] = 1;
   ll mul = 1;
   ll curr = 0;
   ll ans = 0;
   for(ll i=n-1;i>-1;i--)
   {
       curr = (curr + mul*((ll)s[i] - '0'))%2019;
       mul*=10;
       mul%=2019;
       ans+=ma[curr];
       ma[curr]++;
       
   }
   cout<<ans;
   
   return 0;        
}  
  
   

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N, M;
map<int, int> counter;

int main()
{
    cin >> N >> M;
    REP(_, 2 * M)
    {
        int a;
        cin >> a;
        counter[a]++;
    }
    for (auto pa : counter) if (pa.second & 1)
    {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 4352
def rep(n, k):
    if n < k:
        if n <= k-n:
            print(n)
        else:
            print(k-n)
    elif n == k:
        print(0)
    else:
        r = n % k
        if r <= k-r:
            print(r)
        else:
            print(k-r)

n, k = [int(i) for i in input().split()]

rep(n, k)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

int  A(int x){
    if(x>=0)return x;
    else return -x;
}



int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n);
    bool flag = false;
    int num = 0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0)flag = true;
        if(a[i]<0)num++;
    }
    ll sum = 0;
    ll mi = (ll)INF;
    for(ll i=0;i<n;i++){
        ll x = A(a[i]);
        sum+=x;
        mi = min(mi,x);
    }
    if(flag)cout<<sum<<endl;
    else{
        if(num%2==0)cout<<sum<<endl;
        else{
            cout<<sum-2*mi<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, M, K;
	cin >> N >> M >> K;
	VLL A(N+1,0), B(M+1,0);
	for (int n = 1; n <= N; n++)cin >> A[n];
	for (int m = 1; m <= M; m++)cin >> B[m];
	for (int n = 1; n <= N; n++)A[n] += A[n - 1];
	for (int m = 1; m <= M; m++)B[m] += B[m - 1];
	int ans = 0;
	for (int i = 0; i <= N; i++) {
		int s = -1, e = M + 1;
		while (e - s > 1) {
			int m = (e + s) / 2;
			if (A[i] + B[m] <= K)s = m;
			else e = m;
		}
		if(s != -1)ans = max(ans, i + s);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 6040
#include <iostream>

using namespace std;

class D {
	int n, m;
public:
	D()
	{
		cin >> n >> m;
	}
	void solve()
	{

		int div;
		int over = m / 2 + 1;
		for (div = n; div < over; div++)
		{
			if ((m % div) == 0)
				break;
		}

		if (div == over) cout << 1 << endl;
		else cout << m / div << endl;
	}

};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll mod = 1000000007;

    vector <int> table(26,1);

    rep(i,n){
        char tmp = s[i];
        int tmp1 = tmp - 97;
        table[tmp1] ++;
    }

    long long ans = 1;
    rep(i,26){
        ans *= table[i];
        ans %= mod;
    }
    ans --;

    cout << ans << endl;

}

Measured memory_bytes: 3712
#include<stdio.h>
long long int a[1000001],x[1000001],y[1000001];
int main(void)
{
	int i,j,l,k,n,m;
	j=0;
	l=0;
	k=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x[i]=0;
		y[i]=0;
	}
	for(i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(i=1;i<=n;i++){
		if(a[i]%4==0){
			j++;
			x[j]=a[i];
		}
		else {
			l++;
			y[l]=a[i];
		}
	}
	for(i=1;i<=l;i++){
		if(y[i]%2==0){
			k++;
		}
	}
	if(k%2!=0) k--;
	l=l-k;
	if(j+2<=l) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int MOD=1000000007;


int add(int x, int y)
{
	return (x + y) % MOD;
}

int sub(int x, int y)
{
	return add(x, MOD - y);
}

int mul(int x, int y)
{
	return (x * 1ll * y) % MOD;
}

int binpow(int x, int y)
{
	int z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = mul(z, x);
		x = mul(x, x);
		y /= 2;
	}
	return z;
}

int inv(int x)
{
	return binpow(x, MOD - 2);
}

int C(int n, int r){
	if(n==r || r==0){
		return 1;
	}
	int ans=1;
	for(int i=n; i>n-r; i--){
		ans=mul(ans, i);
	}
	for(int i=1; i<=r; i++){
		ans=mul(ans, inv(i));
	}
	return ans;
}


main() {
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int val=n-5;
		if(val<0){
			cout<<0<<endl;
			continue;
		}
		int ans=0;
		for(int i=0; i<=11; i++){
			int rem=val-(i);
			if(rem<0 || rem%2==1){
				continue;
			}
			int po2=rem/2;
			int ad=1;
			ad=mul(ad, C(11, i));
			ad=mul(ad, C(15+po2, 15));
			ans=add(ans, ad);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    unsigned long long int x,y;
    cin>>x>>y;
    y/=x;
    int n=0;
    while(y!=1){
        n++;
        y/=2;
    }
    cout<<n+1;
}


Measured memory_bytes: 256
/**
 * 色が全部で8種類とは言ってないことに注意
 * (サンプルに「紫」「黒」がある)
 */

#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

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

#define DEBUG
#undef DEBUG

int N;
int bin[8] = {};
int wild = 0;

int main()
{
    cin >> N;
    REP(i, N) {
        int a;
        cin >> a;
        if(1 <= a && a <= 399)
            ++bin[0];
        else if(400 <= a && a <= 799) {
            ++bin[1];
        }
        else if(800 <= a && a <= 1199) {
            ++bin[2];
        }
        else if(1200 <= a && a <= 1599) {
            ++bin[3];
        }
        else if(1600 <= a && a <= 1999) {
            ++bin[4];
        }
        else if(2000 <= a && a <= 2399) {
            ++bin[5];
        }
        else if(2400 <= a && a <= 2799) {
            ++bin[6];
        }
        else if(2800 <= a && a <= 3199) {
            ++bin[7];
        }
        else {
            ++wild;
        }
    }

    int kmin = 0;
    int kmax;
    REP(i, 8) {
        if(bin[i]) ++kmin;
    }
    if(kmin == 0) {
        kmin = 1;
        kmax = wild;
    }
    else {
        kmax = kmin + wild;
    }

    cout << kmin << " " << kmax << "\n";

    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> student(N, vector<int> (2));
    vector<vector<int>> check(M, vector<int> (2));
    rep(i, N) cin >> student[i][0] >> student[i][1];
    rep(i, M) cin >> check[i][0] >> check[i][1];
    rep(i, N) {
        int mini = 1000000000;
        int ans = 0;
        int x1 = student[i][0];
        int y1 = student[i][1];
        rep(j, M) {
            int x2 = check[j][0];
            int y2 = check[j][1];
            int tmp = abs(x1 - x2) + abs(y1 - y2);
            if (mini > tmp) {ans = j + 1; mini = tmp;}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define int long long

using namespace std;


int n, m;
vector < vector < int > > g;
vector < vector < int > > rg;
vector < int > used;
vector < int > color;

void bad(){
    cout << -1;
    exit(0);
}




void dfs1(int v, int &oneplus, int &twoplus){
    used[v] = 1;
    for(int i = 0; i < n; ++i){
        if(i == v)continue;
        if(used[i] == 1 && color[i] == color[v] && rg[v][i] == 1)bad();
        if(i != v && rg[v][i] == 1 && used[i] == 0){
            color[i] = 3 - color[v];
            if(color[i] == 1){
                oneplus++;
            } else {
                twoplus++;
            }
            dfs1(i, oneplus, twoplus);
        }
    }

}




void solve(){
    cin >> n >> m;
    g.resize(n, vector < int > (n));
    rg.resize(n, vector < int > (n));
    used.resize(n, 0);
    color.resize(n, -1);
    for(int i = 0; i < m; ++i){
        int v, u;
        cin >> v >> u;
        --v, --u;
        g[v][u] = 1;
        g[u][v] = 1;
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(i == j)continue;
            rg[i][j] = 1 - g[i][j];
        }
    }
    vector < vector < int > > srt;
    for(int i = 0; i < n; ++i){
        if(!used[i]){
            int oneplus = 1;
            int twoplus = 0;
            color[i] = 1;
            dfs1(i, oneplus, twoplus);
            srt.push_back({abs(oneplus - twoplus), oneplus, twoplus});
        }
    }
    sort(srt.begin(), srt.end());
    reverse(srt.begin(), srt.end());
    int a = 0;
    int b = 0;
    int bal = 0;
    for(int i = 0; i < srt.size(); ++i){
        //cerr << srt[i][1] << " " << srt[i][2] << "\n";
        if(bal >= 0){
            b += max(srt[i][1], srt[i][2]);
            a += min(srt[i][1], srt[i][2]);
            bal = a - b;
        } else {
            a += max(srt[i][1], srt[i][2]);
            b += min(srt[i][1], srt[i][2]);
            bal = a - b;
        }
    }
    int val = a * (a - 1) / 2 + b * (b - 1) / 2;
    //cerr << a << " " << b << "\n";
    cout << val << "\n";
}



signed main() {
    srand(time(0));
    cout << fixed;
    cout << setprecision(5);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        cin >> t;
    #endif
    for(int i = 0; i < t; ++i){
        solve();
    }
}


Measured memory_bytes: 8064
#include<stdio.h>
#include<math.h>

int main(void)
{
	int x;
	int i;
	int limit;
	int j;
	int flag=0;
	int ans=0;
	
	scanf("%d",&x);
	
	while(ans==0){
		limit = (int)sqrt((double)x);
		for(j=limit;j>1;j--)
			if(x%j==0)
				break;
		if(j==1)
			ans=x;
		x++;
	}
	
	printf("%d",ans);
	return 0;
}
	

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll Ans=0;
int m,n;
#define Maxn 100010
int x[Maxn];
inline bool cmp(int z1,int z2){return z1>z2;}
int main(){
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=m;++i)scanf("%d",&x[i]);
	sort(x+1,x+m+1);
	if(m<=n){
		puts("0");
		return 0;
	}
	for(register int i=1;i<m;++i){
	    x[i]=x[i+1]-x[i];
	    Ans+=x[i];
	}
	sort(x+1,x+m,cmp);
	for(register int i=1;i<n;++i)Ans-=x[i];
	printf("%lld\n",Ans);
	return 0;
}

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

int main(){
	int box[3][3] = {0};
	int N, P;
	for (int i=0; i<3; i++){
		for (int j=0; j<3; j++){
			scanf("%d", &box[i][j]);
		}
	}
	
	int pick[3][3]={0};
	scanf ("%d", &N);
	for (int i=0; i<N; i++){
		scanf ("%d", &P);
		for (int i=0; i<3; i++){
			for (int j=0; j<3; j++){
				if (box[i][j]==P){
					pick[i][j]++;
				}
			}
		}
	} 
	
	// Bingo Down
	for (int i=0; i<3; i++){ 
		if (pick[i][0]>=1){
		if (pick[i][1]>=1){
		if (pick[i][2]>=1){
		printf ("Yes\n");
		return 0;
		}
		}
		}
	}
	
	//Bingo Across
	for (int i=0; i<3; i++){
		if (pick[0][i]>=1){
		if (pick[1][i]>=1){
		if (pick[2][i]>=1){
		printf ("Yes\n");
		return 0;
		}
		}
		}
	}
	
	//Bingo Diagonal 11 22 33
		if (pick[0][0]>=1){
		if (pick[1][1]>=1){
		if (pick[2][2]>=1){
		printf ("Yes\n");
		return 0;
		}
		}
		}
	
	
	//Bingo Diagonal 02, 11, 20
		if (pick[0][2]>=1){
		if (pick[1][1]>=1){
		if (pick[2][0]>=1){
		printf ("Yes\n");
		return 0;
		}
		}
		}
		
	printf("No\n");
	return 0;
}

Measured memory_bytes: 1632
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}


int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool allb=true;
    REP(i,n){
        if(s[i]=='W')allb = false;
    }
    if(allb){
        put(0);
        return 0;
    }else{
        s.push_back('A');
        int cnt = 0;
        bool con = false;
        REP(i,n+1){
            if(s[i]=='B'){
                if(!con){
                    con = true;
                }
            }else{
                if(con){
                    con = false;
                    cnt+=2;
                }
            }
        }
        if(s[0]=='B')cnt--;
        if(s[n-1]=='B')cnt--;
        put(cnt);
        return 0;
    }
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numX = 0;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numX = scanner.nextInt();
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			System.out.println((numX - numA) % numB);

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;
		int numC = 0;
		int numX = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();
			numC = scanner.nextInt();
			numX = scanner.nextInt();

			int res = 0;
			for (int i = 0; i <= numA; i++) {
				for (int j = 0; j <= numB; j++) {
					for (int k = 0; k <= numC; k++) {
						if (i * 500 + j * 100 + k * 50 == numX) {
							res++;
						}
					}
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23252
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;

int main()
{
	ll k;
	scanf("%lld", &k);
	ll n = k / 50;
	ll r = k % 50;
	puts("50");
	for (int i = 1; i <= r; i ++) printf("%lld ", 99 - r + n);
	for (int i = r + 1; i <= 50; i ++) printf("%lld ", 49 - r + n);
	return 0;
}

Measured memory_bytes: 128
#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))

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 A,B,C;
	cin>>A>>B>>C;
	int ans = 0;
	ans += B;
	//cout<<ans<<endl;
	ans += min(C,B+1);
	//cout<<ans<<endl;
	C = max(0,C-(B+1));
	//cout<<C<<endl;
	if(C>0){
		ans += min(C,A);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)

if N < 26:
    for i in range(97, 123):
        if chr(i) not in S:
            print(S + chr(i))
            exit()

min_c = [S[-1]]
for c, i in zip(S[-2::-1], range(24, -1, -1)):
    for mc in min_c:
        if c < mc:
            print(S[:i] + mc)
            exit()
    else:
        min_c.append(c)
        min_c.sort()
print(-1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e18
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}
double dp[3001][3001];
int main()
{
    fill(dp,0);
    ll n;
    cin>>n;
    double heads[n+1],tails[n+1];
    repA(i,1,n){
        cin>>heads[i];
        tails[i]=1-heads[i];
    }
    dp[1][0]=tails[1];dp[1][1]=heads[1];
    repA(i,2,n)
    {
        rep(j,i+1)
        {
            if(j==0)
                dp[i][j]=dp[i-1][j]*tails[i];
            else
            {
                dp[i][j]=dp[i-1][j-1]*heads[i]+dp[i-1][j]*tails[i];
            }
        }
    }
    double ans=0;
    repA(i,1,n)
    {
        if(i>n/2)
            ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(12)<<ans;
    return 0;
}


Measured memory_bytes: 70656
fun main(args: Array<String>) {
	val s = readLine()!!.toString()
  	val t = readLine()!!.toString()
  
  	if (s.length + 1 == t.length) {
    	val sSubstring = s.substring(0, s.length)
  		val tSubstring = t.substring(0, s.length)
      	if (sSubstring == tSubstring) {
        	 println("Yes")
        } else {
        	println("No") 
        }
    } else {
    	println("No") 
    }
}

Measured memory_bytes: 34396
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
using namespace std;

long long int len(long long int n);

int main(){
    long long int n, a, b;
    long long int ans = 11;
    long long int tmp;
    
    cin >> n;
    
    for(a = 1; a <= sqrt(n); a++){
        if(n % a == 0){
            b = n / a;
            tmp = max(len(a), len(b));
            
            if(tmp < ans){
                ans = tmp;
            }
        }
    }
    
    cout << ans << endl;
}

long long int len(long long int n){
    long long int count = 0;
    
    while(n != 0){
        n /= 10;
        count++;
    }
    
    return count;
}


Measured memory_bytes: 256
import itertools
N = int(input())
L = list(map(int, input().split()))
ans = 0
for (a, b, c) in itertools.combinations(L, 3):
    if len(set({a, b, c})) == 3:
    #if a != b != c:
        if a + b > c and b + c > a and c + a > b:
            ans += 1
print(ans)

Measured memory_bytes: 9180