akhauriyash/Code-Regression huggingface dataset:
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

int main() {
	ll a, b, c;
	rd(a, b, c);
	print(min(a + b + 1, c) + b);
	return 0;
}

Measured memory_bytes: 3652
def main():
    N = int(input())
    L = list(map(int, input().split()))
    cnt = 0
    for i in range(N):
        for j in range(i+1,N):
            for k in range(j+1,N):
                if (L[i] != L[j]) and (L[j] != L[k]) and (L[k] != L[i]):
                    if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                        cnt += 1

    print(cnt)



if __name__ == "__main__":
    main()

Measured memory_bytes: 67896
defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.split()
    |> process()
    |> IO.puts()
  end
  
  defp process([a, "+", b]), do:
    String.to_integer(a) + String.to_integer(b)
  defp process([a, "-", b]), do:
    String.to_integer(a) - String.to_integer(b)
  
end

Measured memory_bytes: 30824
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int n, m; cin >> n >> m;
	string s, t; cin >> s >> t;
	int ans = lcm(n, m);
	int gc = lcm(ans / n, ans / m);
	for (int i = 0; i < ans; i += gc) {
		if (s[i / (ans / n)] != t[i / (ans / m)]) {
			cout << -1 << endl; return 0;
		}
	}
	cout << ans << endl;
}

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

int main() 
{
    int n, m;

    cin >> n >> m;

    int a[n][m];                            //n行m列の配列を確保
    int b[m][1];                            //m行1列の配列を確保

    for( int i = 0; i < n; i++ )            //入力
        for( int j = 0; j < m; j++ )
            cin >> a[i][j];
    
    for( int i = 0; i < m; i++ )            //入力
        cin >> b[i][1];;

    for( int i = 0; i < n; i++ )
    {
        int sum = 0;                        //m行1列の値を格納する変数(これをm回計算して出力すればいい)
        for( int j = 0; j < m; j++ )
        {
            sum += a[i][j] * b[j][1];       //行列の計算
        }
        cout << sum << endl;
    }            
        
    return 0;
}


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

int a, b, c, x, y, a1, b1, sum, tmp;

int main(void) {
    scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
    c *= 2;
    tmp = min(x, y);
    sum = min(c, a + b) * tmp;
    sum += min(a, c) * (x - tmp) + min(b, c) * (y - tmp);
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

const int K = 2e5 + 10;
bool dp[K];
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < k; i++) {
		if (!dp[i]) {
			for (int j = 0; j < n; j++) {
				dp[i + a[j]] = true;
			}
		}
	}
	if (dp[k]) {
		cout << "First\n";
	} else {
		cout << "Second\n";
	}
}



Measured memory_bytes: 512
N = int(input())
# 再帰関数
def dfs(s):
  if int(s) > N:
    return 0
# ７５３が含まれる数列を回収
  if(all(s.count(c) for c in '753')):
    ret = 1
  else:
  	ret = 0
# 条件にあう数列を抜き出している
  for c in '753':
    ret += dfs(s + c)
  return ret
# ’０’からスタート
print(dfs('0'))


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main (void) {
    int N;
    int K;
    int X;
    int Y;

    cin >> N >> K >> X >> Y;

    if (N <= K) cout << N * X << endl;
    else cout << K * X + (N - K) * Y << endl;

    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll A, B;
    cin >> A>> B;
    cout << A*B << '\n';

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

vector<string> divide = {"dream", "dreamer", "erase", "eraser"};

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

  reverse(s.begin(), s.end());
  for(int i = 0; i < divide.size(); ++i)reverse(divide[i].begin(), divide[i].end());

  bool flg = true;
  for(int i = 0; i < s.size(); ){
    bool canDivide = false;
    for(int j = 0; j < divide.size(); ++j){
      string d = divide[j];
      if(s.substr(i, d.size()) == d){
        i += d.size();
        canDivide = true;
      }
    }
    if(!canDivide){
      flg = false;
      break;
    }
  }

  if(flg)cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        int cnt = 0;
        for (int i = 0; i < N; i++)
        {
            if (cnt == A[i] - 1) cnt++;
        }
        if (cnt == 0) Console.WriteLine(-1);
        else Console.WriteLine(N - cnt);

    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
        
    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}





Measured memory_bytes: 34524
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import fractions
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        ans += fractions.Fraction(1, A[i])

    print(float(fractions.Fraction(1, ans)))


if __name__ == '__main__':
    main()


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

typedef long long   ll;
const ll mod = 1e18 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { return ((a ) * (b ));    }
ll add(ll a, ll b)  { return (a  + b ) ;        }
ll sub(ll a, ll b)  { return (a  - b) ;  }

const ll inf = 1e18;
const int nax = 110;

ll n,k;
string s;
ll dp[nax][4][2];

ll solve(ll idx,ll allowed,ll rqd)
{
	if(rqd<0)
		return 0;

	if(idx>=n)
	{
		if(rqd == 0)
			return 1;
		else
			return 0;
	}

	if(dp[idx][rqd][allowed]!=-1)
		return dp[idx][rqd][allowed];

	ll ans = 0;
	if(allowed == 0)
	{
		if((s[idx]-'0'-1)>0)
		{
			ans = (s[idx]-'0'-1)*solve(idx+1,1,rqd-1);
		}

		if(s[idx]!='0')
		{
			ans = ans + solve(idx+1,0,rqd-1);
          	ans = ans + solve(idx+1,1,rqd);
		}
      	else
        {
          	ans = ans + solve(idx+1,0,rqd);
        }
		
	}

	else
	{
		ans = 9*solve(idx+1,1,rqd-1)+ solve(idx+1,1,rqd);
	}

	dp[idx][rqd][allowed] = ans;
	return ans;
}

int main()
{
	speedup_IO;
	
	cin>>s>>k;
	n = s.length();

	ll ans = 0;

	forn(i,0,nax)
	{
		forn(j,0,4)
		{
			forn(k,0,2)
			{
				dp[i][j][k] = -1;
			}
		}
	}
	ans = solve(0,0,k);
	cout<<ans;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(ll N, ll A, ll B, ll &ans){

    if(A > B) ans = 0;
    else if(N == 1){
        if(A == B) ans = 1;
        else ans = 0;
    }
    else{
        ll min_sum{}, max_sum{};
        min_sum = A + B + A*(N-2);
        max_sum = A + B + B*(N-2);
        ans = max_sum - min_sum + 1;
    }
    return;
}

int main(){

    ll N, A, B;
    cin >> N >> A >> B;

    ll ans{};
    solver(N, A, B, ans);

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

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (SZ(s) & 1) cout << "No";
	else
	{
		string t = s.substr(0, SZ(s) >> 1);
		if (t + t == s) cout << "Yes";
		else cout << "No";
	}
	
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef long double lld;
const ll mod = 1000000007;

int n;
vector<vector<int>> adj;
vector<vector<ll>> cnt;

void dfs(int u) {
	if(cnt[u][0] >= 0) return;

	cnt[u][0] = cnt[u][1] = 1;
	for(int i = 0; i < adj[u].size(); i++) {
		int v = adj[u][i];
		if(cnt[v][0] >= 0) continue;
		dfs(v);
		cnt[u][0] = (cnt[u][0] * cnt[v][1]) % mod;
		cnt[u][1] = (cnt[u][1] * (cnt[v][0] + cnt[v][1])) % mod;
	}
}

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

	cin >> n;
	adj.resize(n, vector<int>());
	cnt.resize(n, vector<ll>(2, -1));

	for(int i = 1; i < n; i++) {
		int u, v; cin >> u >> v; --u; --v;
		adj[u].push_back(v); adj[v].push_back(u);
	}

	dfs(0);
	ll ans =(cnt[0][0] + cnt[0][1]) % mod;
	cout << ans << endl;
}

Measured memory_bytes: 15360
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		if(n>=400 && n<=599) System.out.println(8);	
		else if(n>599 && n<=799) System.out.println(7);
		else if(n>799 && n<=999) System.out.println(6);
		else if(n>999 && n<=1199) System.out.println(5);
		else if(n>1199 && n<=1399) System.out.println(4);
		else if(n>1399 && n<=1599) System.out.println(3);
		else if(n>1599 && n<=1799) System.out.println(2);
		else if(n>1799 && n<=1999) System.out.println(1);
	}
}


Measured memory_bytes: 32744
#include <stdio.h>
int main(void)
{
int a, b, c;
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);

if(a == b && b != c )
printf("Yes");
else if(b == c && b != a)
printf("Yes");
else if(c == a && c != b)
printf("Yes");
else
printf("No");

return 0;
}

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

int main() {
	int num[3];
	cin>>num[0]>>num[1]>>num[2];

	
	if((num[1]*10+num[2])%4==0){cout<<"YES"<<endl;}
	else{cout<<"NO"<<endl;}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
	const long long size=2e5+1;
	long long a[size],x[size];
	long long n,s;
int main()
{

	cin>>n; 
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	    x[i]=x[i-1]+a[i];
	    s+=a[i];
	}
	
	
	long long min=2e10+5,result;
	for(int i=1;i<n;i++)
	{
	result=abs(2*x[i]-s);
	if(min>result)
	min=result;
	}
	

	cout<<min;
	return 0;
	
	
	
	
 } 

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
#define mod 1000000007
class dj{
  int* parent;
  int* rank;
  int n;
  public:
  dj(int n){
     parent=new int[n];
     rank=new int[n];
     this->n=n;
   for(int i=1;i<n;i++)
   {
  

     parent[i]=i;
     rank[i]=1;
   }
  }
  int find(int a){
   if(a!=parent[a]){
     parent[a]=find(parent[a]);
   }
    return parent[a];
  }
  void Union(int a ,int b){
    int ap=find(a);
    int bp=find(b);
    if(ap==bp)
      return;
    
    parent[ap]=bp;
    rank[bp]+=rank[ap];
}
  int max(){
    int ans=0;
   for(int i=1;i<n;i++){
    if(ans<rank[i])
      ans=rank[i];
   //cout<<rank[i]<<endl;
   }
    return ans;
   
  }
};
int main()
{
  int n,m;
  cin>>n>>m;
  dj obj(n+1);
  for(int i=0;i<m;i++){
  int a,b;
    cin>>a>>b;
    obj.Union(a,b);
  
  }
  cout<<obj.max()<<endl;
    return 0;}

Measured memory_bytes: 5200
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

#define INF 1 << 16

int m[500][500];

int count(int x, int y) {
	if (x < 0 || y < 0) return 0;
	return m[y][x];
}

typedef pair<int, int> P;

P min(P p1, P p2) {
	return P( max(p1.first, p2.first), min(p1.second, p2.second) );
}

int main() {
	int H, W;
	while (cin >> H >> W, H || W) {
		for (int y = 0; y < H; ++y) {
			string str; cin >> str;
			for (int x = 0; x < W; ++x)
				m[y][x] = str[x] == '*';
		}

		int len[500][500] = {0};
		for (int y = 0; y < H; ++y) {
			if (!m[y][W-1]) len[y][W-1] = 1;
			for (int x = W-1; x; --x)
				if (!m[y][x-1]) len[y][x-1] = len[y][x]+1;
		}

		int ans = 0;
		for (int y = 0; y < H; ++y)
			for (int x = 0; x < W; ++x) {
				int w = INF;
				for (int y2 = y; y2 < H; ++y2) {
					int h = y2 - y + 1;
					w = min(w, len[y2][x]);
					ans = max(ans, w*h);
					if (!w) break;
				}
			}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3168
#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lb(x) x&-x
#define il inline
#define ll long long
#define llu unsigned long long
#define mem(x) memset(x,0,sizeof(x))
#define mem3(x) memset(x,0x3f,sizeof(x))
#define ccA() puts("耐心冷静查代码")
#define cc() puts("谁知盘中餐，粒粒皆辛苦")
#define fo(i,a,b) for(register int i=a;i<=b;++i)
#define fd(i,a,b) for(register int i=a;i>=b;--i)
#define fk(i,j) for(register int i=fir[j];i;i=nxt[i])
#define fv(i,q) for(int i=0;i<q.size();i++)
using namespace std;
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());
    return x*f;
}
inline void write(ll a){
    if(a==0){putchar('0');return;}
    if(a<0)putchar('-'),a=-a;
    char c1[120];
    ll h=0;
    while(a)c1[++h]=a%10+'0',a/=10;
    fd(i,h,1)putchar(c1[i]);
    return;
}
inline void write_(ll a){write(a);putchar(' ');}
inline void writeln(ll a){write(a);putchar('\n');}
//------------------------------------------------------

int p,a;
int main(){
	a=read();p=read();
	writeln((a*3+p)/2);
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	N := getStdinInt()
	switch N % 10 {
	case 2:
		fmt.Printf("%s\n", "hon")
	case 4:
		fmt.Printf("%s\n", "hon")
	case 5:
		fmt.Printf("%s\n", "hon")
	case 7:
		fmt.Printf("%s\n", "hon")
	case 9:
		fmt.Printf("%s\n", "hon")
		break
	case 0:
		fmt.Printf("%s\n", "pon")
	case 1:
		fmt.Printf("%s\n", "pon")
	case 6:
		fmt.Printf("%s\n", "pon")
	case 8:
		fmt.Printf("%s\n", "pon")
		break
	case 3:
		fmt.Printf("%s\n", "bon")
		break
	}
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


Measured memory_bytes: 1756
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, T;
  cin >> N >> T;
  int ans = 1e9;
  FOR(i,0,N) {
    int c, t;
    cin >> c >> t;
    if(t <= T) {
      ans = min(ans, c);
    }
  }
  if(ans == 1e9) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	m := make(map[int]int, 0)
	for i := 0; i < 3; i++ {
		fmt.Scan(&a, &b)
		m[a]++
		m[b]++
	}
	ans := "YES"
	for _, v := range m {
		if v >= 3 {
			ans = "NO"
			break
		}
	}
	fmt.Println(ans)
}


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

int main() {
  //input
  int N;
  cin >> N;
  vector<tuple<string,int,int>> r(N);
  rep(i,N) {
    string S;
    int P;
    cin >> S >> P;
    r.at(i) = make_tuple(S, -P, i+1);
    //-P: 大きい順に並べ替えるため、マイナスとしている
    //i+1: あとで出力に用いるので、番号を合わせて保持しておく。
    //     順序に影響しないように、各タプルの最後に置く
  }
  //calc
  sort(r.begin(), r.end());
  //output
  int num;
  rep(i,N) {
    tie(ignore,ignore,num) = r.at(i);
    cout << num << endl;
  }
}

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

// 内部定数
#define D_ON			1										// 汎用フラグ - ON
#define D_OFF			0										// 汎用フラグ - OFF
#define D_BOX_MAX		100000									// 最大箱数

// 内部構造体 - 箱情報
typedef struct Box {
	int miRed;													// 赤の有無
	int miCnt;													// ボール数
} Box;

// 内部変数
static FILE *szpFpI;											// 入力
static Box sz1Box[D_BOX_MAX + 5];								// 箱
static int siBCnt;												// 箱数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 箱数・操作数 - 取得
	int liMCnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siBCnt, &liMCnt);

	// 箱 - 初期化
	sz1Box[1].miRed = D_ON;
	sz1Box[1].miCnt = 1;
	for (i = 2; i <= siBCnt; i++) {
		sz1Box[i].miRed = D_OFF;
		sz1Box[i].miCnt = 1;
	}

	// 操作 - 取得
	for (i = 0; i < liMCnt; i++) {
		int liFNo, liTNo;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d%d", &liFNo, &liTNo);

		// 移動先
		sz1Box[liTNo].miCnt++;
		if (sz1Box[liFNo].miRed == D_ON) {
			sz1Box[liTNo].miRed = D_ON;
		}

		// 移動元
		sz1Box[liFNo].miCnt--;
		if (sz1Box[liFNo].miCnt == 0) {
			sz1Box[liFNo].miRed = D_OFF;
		}
	}

	// 箱数 - 取得
	int liCnt = 0;
	for (i = 1; i <= siBCnt; i++) {
		if (sz1Box[i].miRed == D_ON) {
			liCnt++;
		}
	}

	// 結果 - セット
	sprintf(lc1Out, "%d\n", liCnt);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 896
n1 = int(input())

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

r1 = "YES"

n3 = sorted(n2)

c1 = 0

for i1 in range(n1):
    if n2[i1] != n3[i1]:
        c1 += 1
        if c1 == 3:
            r1 = "NO"

print(r1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
  #define DUMP(i) 
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

struct Edge{
public:
  int from,to,cost;
  Edge(){}
  Edge(int _from,int _to,int _cost){
    from = _from;
    to = _to;
    cost = _cost;
  }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;


const int EPS = 1e-9;
const int MOD = 1e9+7;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string sa,sb,sc;
  cin >> sa >> sb >> sc;
  vector<queue<int>> V(3);
  REP(i,SZ(sa)){
    if(sa[i] == 'a')V[0].push(0);
    else if(sa[i] == 'b')V[0].push(1);
    else V[0].push(2);
  }
  REP(i,SZ(sb)){
    if(sb[i] == 'a')V[1].push(0);
    else if(sb[i] == 'b')V[1].push(1);
    else V[1].push(2);
  }
  REP(i,SZ(sc)){
    if(sc[i] == 'a')V[2].push(0);
    else if(sc[i] == 'b')V[2].push(1);
    else V[2].push(2);
  }

  int next = V[0].front();
  V[0].pop();

  while(true){
    if(V[next].empty()){
      cout << (char)('A' + next) << endl;
      return 0;
    }
    DUMP((char)(V[0].front() + 'A'));
    DUMP((char)(V[1].front() + 'A'));
    DUMP((char)(V[2].front() + 'A'));
    int pnext = next;
    next = V[next].front();
    V[pnext].pop();
  }
  return 0;
}



Measured memory_bytes: 256
n = str(input().rstrip())

def solve1(n):
    ans = 0

    a = list(map(int, list(n)))
    a = a[::-1]
    a.append(0)
    for i in range(len(a) - 1):
        c = a[i]
        if c < 5:
            ans += c
        else:
            if c == 5 and a[i+1] < 5:
                ans += 5
            else:
                a[i+1] += 1
                ans += 10 - c
    ans += n_list[-1]

    print(ans)

def solve2(n):
    INF = 10**9
    n = n[::-1]
    n += '0'
    n_len = len(n)
    dp = [[INF for _ in range(2)] for _ in range(n_len+1)]
    dp[0][0] = 0

    for i in range(n_len):
        for j in range(2):
            x = int(n[i])
            x += j
            if x < 10:
                dp[i+1][0] = min(dp[i+1][0], dp[i][j]+x)
            if x > 0:
                dp[i+1][1] = min(dp[i+1][1], dp[i][j]+(10-x))

    print(dp[n_len][0])
solve2(n)

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

signed main(){
  lint a, b; cin >> a >> b;
  if(a == b){
    for(lint i = 0; i < a; i++) cout << a;
    cout << endl;
  }
  if(a < b){
    for(lint i = 0; i < b; i++) cout << a;
    cout << endl;
  }
  if(a > b){
    for(lint i = 0; i < a; i++) cout << b;
    cout << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <queue>
#include <vector>
#include <climits>

using namespace std;

static const int MaxV = 10000;

vector<int> AdjL[MaxV];
int InDegree[MaxV];
queue<int> Q;

int main() {
	int V, E;
	int s, t;

	cin >> V >> E;
	for (int i = 0; i < V; i++) {
		InDegree[i] = 0;
	}
	for (int i = 0; i < E; i++) {
		cin >> s >> t;
		AdjL[s].push_back(t);
		InDegree[t]++;
	}
	for (int i = 0; i < V; i++) {
		if (InDegree[i] == 0) {
			Q.push(i);
		}
	}
	while (Q.empty() == false) {
		s = Q.front();
		Q.pop();
		cout << s << endl;
		for (unsigned int i = 0; i < AdjL[s].size(); i++) {
			t = AdjL[s][i];
			if (--InDegree[t] == 0) {
				Q.push(t);
			}
		}
	}

	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;

    int A[n][m], B[m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }
    for (int j = 0; j < m; j++) {
        cin >> B[j];
    }

    for (int i = 0; i < n; i++) {
        int value = 0;
        for (int j = 0; j < m; j++) {
            value += A[i][j] * B[j];
        }
        cout << value << endl;
    }

    return 0;
}

Measured memory_bytes: 1196
#[allow(unused)]
use proconio::marker::*;
use proconio::{fastout, input};
#[allow(unused)]
use std::cmp::{max, min, Reverse};
#[allow(unused)]
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

#[fastout]
fn main() {
    input! {
        x: i64,
        y: i64,
    }

    if y - 2 * x >= 0 && (y - 2 * x) % 2 == 0 && y - 4 * x <= 0 && (y - 4 * x) % 2 == 0 {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
int main()
{
int r,b,g,k;
cin>>r>>g>>b>>k;
while(r>=g)
{
g=g*2;
k--;
if(k<0)
break;
}
while(b<=g)
{
b=b*2;
k--;
if(k<0)
break;
}
if(k>=0)
cout<<"Yes";
else
cout<<"No";
return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	vector<pair<pair<long long,long long>,long long> > ypx(m);
	vector<long long> ans(m);
	vector<long long> cnt(n + 1);
	for (int i = 0; i < m; ++i) {
		cin >> ypx[i].first.second >> ypx[i].first.first;
		ypx[i].second = i;
	}
	sort(ypx.begin(), ypx.end());
	for (int i = 0; i < m; ++i) {
		long long pi = ypx[i].first.second;
		cnt[pi]++;
		ans[ypx[i].second] = pi * 1000000 + cnt[pi];
	}
	for (int i = 0; i < m; ++i)
		printf("%012lld\n", ans[i]);

	return 0;
}

Measured memory_bytes: 5376
package main

import (
	"fmt"
)

func main() {
	var x, y, z int
	fmt.Scan(&x, &y, &z)
	mx := 0
	for i := 1; i <= 100000; i++ {
		if y*i+z*(i-1)+z*2 <= x {
			if mx < i {
				mx = i
			}
		}
	}
	fmt.Println(mx)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const ll inf=1e9+7;
const ll ful=1e18;
using namespace std;
namespace mp = boost::multiprecision;
int main() 
{
	ll a;
	long double b;
	cin>>a>>b;
	long double ansf=a*b;
	ll anst=ansf;
	cout<<anst<<endl;
	return 0;
}


Measured memory_bytes: 3728
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,M,Q; cin >> N >> M >> Q;
    using Item = tuple<ll,ll,ll,ll>;
    vector<ll> a(Q),b(Q),c(Q),d(Q);
    for(int i = 0; i < Q;i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    
    vector<int> A(N);
    
    function<void(int,int)> dfs = [&](int n,int pre){
        if(n == N){
            ll T = 0;
            for(int i = 0; i < Q;i++){
                if(A[b[i]]-A[a[i]] == c[i]) T += d[i];
            }
            res = max(res,T);
            return;
        }
        for(int m = pre; m <= M; m++){
            A[n] = m;
            dfs(n+1,m);
        }
    };
    dfs(0,1);
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES

int main()
{
    int n=0,a_row[101]={0},max_diff=0,new_max_diff=0;

    scanf("%d",&n);

    for(int i=0;i<n;i++)
	scanf("%d",&a_row[i]);


    for(int i=0;i<n-1;i++){
	for(int j=i+1;j<n;j++){
	    new_max_diff=abs(a_row[j]-a_row[i]);
	    if(new_max_diff>=max_diff)
		max_diff=new_max_diff;
	}
    }

    printf("%d",max_diff);
    return 0;
}



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

typedef long long ll;
typedef pair<int,int> P;
ll const INF = INT_MAX;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<P> edges[2510];

void bellmanford1(int n,vector<ll>& dist) {
    for (int x = 0;x < n-1;++x) {
        for (int i = 0;i < n;++i) if (dist[i] < INF) for (P& p : edges[i]) {
            dist[p.first] = min(dist[i]+p.second,dist[p.first]); 
        }
    }
}


void bellmanford2(int n,vector<ll>& dist) {
    for (int x = 0;x < n-1;++x) {
        for (int i = 0;i < n;++i) if (dist[i] < INF) for (P& p : edges[i]) {
            if (dist[i]+p.second < dist[p.first]) dist[p.first] = -INF;
        }
    }
}

int main() {
    int n,m,p;
    cin >> n >> m >> p;
    vector<ll> dist1(2510,INF),dist2;
    for (int i = 0;i < m;++i) {
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        edges[a].push_back(P(b,p-c));
    }
    dist1[0] = 0;
    bellmanford1(n,dist1);
    dist2 = dist1;
    bellmanford2(n,dist2);
    ll ans = 0;
    if (dist1[n-1] > dist2[n-1]) cout << "-1" << endl;
    else cout << max(0LL,-dist1[n-1]) << endl;
    return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    int x;
    cin>>x;
    
    int max=1;
    int tem=1;
    
    for(int i=1;i<x;i++){
        int e=i*i;
        if(e>x){
            break;
        }
        for(int p=1;p<x;p++){
            e=e*i;
            if(e>x){
                tem=e/i;
                break;
            }
            
            }
        if(tem>=max){
            max=tem;
        }
        
    }
    
    cout<<max<<endl;
        
  
    
    return 0;
   
}






Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = i + 1;
            b[i] = n - i;
        }

        for (int i = 0; i < n; i++) {
            int p = scanner.nextInt() - 1;
            for (int j = 0; j <= p; j++) {
                b[j] += i;
            }
            for (int j = p; j < n; j++) {
                a[j] += i;
            }
        }

        Arrays.stream(a).forEach(System.out::println);
        Arrays.stream(b).forEach(System.out::println);
    }
}

Measured memory_bytes: 45908
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, Q;
std::set<P> st;
std::vector<std::vector<ll>> vs;
ll ans[200010];

int main()
{
  std::cin >> N >> Q;

  rep( i, N )
  {
    ll S, T, X;
    std::cin >> S >> T >> X;

    vs.push_back( { X, S-X, T-X } );
  }

  std::sort( all(vs) );

  rep( i, Q )
  {
    ll D;
    std::cin >> D;

    st.emplace( D, i );

    ans[i] = -1;
  }

  rep( i, N )
  {
    ll l = vs[i][1], r = vs[i][2], x = vs[i][0];

    auto it = st.lower_bound( P( l, -1 ) );

    while( it != st.end() )
    {
      if( it->first >= r )
        break;

      ans[it->second] = x;

      st.erase( it++ );
    }
  }

  rep( i, Q )
    std::cout << ans[i] << std::endl;

  return 0;
}

Measured memory_bytes: 28076
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int color[MAXN];
vector<pii> G[MAXN];

void dfs(int node, int par, int c){
	ans=max(ans, (int)G[node].size());
	int tmp=1;
	for (pii p:G[node]) if (p.first!=par){
		if (tmp==c) tmp++;
		color[p.second]=tmp;
		dfs(p.first, node, tmp);
		tmp++;
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<n; i++){
		cin>>u>>v;
		G[u].pb({v, i});
		G[v].pb({u, i});
	}
	dfs(1, 1, 0);
	cout<<ans<<'\n';
	for (int i=1; i<n; i++) cout<<color[i]<<'\n';
	
	return 0;
}


Measured memory_bytes: 10240
#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;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    string s;
    cin >> n >> s;
    vector<int> left(n+1,0), right(n+1,0);
    int ans = inf;
    int same = 0;
    rep(i,n){
        if(i == 0){
            if(s[i] == 'E') left[i+1]++;
        }else if(i != n-1){
            if(s[i] == 'E') left[i+1] = left[i] + 1;
            else left[i+1] = left[i];
        }
    }
    for(int i = n-1;i >= 0; i--){
        if(i == n-1){
            if(s[i] == 'W') right[i-1]++;
        }else if( i != 0){
            if(s[i] == 'W') right[i-1] = right[i] + 1;
            else right[i-1] = right[i];
        }
    }
    rep(i,n){
        int now = left[i] + right[i];
        if(now > same){
            same = now;
            ans = n - 1 - same;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define debug(x) cout<<#x<<" "<<x<<endl;

const int N=1e6+5;
const double eps=1e-9;
const int INF=1e18;

int n,T;
int w[N],v[N];
int f[N];

struct node{
    int x,y;
}a[N];

bool cmp(node A,node B){
    return A.x<B.x;
}

signed main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    cin>>n>>T;
    for(int i=1;i<=60000;i++) f[i]=-10000000;
    f[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i].x>>a[i].y;
    }
    sort(a+1,a+1+n,cmp);
    for(int i=1;i<=n;i++){
        w[i]=a[i].x,v[i]=a[i].y;
    }
    for(int i=1;i<=n;i++){
        for(int j=T-1;j>=0;j--)
            f[j+w[i]]=max(f[j+w[i]],f[j]+v[i]);
    }
    int ans=-1;
    for(int i=1;i<=6000;i++) ans=max(ans,f[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
//#define cin (type == 0?cin:fin)
//#define cout (type == 0?cout:fout)
#define tcn cin.tie(0);
#define tct cout.tie(0);
#define r_0 return 0
#define ll long long
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long N = 2e5 + 7;
const long long MrBeast = 1e9;


ll T = 1, n, u[N], m, x, pluse, minuse, NAZSHO, cnt, ans;
vector < ll > v, t;
int type = 0;
set< ll > st;
pair< ll ,ll > p[N];
int main()
{
    TIME
    //ifstream  fin("swap.in");
    //ofstream  fout("swap.out");
    cin >> n;
    for ( int i=1; i<=n; i++ ){
        if ( i % 3 != 0 and i % 5 != 0 ){
            cnt += i;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>

using namespace std;

struct block {
    int w, s, v;
    bool operator<(block a) const {
        return w + s < a.w + a.s;
    }
};

long long dp[20001]; // dp[i] is max value with weight of i

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    block blocks[n];
    for (int i = 0; i < n; i++) cin >> blocks[i].w >> blocks[i].s >> blocks[i].v;
    sort(blocks, blocks + n);
    for (int i = 0; i < n; i++) {
        for (int j = blocks[i].s; j >= 0; j--) dp[j + blocks[i].w] = max(dp[j + blocks[i].w], dp[j] + blocks[i].v);
    }
    long long ans = 0;
    for (int i = 0; i < 20001; i++) ans = max(ans, dp[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
import math
n=int(input())
p=[]
for i in range(n):
    p.append(list(map(int,input().split())))
#print(p)
ans=0
for i in range(n):
    for j in range(n):
        if i!=j:
            ans+=math.sqrt((p[j][0]-p[i][0])**2+(p[j][1]-p[i][1])**2)
ans/=n
print(ans)


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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

const i64 NUM = 1000000007LL;

i64 modpow(i64 a, i64 b, i64 NUM) {
  i64 ans = 1;
  //cout << a << " " << b << endl;
  while(b != 0) {
    if(b % 2 == 1) {
      ans *= a;
      ans %= NUM;
    }
    a = a * a;
    a %= NUM;
    b /= 2;
  }
  return ans;
}

i64 modinv(i64 a, i64 NUM) {
  return modpow(a, NUM-2, NUM);
}

vi factorial;
vi inv_factorial;

void prepare(i64 n, const i64 NUM) {
  i64 i;
  factorial.resize(n+1);
  inv_factorial.resize(n+1);
  factorial[0] = factorial[1] = 1;
  inv_factorial[0] = inv_factorial[1] = 1;
  REP(2, n+1, i) {
    factorial[i] = (factorial[i-1] * i) % NUM;
    inv_factorial[i] = modinv(factorial[i], NUM);
  }
}

i64 comb(i64 n, i64 r, i64 NUM) {
  if(r == n || r == 0) {
    return 1LL;
  }
  i64 ans = 1;
  ans *= factorial[n];
  ans *= inv_factorial[r];
  ans %= NUM;
  ans *= inv_factorial[n-r];
  ans %= NUM;
  return ans;
}

int main(int argc, char *argv[]) {
  i64 K;
  string S;
  cin >> K;
  cin >> S;

  prepare(sz(S)+K+1, NUM);

  i64 ans = 0, k;
  REP(0, K+1, k) {
    i64 delta = modpow(26, K-k, NUM);
    delta *= modpow(25, k, NUM);
    delta %= NUM;
    delta *= comb(sz(S)+k-1, sz(S)-1, NUM);
    delta %= NUM;

    /*
    cout << "prefix = " << K-k << endl;
    cout << "n = " << sz(S)+k-1 << " r = " << sz(S)-1 <<
      " comb = " << comb(sz(S)+k-1, sz(S)-1, NUM) << endl;
    cout << delta << endl;
    */
    
    ans += delta;
    ans %= NUM;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int g[525][525];

void dfs(vi v, int level=1){
    if(v.size() <= 1)return;
    int n = v.size();
    vi a(n/2),b(n-n/2);
    REP(i,n/2)a[i]=v[i];
    FOR(i,n/2,n)b[i-n/2]=v[i];
    for(int x:v)for(int y:v)g[x][y] = level;
    dfs(a,level+1);
    dfs(b,level+1);
}

int main(){
    int n;
    cin>>n;
    vi v(n);
    REP(i,n)v[i]=i;
    dfs(v);
    REP(i,n){
        FOR(j,i+1,n)printf("%d%c",g[i][j],j==n-1?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 1536