akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    if(v <= w){
        cout << "NO" << endl;
        return 0;
    }
    ll d = v-w;
    ll k = abs(a-b);
    if(k <= d * t){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    system("pause");
}

Measured memory_bytes: 3692
if __name__ == '__main__':
    A, B = map(int, input().split())

    if A == B:
        print(A)
        exit()

    lower_4 = (A // 4 + 1) * 4
    upper_4 = (B + 1) // 4 * 4 - 1

    ans = 0
    for i in range(A, lower_4):
        ans ^= i

    for i in range(upper_4 + 1, B + 1):
        ans ^= i

    print(ans)


Measured memory_bytes: 3060
/*
  AtCoder Beginner Contest 083
  C - Multiple Gift
*/

#include<iostream>
using namespace std;

template <typename T>
T gcd(T a, T b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  while(b != 0) {
    a %= b;
    if (a == 0) return b;
    b %= a;
  }
  return a;
}

template <typename T>
T lcm(T a, T b) {
  if (a == 0 && b == 0) return 0;
  return a * b / gcd(a, b);
}

long long X, Y;

int main() {
  scanf("%lld %lld", &X, &Y);
  
  long long cnt = 1;

  // (1) A0はなるべく小さいほうがよい -> A0 = X
  // (2) A_{i+1} > A_{i} を満たす最小のA_{i}の倍数はA_{i} * 2である。
  // (3) A_{i}はA_{j} (1 <= j < i)の倍数であるから、A_{i} * 2もA_{j}の倍数である。
  // 以上から
  //    Xに何回2をかけると、Yを超えるか
  long long buf = X;
  while (1) {
    buf = buf * 2;
    if (buf > Y) break;
    cnt += 1;
  }

  printf("%lld\n", cnt);
  return 0;
}

Measured memory_bytes: 256
import math
n, m = map(int, input().split())

fact_n = math.factorial(n)
fact_m = math.factorial(m)
if abs(n - m) == 0:
  print((2 * fact_n * fact_m) % (7 + 10 ** 9))
elif abs(n - m) == 1:
  print((fact_n * fact_m) % (7 + 10 ** 9))
else:
  print(0)

Measured memory_bytes: 5320
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {

    public static void main(String[] args) {
        Thread tt = new Thread(null, new Main(), "", 256 * 1024 * 1024);
        tt.start();
    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
    	//int[] ar = new int[3];
    	//ar[0]=Integer.parseInt(sc.next());
    	//Arrays.parallelSort(ar);
		int a = Integer.parseInt(sc.next());

		//long a = Long.parseLong(sc.next());
		String s = sc.next();
		//String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//ArrayList<Str_4> lists = new ArrayList<Str_4>();
		//lists = new ArrayList;
		PrintWriter out = new PrintWriter(System.out);
		if(a < 3200)
		{
			out.println("red");
		}
		else {
			out.println(s);
		}

			
		
		out.flush();
    }
    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    ll n; cin >> n;
    rep(i,n+1){
        ll num = i * 1.08;
        if(num == n){
            out(i);
            return 0;
        }
    }
    out(":(");
}

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

if sum(A) < sum(B):
    print(-1)
else:
    P = []
    m, ans = 0, 0
    for a, b in zip(A, B):
        if a > b:
            P.append(a-b)
        elif a < b:
            m += (b-a)
            ans += 1
    P = sorted(P, reverse=True)
    if ans > 0:
        for p in P:
            m -= p
            ans += 1
            if m <= 0:
                break
    print(ans)


Measured memory_bytes: 18356
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 2e5 + 5;
 
int n, m, k, ans = 0;
int a[N], b[N];
 
int32_t main()
{
	IOS;
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		a[i] += a[i - 1];
	}
	for(int i = 1; i <= m; i++)
	{
		cin >> b[i];
		b[i] += b[i - 1];
	}
	int ans = 0;
	int idx = m;
	for(int i = 0; i <= n; i++)
	{
		if(a[i] > k)
			break;
		while(a[i] + b[idx] > k)
			idx--;
		ans = max(ans, i + idx);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6772
import scala.annotation.tailrec
import scala.io.StdIn

object Main extends App {
  
  @tailrec def loop(x: Int, y: Int): Unit = {
    if(x == 0 && y == 0) ()
    else {
      if(x <= y) println(x + " " + y)
      else println(y + " " + x)

      val a = StdIn.readLine().trim.split(' ').map(_.toInt)
      loop(a(0), a(1))
    } 
  }

  val f = StdIn.readLine().trim.split(' ').map(_.toInt)

  loop(f(0), f(1))

}


Measured memory_bytes: 46452
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		int ans = 0;
		for(int i = 1; i <= N; i++) {
			int x = sc.nextInt();
			if(x > N)
				ans += 1;
			else
				A[x] += 1;
		}
		for(int i = 1; i <= N; i++) {
			if(A[i] < i)
				ans += A[i];
			else
				ans += A[i] - i;
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 50924
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


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

Measured memory_bytes: 256
L, R = gets.split.map(&:to_i)

if R - L > 2019
  puts "0"
  exit
end
min = Float::INFINITY
L.upto(R) do |i|
  (i + 1).upto(R) do |j|
    x = (i * j) % 2019
    min = x if min > x
  end
end
puts min

Measured memory_bytes: 14312
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

long long GCD(long long a, long long b){
    if(a % b == 0){
        return b;
    }else if(b % a == 0){
        return a;
    }else{
        return GCD(b, a % b);
    }
}

int main(void){
    long long A, B;
    vector<long long> CD_AB;
    cin >> A >> B;

    long long GCD_AB = GCD(A, B);
    int sqrtGCD_AB = (int)(sqrt((long double)GCD_AB));

    for(int i=sqrtGCD_AB; i>0; i--){
        if(GCD_AB%i == 0){
            CD_AB.push_back(i);
            CD_AB.push_back(GCD_AB/i);
        }
    }
    sort(CD_AB.begin(), CD_AB.end());
    vector<long long> PCD_AB;
    bool ifprime;
    for(long long j: CD_AB){
        if(j==1)continue;
        ifprime = true;
        for(long long k: PCD_AB){
            if(j % k == 0){
                ifprime = false;
                break;
            }
        }
        if(ifprime)PCD_AB.push_back(j);
    }

    cout << 1 + PCD_AB.size() << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> Q;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		string s;
		vector<Q> d(n);
		int mlevel = -1;
		for (int i = 0; i < n; i++) {
			cin >> s;
			int cc = 0;
			for (int j = 0; j < s.size(); j++) {
				if (s[j] == '.') {
					cc++;
				} else if (0 <= s[j]-'0' && s[j]-'0' <= 9) {
					cc--;
					d[i].first = cc;
					(d[i].second).first = 0;
					(d[i].second).second = s[j]-'0';
				} else {
					d[i].first = cc;
					(d[i].second).first = 1;
					int k = 0;
					if (s[j] == '+') {
						k = 0;
					} else if (s[j] == '-') {
						k = 1;
					} else if (s[j] == '*') {
						k = 2;
					} else if (s[j] == '/') {
						k = 3;
					}
					(d[i].second).second = k;
				}
			}
			mlevel = max(mlevel, cc);
		}
		//cout << mlevel << endl;
		vector<Q> d2;
		while (true) {
			if (mlevel == -1) {
				cout << (d[0].second).second << endl;
				break;
			}
			for (int i = 0; i < d.size(); i++) {
				if (d[i].first == mlevel) {
					int kc;
					if ((d[i].second).second == 0) {
						kc = 0;
						for (int j = i+1; j < d.size(); j++) {
							if (d[j].first == mlevel && (d[j].second).first == 0) {
								//cout << j << ' ' << (d[j].second).second << endl;
								kc += (d[j].second).second;
								i++;
							} else {
								break;
							}
						}
					} else {
						kc = 1;
						for (int j = i+1; j < d.size(); j++) {
							if (d[j].first == mlevel && (d[j].second).first == 0) {
								kc *= (d[j].second).second;
								i++;
							} else {
								break;
							}
						}
					}
					//cout << mlevel << ' ' << kc << endl;
					d2.push_back(Q(mlevel-1, P(0, kc)));
				} else {
					d2.push_back(d[i]);
				}
			}
			d = d2;
			mlevel--;
			d2.clear();
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
using namespace std;
int main(){
  int a,b;
  while(cin >> a >> b&&a||b){
    int cnt=0;
    for(int i=1;i<=a;i++){
      for(int j=i+1;j<=a;j++){
	for(int k=j+1;k<=a;k++){
	  if(i+j+k==b)cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1160
A,B=map(int,input().split())

keta=0
b=B
while b:
  keta+=1
  b>>=1
  
d=[0]*keta

for i in range(keta):
  paircnt=2**(i+1)
  BpairBit=(B+1)//paircnt*(paircnt//2)
  
  rest=(B+1)%paircnt
  if rest>paircnt//2:
    BpairBit+=(rest-paircnt//2)
    
  ApairBit=A//paircnt*(paircnt//2)
  restA=A%paircnt
  if restA>paircnt//2:
    ApairBit+=(restA-paircnt//2)
    
  d[i]=(BpairBit-ApairBit)%2
  
ans=0
for i in range(len(d)):
  ans+=d[i]*(2**i)

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(){
    unsigned long long n;
    cin >> n;

    map<int,int> mp;

    const auto &res = prime_factorize(n);
    
    for (auto p : res) {
        for (int i = 0; i < p.second; ++i){
            mp[p.first]++;
        }
    }

    ll ans = 0;

    for(auto a :mp){
        int x=1;
        for(int i=a.second;i>=x;){
            ans++;
            i-=x;
            x++;
        }
    }
    cout << ans << endl;

}


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

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i=0;i<n;++i) cin >> x[i];

  int ans=1001001001;
  for (int p=1;p<=100;++p){
    int now=0;
    for (int i=0;i<n;++i){
       now+=(x[i]-p)*(x[i]-p);
    }
       ans = min(ans,now);
  }
  cout << ans << "\n";
}
//squareとか書いてるやつは自力でやってみたやつ


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut kane = 1000;
    let mut kabu = 0;
    for i in 1..=n {
        // i nichime no koto
        // mazu zennbu utte daijoubu w.l.o.g.
        kane += kabu * a[i - 1];
        kabu = 0;
        // saishuubi niha nanimo sezuni owaru
        if i == n {
            continue;
        }
        // ashita agarunara kaerudake kau
        if a[i] > a[i - 1] {
            kabu = kane / a[i - 1];
            kane = kane % a[i - 1];
        }
    }
    println!("{}", kane);
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,A, B, C;
ll i, j, k;
int main(){
    scanf("%lld%lld%lld%lld", &A, &B, &C, &N);
    if(N<=A+B){
        printf("%lld\n", min(A,N));
    }else{
        printf("%lld\n", A - (N - A - B));
    }

    return 0;
}

Measured memory_bytes: 3828
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
using namespace std;


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

	int len = (int)s.length();

	for (int i = 0; i < len; i++) {
		cout << "x";
	}
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    map<string, int> sum;
    sum["A"] = 0;
    sum["B"] = 0;
    sum["AB"] = 0;
    sum["O"] = 0;
    int n;
    char c;
    string type;
    while (cin >> n >> c >> type)
    {
        sum[type]++;
    }

    OP(sum["A"]);
    OP(sum["B"]);
    OP(sum["AB"]);
    OP(sum["O"]);
    return 0;
}


Measured memory_bytes: 3128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp69 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int W = st[0];
            int a = st[1];
            int b = st[2];

            int ans = 0;

            if (b >= a + W) {
                ans = Math.Abs(b - (a + W));
            } else if (b + W <= a) {
                ans = Math.Abs(a - (b + W));
            } else {
                ans = 0;
            }


            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
int gcd(int a, int b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
int ans = 0;
int s[10][10];
int k[10];
int p[10];
void bit(int m, int n, int d) {
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			bool w = true;
			rep(i, 0, d) {
				int x = 0;
				rep(j, 0, k[i])if (now[s[i][j] - 1] == '1')x++;
				if (x % 2 != p[i])w = false;
			}
			if (w)ans += 1;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}
;
int ketaa(ll v) {
	int x = 0;
	ll a = v;
	while (a) {
		x++;
		a /= 10;
	}
	int ans = 12 - x;
	return ans;
}
int main() {
	int n, m;
	cin >> n >> m;
	vector<llint> p(m), y(m), a[100010];
	rep(i, 0, m) {
		cin >> p[i] >> y[i];
		a[p[i] - 1].push_back(y[i]);
	}
	rep(i, 0, n)sort(a[i]);
	vector<ll> v(m);
	rep(i, 0, m) {
		auto x = lower_bound(a[p[i] - 1].begin(), a[p[i] - 1].end(), y[i]);
		v[i] = p[i] * 1000000 + 1 + (x - a[p[i] - 1].begin());
	}
	rep(i, 0, m) {
		rep(j, 0, ketaa(v[i]))cout << "0";
		cout << v[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 9344
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
    int n,s;cin>>n>>s;
    vector<int> a(n);
    rep(i,0,n) cin>>a[i];
    vector<vector<ll>> dp(n+1,vector<ll>(s+1));
    dp[0][0] = 1;
    rep(i,0,n){
        rep(j,0,s+1){
            dp[i+1][j]+=dp[i][j]*2%mod2;
            if (j-a[i]>=0){
                dp[i+1][j]+=dp[i][j-a[i]]%mod2;
            }
            dp[i+1][j]%=mod2;
        }
    }
    cout<<dp[n][s]%mod2<<endl;
}

Measured memory_bytes: 73644
from collections import deque
N = int(input())
v = list(map(int,input().split()))
v.sort()
que = deque(v)
for _ in range(N-1):
  a = que.popleft()
  b = que.popleft()
  c = (a+b)/2
  que.appendleft(c)
print(que.popleft())

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
	long long a,b,c;
	cin >> a >> b >> c;
	long long tmpp = c - a - b;
	long long tmpc = 4 * a * b;
	if(tmpp*tmpp - tmpc > 0 && tmpp > 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, d; cin >> n >> d;
    vector<vector<int>> a(n, vector<int>(d));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> a[i][j];
        }
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            long double dist = 0;
            for (int k = 0; k < d; k++) {
                dist += (a[j][k] - a[i][k]) * (a[j][k] - a[i][k]);
            }
            dist = sqrt(dist);
            if (dist == (int) dist) {
                res++;
            }
        }
    }
    cout << res << "\n";
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n){
        ll b; cin>>b;
        b--;
        a[i]=b;
    }
    ll cnt=0,tmp=0;
    while(true){
        if(tmp==1){
            cout<<cnt<<endl;
            break;
        }
        else if(cnt>=n){
            cout<<"-1"<<endl;
            break;
        }
        cnt++;
        tmp=a[tmp];
    }
    return 0;
}

Measured memory_bytes: 4060
package main

import "fmt"

func main() {
	var A,B,C,D int
	fmt.Scan(&A,&B,&C,&D)
	
	
	if A+B == C+D {
		fmt.Println("Balanced")
	} else if A+B > C+D {
		fmt.Println("Left")
	} else {
		fmt.Println("Right")
	}
}

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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

typedef long long ll;
typedef pair<ll,ll> pll;

ll X,D;
ll N,P[100];
ll V[100];
ll M[100];
ll dp[200010];
ll INF = 1001001001001001001;
int id[100];
ll rest[100];
ll MAX = 0;

vector<pair<double,int>> vec;
vector<int> G[110];

pll DFS(int v,int p)
{
    pll res = mk(1,M[v]);
    for(int i = 0; i < G[v].size(); i++)
    {
        int w = G[v][i];
        if(w == p)continue;
        pll tmp = DFS(w,v);
        res.fi += tmp.fi;
        res.se += tmp.se;
    }
    V[v] = res.fi;
    M[v] = res.se;
    vec.push_back(mk((double)res.se / (double)res.fi,v));
    return res;
}

int main()
{
    scanf("%d%lld%lld",&N,&X,&D);
    scanf("%lld",&M[1]);
    for(int i = 2; i <= N; i++)
    {
        scanf("%lld%d",M + i,P + i);
        G[P[i]].push_back(i);
    }

    DFS(1,0);

    sort(vec.begin(),vec.end());
    for(int i = 1; i <= N; i++)id[i] = vec[i - 1].se;

    for(int i = 0; i < 200000; i++)dp[i] = INF;
    dp[0] = 0;
    for(int i = 1; i <= N; i++)
    {
        for(int j = 125000; j >= 0 ; j--)
        {
            if(i == 1)
            {
                for(ll k = 0; j + k * V[i] <= 125000LL && k <= 50LL; k++)
                {
                    dp[j + k * V[i]] = min(dp[j + k * V[i]],dp[j] + k * M[i]);
                }
            }
            else
            {
                for(ll k = 0; j + k * V[i] <= 125000 && k <= min(D,50LL); k++)
                {
                    dp[j + k * V[i]] = min(dp[j + k * V[i]],dp[j] + k * M[i]);
                }
            }
        }
    }

    rest[1] = INF;
    for(int i = 2; i <= N; i++)rest[i] = max(0LL,D - 50LL);

    int now = 1;
    ll sum = 0;
    ll ans = 0;
    ll cnt = 0;
    for(ll i = 125000; i >= 0; i--)
    {
        while(now != N + 1 && X - dp[i] - sum >= M[id[now]])
        {
            if(rest[id[now]] == 0)
            {
                now++;
                continue;
            }
            cnt += V[id[now]];
            sum += M[id[now]];
            rest[id[now]]--;
        }
        if(dp[i] + sum <= X)
        {
            ans = max(ans,i + cnt);
        }
    }

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
int main(void){
    ll n;
    cin>>n;
    vector<ll> a(n+1);
    rep(i,n){
        cin>>a[i];
    }
    int c=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(abs(a[k]-a[j])<a[i]&&a[i]<a[j]+a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]){
                    c++;
                }
            }
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
int main(void)
{
  int n,m,lmax=0,rmin=100000;
  scanf("%d%d",&n,&m);
  int l[m],r[m];
  for(int i=0;i<m;i++){
    scanf("%d%d",&l[i],&r[i]);
    lmax=max(l[i],lmax);
    rmin=min(r[i],rmin);
  }
  if(rmin>=lmax){
    printf("%d",rmin-lmax+1);
  }else{
    printf("0");
  }
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, y; cin >> n >> y;
	int a = -1, b = -1, c = -1;
	FORR(i, 0, n) {
		FORR(j, 0, n) {
			int k = n - i - j;
			if (0 <= k && k <= n && 10000 * i + 5000 * j + 1000 * k == y) {
				a = i, b = j, c = k;
			}
		}
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 256
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 753数の数を再帰的に求める.
fn chk_753(n: u64, value: u64, bit753: u8, count: &mut u64) {
    if value > n { return; }
    if bit753 & 7 == 7 { *count += 1; }

    // add 7
    chk_753(n, value * 10 + 7, bit753 | 4, count);
    // add 5
    chk_753(n, value * 10 + 5, bit753 | 2, count);
    // add 3
    chk_753(n, value * 10 + 3, bit753 | 1, count);
}

fn main() {
    let n: u64 = read();
    let mut count: u64 = 0;
    chk_753(n, 0, 0, &mut count);

    println!("{}", count);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll dp[100][100];

int main(){
  cin >> s;
  if(s[0] == s[2])puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = 0;
    int result = -1;
    for (int i = 1; i <= k; i++) {
      x = x * 10 + 7;
      if (x % k == 0) {
        result = i;
        break;
      }
      x %= k;
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 35604
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main() {
  
    int h,w ;
    cin>>h>>w ;
   char ans[h+2][w+2] ;
   char a[h][w] ;

  for (int i = 0; i < h ; i++)
  {
      for (int j = 0; j < w ; j++)
      {
            cin >> a[i][j] ;
      }
  }


for (int i = 0; i < h+2 ; i++)
  {
      for (int j = 0; j < w+2 ; j++)
      {
              ans[i][j] = '#' ;
          }
      }


  for (int i = 0; i < h ; i++)
  {
      for (int j = 0; j < w ; j++)
      {
            ans[i+1][j+1] = a[i][j] ;
      }
  }

 for (int i = 0; i < h+2 ; i++)
  {
      for (int j = 0; j < w+2 ; j++)
      {
              cout <<  ans[i][j] ;
      }
      cout << endl ;
  }

return 0 ;

}

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

using namespace std;
int freq[26];
int main()
{
    string s;
    cin>>s;
    int sz =s.size();
    int cnt =0;
    int start =0;
    int end = sz-1;
    while(start<=end){
        if(s[start++]!=s[end--])cnt++;

    }
    if(cnt)
    printf("%d",cnt);
    else printf("%d",cnt);
    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 h = sc.nextInt(), w=sc.nextInt();
    String frame="";
    for(int i=1; i<=w+2; i++){
      frame +="#";
    }
    System.out.println(frame);
    for(int i=0; i<h; i++){
      String pt= sc.next();
      System.out.println("#" + pt + "#");
    }
    System.out.println(frame);
  }
}

Measured memory_bytes: 21844
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 100009
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
    	ll n,m,x,i,t,l,j,k,c=0,ans=0;
    	cin>>n;
    	c=n+(n*n)+(n*n*n);
    	cout<<c;
}




Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    String s = str[0];
    String t = str[1];
    System.out.println(t+s);
  }
}

Measured memory_bytes: 21332
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  ll n, k;
  cin >> n >> k;
  // vector<ll> v;
  // for (ll i=0;i<n+1;++i){
  //   v.push_back(i);
  // }
  const ll mod = 1e+9 + 7;
  ll _min = 0;
  ll _max = 0;
  ll ans = 0;
  rep(i, n+1){
    _min += i;
    _max += n-i;
    // cout << "min" << _min << ", " << "max" << _max << endl;
    if(k-1 <= i){
      // cout << ans << endl;
      ans += _max - _min + 1;
      ans = ans % mod;
    }
  }
  // cout << mod << endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>

int main() {
    std::string s;
    for (int i=0; i<3; ++i) {
        char tmp;
        std::cin >> tmp;
        s += tmp;
    }
    if (std::stoi(s) % 4 == 0) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }

    return 0;
}

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

vector<int> dx = { -1, 0, 0, 1 };
vector<int> dy = { 0, -1, 1, 0 };

void solve() {
	int H, W; cin >> H >> W;
	vector<string> canvas(H);
	rep(h, H) cin >> canvas[h];

	bool ok = true;
	int nx, ny;
	rep(h, H) {
		rep(w, W) {
			if (canvas[h][w] != '#') continue;
			else {
				int cnt = 0;
				rep(i, 4) {
					ny = h + dy[i];
					nx = w + dx[i];
					if (ny >= H || 0 > ny || nx >= W || 0 > nx) continue;
					if (canvas[ny][nx] != '#') {
						cnt++;
					}
					if (cnt == 4) {
						ok = false; break;
					}
				}
			}
		}
	}

	cout << (ok ? "Yes" : "No") << endl;

}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 256
/*package whatever //do not write package name here */

// Working program with FastReader 
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 

public class Main 
{ 
	static class FastReader 
	{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

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

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	} 

	public static void main(String[] args) 
	{ 
		FastReader ob=new FastReader(); 
		int h = ob.nextInt(),w=ob.nextInt();
		char c[][] = new char[h+1][w+1];
		for (int i=1;i<=h ;i++ ) {
		    String s = ob.next();
		    for (int j=1;j<w+1 ;j++ ) {
		        c[i][j]=s.charAt(j-1);
		    }
		}
		for (int i=1;i<=h*2 ;i++ ) {
		    for (int j=1 ;j<=w;j++ ) {
		        System.out.print(c[Math.min(h,(i+1)/2)][j]);
		    }
		    System.out.println();
		}
	
	} 
} 


Measured memory_bytes: 29196
#include <stdio.h>
#define N 1000

void BubbleSort(int A[],int B[], int n)
{
  int i,j,t;
  for(i=0;i<n;i++){
    for(j=n-1;i<j;j--){
      if (A[j]>A[j-1]){
        t=A[j];
        A[j]=A[j-1];
        A[j-1]=t;
        t=B[j];
        B[j]=B[j-1];
        B[j-1]=t;
      }
    }
  }
}

int main()
{
  int i=0,j,n,k;
  int num,score;
  int R[N],S[N];
  while(scanf("%d,%d",&num,&score)){
    if ((num==0) && (score==0))
      break;
    R[i]=num;
    S[i++]=score;
  }
  BubbleSort(S,R,i);
  while(scanf("%d",&n)!=EOF){
    int cnt=1;
    for (j=0;j<i;j++)
      if (R[j]==n)
        break;
    int temp=S[0];
    for (k=1;k<=j;k++)
      if (S[k]!=temp){
        temp=S[k];
        cnt++;
      }
    printf("%d\n",cnt);
  }

  return 0;
}

Measured memory_bytes: 604
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdlib>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define pb push_back

using namespace std;

const int N = 100010;

typedef long long LL;

int n;
LL val[N], up[N];
vector<int> G[N];

int deg[N];

void DFS(int o, int f){
	if(deg[o] == 1){
		up[o] = val[o];
		return;
	}
	LL mx = 0, sum = 0;
	for(int v : G[o]){
		if(v == f) continue;
		DFS(v, o);
		sum += up[v];
		mx = max(mx, up[v]);
	}
	LL x = sum - val[o];
	//printf("%d: %d %lld %lld %lld\n", o, x, sum, val[o], mx);
	up[o] = sum - 2 * x;
	if(x > sum - mx || x < 0 || up[o] < 0){
		puts("NO");
		exit(0);
	}
}

int main(){
	scanf("%d", &n);
	For(i, 1, n) scanf("%lld", &val[i]);
	For(i, 2, n){
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].pb(v), G[v].pb(u);
		++deg[u], ++deg[v];
	}
	if(n == 2){
		puts(val[1] == val[2] ? "YES" : "NO");
		return 0;
	}
	int root = 0;
	For(i, 1, n) if(deg[i] ^ 1){
		root = i;
		break;
	}
	DFS(root, 0);
	puts(up[root] ? "NO" : "YES");
	return 0;
}

Measured memory_bytes: 14336
<?php 
  fscanf(STDIN, "%d", $n);
  $monster = explode(" ", trim(fgets(STDIN)));
  $braver = explode(" ", trim(fgets(STDIN)));

  $count = 0;
  for($i = 0; $i < $n; $i++)
  {
    if($monster[$i] >= $braver[$i]) {
      $count += $braver[$i];
      continue;
    } else {
      $count += $monster[$i];
      $braver[$i] -= $monster[$i];
      
      if($monster[$i+1] >= $braver[$i]) {
        $count += $braver[$i];
        $monster[$i+1] -= $braver[$i];
      } else {
        $count += $monster[$i+1];
        $monster[$i+1] = 0;
      }
    }
  }

  echo $count;

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

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int k;
    k=c-a+b;
    if(k<0)
        k=0;
    printf("%d\n",k);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	bool is_visited = false;
} node;
typedef struct {
	int to;
	int cost;
	P <int, int> change;
} edge;

int main( void ){
	ll N; cin >> N;
	cout << N*(N-1)/2 << endl;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "E"
#define next kato
string s;
int next[200001][26];
int old[26];
int f[200001];
bool done[200001];
int F(int u){
    if(done[u]) return f[u];
    done[u]=1;
    f[u]=200002;
    FFOR(i, 0, 26){
        if(next[u][i]==0)  return f[u]=1;
        f[u]=min(f[u], F(next[u][i])+1);
    }
    return f[u];
}
string t;
void bye(){
    FFOR(i, 0, t.size()) t[i]+='a';
    cout<<t;
    exit(0);
}
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    cin>>s;
    s='0'+s;
    FFOR(i, 1, s.size()) s[i]-='a';
    DFOR(i, s.size()-2, 0){
        FFOR(j, 0, 26) next[i][j]=next[i+1][j];
        next[i][s[i+1]]=i+1;
    }
    int c=0;
    while(true){
        FFOR(i, 0, 26){
            if(next[c][i]==0){
                t+=i;
                bye();
            }
        }
        FFOR(i, 0, 26) if(F(next[c][i])+1==F(c)){
            t+=i;
            c=next[c][i];
            break;
        }
    }
}

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

const int MAX_N = 110;
int n, a[MAX_N];

void solve()
{
	int tot = 0;
	for(int i=0;i<n;++i) tot+=a[i];
	int ans = 0;
	for(int i=1;i<n;++i)if(abs(n*a[i]-tot)<abs(n*a[ans]-tot))ans=i;
	cout<<ans;
}

int main()
{
	cin >> n;
	for(int i=0;i<n;++i) cin >> a[i];
	solve();
	return 0;
}


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

#include <iostream>
#include <string>
using namespace std;

int main(int argc, char* argv[]){
        int S=0, W=0;

        cin >> S;
        cin >> W;

        if(W>=S){
                printf("unsafe\n");
        }
        else{
                printf("safe\n");
        }

        return 0;

}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const ll MAX_N = 100000;
ll n;
ll a[MAX_N], b[MAX_N];

int main(){
  cin >> n;
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];

  ll sa = 0, sb = 0;
  REP(i, n) {
    sa += a[i];
    sb += b[i];
  }
  if(sa < sb) {
    cout << -1 << endl;
    return 0;
  }

  ll d[n];
  REP(i, n) d[i] = a[i] - b[i];
  sort(d, d + n);

  ll ans = 0;
  ll i = 0;
  ll s = 0;
  while(d[i] < 0) {
    s += d[i];
    i++;
    ans++;
  }

  i = n - 1;
  while(s < 0) {
    s += d[i];
    i--;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
	string S, T;
	cin >> S;
	cin >> T;
	int len = S.length();
	int match = 0;
	for(int i = 0; i < len; i++){
		match = 0;
		for(int j = 0; j < len; j++){
			if(S[(i + j) % len] == T[j]) match++;
			else break;
		}
		if(match == len){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
bool visited[4][114514] = {false};
vector<vector<ll>> q(114514);
ll n,m,s,t;
vector<vector<ll>> edge(114514);
void dfs(ll depth, ll node, ll cnt){
  if(visited[depth][node]) return;
  visited[depth][node] = true;
  if(depth == 3){
    q[cnt+1].push_back(node);
    if(node == t){
      cout << cnt+1 << endl;
      exit(0);
    }
  }else{
    FOREACH(x, edge[node]){
      dfs(depth+1, x, cnt);
    }
  }
}

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

  REP(i, m){
    ll u, v;
    cin >> u >> v;
    u--; v--;
    edge[u].push_back(v);
  }

  cin >> s >> t;
  s--; t--;

  
  q[0].push_back(s);

  ll cnt = 0;
  while(!q[cnt].empty()){
    FOREACH(x, q[cnt]){
      // DUMP(x);
      // DUMP(cnt);
      dfs(0, x, cnt);
    }
    cnt++;
  }
  cout << -1 << endl;
}


Measured memory_bytes: 12288
#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; }

int main()
{
  ll X;
  std::cin >> X;

  std::cout << 8-(X-400)/200 << std::endl;

  return 0;
}

Measured memory_bytes: 3632
def dfs(v, visited):
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or dfs(matched[u], visited):
            matched[u] = v
            return True
    return False


xn, yn, e = map(int, input().split())
edges = [set() for _ in range(xn)]
matched = [-1] * yn

for _ in range(e):
    x, y = map(int, input().split())
    edges[x].add(y)

print(sum(dfs(s, set()) for s in range(xn)))

Measured memory_bytes: 8500
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
fast;
int a,b;cin>>a>>b;
  cout<<a*b;
return 0;
}

Measured memory_bytes: 3652