akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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 T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll N; cin >> N;
	vector<ll> v(N);
	rep(i, N) cin >> v[i];
	sort(ALL(v), greater<ll>());

	ll ans = 0;

	N -= 2;
	ans += v[0];
	int k = 0;
	rep(i, N){
		if(i % 2 == 0) k ++;
		// print(k, i);
		ans += v[k];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 2000000000;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll nCr(int n, int r)
{
    ll ans = 1;
    for (int i = n; i > n - r; --i)
    {
        ans = ans * i;
    }
    for (int i = 1; i < r + 1; ++i)
    {
        ans = ans / i;
    }
    return ans;
}

int main()
{
    int N = 0;
    cin >> N;
    map<int, int> W;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int pre = 1;
    int ans = 0;
    sort(all(A));
    for (int i = 1; i < N; i++)
    {
        if(A[i] == A[i-1]){
            pre++;
        }
        else{
            if(pre % 2 == 1){
                ans++;
            }
            pre = 1;
        }
    }
    if(pre % 2 == 1){
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {
	static long[] a;
	static long[] p;
	private static void solve(){
		//Implement solution here.
		int n = ni();
		long k = nl();
		a = new long[n];
		p = new long[n];
		a[0] = 1;
		p[0] = 1;
		for(int i = 1; i < n; i++) {
			a[i] = a[i - 1] * 2 + 3;
			p[i] = p[i - 1] * 2 + 1;
		}
		System.out.println(burger(n,k));		
	}

	static long burger(int n, long x) {
		if(n == 0) {
			return x > 0 ? 1 : 0;
		}else if(x <= a[n - 1] + 1) {
			return burger(n - 1, x - 1);
		} else {
			return p[n - 1] + burger(n - 1, x - a[n - 1] - 2) + 1;
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

ll gcd(ll a,ll b){
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b,a%b);
    }
}

ll lcm(ll x, ll y) {
    return x / gcd(x,y) * y;
}

int main(void)
{
    IOS
    int N, M;
    cin >> N >> M;
    string S; cin >> S;
    string T; cin >> T;

    ll xl = lcm(N,M);
    ll ln = xl / N;
    ll lm = xl / M;


    map<ll,char> X;
    REP(i,N) {
        X[ln*i] = S[i];
    }
    REP(i,M) {
        if (!(X.count(lm*i) == 0 || X[lm*i] == T[i])) {
            OUT(-1)
            return 0;
        }
    }


    cout << xl << '\n';

    return 0;
}


Measured memory_bytes: 6144
N = int(input())
p = [list(map(int, input().split()))for _ in range(N)]
ax, ay, ah = list(filter(lambda x: x[2], p))[0]
for x in range(101):
    for y in range(101):
        H = ah+abs(ax-x)+abs(ay-y)
        if all(max(H-abs(t[0]-x)-abs(t[1]-y), 0) == t[2]for t in p):
            print(x, y, H)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin>>a;
  for(int i=0;i<10;i++){
    for(int b=0;b<10;b++){
      if(a==i*b){
        cout<<"Yes";
        return 0;
      }
    }
  }
  cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <iomanip>
#include <math.h>
#include <algorithm>
#define M_PI 3.14159265358979323846264338327950288
#define oo 998244353
#define maxN 200007
using namespace std;

long long f[maxN];
long long sum[maxN];
int l[maxN], r[maxN];

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

    for (int i = 1; i <= k; ++i) cin >> l[i] >> r[i];
    f[1] = 1LL;
    sum[1] = 1LL;
    for (int i = 2; i <= n; ++i) {
        for (int j = 1; j <= k; ++j) {
            f[i] = (f[i]+(sum[max(0, i-l[j])]-sum[max(0, i-r[j]-1)])%oo+oo)%oo;
        }
        sum[i] = sum[i-1]+f[i];
    }

    cout << f[n] << endl;
    return 0;
}

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

class P
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        Console.WriteLine(s[1] == "+" ? int.Parse(s[0]) + int.Parse(s[2]) : int.Parse(s[0]) - int.Parse(s[2]));
    }
}

Measured memory_bytes: 11092
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = input()
ans = 0
for i in range(len(n)):
    ans += int(n[i])
print('Yes' if ans%9 == 0 else 'No')


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

int main() {
  long double l;
  cin>>l;
  l=l/3;
  cout<<fixed<<setprecision(10);
  cout<<l*l*l<<endl;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	if(n / 10 == 9) cout<< "Yes"<<"\n";
	else if(n % 10 == 9) cout<< "Yes"<<"\n";
	else cout<< "No" <<"\n";

	return 0;
}

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

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

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

int getCount(string s){
  int count = 0;
  std::string::size_type pos = 0;
  while((pos = s.find("D", pos)) != std::string::npos){
    count++;
    pos++;
  }
  pos = 0;
  while((pos = s.find("PD", pos)) != std::string::npos){
    count++;
    pos++;
  }
  return count;
}

signed main() {
  string str;
  cin >> str;
  
  string strR = str;
  string strD = str;
  replace(strR.begin(),strR.end(),'?','R');
  replace(strD.begin(),strD.end(),'?','D');
  
  if(getCount(strR)>getCount(strD))
    cout << strR << endl;
  else
    cout << strD << endl;
  
  return 0;
}

Measured memory_bytes: 4492
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
using namespace std;

const int N = 1e4 + 47;

int dp[N], n, a[N], b[N], h;

void PUNKS_NOT_DEAD() {
    cin >> h >> n;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    fill(dp, dp + N, 2e18);
    dp[0] = 0;
    for (int x = 0; x < h; x++) {
        for (int i = 0; i < n; i++) {
           int s = min(h, x + a[i]);
           dp[s] = min(dp[s], dp[x] + b[i]);
        }
    }
    cout << dp[h];
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    PUNKS_NOT_DEAD();
}

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

template <typename T>
void print_vec(vector<T> v) {
  for (auto i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> ans(n);
  rep(i, n) {
    if (i % 2 == 0)
      ans[0] += a[i];
    else
      ans[0] -= a[i];
  }
  for (int j = 1; j < n; j++) {
    ans[j] = a[j - 1] * 2 - ans[j - 1];
  }

  print_vec(ans);
  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main(){
	multiset<int> x;
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
		x.insert(a[i]);
	}
	for(int i=1;i<=n;i++){
		if(*--x.end()!=a[i]){
			cout<<*--x.end()<<endl;
		}else{
			cout<<*--(--x.end())<<endl;
		}
	}
	return 0;
}


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

int main() {
	string s;
	int k;
	cin >> s >> k;
	int n = s.size();
	vector<string> bubun;
	for (int i=0;i<n;i++) {
		for (int j=1;(i+j<=n)&&(j<=k);j++) {
			string b = s.substr(i,j);
			bubun.push_back(b);
		}
	}
	sort(bubun.begin(), bubun.end());
	bubun.erase(unique(bubun.begin(), bubun.end()), bubun.end());
	cout << bubun[k-1] << endl;
	return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string s;
int ans;
int main()
{
	cin>>s;
	for(int i=1;i<s.size();i++)
	{
		if(s[i]!=s[i-1])ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int P=1e9+7,N=2e5+7;
int c[N],w[N],d[N],f[N],iv[N],fc[N],fciv[N];
int main(){
	int n,x,y,i,j,t=0,mn=2e9,mn2=2e9,ans=1;
	scanf("%d%d%d",&n,&x,&y);
	memset(d,63,n+1<<2);
	for(i=1;i<=n;++i)scanf("%d%d",c+i,w+i),d[c[i]]=min(d[c[i]],w[i]);
	for(i=1;i<=n;++i)if(d[i]<mn)mn2=mn,mn=d[i];else if(d[i]<mn2)mn2=d[i];
	if(mn+mn2>y)return puts("1"),0;
	fc[1]=iv[1]=fciv[1]=1;
	for(i=2;i<=n;++i)iv[i]=(P-P/i)*1ll*iv[P%i]%P,fc[i]=fc[i-1]*1ll*i%P,fciv[i]=fciv[i-1]*1ll*iv[i]%P;
	for(i=1;i<=n;++i)if((w[i]+d[c[i]]<=x)||(w[i]+(d[c[i]]==mn?mn2:mn)<=y))++f[c[i]];
	for(i=1;i<=n;++i)if(d[i]+mn<=y)t+=f[i],ans=ans*1ll*fciv[f[i]]%P;
	printf("%d",ans*1ll*fc[t]%P);
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int sum=700;
  cin>>s;
  if(s.at(0)=='o') sum+=100;
  if(s.at(1)=='o') sum+=100;
  if(s.at(2)=='o') sum+=100;
  cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
	int T[101][101],r,c;

	cin>>r>>c;
	for(int i=0;i<r;i++)
		for(int j=0;j<c;j++)cin>>T[i][j];

	for(int i=0;i<=r;i++)T[i][c]=0;
	for(int j=0;j<=c;j++)T[r][j]=0;

	for(int i=0;i<r;i++){
	    for(int j=0;j<c;j++){
			T[i][c]+=T[i][j];
			T[r][j]+=T[i][j];
			T[r][c]+=T[i][j];
		}
	}

	for(int i=0;i<=r;i++){
		for(int j=0;j<=c;j++){
			if(j)cout<< " ";
			cout<<T[i][j];
		}
		cout<<endl;
	}

	return 0;
}

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

using namespace std;

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

typedef int _loop_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 DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,m;
  cin>>n>>m;
  if(n<m)swap(n,m);
  assert(n>=m);
  if(n-m>=2){
    puts("0");
    return 0;
  }
  ll ans = 1;
  FOR(i,1,n+1)ans=ans*i%MOD;
  FOR(i,1,m+1)ans=ans*i%MOD;
  if(n==m){
    ans = ans * 2 % MOD;
  }
  cout<<ans<<endl;
  return 0;
}


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

const int MAX_N = 2e5 + 10;
int A, B, C, X, Y, ans;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> A >> B >> C >> X >> Y;
	ans = A * X + B * Y;

	for (int c = 2; c < MAX_N; c += 2)
		ans = min(ans, c * C + max(0, X - c/2) * A + max(0, Y - c/2) * B);

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [0] + list(map(int, input().split())) + [0]
C = []
c = 0
for i in range(n+1):
  c += abs(A[i+1] - A[i])
for i in range(1, n+1):
  if A[i-1] <= A[i] <= A[i+1] or A[i+1] <= A[i] <= A[i-1]:
    print(c)
  elif A[i] <=A[i-1] <= A[i+1] or A[i] <= A[i+1] <= A[i-1]:
    print(c - abs(min(A[i-1], A[i+1]) - A[i])*2)
  elif A[i-1] <= A[i+1] <= A[i] or A[i+1] <= A[i-1] <= A[i]:
    print(c - abs(A[i] - max(A[i+1], A[i-1]))*2)

Measured memory_bytes: 13920
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> p(n);
  int temp_max = 0;
  int ans = 0;
  for(int i = 0; i < n; i++){
    cin >> p[i];
    temp_max = max(temp_max, p[i]);
    ans += p[i];
  }
  ans -= 0.5*temp_max;
  cout << ans << endl;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b,c,d,hoge=0;cin>>a>>b>>c>>d;
  a<b ? hoge+=a : hoge+=b;
  c<d ? hoge+=c : hoge+=d;
  cout<<hoge<<endl;
}


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

int main() {
  int N, p = 0, w = 0, g = 0, y = 0;
  cin >> N;
  string S;
  
  for (int i = 0; i < N; i++) {
    cin >> S;
    
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    
    if (((i + 1) == N) && (S != "Y")) {
      cout << "Three" << endl;
    }
  
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
const long long INF=4000000000000000000LL;
typedef pair<long long,int> P;
int main(){
	long long ans=INF;
	int N,K,a,b,C[55][55]={},S[55][55];
	P AX[55],AY[55];
	int BX[55],BY[55],nx,ny;
	cin>>N>>K;
	nx=N;ny=N;
	for(int i=1;i<=N;++i){
		cin>>a>>b;
		AX[i]=P(a,i);
		AY[i]=P(b,i);
		BX[i]=i;
		BY[i]=i;
	}
	for(int i=1;i<=nx-1;++i){
		for(int j=i+1;j<=nx;++j){
			if(AX[i].first>AX[j].first){
				P d=AX[i];
				AX[i]=AX[j];
				AX[j]=d;
				BX[AX[i].second]=i;
				BX[AX[j].second]=j;
			}
			if(AX[i].first==AX[j].first){
				AX[j]=AX[nx-1];
				--nx;
				BX[AX[i].second]=i;
				AX[j].second=AX[i].second;
//				BX[AX[j].second]=i;
			}

		}
	}
	for(int i=1;i<=ny-1;++i){
		for(int j=i+1;j<=ny;++j){
			if(AY[i].first>AY[j].first){
				P d=AY[i];
				AY[i]=AY[j];
				AY[j]=d;
				BY[AY[i].second]=i;
				BY[AY[j].second]=j;
			}
			if(AY[i].first==AY[j].first){
				AY[j]=AY[nx-1];
				--ny;
				BY[AY[i].second]=i;
				AY[j].second=AY[i].second;
//			BY[AY[j].second]=i;
			}

		}
	}
	for(int i=1;i<=N;++i){
		C[BX[i]][BY[i]]=1;
	}
	for(int i=1;i<=nx;++i){
		for(int j=1;j<=ny;++j){
			C[i][j]+=C[i][j-1]+C[i-1][j]-C[i-1][j-1];
//			cout<<C[i][j]<<" ";
		}
//		cout<<endl;
	}
	for(int i1=1;i1<=nx;++i1){
		for(int j1=1;j1<=ny;++j1){
			for(int i2=i1+1;i2<=nx;++i2){
				for(int j2=j1+1;j2<=ny;++j2){
					if(C[i2][j2]-C[i1-1][j2]-C[i2][j1-1]+C[i1-1][j1-1]>=K){
						ans=min(ans,(AX[i2].first-AX[i1].first)*(AY[j2].first-AY[j1].first));
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;

int main() {

    ll N, K;
    cin >> N >> K;

    vector<bool> seen(N, false);
    seen[0] = true;
    
    vector<ll> now(N+1, 0);
    vector<ll> see(N, -1);
    // see[0] = 0;
    now[0] = 0;
    vector<ll> A(N);

    REP(i, N){
        cin >> A[i]; A[i]--;
    }
    ll start = 0;
    ll end = 0;
    REP(i, N){
        now[i+1] = A[now[i]];
    }
    REP(i, N+1){
        if(see[now[i]] != -1){
            start = see[now[i]];
            end = i-1;
            break;
        }
        see[now[i]] = i;
    }
    vector<ll> ring(end-start+1);
    for(int i = 0; i <= end-start; i++){
        ring[i] = now[start+i];
    }

    // cout << start << " " << end << endl;

    if(K <= start)cout << now[K]+1 << endl;
    else{
        cout << ring[(K-start) % (end-start+1)]+1 << endl;
    }

    // REP(i, N+1){
    //     cout << now[i] << endl;
    // }

    // for(int i = 0; i <= end-start; i++){
    //     cout << ring[i] << endl;
    // }

    

    



}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 9268
mod = 10**9+7

def main():
    X,Y = map(int,input().split())

    choice = min(X,Y) - abs(X-Y)

    if choice >= 0 and choice %3 == 0:
        A = choice//3
        B = A+abs(X-Y)
        ans = 1
        for i in range(B+1,A+B+1):
            ans *= i
            ans %= mod
        for i in range(1,A+1):
            ans *= pow(i,mod-2,mod)
            ans %= mod
        return ans
    else:
        return 0

    

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 40868
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N,A;
    cin >> N >> A;
    
    bool ans = N%500 <= A;
    
    if(ans == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int k = sc.nextInt();
   int count = 1;
   while(true){
    if(n/(int)(Math.pow(k,count))==0) break;
    count++;
   }
   System.out.println(""+count);
 }
}

Measured memory_bytes: 22868
/// I won't go back on my word, that's my ninja way!
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5 ;
int n ,x ,cnt[N][21] ;
bool ok(int i,int j){
    for(int u=0;u<21;++u)if(cnt[j][u] - cnt[i][u]>1) return 0;
    return 1;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&x);
        for(int j=0;j<21;++j){
            if(x&(1<<j))++cnt[i][j];
            cnt[i][j] += cnt[i-1][j] ;
        }
    }
    long long ans = 0 ;
    for(int i=1;i<=n;++i){
        int st = i ,en = n ;
        while(st<en){
            int mid=(st+en+1)/2;
            if(ok(i-1,mid))st=mid;
            else en=mid-1;
        }
        ans += st - i + 1 ;
    }
    printf("%lld",ans);
    return 0 ;
}


Measured memory_bytes: 16768
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

int main(void){
    int A;
    scanf("%d",&A);

    int B;
    scanf("%d",&B);

    int ans;
    if(B==1){
        ans=0;
    }
    else if(B<=A){
        ans=1;
    }
    else{
        ans=(B-A)/(A-1)+1;
        if((B-A)%(A-1)!=0){
            ans+=1;
        }
    }

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

    return 0;
}

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

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC088_B();
        }

        static void ABC088_B()
        {
            var N = int.Parse(Console.ReadLine());
            var cards = Console.ReadLine().Split(' ').Select(int.Parse).OrderByDescending(x => x);
            var alice = new List<int>();
            var bob = new List<int>();

            foreach (var card in cards)
            {
                if (alice.Count == bob.Count)
                    alice.Add(card);
                else
                    bob.Add(card);
            }
            Console.WriteLine(alice.Sum() - bob.Sum());
        }
    }
}


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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define MOD 1000000007

const int MAX_M = 100000;


int main(){
  ll n;
  //string s;
  cin >> n;
  
  //vector<ll> a(n);
  //queue<ll> q;
  //map<string,ll> d{};
  
  
  cout << ((n == 1)? 0 : 1) << endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int A, B;
int H, M;

int main() {
    cin >> A >> B;
    cin >> H >> M;

    double degree_hour = H * 30 + M * 0.5;
    double degree_minute = M * 6;

    double x_hour = A * cos(degree_hour * M_PI / 180.0);
    double y_hour = A * sin(degree_hour * M_PI / 180.0);

    double x_minute = B * cos(degree_minute * M_PI / 180.0);
    double y_minute = B * sin(degree_minute * M_PI / 180.0);

    // cout << x_hour << " " << y_hour << '\n';
    // cout << x_minute << " " << y_minute << '\n';

    double dist = sqrt((x_hour - x_minute) * (x_hour - x_minute) + 
                       (y_hour - y_minute) * (y_hour - y_minute));
    
    // double dist = sqrt(A * A + B * B - 2 * A*B*cos((degree_hour - degree_minute) * M_PI / 180.0));
    cout << fixed << setprecision(15) << dist << '\n';

    return 0;
}

Measured memory_bytes: 4096
n,m=map(int,input().split())
a=[]
for i in range(m):
    l=list(map(int,input().split()))
    a.append(l)

p=list(map(int,input().split()))
ans=0
for s in range(2**n):#switchの組み合わせ
    s=format(s,'b')
    s=s.zfill(n)
    s=str(s)
    for j in range(m):#各電球について
        sn=0
        for k in range(1,a[j][0]+1):#点灯個数みる
            sn+=int(s[a[j][k]-1])
        if sn%2==p[j]:
            flag=True
        else:
            flag=False
            break
    if flag:
        ans+=1
        
print(ans)


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



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

    int ans = 1;

    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1])ans++;
    }

    cout << ans << endl;
}


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

int main() {
  int N,X,T;cin>>N>>X>>T;
  if(N%X==0) cout << (N/X)*T << endl;
  else cout << ((N/X)+1)*T << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007


int main() {
    int N; cin >> N;
    vector<ll> T(N);
    vector<ll> A(N);
    for(int i=0; i<N; i++)
        cin >> T[i] >> A[i];
    
    ll st = T[0];
    ll sa = A[0];
    for(int i=1; i<N; i++){
        ll k = (st+T[i]-1)/T[i];
        ll l = (sa+A[i]-1)/A[i];
        st = T[i]*max(k,l);
        sa = A[i]*max(k,l);
    }
    
    cout << st + sa << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod (ll)(1e9+7)
#define inf (ll)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define prique priority_queue
using namespace std;
typedef pair<ll,ll> P;
ll p[114514],a[114514];
signed main(){
	ll n,k,q;
	cin>>n>>k>>q;
	rep(i,q)cin>>a[i];
	rep(i,q)p[a[i]-1]++;
	rep(i,n){
		if(q-p[i]<k)puts("Yes");
		else puts("No");
	}
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
using namespace std;
 
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> v(10),l;
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        v[d]++;
    }
    for(int i=n;;i++){
        int j=i;
        bool flag=true;
        while(j>0){
            int r=j%10;
            j/=10;
            if(v[r]){
                flag=false;
                break;
            }
        }
        if(flag){
            cout<<i<<endl;
            return 0;
        }
    }
}

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

using namespace std;

int main(){
  int n;
  while(cin >> n && n){
    vector<int> a(n);
    for(int i=0;i<n;++i) cin >> a[i];
    sort(a.begin(),a.end());
    int mini=1000005;
    for(int i=0;i<n-1;++i){
      mini=min(mini,(a[i]<a[i+1])?a[i+1]-a[i]:a[i]-a[i+1]);
    }
    cout << mini <<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
const int maxn = 1e5;
int main() {
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int &i:a) {
		cin>>i;
	}
	vector<bool> dp(k+1);
	//dp is false if first player loses when there are i stones remaining
	for(int i=0;i<=k;i++) {
		for(auto it:a) {
			if(i>=it && !dp[i-it]) {
				dp[i] = 1;
			}
		}
	}
	cout<<(dp[k]==1?"First":"Second");
}



Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <map>
#include <utility>
#include <algorithm>

int main() {
    int n;
    auto ret = 0ll;
    std::string s;
    std::cin >> n >> s;
    std::string l(s.substr(0, n)), r(s.substr(n, n));
    std::reverse(r.begin(), r.end());
    std::map<std::pair<std::string, std::string>, long long> ml, mr;

    for (auto i = 0ll, limit = (1ll << n); i < limit; i++) {
        std::string sublr, sublb, subrb, subrr;
        for (auto d = 0; d < n; d++) {
            if ((1ll << d) & i) sublr += l[d], subrr += r[d];
            else sublb += l[d], subrb += r[d];
        }
        std::reverse(sublb.begin(), sublb.end());
        std::reverse(subrb.begin(), subrb.end());
        ml[std::make_pair(sublr, sublb)]++;
        mr[std::make_pair(subrr, subrb)]++;
    }

    for (auto& el : ml) {
        ret += el.second * mr[el.first];
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 103424
//C++11

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

const int MAXN = 1000;
int n;
int  num[MAXN][MAXN];
bool mat[MAXN][MAXN];

int solve(void)
{   
    int lmax=0;
    REP(i,n){ REP(j,n){
        if(i==0||j==0) num[i][j]=(mat[i][j])?1:0;
        else num[i][j]=(mat[i][j])?min(num[i-1][j-1],min(num[i-1][j],num[i][j-1]))+1:0;
        if(num[i][j]>lmax) lmax=num[i][j];
    }}
    return lmax;
}

int main(void)
{
    while(true){
        //read
        cin >> n;
        if(!n) break;
        REP(j,n){ 
            string s;
            cin >> s;
            REP(i,n) mat[i][j] = (s[i]=='.') ? true : false;
        }
        //solve and print
        int res = solve();
        cout << res << endl;
    }
    return 0;
}

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

first = []
second = []
for i in range(m):
    a = list(map(int, input().split()))
    if a[0] == 1:
        first.append(a[1])
    if a[1] == n:
        second.append(a[0])


if len(set(first) & set(second)) > 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 21820
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL N, A, B; std::cin >> N >> A >> B;
  LL D = B - A;
  if (D % 2 == 0) {
    std::cout << D/2 << std::endl;
  } else {
    std::cout << std::min(A-1LL, N-B) + 1+ (D-1)/2 << std::endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[114514]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long int ans;
    sort(a,a+n);
    if(n%2==0){
        for(int i=1;i<n;i+=2){
            if((a[i]!=a[i-1])||(a[i]!=i)){
                cout<<0<<endl;
                return 0;
            }
        }
        ans=1;
        for(int i=0;i<n/2;i++){
            ans*=2;
            if(ans>1000000007){
                ans=ans%1000000007;
            }
        }
    }else{
        for(int i=2;i<n;i+=2){
            if((a[i]!=a[i-1])||(a[i]!=i)){
                cout<<0<<endl;
                return 0;
            }
        }
        ans=1;
        for(int i=0;i<(n-1)/2;i++){
            ans*=2;
            if(ans>1000000007){
                ans=ans%1000000007;
            }
        }
    }
  cout<<ans<<endl;
}   





Measured memory_bytes: 640
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<ctime>
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<deque>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<complex>
#pragma GCC optimize ("O0")
using namespace std;
template<class T> inline T read(T&x){
    T data=0;
	int w=1;
    char ch=getchar();
    while(!isdigit(ch))
    {
		if(ch=='-')
			w=-1;
		ch=getchar();
	}
    while(isdigit(ch))
        data=10*data+ch-'0',ch=getchar();
    return x=data*w;
}
typedef long long ll;
typedef pair<int,int>pii;

const int MAXN=1e5+7;

int n;
map<ll,int>M;
queue<pii>Q;
set<int>l[MAXN];
int fa[MAXN];

int find(int x)
{
	return fa[x]==x?x:fa[x]=find(fa[x]);
}

ll getid(int x,int y)
{
	if(x>y)
		swap(x,y);
	return (ll)x*n+y;
}

void link(int x,int y)
{
	l[x].insert(y);
	l[y].insert(x);
	ll v=getid(x,y);
	++M[v];
	if(M[v]==3)
	{
		printf("NO\n");
		exit(0);
	}
	if(M[v]==2)
		Q.push(pii(x,y));
}

int main()
{
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	read(n);
	for(int i=1;i<=n;++i)
		fa[i]=i;
	for(int i=1;i<=2*n-2;++i)
	{
		int x,y;
		read(x);read(y);
		link(x,y);
	}
	for(int i=1;i<n;++i)
	{
		int x,y;
		while(1)
		{
			if(Q.empty())
			{
				printf("NO\n");
				return 0;
			}
			x=Q.front().first,y=Q.front().second;
			Q.pop();
			x=find(x),y=find(y);
			if(x!=y)
				break;
		}
		if(l[x].size()>l[y].size())
			swap(x,y);
		fa[x]=y;
		M.erase(getid(x,y));
		l[y].erase(x);
		for(auto v:l[x])
		{
			v=find(v);
			if(v==y)
				continue;
			M.erase(getid(x,v));
			link(v,y);
			l[v].erase(x);
			l[x].erase(v);
		}
	}
	printf("YES\n");
//  fclose(stdin);
//  fclose(stdout);
    return 0;
}



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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

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

const int MOD = 1e9 + 7;


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

    int n;
    cin >> n;
    vi p(n);

    rep(i, n){
        cin >> p.at(i);
    }
    
    int ans = 0;
    int x = MOD;
    rep(i, n){
        x = min(x, p.at(i));
        if(x >= p.at(i)){
            ans++;
        }
    }

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



Measured memory_bytes: 1024
s = input()

if s=="SUN":
  print(7)
elif s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
elif s == "SAT":
  print(1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100
void solve(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d)cout<<"Balanced"<<endl;
	else if(a+b>c+d) cout<<"Left"<<endl;
	else cout<<"Right"<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



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

int main()
{
  int N, K;
  int res=0;
  cin >> N >> K;

  if(N%K==0) res = 0;
  else res = 1;

  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define N  200
string s;

void process(){

}
int main(){
    _io;
	
    cin>>s;
    int sum=0;
    FOR(i,0,s.size()-1){
        sum+=s[i]-48;
    }
    if (sum%9) cout<<"No"; else cout<<"Yes";
}



Measured memory_bytes: 3736
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        x: isize,
        n: usize,
        p: [isize; n],
    }

    let mut mn = std::isize::MAX;
    let mut mnp = 0;

    let mut set = (0..102).collect::<BTreeSet<_>>();
    for e in p {
        set.remove(&e);
    }

    for e in set {
        if mn > (e - x).abs() {
            mn = (e - x).abs();
            mnp = e;
        }
    }
    println!("{}", mnp);
}


Measured memory_bytes: 2200
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int act(int num){
  num=floor((double(jo(num,2))+4.0)/8.0);
  return num;
}

int main(){
  int a;
  cin>>a;
  cout<<(a-1)/2;
}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

template<typename value_type>
class fast_combination
{
public:
	value_type mod_value;

	vector<value_type> mod_inv;
	vector<value_type> fact;
	vector<value_type> fact_inv;

public:
	fast_combination(const value_type& limit, const value_type& m)
		: mod_value(m), mod_inv(), fact(), fact_inv()
	{
		mod_inv.assign(limit + 1, 0);
		fact.assign(limit + 1, 0);
		fact_inv.assign(limit + 1, 0);

		mod_inv[1] = 1;
		fact[0] = 1;
		fact[1] = 1;
		fact_inv[0] = 1;
		fact_inv[1] = 1;

		for (value_type i = 2; i <= limit; i++)
		{
			mod_inv[i] = (mod_value - ((mod_value / i) * mod_inv[mod_value % i] % mod_value)) % mod_value;
			fact[i] = (fact[i - 1] * i) % mod_value;
			fact_inv[i] = (fact_inv[i - 1] * mod_inv[i]) % mod_value;
		}
	}

public:
	value_type process(const value_type& n, const value_type& r)
	{
		if (n < 0 || r < 0) return 0;
		if (n < r) return 0;

		return (fact[n] * (fact_inv[r] * fact_inv[n - r] % mod_value)) % mod_value;
	}
};

//fast_combination<long long> fc(N, MOD);
//int result = fc.process(n, r);

const long long MOD = 1e9 + 7;

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

	fast_combination<long long> fc(3e6, MOD);

	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	long long result = fc.process(r2 + 1 + c2 + 1, r2 + 1);
	result += (MOD - fc.process(r2 + 1 + c1, c1));
	result += (MOD - fc.process(r1 + c2 + 1, r1));
	result += fc.process(r1 + c1, r1);
	cout << result % MOD;

	return 0;
}

Measured memory_bytes: 70528
#include <iostream>
#include <stack>

using namespace std;

const int MAX_NM = 50;

bool visited[MAX_NM];
bool graph[MAX_NM][MAX_NM];

int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  int a[MAX_NM], b[MAX_NM];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) visited[i] = false;
  for (int i = 0; i < m; i++) {
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    stack<int> sta;
    sta.push(0);
    while (!sta.empty()) {
      int v = sta.top();
      sta.pop();
      visited[v] = true;
      for (int j = 0; j < n; j++) {
        if (visited[j]) continue;
        if (graph[v][j]) sta.push(j);
      }
    }
    bool tf = true;
    for (int j = 0; j < n; j++) if (!visited[j]) tf = false;
    if (!tf) ans++;

    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    for (int j = 0; j < n; j++) visited[j] = false;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256