akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;
ll dp[100100];
 
int main() {
     int n;
     cin >> n;
     int ans = 0;
     vector<int> a(n),b(n),c(n-1);
     rep(i,n)cin>>a[i];
     rep(i,n) a[i]--;
     rep(i,n) cin>> b[i];
     rep(i,n-1) cin >> c[i];
     rep(i,n) ans +=b[i];
     rep(i,n-1){
         if(a[i+1]==a[i]+1) ans +=c[a[i]];
     }
     cout << ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
 
const ll inf = 1LL << 60;

struct Maze{
    int H,W;
    vector<string> S;

    Maze(){
        cin >> H >> W;
        S.resize(H);
        REP(i,H){
            cin >> S[i];
        }
    }

    int cal_max(P s,vector<string> maze){
        vector<vector<int> > seen(H,vector<int>(W,-1));
        queue<P> que;
        if(maze[s.first][s.second] == '#'){
            return -1;
        }
        que.push(s);
        seen[s.first][s.second] = 0;
        int res = 0;
        while(!que.empty()){
            P now = que.front();
            //seen[now.first][now.second] = true;
            que.pop();
            REP(i,4){
                int nx = now.first + dx[i];
                int ny = now.second + dy[i];
                if(0 <= nx && nx < H && 0<=ny && ny < W && maze[nx][ny] == '.' && seen[nx][ny] == -1){
                    seen[nx][ny] = seen[now.first][now.second] + 1;
                    res = max(res,seen[nx][ny]);
                    que.push(P(nx,ny));
                }
            }
        }
        return res;
    }

    int solve(){
        int ans = 0;
        REP(i,H){
            REP(k,W){
                int now = cal_max(P(i,k), S);
                ans = max(ans,now);
            }
        }
        return ans;
    }

};

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    Maze maze;
    cout << maze.solve() << endl;

}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(0, B + C - A) << endl;
    return 0;
}

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

multiset<int> ms;
int fl[100005];

int main() {
  int x,n;
  scanf("%d%d",&x,&n);
  for(int i=0;i<n;i++) scanf("%d",fl+i);
  fl[n] = 1e9+7;
  int q,i=0,pt=0,lb=0, lv=0, rb=x, rv=x;
  bool up=false;
  scanf("%d",&q);
  while(q--) {
    int t,a;
    scanf("%d%d",&t,&a);
    while(pt<t) {
      if(fl[i] > t) {
        int v = (up?1:-1)*(t-pt);
        lv += v;
        rv += v;
        pt = t;
      } else {
        int v = (up?1:-1)*(fl[i]-pt);
        up = !up;
        pt = fl[i++];
        lv += v;
        rv += v;
      }
      if(rv > x) {
        rb -= rv-x;
        rv = x;
        if(lv > x) {
          lb = rb;
          lv = x;

        }
      }
      if(lv < 0) {
        lb -= lv;
        lv = 0;
        if(rv < 0) {
          rb = lb;
          rv = 0;
        }
      }
      if(lb<0) lb = 0;
      if(lb>x) lb = x;
      if(rb<0) rb = 0;
      if(rb>x) rb = x;
    }
    if(a <= lb) printf("%d\n",lv);
    else if(a >= rb) printf("%d\n",rv);
    else printf("%d\n",lv + (a-lb));
  }
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

int main()
{
  int N,k;
  cin >> N;
  for(int i=1;i<=10000;i++){
    if(2*N == i*(i+1)){
      k = i;
      break;
    }
    if(i == 10000){
      cout << "No" << endl;
      return 0;
    }
  }
  vector<vector<int> >G(k+1,vector<int>(0));
  int cn=1;
  REP(i,k){
    for(int j=i+1;j<k+1;j++){
      G[i].push_back(cn);
      G[j].push_back(cn);
      cn++;
    }
  }
  cout << "Yes" << endl;
  cout << k+1 << endl;
  REP(i,k+1){
    cout << k << " ";
    REP(j,G[i].size())
      cout << G[i][j] << " ";
    cout << endl;
  }
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

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

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 2304
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

const int MOD = 1e9+7;

signed main() {
	std::string s;
	std::cin >> s;
	std::vector<int> d(4,0);
	std::vector<int> p(4,0);
	d[0] = 1;
	for(auto c:s) {
		rep(i,4) {
			if(c=='?') {
				p[i] = d[i]*3;
				p[i] %= MOD;
			}
			else p[i] = d[i];
		}
		if(c=='A' || c=='?') p[1] = (p[1] + d[0])%MOD;
		if(c=='B' || c=='?') p[2] = (p[2] + d[1])%MOD;
		if(c=='C' || c=='?') p[3] = (p[3] + d[2])%MOD;
		std::swap(d,p);
	}
	print(d[3]);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

int main(){
    double a,b,x; cin >> a >> b >> x;
    double v=a*a*b;
    double lin,sha;
    if(v>=x*2){
        lin=lin=x*2/(a*b);
        sha=sqrt((b*b)+(lin*lin));
    }
    else{
        lin=(b-(x/(a*a)))*2;
        sha=sqrt((a*a)+(lin*lin));
        lin=a;
    }
    printf("%.20lf",acos(lin/sha)*(180/PI));
return 0;
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int N;
void in(){
    cin >> N;
}

void solve(){
    
    rep(h,1,3501){
        rep(n,1,3501){
            int numerator = (4 * h * n - N * n - N * h);
            int denominator = (N * h * n);
            if(numerator == 0) continue;
            if(denominator % numerator == 0 && denominator / numerator > 0){
                cout << h << " " << n << " " << (N * h * n) / (4 * h * n - N * n - N * h) << endl;
                exit(0);
            }
        }
    }


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include<algorithm>
#include<string.h>
#include<cmath>
#include <vector>
#include<set>
using namespace std;
int main()
{
    if("ab">"b")cout<<"???"<<endl;
    string x;int k;
    cin>>x;scanf("%d",&k);
    int l=x.length();
    set<string> s;
    for(int i=0;i<l;i++)
    {
        string p=x.substr(i,1);
        s.insert(p);
    }
    for(int i=0;i<l-1;i++)
    {
        string p=x.substr(i,2);
        s.insert(p);
    }
    for(int i=0;i<l-2;i++)
    {
        string p=x.substr(i,3);
        s.insert(p);
    }
    for(int i=0;i<l-3;i++)
    {
        string p=x.substr(i,4);
        s.insert(p);
    }
    for(int i=0;i<l-4;i++)
    {
        string p=x.substr(i,5);
        s.insert(p);
    }

    set<string>::iterator ite1 = s.begin();
    for(int i=0;i<k-1;i++){


        ite1++;
    }
cout<<*ite1<<endl;
}


Measured memory_bytes: 1664
N,M,C=map(int,input().split())
B=[int(i) for i in input().split()]
ans=0
for i in range(N):
    A=[int(i) for i in input().split()]
    tmp=C
    for j in range(M):
        tmp+=A[j]*B[j]
    if tmp>0:
        ans+=1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long double ld;
int w,h,x,y;
bool flag;
db ans;
int main(){
	scanf("%d%d%d%d",&w,&h,&x,&y);
	flag=x*2==w&&y*2==h;
	ans=(db)w*(db)h/2;
	printf("%.6f %d\n",ans,flag);
	return 0;
}

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

int main(){
  int a[4],i;
  for(i=0;i<3;i++){
    cin >> a[i];
  }
  sort(a,a+3);
  for(i=0;i<3;i++){
    cout << a[i];
    if(i<2){
      cout << " ";
    }
  }
  cout << '\n';
  return 0;
}
  



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    ll ans=0;
    if(a<b){
        swap(a,b);
    }
    ans += a;
    a--;
    if(a<b){
        swap(a,b);
    }
    ans += a;
    a--;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
s = list(input())
ans = 1
cE = s.count("E")
cW = s.count("W")
cS = s.count("S")
cN = s.count("N")
if cE >=1:
    if cW == 0:
        ans = 0
if cW >=1:
    if cE == 0:
        ans = 0
if cN >=1:
    if cS == 0:
        ans = 0
if cS >=1:
    if cN == 0:
        ans = 0
if ans == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] numOfDivisor = new int[n + 1];
    for (int i = 1; i <= n; i++) {
      for (int k = i; k <= n; k += i) {
        numOfDivisor[k]++;
      }
    }
    long ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += (long) i * numOfDivisor[i];
    }
    pw.println(ans);
  }
}


Measured memory_bytes: 74796
package main

import (
	"fmt"
)

func main() {
	var n, y int
	fmt.Scan(&n, &y)
	y /= 1000
	for i := 0; i <= n; i++ {
		for j := 0; j <= n-i; j++ {
			k := n - i - j
			if i*10+j*5+k == y {
				fmt.Println(i, j, k)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
import java.util.*

data class Edge(val from: Int, val to: Int)

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val graph = Array(3 * n, { mutableListOf<Edge>() })
    repeat(m) {
        val (v1Raw, v2Raw) = readLine()!!.split(" ").map { it.toInt() }
        val v1 = v1Raw - 1
        val v2 = v2Raw - 1
        graph[v1].add(Edge(v1, n + v2))
        graph[n + v1].add(Edge(n + v1, 2 * n + v2))
        graph[2 * n + v1].add(Edge(2 * n + v1, v2))
    }
    val (sRaw, tRaw) = readLine()!!.split(" ").map { it.toInt() }
    val s = sRaw - 1
    val t = tRaw - 1

    val queue = ArrayDeque<Int>()
    val visited = BooleanArray(3 * n)
    val dists = IntArray(3 * n, { -1 })
    queue.offerLast(s)
    dists[s] = 0
    visited[s] = true
    while (queue.isNotEmpty()) {
        val v = queue.pollFirst()
        for (e in graph[v]) {
            val u = e.to
            if (visited[u]) continue
            dists[u] = dists[v] + 1
            visited[u] = true
            queue.offerLast(u)
        }
    }

    if (dists[t] == -1) {
        println(-1)
    } else {
        println(dists[t] / 3)
    }
}

Measured memory_bytes: 118508
// Author: pankaj_m05 
// Problem: C 
// Created: 04.06.2020 19:32:30

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define f_in(file) freopen(file, "r", stdin)
#define f_out(file) freopen(file, "w", stdout)
#define sz(a) int((a).size())
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) c.begin(), c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())  // Set and Maps
#define cpresent(c,x) (find(allc,x) != c.end()) // Vectors
using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef long long ll;

const int mod = 1e9 + 7;

int main(void) { 
	fast
	ll a;
	double b;
	cin >> a >> b;
	ll B = b * 100 + 0.5;
	cout << a * B / 100 << '\n';
	return 0;
}                                          

Measured memory_bytes: 3716
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Data.IntMap as IntMap
import Control.Monad

type Weight = Int
type Tree = IntMap.IntMap [(Int,Weight)]

insert' :: Int -> a -> IntMap.IntMap [a] -> IntMap.IntMap [a]
insert' !k v = IntMap.alter (\m -> Just (v : fromMaybe [] m)) k

main = do
  n <- readLn
  edges <- U.replicateM (n-1) $ do
    [u,v,w] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (u-1, v-1, w)
  let tree :: Tree
      tree = U.foldl' (\m (u,v,w) -> insert' u (v,w) $ insert' v (u,w) m) IntMap.empty edges
  let result = U.create $ do
        vec <- UM.replicate n (-1)
        -- white: 0, black: 1
        let dfs !i !color = do
              x <- UM.read vec i
              if x == -1
                then do UM.write vec i color
                        let Just t = IntMap.lookup i tree
                        forM_ t $ \(j,w) -> do
                          dfs j ((color + w) `rem` 2)
                else return ()
        dfs 0 0
        return vec
  U.mapM_ print result


Measured memory_bytes: 54780
#include<stdio.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;


P Q[LEN+1];
int head, tail, n;



void enqueue(P x){
  Q[tail]=x;
  if(tail == n+1){
    tail=0;
  }else{
    tail++;
  }
}



P dequeue(){
  P x;
  x=Q[head];
  if(head==n+1){
    head=0;
  }else{
    head++;
  }
  return x;
}



int main(){
  int tsum = 0, c;
  int i,q;
  P u;

  
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    
    if(u.t<q) c=u.t;
    else c=q;

    u.t = u.t-c;
    tsum = tsum + c;

    if(u.t>0) enqueue(u);
    else printf("%s %d\n",u.name,tsum);	
  }
  return 0;
}



Measured memory_bytes: 6812
#include <bits/stdc++.h>
#define NMAX 100010
#define MMAX 200010

using namespace std;

struct Link
{
    int l, r, d, gr;

    int other(int x) const
    {
        return x == l ? r : l;
    }
} v[MMAX];

int vizgr[NMAX];
int t[NMAX];
int arepos[NMAX];
int pos[NMAX];
vector<int> g[NMAX];

int tata(int n)
{
    if(t[n] == n)
        return n;
    int r = tata(t[n]);
    t[n] = r;
    return r;
}

int main() {
    //freopen("in.in", "r", stdin);
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        t[i] = i;
    for(int i = 0; i < m; i++)
    {
        cin >> v[i].l >> v[i].r >> v[i].d;

        g[v[i].l].push_back(i);
        g[v[i].r].push_back(i);

        int tl = tata(v[i].l);
        int tr = tata(v[i].r);
        t[tl] = tr;
    }
    queue<int> q;
    for(int i = 0; i < m; i++) {
        v[i].gr = tata(v[i].l);
        if(vizgr[v[i].gr] == 0) {
            vizgr[v[i].gr] = 1;

            arepos[v[i].l] = 1;
            pos[v[i].l] = 0;
            q.push(v[i].l);
        }
    }
    while(!q.empty())
    {
        int nod = q.front();
        q.pop();

        for(int vecid : g[nod])
        {
            if(arepos[v[vecid].other(nod)] == 1)
            {
                if(pos[v[vecid].r] - pos[v[vecid].l] != v[vecid].d)
                {
                    cout << "No";
                    return 0;
                }
            }
            else
            {
                arepos[v[vecid].other(nod)] = 1;
                if(v[vecid].l == nod)
                {
                    pos[v[vecid].r] = pos[nod] + v[vecid].d;
                }
                else
                {
                    pos[v[vecid].l] = pos[nod] - v[vecid].d;
                }
                q.push(v[vecid].other(nod));
            }
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> x(8);
vector<int> y(8);
vector<bool> visit(8,false);
void dfs(int count,int prex,int prey,double length);
double sum=0;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    for(int i=0;i<n;i++){
        visit[i]=true;
        dfs(0,x[i],y[i],0);
        visit[i]=false;
    }
    int div=1;
    for(int i=n;i>=1;i--){
        div*=i;
    }
    printf("%.10lf\n",sum/(div*1.0));
    return 0;
}
void dfs(int count,int prex,int prey,double length){
    if(count==n-1){
        sum+=length;
        return;
    }else{
        for(int i=0;i<n;i++){
            if(!visit[i]){
                visit[i]=true;
                dfs(count+1,x[i],y[i],length+sqrt(pow(x[i]-prex,2)+pow(y[i]-prey,2)));
                visit[i]=false;
            }
        }
    }
}


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

int main() {
  int n, d;
  cin >> n;
  cin >> d;
  if (n % (2*d+1) > 0) {
    cout << n / (2*d+1) + 1;
  }
  else {
    cout << n / (2*d+1);
  }    
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int x;
	int i;
	int j;
	int r;
	int c;
	int temp[200][200]={0};
	scanf("%d %d",&r,&c);
	for(j=0;j<r;j++){
		for(i=0;i<c;i++){
			scanf("%d",&x);
			temp[i][j]+=x;
		}
	}
	for(j=0;j<r;j++){
		for(i=0;i<c;i++){
			temp[c][j]+=temp[i][j];
		}
	}
	for(i=0;i<=c;i++){
		for(j=0;j<r;j++){
			temp[i][r]+=temp[i][j];
		}
	}
	for(j=0;j<=r;j++){
		for(i=0;i<=c;i++){
			printf("%d", temp[i][j]);
			if(i!=c) printf(" ");                                     
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>
 
using namespace std;

#define ll long long
#define ulli  unsigned ll int
#define sl(n) scanf("%lld", &n)
#define sl2(a,b) scanf("%lld%lld", &a,&b)
#define sl3(a,b,c) scanf("%lld%lld%lld", &a,&b,&c)
#define VI  vector<int>
#define Vll  vector<ll>
#define all(v)  v.begin(),v.end()
#define ub(v,x)  upper_bound(all(v),x)

int st(int x,int pos){  return x= x |(1<<pos);}
int  Reset(int x,int pos ){ return x= x &~(1<<pos);}

#define  si(n) scanf("%d", &n)
#define  si2(a,b) scanf("%d%d", &a,&b)
#define  si3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define  sf(n) scanf("%lf", &n)
#define  pii pair <int, int>
#define  pll pair <ll, ll>
#define  plp pair <int, pll >
#define  pb push_back
#define  mkpr  make_pair
#define  ff   first
#define  ss  second
#define  srt(V)  sort(V.begin(),V.end());
#define  rsrt(V)  sort(V.rbegin(),V.rend());
#define  nl printf("\n");   
#define  PI  2*acos(0.0);
#define  INFP ((ll)1<<62)
#define  INFN (0-(ll)1<<62)
#define  loop(a,b)  for(int g=a;g<=b;g++)
#define  for1(n)  for(int i=0;i<n;i++)
#define  for2(n)  for(int j=0;j<n;j++)
#define  for3(n)  for(int k=0;k<n;k++)
#define  for4(n)  for(int l=0;l<n;l++)
#define  fr(i,a,b) for(int i=a;i<=b;i++)
#define  bug1(a)  cout<<a<<endl;
#define  bug2(a,b)  cout<<a<<" "<<b<<endl;
#define  bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
#define  bug4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define  tst(n)  for(int cs=1;cs<=n;cs++)
#define  spc <<" "<<
#define  pys puts("YES");
#define  pno  puts("NO");
#define  bug puts("bug");
#define  pmn puts("-1");
#define  zero puts("0");
#define  limit 200006
#define  md 1000000007
#define  sq(n)  n*n





typedef pair<ll,ll> iPair;


int main()
{
/* 
               
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);*/

       double n;

       cin>>n;

       double ans=(double)(n/3)*(double)(n/3)*(double)n/3;

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





    

 

        /**
       *    @author     : Ikbal Hossain
       *    @University  : RUET CSE 15
       *    @CodeForces : iAmrifat
       *    @UVA        : rifat_ikbal
       *    @facebook   : https://www.facebook.com/ikbal.rifat.5
       */
 
      /* ll dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
      /* ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
      /* ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
      /* ll dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction
 
}
 
 
 


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define Nmax 9
using namespace std;
bool graph[Nmax][Nmax];
bool visited[Nmax];
int dfs(int v,int N){
	bool all_visited = true;
	for(int i=1;i<=N;i++){
		if(visited[i]==false)all_visited=false;
	}
	if(all_visited)return 1;
	int ret = 0;
	for(int i=1;i<=N;i++){
		if(graph[v][i]==true && visited[i]==false){
			visited[i]=true;
			ret +=dfs(i,N);
			visited[i]=false;
		}
	}
	return ret;
}
int main(void){
	int N,M,ans;
	cin >> N >> M;
	for(int i=1;i<=M;i++){
		int A,B;
		cin >> A >> B;
		graph[A][B]=graph[B][A]=true;
	}
	visited[1] = true;
	ans = dfs(1,N);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(){

  for(int n,t,l,b;cin>>n>>t>>l>>b,n;){
    int a[200]={};
    double dp[200][200]={1};
    for(int i=0,t1;i<l&&cin>>t1;i++) a[t1]=1;
    for(int i=0,t1;i<b&&cin>>t1;i++) a[t1]=2;
    for(int i=0;i<t;i++){
      for(int j=0;j<n;j++){
	for(int k=1;k<=6;k++){
	  int t1=j+k;
	  if(t1>n) t1=n-(t1-n);
	  if(a[t1]==2) dp[i+1][0]+=dp[i][j]/6;
	  else if(a[t1]==1) dp[i+2][t1]+=dp[i][j]/6;
	  else dp[i+1][t1]+=dp[i][j]/6;
	}
      }
    }
    double r=0;
    for(int i=0;i<t+1;i++) r+=dp[i][n];
    cout<<fixed<<setprecision(10)<<r<<endl;
  }
  return 0;

}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,s;cin>>k>>s;
	int ct=0;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			int temp = s - (i + j);
			if(temp<=k and temp >= 0){
				ct++;
				// cout<<i<<" "<<j<<" "<<temp<<endl;
			}
		}
	}
	cout<<ct<<endl;
}

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

struct P{
    int y;
    int x;
    int z;
    P(int a, int b, int c){
        y=a;
        x=b;
        z=c;
    }
};

int h,w,k,d[800][800],v=1e9,dy[4]={0, 1, 0, -1},dx[4]={1, 0, -1, 0};
string a[800];

int main(void){
    cin>>h>>w>>k;
    for(int i=0;i<h;i++){
        cin>>a[i];
        fill(d[i], d[i]+w, 1e9);
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='S'){
                queue<P> q;
                q.push(P(i,j,0));
                while(!q.empty()){
                    P p=q.front();
                    q.pop();
                    if(p.z<d[p.y][p.x]&&p.z<=k){
                        v=min(v,min(min(p.y, h-1-p.y), min(p.x, w-1-p.x)));

                        d[p.y][p.x]=p.z;
                        for(int i=0;i<4;i++){
                            int ny=p.y+dy[i],nx=p.x+dx[i];
                            if(ny>=0&&ny<h&&nx>=0&&nx<w){
                                if(a[ny][nx]=='.')q.push(P(ny,nx,p.z+1));
                            }
                        }
                    }
                }
                int ans = (v+k-1)/k+1;
                //cout<<v<<endl;
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  int n;
  cin >> n;
  // // map<string, int> words;
  // vector<int> nums;
  // // int m = 1; 
  // for(int i=0; i<n; ++i){
  //   cin >> nums[i];
  // }
  if (n % 2 == 0) {
    cout << n / 2 << endl;
  } else {
    cout << n / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  cout << n*(n+1)/2 << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 1e5+5;

vector <ll> cnt(L);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N, Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    ll cur = 0;
    for(ll i=0; i<(ll)S.size(); i++)
    {
        if(S[i]=='A' && S[i+1]=='C')
        {
            cnt[i] = cur;
            cur++;
            i++;
            cnt[i] = cur;
        }

        else
        {
            cnt[i] = cur;
        }

        // cout << cnt[i] << " at i=" << i << endl;
    }

    while(Q--)
    {
        ll l, r;
        cin >> l >> r;
        l--;
        r--;
        cout << cnt[r]-cnt[l] << endl; 
    }

    return 0;
}

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

using namespace std;

const int MaxN = 2e5 + 25;
const int MOD = 1e9 + 7;

void make(vector <long long> & v)
{
    map<long long, int> mp;
    for(long long x : v)
        mp[x];

    int cur = 0;

    for(map<long long, int>:: iterator it = mp.begin(); it != mp.end(); ++it)
        it -> second = ++cur;

    for(long long & x : v)
        x = mp[x];
}

int main()
{
//    freopen("input.txt", "r", stdin);

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    vector <long long> v;

    long long n, a, b;
    cin >> n >> a >> b;

    if(a + b - 1 > n || a * b < n)
    {
       cout << -1 << '\n';
       return 0;
    }

    long long k = n - (a + b - 1);

    for(long long i = a * b - a + 1; i <= a * b; ++i)
        v.push_back(i);

    long long B = b - 1;

    while(k)
    {
        v.push_back((B - 1) * a + 1);

        long long p = min(k, a - 1);

        k -= p;

        for(int i = 2; i <= a && p; ++i, --p)
            v.push_back((B - 1) * a + i);

        --B;
    }

    while(B)
    {
        v.push_back((B - 1) * a + 1);
        --B;
    }

    make(v);

    for(int i = 0; i < v.size(); ++i)
        cout << v[i] << ' ';
    cout << '\n';

    return 0;
}


Measured memory_bytes: 24044
#include <bits/stdc++.h>
#define  ref(i,n) for(int i=0;i<n;i++)
typedef long double ll;
typedef long long lll;

using namespace std;
ll a,b;


int main()
{

    cin>>a>>b;

    cout<<lll(a*b);

    return 0;
    }




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

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

  vector<pair<int, int>> AB(N);
  for(int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    AB[i] = make_pair(a, b);
  }

  int zero_mask = 0;
  long long ans = 0;
  for(int i = 29; i >= 0; i--){
    if(((K >> i) & 1) == 0){
      zero_mask |= (1 << i);
    }else{
      zero_mask |= (1 << i);
      long long ans_tmp = 0;
      for(int j = 0; j < N; j++){
        if((AB[j].first & zero_mask) == 0){
          ans_tmp += AB[j].second;
        }
      }
      ans = max(ans, ans_tmp);
      zero_mask ^= (1 << i);
    }
  }

  long long ans_tmp = 0;
  for(int i = 0; i < N; i++){
    if((AB[i].first & zero_mask) == 0){
      ans_tmp += AB[i].second;
    }
  }
  ans = max(ans, ans_tmp);

  cout << ans << endl;
}


Measured memory_bytes: 1152
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<Integer>();
		for(int i=0; i<10; i++) {
			list.add(Integer.parseInt(sc.nextLine()));
		}
		Collections.sort(list, new Comparator<Integer>() {
			@Override
			public int compare(Integer first, Integer second) {
				int f = first;
				int s = second;
				return s-f;
			}
		});
		for(int i=0; i<3; i++) {
			System.out.println(list.get(i));
		}
	}
}

Measured memory_bytes: 26024
import numpy as np
from numba import jit


@jit("i8, i8, i8[:]", nopython=True)
def myfunc(n, k, A):
    for _ in range(k):
        l = np.zeros((n + 1,), dtype=np.int64)
        for i, a in enumerate(A[:-1]):
            l[max(0, i - a)] += 1
            l[min(n, i + a + 1)] -= 1
        A = np.cumsum(l)
        if np.all(A[:-1] == n):
            break
    return A


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    A = np.append(A, 0)
    print(*myfunc(n, k, A)[:-1])


if __name__ == "__main__":
    main()

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

int n,K;

int main()
{
    int i,x,g = 0,mx = 0;
    
    scanf("%d%d",&n,&K);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(x > mx) mx = x;
        if(g == 0) g = x;
        else g = __gcd(g,x);
    }
    
    if(K > mx || K % g) printf("IMPOSSIBLE");
    else printf("POSSIBLE");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int Q;
int TYPE;
int A;
int B;
int main(){
  int Lj4PdHRW, i, j, k;
  long long res1, res2, sum=0, sum1=0, sum2=0;
  multiset<int> s1;
  multiset<int> s2;
  multiset<int>::iterator it;
  multiset<int>::iterator jt;
  rd(Q);
  for(Lj4PdHRW=0;Lj4PdHRW<Q;Lj4PdHRW++){
    rd(TYPE);
    if(TYPE==1){
      rd(A);
      rd(B);
      s1.insert(A);
      sum1 += A;
      sum += B;
    }
    else{
      while(s1.size() > s2.size()+1){
        it = s1.end();
        it--;
        i = *it;
        sum1 -= *it;
        sum2 += *it;
        s2.insert(*it);
        s1.erase(it);
      }
      while(s1.size() && s2.size()){
        it = s1.end();
        it--;
        jt = s2.begin();
        if(*it > *jt){
          i = *it;
          j = *jt;
          s1.erase(it);
          s2.erase(jt);
          s1.insert(j);
          s2.insert(i);
          sum1 += j - i;
          sum2 += i - j;
        }
        else{
          break;
        }
      }
      it = s1.end();
      it--;
      res1 = *it;
      res2 = sum;
      res2 += res1 * s1.size() - sum1;
      res2 += sum2 - res1 * s2.size();
      wt_L(res1);
      wt_L(' ');
      wt_L(res2);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190309-1 [beta]

// --- original code ---
// int Q, TYPE, A, B;
// {
//   int i, j, k;
//   multiset<int> s1;
//   multiset<int> s2;
//   multiset<int>::iterator it;
//   multiset<int>::iterator jt;
// 
//   ll sum1 = 0, sum2 = 0;
//   ll sum = 0, res1, res2;
//   rd(Q);
//   
//   rep(Q){
//     rd(TYPE);
//     if(TYPE==1){
//       rd(A,B);
//       s1.insert(A);
//       sum1 += A;
//       sum += B;
//     } else {
//       while(s1.size() > s2.size()+1){
//         it = s1.end();
//         it--;
//         i = *it;
//         sum1 -= *it;
//         sum2 += *it;
//         s2.insert(*it);
//         s1.erase(it);
//       }
//       while(s1.size() && s2.size()){
//         it = s1.end();
//         it--;
//         jt = s2.begin();
//         if(*it > *jt){
//           i = *it;
//           j = *jt;
//           s1.erase(it);
//           s2.erase(jt);
//           s1.insert(j);
//           s2.insert(i);
//           sum1 += j - i;
//           sum2 += i - j;
//         } else {
//           break;
//         }
//       }
// 
//       it = s1.end();
//       it--;
//       res1 = *it;
//       res2 = sum;
//       res2 += res1 * s1.size() - sum1;
//       res2 += sum2 - res1 * s2.size();
//       wt(res1, res2);
//     }
//   }
// }


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


int main(void) {
    using namespace std;

    long n, m, d;
    cin >> n >> m >> d;

    if(d > n-1) {
        cout << 0 << endl;
        return 0;
    }

    long k = n - d;
    double a = 1.0*(d==0?1:2)*k*(m-1);

    printf("%.16f\n", a / pow(1.0*n, 2.0));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb  push_back
using namespace std;
 
typedef pair<int,int>  PII;
int n,a[2010],e[2010][2010],vis[2010];
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
vector <int> solve(int x)
{
	int m=0;
	vector <vector <int> > V;
	vector <vector <int> ::iterator> h;
	vector <int> r;
	vis[x]=1;
	for (int y=1; y<=n; y++)
		if ((e[x][y])&&(!vis[y]))
			V.pb(solve(y)),h.pb(V[m].begin()),m++;
	r.pb(a[x]);
	while (1)
		{
			int x=-1;
			for (int i=0; i<m; i++)
				if ((h[i]!=V[i].end())&&((x<0)||(*h[i]>*h[x])))
					x=i;
			if (x<0)  return r;
			r.pb(*h[x]),h[x]++;			
		}
}
 
void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)  scanf("%d",&a[i]),e[0][i]=1;
	sort(a+1,a+n+1);
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++)
			if (gcd(a[i],a[j])!=1)
				e[i][j]=e[j][i]=1;
	vector <int> ans=solve(0);
	for (int i=1; i<=n; i++)  printf("%d ",ans[i]);
}
 
int main()
{
	work();
	return 0;
}

Measured memory_bytes: 16384
#include<stdio.h>

int main(){
	int n,ab[100][2],cd[100][2],i,j,ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d%d",&ab[i][0],&ab[i][1]);
	for(i=0;i<n;i++)scanf("%d%d",&cd[i][0],&cd[i][1]);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(ab[i][1]>ab[j][1]){
				int a=ab[i][0],b=ab[i][1];
				ab[i][0]=ab[j][0];
				ab[i][1]=ab[j][1];
				ab[j][0]=a;
				ab[j][1]=b;
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(cd[i][0]<cd[j][0]){
				int a=cd[i][0],b=cd[i][1];
				cd[i][0]=cd[j][0];
				cd[i][1]=cd[j][1];
				cd[j][0]=a;
				cd[j][1]=b;
			}
		}
	}
	int memo[100]={0};
//	for(i=0;i<n;i++)printf("%d\n",cd[i][0]);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(memo[j]==0&&cd[i][0]>=ab[j][0]&&cd[i][1]>=ab[j][1]){
				ans++;
				memo[j]=1;
				break;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int l, i, al[120] = {};
  char s[2048] ={};
  while(scanf("%s", s) != EOF){
     l = strlen(s);
    for(i = 0;i < l;i++) if('A' <= s[i] && 'Z' >= s[i]) s[i] += 'a' - 'A';
    for(i = 0;i < l;i++) if('a' <= s[i] && s[i] <= 'z') al[s[i] - 'a']++;
  }
  for(i = 0;i < 26;i++)
    printf("%c : %d\n", i + 'a', al[i]);
  return 0;
}



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

using namespace std;

int main(){
    int n;
    cin>>n;
    int dp[n+1][3];
    int a,b,c;
    cin>>a>>b>>c;
    dp[1][0] = a;
    dp[1][1] = b;
    dp[1][2] = c;
    for (int i=2; i<=n; i++){
        cin>>a>>b>>c;
        dp[i][0] = a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n][0], max(dp[n][1], dp[n][2]));
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int flag = Integer.parseInt(sc.next());
        if(flag == 1){
            System.out.println("Hello World");
        }else{
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            sc.close();
            System.out.println(a + b);
        }
    }
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion


int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n, p;

    while (true) {
        cin >> n >> p;
        if (!n && !p) break;
        
        vector<int> hand(n);
        int bowl = p;

        for (int i = 0; ; i = (i + 1) % n) {
            if (bowl) hand[i]++, bowl--;
            else bowl += hand[i], hand[i] = 0;
            if (hand[i] == p) {
                cout << i << endl;
                break;
            }
        }
    }
}


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

using namespace std;

const int N = 5050;

int a[N], n, k;
bool dl[N][N], dr[N][N];

int main() {
  memset(dl, 0, sizeof dl);
  memset(dr, 0, sizeof dr);
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++)
    scanf("%d", a+i);
  dl[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) if (dl[i][j]) {
      dl[i+1][j] = 1;
      if (j + a[i] < k)
        dl[i+1][j+a[i]] = 1;
    }
  }
  dr[n-1][0] = 1;
  for (int i = n-1; i > 0; i--) {
    for (int j = 0; j < k; j++) if (dr[i][j]) {
      dr[i-1][j] = 1;
      if (j + a[i] < k)
        dr[i-1][j+a[i]] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int it = k-1;
    bool ok = 1;
    for (int j = 0; j < k; j++) if (dl[i][j]) {
      it = min(it, k-1-j);
      while (it >= 0 && !dr[i][it]) it--;
      if (it >= 0 && it + j < k && it + j + a[i] >= k) {
        ok = 0;
        break;
      }
    }
    ans += ok;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 50176
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<climits>
#include<ctime>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

int main(){
    srand((unsigned)time(NULL));
    int N;
    scanf("%d",&N);
    char a[16][16];
    rep(i,N)scanf("%s",a[i]);

    int hand=rand()%N;
    rep(i,1000){
        printf("%d\n",hand+1);fflush(stdout);
        int ai_hand;scanf("%d",&ai_hand);ai_hand--;
        if(a[hand][ai_hand]=='x')hand=rand()%N;
    }
}

Measured memory_bytes: 1328
#include<iostream>

int main(){

    size_t h, n;
    std::cin >> h >> n;

    size_t sum = 0;

    for(size_t i = 0; i < n; i++){
        size_t a;
        std::cin >> a;
        sum += a;
    }

    std::cout << (sum >= h ? "Yes" : "No") << std::endl;

    return 0;
}


Measured memory_bytes: 384
n, y = map(int, input().split())
for i in range(n+1):
  for j in range(n+1):
    if 10000*n - 5000*i - 9000*j == y and n-i-j>=0:
      print(n-i-j, i, j)
      quit()
print(-1,-1,-1)


Measured memory_bytes: 3064
str = gets.chomp.split("")

n = str.count("N")
s = str.count("S")
e = str.count("E")
w = str.count("W")

if ((n >= 1) and (s == 0)) or ((s >= 1) and (n == 0)) or ((e >= 1) and (w == 0)) or ((w >= 1) and (e == 0))
    puts "No"
else 
    puts "Yes"
end 


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    int n;
    cin >> n;
    vector<double> x(n);
    vector<string> u(n);
    rep(i, n) {
        cin >> x[i] >> u[i];
    }
    double ans = 0;
    rep(i, n) {
        if(u[i] == "BTC") {
            ans += x[i]*380000.0;
        }
        else {
            ans += x[i];
        }
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 256
a,b,c,x,y = map(int, input().split())

if 2*c >= a+b: 
    print(a*x + b*y) # buy separately
else:
    if max(x,y) == x:
        if a <= 2*c:  print((x-y)*a + y*2*c)
        else:         print(x*2*c)
            
    else: # max(x,y) == y
        if b <= 2*c:  print((y-x)*b + x*2*c)
        else:         print(y*2*c)

Measured memory_bytes: 3060