akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
		Scanner cin = new Scanner();
	  while (true)
	  {
	    int ReturnMoney = 1000 - cin.nextInt();
	    if (ReturnMoney == 1000)
	    {
	      break;
	    }
	    int[] coinInts = new[] {500, 100, 50, 10, 5, 1};
	    int ans = 0;
	    for (int i = 0; i < coinInts.Length && ReturnMoney > 0; i++)
	    {
	      ans += ReturnMoney/coinInts[i];
	      ReturnMoney %= coinInts[i];
	    }
	    Console.WriteLine(ans);
	  }
	  return 0;
	}

}

class Scanner {
	string[] s;
	int i;

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

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

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

	public int nextInt() {
		return int.Parse(next());
	}

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

	public double nextDouble() {
		return double.Parse(next());
	}

}

Measured memory_bytes: 5612
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int A,B,C,D;
    string S,T;
int main(){
    cin>>A>>B>>C;
    cout<<(A+B>=C?"Yes":"No")<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const long long NR=210000;
long long k,n,maxn,a[NR];
int main()
{
	scanf("%lld%lld",&k,&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	a[n+1]=a[1]+k;
	for(long long i=1;i<=n;i++)
	{
		if((a[i+1]-a[i])>maxn)
		{
			maxn=a[i+1]-a[i];
		}
	}
	printf("%lld",k-maxn);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(), a.end());
    long long ans = 0;
    for(int i=0;i<n-k;i++){
        ans += a[i];
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
    }

    ll ans = 0;
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());
    for (int i = 0; i < n; ++i) {
        ll upper = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll lower = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += upper * lower;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <string>
#include <random>
#include <queue>


using namespace std;

// ans = a ? b : c; // to simplify: if (a) ans = b; else ans = c;
// ans += val; // to simplify: ans = ans + val; and its variants
// index = (index + 1) % n; // index++; if (index >= n) index = 0;
// index = (index + n - 1) % n; // index--; if (index < 0) index = n - 1;
// int ans = (int)((double)d + 0.5); // for rounding to nearest integer
// ans = min(ans, new_computation); // min/max shortcut
// alternative form but not used in this book: ans <?= new_computation;
// some code use short circuit && (AND) and || (OR)

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> ii; // are aligned to the right like this
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
#define INF 1000000000
#define M_PI 3.14159265358979323846

void printVector2d(vector<vector<int>> a){
    for(int i=0;i<a.size();i++){
        for(int j=0;j<a[i].size();j++){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<"end"<<endl;
}

void printVector(vector<ll> a){
    for(int i=0;i<a.size();i++){
        cout<<"Total "<<i<<": "<<a[i]<<endl;
    }
}

void printVectorPair(vector<pair<int,int>> a){
    for(int i=0;i<a.size();i++){
        cout<<"Total "<<i<<": "<<a[i].first<<" "<<a[i].second<<endl;
    }
}

void printMap(map<char, int> mp){
    for(auto x:mp){
        cout<<x.first<<": "<<x.second<<endl;
    }
}

void printMapVec(map<int, vector<int>> mpV){
    for(auto x:mpV){
        cout<<x.first<<": ";
        for(auto y:x.second){
            cout<<y<<" ";
        }
        cout<<endl;
    }
}

void printQueue(queue<char> q){
    while(!q.empty()){
        cout<<q.front()<<" ";
        q.pop();
    }
    cout<<" ##### ";
}

void solve(){
    int n,x,t;
    cin>>n>>x>>t;
    double mult = ceil((n*1.0)/x);
    int ans = mult*t;
    cout<<ans<<endl;
}

int main() {
    //solve();
    int T;
//    cin >> T;
    T=1;
    for (int case_num = 1; case_num <= T; case_num++) {
        solve();
    }
    return 0;
}


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

using namespace std;

int N, A, B, C,minans;
vector<int> l(100,0);
vector<int> minchoice(100,0);

int dfs(int depth, vector<int> choice){

  int a = 0, b = 0, c = 0, ans = 0, countera = -1, counterb = -1, counterc = -1;

  if(depth == N-1){
    for(int i = 0; i < N; i++){
      if(choice[i] == 1) {
         a += l[i];
         countera++;
      }
      if(choice[i] == 2) {
         b += l[i];
         counterb++;
      }
      if(choice[i] == 3) {
         c += l[i];
         counterc++;
      }
    }
    if(countera < 0) countera = 0;
    if(counterb < 0) counterb = 0;
    if(counterc < 0) counterc = 0;
    ans = countera * 10 + counterb * 10 + counterc * 10 + abs(A - a) + abs(B - b) + abs(C - c);
    if(a * b * c == 0){
      return minans;
    }
    minans = min(ans,minans);
    return minans;
  }else{
    for(int i = 0; i < 4; i++){
      choice[depth + 1] = i;
      ans = dfs(depth + 1, choice);
      //minans = (ans, minans);
    }
    return minans;
  }
}

int main(){
  minans = 100000;
  N = 0;
  A = 0;
  B = 0;
  C = 0;
  int result = 0;
  cin >> N >> A >> B >> C;
  vector<int> choice(N,0);
  
  for(int i = 0; i < N; i++)cin >> l[i];
  for(int i = 0; i < 4; i++){
    choice[0] = i;
    result = dfs(0,choice);
    minans = min(result,minans);
  }
  cout << minans;
} 


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int idx = str.lastIndexOf("FESTIVAL");

        String ans = "";
        for (int i = 0; i < idx; i++) {
            ans += str.charAt(i);
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    string s,t,u;
    int64 a,b;
    
    cin>>s>>t>>a>>b>>u;

    cout<<(s==u?a-1:a)<<" "<<(t==u?b-1:b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(){
    int p[5];
    int k;
    cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> k;
    
    bool ans = false;
    
    for(int i = 1; i <= 4; i++){
        if(abs(p[0] - p[i]) <= k){
            ans = true;
        }else{
            ans = false;
            break;
        }
    }
    if(ans){
        for(int i = 2; i <= 4; i++){
            if(abs(p[1] - p[i]) <= k){
                ans = true;
            }else{
                ans = false;
                break;
            }
        }
    }
    if(ans){
        for(int i = 3; i <= 4; i++){
            if(abs(p[2] -p[i]) <= k){
                ans = true;
            }else{
                ans = false;
                break;
            }
        }
    }
    if(ans){
        for(int i = 4; i <= 4; i++){
            if(abs(p[3] - p[i]) <= k){
                ans = true;
            }else{
                ans = false;
                break;
            }
        }
    }
    if(ans){
        cout << "Yay!";
    }else{
        cout << ":(";
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll n, k;
   cin >> n >> k;
   vector<ll> a(n);
   vector<bool> flag(n);
   vector<ll> store;
   vector<ll> stock;
   for (int i = 0; i < n; i++)
   {
      cin >> a[i];
      flag[i] = false;
   }
   vector<bool> f(n);
   for (ll i = 0; i < n; i++)
   {
      f[i] = false;
   }

   flag[0] = true;
   ll next = a[0];
   ll step = 0;
   stock.pb(next);
   while (1)
   {
      if (!flag[next - 1])
      {
         flag[next - 1] = true;
         next = a[next - 1];
         stock.pb(next);
         step++;
      }
      else
      {
         ll ni = next - 1;
         store.pb(a[ni]);
         f[ni] = true;
         ni = a[ni] - 1;
         while (1)
         {
            if (!f[ni])
            {
               f[ni] = true;
               store.pb(a[ni]);
               ni = a[ni] - 1;
            }
            else
            {
               break;
            }
         }
         break;
      }
   }
   if (k <= stock.size())
   {
      cout << stock[k - 1] << endl;
   }
   else
   {
      ll num = (k - (stock.size() + 1 - store.size())) % store.size();
      cout << store[num] << endl;
   }
}

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

signed main(void)
{
	int r, g, b, n;
	int i, j;
	int cnt;
	cin >> r >> g >> b >> n;
	cnt = 0;
	i = j = 0; 
	while (r * i <= n)
	{
		j = 0;
		while (r * i + g * j <= n)
		{
			if (n - r * i - g * j < 0) continue;
			if ((n - r * i - g * j) % b == 0) cnt++;
			j++;
		}
		i++;
	}
	cout << cnt << endl;
	return 0;
}


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

const int inf = 1e9;
const ll linf = 1e18;

struct playlist { string s; int t; };

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

    int n; cin >> n;
    vector<playlist> p;
    for (int i = 0; i < n; i++) {
        string s; int t;
        cin >> s >> t;
        p.push_back({s, t});
    }
    string x; cin >> x;

    int ans = 0;
    for (auto &e: p) {
        static bool flag = false;
        if (flag) ans += e.t;
        if (x == e.s) flag = true;
    }
    cout << ans << endl;
    return 0;
}

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

#define M 1000213
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

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

int find(char str[]){
        long long key, i = 0, j;
        key = getKey(str);

        while(1){
                j = (h1(key) + i * h2(key)) % M;
                if(strcmp(H[j], str) == 0)return 1;
                else if(strlen(H[j]) == 0)return 0;
                i++;
        }
}

int insert(char str[]){
        long long key, i = 0, j;
        key = getKey(str);

        while(1){
                j = (h1(key) + i * h2(key)) % M;
                if(H[j][0] == '\0'){
                        strcpy(H[j], str);
                        break;
                }else i = i+1;
        }
        return 0;
}

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

    return 0;
}



Measured memory_bytes: 15420
# -*- coding: utf-8 -*-

N = int(input())
X, U = [], []
sm = 0.0
RATE = 380000.0

for i in range(N):
    x, u = input().split()
    if u == "JPY":
        x = int(x)
        sm += x
    elif u == "BTC":
        x = float(x)
        sm += RATE * x
    else:
        raise ValueError("")

    X.append(x)
    U.append(u)

print(sm)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

N = int(input())
K = int(input())
num_list = list(map(int, input().split()))

ans = 0
for i in range(N):
    A = num_list[i]
    B = abs(K - A)
    if A <= B:
        ans += A * 2
    else:
        ans += B * 2
print(ans)

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;


template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
  typedef Point P;
  T x, y;
  explicit Point(T x=0, T y=0) : x(x), y(y) {}
  bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
  bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
  P operator+(P p) const { return P(x+p.x, y+p.y); }
  P operator-(P p) const { return P(x-p.x, y-p.y); }
  P operator*(T d) const { return P(x*d, y*d); }
  P operator/(T d) const { return P(x/d, y/d); }
  T dot(P p) const { return x*p.x + y*p.y; }
  T cross(P p) const { return x*p.y - y*p.x; }
  T cross(P a, P b) const { return (a-*this).cross(b-*this); }
  T dist2() const { return x*x + y*y; }
  ld dist() const { return sqrt((ld)dist2()); }
  // angle to x-axis in interval [-pi, pi]
  ld angle() const { return atan2(y, x); }
  P unit() const { return *this/dist(); } // makes dist()=1
  P perp() const { return P(-y, x); } // rotates +90 degrees
  P normal() const { return perp().unit(); }
  // returns point rotated 'a' radians ccw around the origin
  P rotate(ld a) const {
    return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
  friend ostream& operator<<(ostream& os, P p) {
    return os << "(" << p.x << "," << p.y << ")"; }
};
typedef Point<ld> P;
ld ccRadius(const P& A, const P& B, const P& C) {
  return (B-A).dist()*(C-B).dist()*(A-C).dist()/
      abs((B-A).cross(C-A))/2;
}
P ccCenter(const P& A, const P& B, const P& C) {
  P b = C-A, c = B-A;
  return A + (b*c.dist2()-c*b.dist2()).perp()/b.cross(c)/2;
}

pair<P, ld> mec(vector<P> ps) {
  shuffle(all(ps), mt19937(time(0)));
  P o = ps[0];
  ld r = 0, EPS = 1 + 1e-8;
  rep(i,0,sz(ps)) if ((o - ps[i]).dist() > r * EPS) {
    o = ps[i], r = 0;
    rep(j,0,i) if ((o - ps[j]).dist() > r * EPS) {
      o = (ps[i] + ps[j]) / 2;
      r = (o - ps[i]).dist();
      rep(k,0,j) if ((o - ps[k]).dist() > r * EPS) {
        o = ccCenter(ps[i], ps[j], ps[k]);
        r = (o - ps[i]).dist();
      }
    }
  }
  return {o, r};
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  int n;
  cin >> n;

  vector<Point<ld>> p;
  rep(i,0,n) {
    ld a, b;
    cin >> a >> b;
    p.emplace_back(a, b);
  }
  cout << setprecision(10) << fixed << mec(p).snd << endl;
}

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

int64_t lucas_num(int N) {
  int64_t L0 = 2, L1 = 1, Li;
  
  if (N == 0) return L0;
  if (N == 1) return L1;
  
  for (int i = 2; i <= N; i++) {
    Li = L0 + L1;
    L0 = L1;
    L1 = Li;
  }
  return Li;
}

int main() {
  int N;
  cin >> N;
  
  cout << lucas_num(N) << endl;
}


Measured memory_bytes: 3596
N, L = map(int, input().split())
count = 0
if L < 0 and L+N-1 >= 0:
    for i in range(1, N+1):
        if L+i-1 != 0:
            count += L+i-1
elif L < 0:
    for i in range(1, N):
        if L+i-1 != 0:
            count += L+i-1            
else:
    for i in range(2, N+1):
        count += L+i-1
print(count)


Measured memory_bytes: 3060
n, m = gets.split.map(&:to_i)
path = n.times.map { Hash.new }
m.times do
  a, b = gets.split.map(&:to_i)
  path[a - 1][b - 1] = true
  path[b - 1][a - 1] = true
end
ok = false
for i in 1..(n - 2) do
  if path[0][i] && path[i][n - 1]
    ok = true
    break
  end
end
puts ok ? "POSSIBLE" : "IMPOSSIBLE"


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

int N,M;
int x,y;
int D[100005];
vector<int> grafo[100005];

int F(int k){
	if(D[k])
		return D[k];
	D[k]=1;
	for(int f:grafo[k])
		D[k]=max(D[k],F(f)+1);
	return D[k];
}

int main(){

	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>x>>y;
		x--,y--;
		grafo[x].push_back(y);
	}
	
	for(int i=0;i<N;i++)
		F(i);
	cout<<*max_element(D,D+N)-1;
}

Measured memory_bytes: 7424
using System;
using System.Linq;

class B
{
    static void Main()
    {
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var m = Math.Max(a[1] - a[0] + 1, -1000000);
        var M = Math.Min(a[1] + a[0] - 1, 1000000);
        Console.WriteLine(string.Join(" ", Enumerable.Range(m, M - m + 1)));
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll l,r;cin>>l>>r;
  r++;
  if(r-l>2019){
    cout<<0<<endl;
    return 0;
  }
  ll res=2019;
  repi(i,l,r)repi(j,i+1,r){
    chmin(res,(ll)i*j%2019);
  }
  cout<<res<<endl;
  return 0;

}


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

struct edge{
    int to;
    int from;
};
struct UnionFind{//雛形を与える(初期化と結合のみ)
    vector<int> par;//親(根)
    vector<int> rank;//木の深さ

    void init(int n){//初期化関数
        par.resize(n);
        rank.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;//初めはノード一個の木なので根は自身
            rank[i] = 1;
        }
    }

    int root(int x){//木の根を求める
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
    }

    bool same(int x, int y){//同じ木かどうか判定
        return root(x) == root(y);//同じ木ならtrue
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;//もし同じ木に属していたら何もしない
        if(rank[x] < rank[y]) swap(x, y);//数が大きい方に小さい方を結合させる
        par[y] = x;
        rank[x] += rank[y];//深さが同じ時だけ結合後深さが増える
    }

    int size(int x) {//深さを返す関数
        return rank[root(x)];
    }
};

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> r[N];
    vector<edge> G1(M);
    vector<ll> fre(N, 0);
    UnionFind U;
    U.init(N);
    for(int i = 0; i < M; i++){
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        fre[x]++;
        fre[y]++;
        U.unite(x, y);
    }
    for(int i = 0; i < K; i++){
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        r[x].push_back(y);
        r[y].push_back(x);
    }
    for(int i = 0; i < N; i++){
        ll ans = U.size(i) - fre[i] - 1;
        for(int j = 0; j < r[i].size(); j++){
            if(U.same(r[i][j], i)) ans--;
        }
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 9088
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    lint n,a;
    cin>>n>>a;
    vec x(n);
    rep(i,n)cin>>x[i];
    rep(i,n)x[i]-=a;
    mat dp(n+1,vec(5001,0));
    dp[0][2501]=1;
    repi(i,1,n+1){
        rep(j,5001){
            dp[i][j]=dp[i-1][j]+dp[i-1][j-x[i-1]];
        }
    }
    cout<<dp[n][2501]-1;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int d,g;
  cin >> d >> g;
  vector<ll> p(d),c(d);
  rep(i,d){ cin >> p[i] >> c[i]; }
  vector<ll> dp(mx,0);
  
  rep(i,d)for(int k=1000; k>=1; k--)for(int j=1; j<=p[i]&&j<=k; j++){
    dp[k]=max(dp[k], dp[k-j]+(i+1)*100*j+(j==p[i]?c[i]:0));
  }
  rep(i,1001)if(dp[i]>=g){ cout<<i<<endl; return 0;}
  
  return 0;
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define divceil(n,d) ((n)/(d) + ((n)%(d) > 0))
#define parity(a,b) (((a) & 1LL)^((b) & 1LL)^1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

int V,E,r;
vector<pair<int,int> > adj[100000];
ll dist[100000];

void solve(){
	
	fill(dist,dist + V,INF_64);
	dist[r] = 0;
	
	queue<int> que;
	que.push(r);
	
	while(!que.empty()){
		int v = que.front();
		que.pop();
		rep(i,adj[v].size()){
			pair<int,int> p = adj[v][i];
			if(dist[p.fir] < dist[v] + p.sec) continue;
			que.push(p.fir);
			dist[p.fir] = dist[v] + p.sec;
		}
	}
	
	rep(i,V){
		if(dist[i] == INF_64) cout<<"INF\n";
		else cout<<dist[i]<<endl;
	}
	
	return;
}

void input(){
	
	cin>>V>>E>>r;
	rep(i,E){
		int s,t,d;
		cin>>s>>t>>d;
		adj[s].pub({t,d});
	}
	
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	input();
	solve();
	
	return 0;
}





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

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> col(h);
  for(int i=0; i<h; ++i) cin >> col[i];
  int ans = 0;
  for(int i=0; i<(1<<h); ++i) for(int j=0; j<(1<<w); ++j){
    int cnt = 0;
    for(int m=0; m<h; ++m) for(int n=0; n<w; ++n){
      if((i>>m & 1) && (j>>n & 1) && col[m][n] == '#') ++cnt;
    }
    if(cnt == k) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint32_t a, b;
  cin >> a >> b;

  if (((a % 3) == 0) || ((b % 3) == 0) || ((a + b) % 3 == 0)) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S;
    cin >> S;
    bool a, b, c;
    a = b = c = false;
    for(int i=0; i<3; i++){
        if(S[i]=='a')a=true;
        if(S[i]=='b')b=true;
        if(S[i]=='c')c=true;
    }
    if(a&&b&&c)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    vector<int> an(n);
    rep(i,n) an[i] = i+1;
    
    int ct = 0;
    rep(i,n) {
        if (p[i] != an[i]) ct++;
        if (ct > 2) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;

}

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

if 7 <= x <= 11:
    print(2)
elif x <= 6:
    print(1)
else:
    a, b = divmod(x, 11)
    if b == 0:
        print(2*a)
    else:
        if b <= 6:
            print(2*a+1)
        else:
            print(2*a+2)

Measured memory_bytes: 9180
#!/usr/bin/env python3
import sys
import collections
import itertools

def main():
    input = sys.stdin.readline
    h, w = map(int, input().split())
    ch, cw = map(lambda x:int(x) - 1, input().split())
    dh, dw = map(lambda x:int(x) - 1, input().split())
    s = [list(input().rstrip()) for _ in range(h)]
    
    que = collections.deque()
    que.append((ch, cw))
    cost = [[float("INF")] * w for _ in range(h)]
    cost[ch][cw] = 0
    
    while que:
        py, px = que.popleft()
        for dy, dx in itertools.product(range(-2, 3), repeat = 2):
            ny, nx = py + dy, px + dx
            if 0 <= ny < h and 0 <= nx < w and s[ny][nx] == ".":
                if dy == dx == 0:
                    continue
                if (dy, dx) in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
                    if cost[ny][nx] > cost[py][px]:
                        cost[ny][nx] = cost[py][px]
                        que.appendleft((ny, nx))
                else:
                    if cost[ny][nx] > cost[py][px] + 1:
                        cost[ny][nx] = cost[py][px] + 1
                        que.append((ny, nx))
                        
    if cost[dh][dw] == float("INF"):
        print(-1)
    else:
        print(cost[dh][dw])
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 145596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	ll ai, ao, at, aj, al, as, az;
	cin >> ai >> ao >> at >> aj >> al >> as >> az;
	ll answer = 0;
	if(ai >= 1 && aj >= 1 && al >= 1){
		answer = max(answer, ao + 3 + ((ai - 1) & ~1) + ((aj - 1) & ~1) + ((al - 1) & ~1));
	}
	answer = max(answer, ao + (ai & ~1) + (aj & ~1) + (al & ~1));
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
import math
n = int(input())
half = math.floor(n**0.5)
#print(half)

num1 = 0
for i in range(half+1,0,-1):
  if n % i == 0:
    num1,num2 = i,n//i  
    #print("Yes")
    break

if num1 == 0:
  print(n-1)
else:
  print(num1+num2-2)
    

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

const int N = 2e5 + 10;

int a[N];

int main(){
	int n;
	long long ans;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
	if (a[1] != 0){
		printf("-1\n");
		return 0;
	}
	ans = 0;
	for (int i = 2; i <= n; i++){
		if (a[i] > a[i - 1] + 1){
			printf("-1\n");
			return 0;
		}
		else if (a[i] == a[i - 1] + 1) ans++;
		else ans += a[i];
	}
	printf("%lld\n",ans);
	return 0;
} 

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N; cin >> N;
  string S, T; cin >> S >> T;

  int ans = 2*N;
  for(int i=0;i<N;++i){
	if(S.substr(i) == T.substr(0,N-i))
	  ans = min(ans, N + i);
  }

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


Measured memory_bytes: 256
#include  <iostream>
#include  <string>
#include  <cstdlib>


int main(void)
{
	std::string s, t;

	std::cin >> s;
	std::cin >> t;

	int size;
	size = s.size();

	int ans = 0;
	for(int i = 0; i < size; i++)
		if(s[i] != t[i])
			ans++;

	std::cout << ans << std::endl;

	return EXIT_SUCCESS;
}


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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x, y, a, b;
  cin >> x >> y;
  if( y%2 == 1){
    cout << "No";
  }
  else{
    a = (y - 2 * x) / 2;
  	b = (4 * x - y) / 2;
  	if( a < 0 || b < 0){
      cout << "No";
    }
  	else{
      cout << "Yes";
    }
  }

  return 0;
}


Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		List<List<Integer>> list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		int[] inCnt = new int[n];
		for (int i = 0; i < n - 1 + m; i++) {
			sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]) - 1;
			int b = Integer.parseInt(sa[1]) - 1;
			list.get(a).add(b);
			inCnt[b]++;
		}
		br.close();

		int[] parent = new int[n];
		Queue<Integer> que = new ArrayDeque<>();
		for (int i = 0; i < n; i++) {
			if (inCnt[i] == 0) {
				que.add(i);
				parent[i] = -1;
			}
		}
		while (!que.isEmpty()) {
			int cur = que.poll();
			for (int i : list.get(cur)) {
				inCnt[i]--;
				if (inCnt[i] == 0) {
					que.add(i);
					parent[i] = cur;
				}
			}
		}
		for (int i : parent) {
			System.out.println(i + 1);
		}
	}
}


Measured memory_bytes: 76848
import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

target = readInt()
nums = [i for i in range(3,target+1)]

dp = [0] * (1+target)
for num in nums:
    if num <= target:
        dp[num] = 1
for i in range(target+1):
    for num in nums:
        if i - num > 0:
            dp[i] += dp[i-num]
print(dp[-1]%mod)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}


int main()
{
    fastio
    int x;
    cin >> x;
    cout << (x?0:1);
}


Measured memory_bytes: 3604
#include <string>
#include <iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i]=='+') ans++;
    if (S[i]=='-') ans--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def resolve():
    N, M = map(int, input().split())
    K = []
    A = []
    ans = 0
    for _ in range(N):
        a = list(map(int, input().split()))
        K.append(a[0])
        A.append(a[1:])
    for i in range(M):
        count = 0
        for j in range(N):
            if i+1 in A[j]:
                count += 1
        if count == N:
            ans += 1
    print(ans)
resolve()

Measured memory_bytes: 3064
import math

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

tot = sum(A)

a = 0
for i in range(N):
    if A[i] >= math.ceil(tot / (4 * M)):
        a += 1

if a >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,k;
  cin>>a>>b>>k;
  rep(i,k)
  {
    b+=a/2;
    a/=2;
    swap(a,b);
  }
  if(k&1)swap(a,b);
  cout<<a<<" "<<b<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
typedef unsigned int uint;
inline static uint gl(void){
    uint x = 0;
    for(;;){
        const uint c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            return x;
        }
    }
}

int main(void){
    const size_t n = gl();
    for(size_t i=0; i<n; i++){
        if(gl()%2==1){
            puts("first");
            return 0;
        }
    }
    puts("second");
    return 0;
}


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

int main(){
  int i;
  int j;
  int change = 0;
  int num = 0;
  int count = 0;
  int min = 0;
  int *data;

scanf("%d",&num);
data = (int *)malloc(sizeof(int)*num);

for(j = 0;j < num;j++){
  scanf("%d",&data[j]);
}

for(i = 0;i < num - 1;i++){
  min = i;
  for(j = i;j < num;j++){
    if(data[j] < data[min]){
      min = j;
    }

  }
  if(i != min){
    change = data[i];
    data[i] = data[min];
    data[min] = change;
    count++;
  }
}

for(i = 0;i < num-1;i++){
  printf("%d ",data[i]);
}
printf("%d",data[num - 1]);
printf("\n");
printf("%d",count);
printf("\n");
return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
	int n, x, sum;
	cin >> n;
	vector<int> l;
	for(int i=0; i<n; i++){
		cin >> x;
		l.push_back(x);
	}
	sort(l.begin(), l.end());
	sum = accumulate(l.begin(), l.end()-1, 0);
	cout << (sum>l[n-1] ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();//n＋1回飛ぶ
        int x = sc.nextInt();//座標
        int[] L = new int[n];
        int sum = 0;
        int cnt = 0;
        int ans = 1;

        for(int i = 0;i < n;i++){
            L[i] = sc.nextInt();
        }
        for(int i = 0;i < n;i++){
            cnt += L[i];
            if(cnt <= x)
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)
	sum := 0
	for i := 0; i < k; i++ {
		sum += p[i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1892
import bisect
N = int(input())
guide_dic = {}
num_i_dic = {}
for _ in range(N):
    S,P = input().split()
    num_i_dic[int(P)] = _+1
    try:
        bisect.insort(guide_dic[S],int(P))
    except KeyError:
        guide_dic[S] = []
        bisect.insort(guide_dic[S],int(P))

for name,score in sorted(guide_dic.items()):
    for _ in score[::-1]:
        print(num_i_dic[_])


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;


int main(void){
  int n,d;
  vector<int> c;
  
  cin >> n;
  
  d=6;
  while (d<=n){
    c.push_back(d);
    d*=6;
  }
  
  d=9;
  while (d<=n){
    c.push_back(d);
    d*=9;
  }
  
  c.push_back(1);
  
  int i,j,dp[100005];
  dp[0]=0;
  for (i=1;i<=n;i++){
    dp[i]=1e9;
    for (j=0;j<c.size();j++){
      if (c[j]<=i) dp[i]=min(dp[i],dp[i-c[j]]+1);
    }
  }
  
  cout << dp[n] << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
using ll=long long;
int main(){
  ll x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  ll straight=min(k,x/d);
  k-=straight;
  x-=straight*d;
  if(k%2==0){
    cout<<x<<endl;
  }
  else{
    cout<<d-x<<endl;
  }
  return 0;
}


Measured memory_bytes: 3616
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long x = long.Parse(input[0]);
		long y = long.Parse(input[1]);
    long answer = Math.Abs(Math.Abs(x)-Math.Abs(y));

    if(x<y && y<=0 || 0<=x && x<y) answer += 0;
    else if(y<x && x<0 || 0<y && y<x) answer += 2;
    else answer += 1;

		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

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

using namespace std; 

long long gcd(long long a,long long b)
{
	return b != 0 ? gcd(b, a % b) : a;
}

int main(void)
{
	long long n,xs;
	cin >> n >> xs;
	long long x[100005];
	x[0]=xs;
	for(int i=1;i<=n;i++)
		cin >> x[i];
	
	sort(x,x+n+1);

	long long ans=x[1]-x[0];

	for(int i=1;i<=n;i++)
	{
		ans=gcd(ans,x[i]-x[i-1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
typedef long long ll;
const int maxn = 1e5 + 7;
using namespace std;
inline ll read()
{
    char c = getchar(); ll x = 0, f = 1;
    while(c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
    return x*f;
}
ll N, A[maxn], B[maxn], C[maxn], ans1 = 0,dp1[maxn],dp2[maxn];
int p1,p2;
int main()
{
    N = read();
    for(ll i = 0; i < N; ++i) A[i] = read();sort(A,A+N);
    for(ll i = 0; i < N; ++i) B[i] = read();sort(B,B+N);
    for(ll i = 0; i < N; ++i) C[i] = read();sort(C,C+N);
    for(ll i = 0; i < N; ++i)
    {
        ll x = B[i]; p1 = N;
        p1 = lower_bound(A,A+N,x)-A;
        dp1[i] = p1;
    }
    for(ll i = 0; i < N; ++i)
    {
        ll x = B[i]; p1 = N;
        p1 = upper_bound(C,C+N,x)-C;
        dp2[i] = N-p1;
    }
    for(int i = 0; i<N; ++i) ans1 += dp1[i]*dp2[i];
    cout << ans1 << endl;
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,r;
    cin>>n>>m>>r;
    ll x[r],a,b,c;
    ll d[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)d[i][j]=0;
            else d[i][j]=1e9;
        }
    }
    for(int i=0;i<r;i++){
        cin>>x[i];
        x[i]--;
    }
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        a--;b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    ll sum=0,ans;
    for(int i=1;i<r;i++){
        sum+=d[x[i]][x[i-1]];
    }
    ans=sum;
    vector<int> v;
    for(int i=0;i<r;i++)v.pb(i);
    while(next_permutation(be(v))){
        sum=0;
        for(int i=1;i<r;i++){
            sum+=d[x[v[i]]][x[v[i-1]]];
        }
        ans=min(ans,sum);
    }
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 640
H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]

n_black = 0
for m in M:
  for n in m:
    if n == '#':
      n_black += 1

si, sj = 0, 0
gi, gj = H - 1, W - 1

queue = []
distance = [[-1 for _ in range(W)] for _ in range(H)]
queue.append((si, sj))
distance[si][sj] = 0

while queue:
  i, j = queue.pop(0)
  if i == gi and j == gj:
    print(H * W - 1 - n_black - distance[i][j])
    exit()
  for i_, j_ in [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]:
    if i_ >= 0 and i_ < H and j_ >= 0 and j_ < W:
      if distance[i_][j_] == -1 and M[i_][j_] == '.':
        distance[i_][j_] = distance[i][j] + 1
        queue.append((i_, j_))
        
print(-1)

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

typedef struct {
  double x, y;
} Point;

void print(Point p){ printf("%.8f %.8f\n", p.x, p.y); }

void plot(int n, Point p1, Point p2){
  Point s, t, u;
  double th = 60.0*(acos(-1)/180.0);
  if ( n == 0 ) return;
  
  s.x = (2.0 * p1.x + 1.0 * p2.x)/3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y ) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y ) * cos(th) + s.y;
  
  plot(n-1, p1, s);
  print(s);
  plot(n-1, s, u);
  print(u);
  plot(n-1, u, t);
  print(t);
  plot(n-1, t, p2);
}

main(){

  Point p1, p2;
  int n;
  scanf("%d", &n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  print(p1);
  plot(n, p1, p2);
  print(p2);

  return 0;
}



Measured memory_bytes: 2056
n = int(input())
city_backup = list(map(int, input().split()))
player = list(map(int, input().split()))
ans = 0
start_sum, end_sum = 0, 0
city = city_backup
for i in city:start_sum+=i
for i in range(n):
    #0 4 2
    if player[i]>city[i]:
        city[i+1] -= player[i] - city_backup[i]
        if city[i+1] < 0:
            city[i+1] = 0
        city[i] = 0
    else:city[i] -= player[i]
for i in city:end_sum+=i
print(start_sum-end_sum)

Measured memory_bytes: 82148
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
 
void Main() {
  int n;
  R n;
  int ans=0;
  rep(i,n) {
    int l,r;
    cin >> l >> r;
    ans+=r-l+1;
  }
  pr(ans);
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 256
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	S := sc.s()
	T := sc.s()

	if strings.HasPrefix(T, S) {
		fmt.Fprintln(wr, "Yes")
	} else {
		fmt.Fprintln(wr, "No")
	}

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n;
    cin >> n;
    if(n% 10 == 2 || n% 10 == 4 || n% 10 == 5 || n% 10 == 7 || n% 10 == 9)
        cout << "hon" << endl;
        else if(n% 10 == 0 || n% 10 ==  1 || n% 10 == 6 || n% 10 == 8)
        cout << "pon" << endl;
        else
        {
            cout << "bon" << endl;
        }
        
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

int N, A, B;

int main()
{
	while(scanf("%d %d %d", &N, &A, &B) != EOF)
	{
		int x = B - A - 1;
		if(x & 1) printf("Alice\n");
		else printf("Borys\n");
	}
	return 0;
}

Measured memory_bytes: 128
A, B, C, X, Y = map(int, input().split())
minXY = min(X, Y)
if A + B >= 2 * C:#C2枚を買う方が良い
  ans = 2 * C *minXY
  X, Y = X - minXY, Y - minXY
  if X == 0:
    if B > 2 * C:
      ans += 2 * C * Y
    else:
      ans += B * Y
  else:# Y == 0
    if A > 2 * C:
      ans += 2 * C * X
    else:
      ans += A * X
else:#それぞれの方が安い
  ans = A * X + B * Y
  
print(ans)

Measured memory_bytes: 38384