akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

/*ai>xとなる最小のi*/
ll upper_bound(ll n, ll a[n], ll l, ll r, ll x){
    while(r-l>1){
        ll p=(l+r)/2;
        if(a[p]<=x) l=p;
        else r=p;
    }
    return a[l]>x?l:a[r]>x?r:n;
}

/*ai<xとなる最大のi*/
ll lower_bound(ll n, ll a[n], ll l, ll r, ll x){
    while(r-l>1){
        ll p=(l+r)/2;
        if(a[p]<x) l=p;
        else r=p;
    }
    return a[r]<x?r:a[l]<x?l:-1;
}


int main(void){
    // char ;
    ll n,q;
    scanf("%lld%lld",&n,&q);
    ll a,b,p[q],x[q],plus[n],point[n],com[2*n-2];
    ll par[200000]={};
    rep(i,0,n-1){
        scanf("%lld%lld",&a,&b);
        com[2*i]=(a-1)*POW(10,6)+b-1;
        com[2*i+1]=(b-1)*POW(10,6)+a-1;
    }
    rep(i,0,q){
        scanf("%lld%lld",&p[i],&x[i]);
    }
    rep(i,0,n) plus[i]=0;
    rep(i,0,q) plus[p[i]-1]+=x[i];
    point[0]=plus[0];

    sortup(com,2*n-2);
    par[0]=0;

    ll que[200005];
    rep(i,0,200005) que[i]=-1;
    ll head=0,tail=0;
    que[head]=0;


    while(que[head]!=-1){
        ll piv=que[head];
        // printf("%lld ",piv);
        ll r = lower_bound(2*n-2,com,0,2*n-3,(piv+1)*POW(10,6)) , l = upper_bound(2*n-2,com,0,2*n-3,piv*POW(10,6)-1) ;

        // printf("%lld %lld\n",l,r);

        rep(i,l,r+1){
            ll tag=com[i]%POW(10,6);
            // printf("%lld    ",com[i]);
            if(tag==par[piv]) continue;
            par[tag]=piv;
            plus[tag]+=plus[piv];
            point[tag]=plus[tag];
            tail++;
            que[tail]=tag;
        }
        head++;
    }
    
    rep(i,0,n){
        printf("%lld ",point[i]);
    }
    printf("\n");
    return 0;
}


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

using namespace std;

long long comb(int n, int r)
{
	long long c = 1;
	for(int i = n; i > n - r ; --i)
		c *= i;
	for(int i = 1; i <= r; ++i)
		c /= i;
	return c;
}

long long fact9(int n)
{
	long long fact = 1;
	while(n--)
		fact *= 9;
	return fact;
}

long long AEZ9(int digits, int k)
{
	if(k > digits) return 0;
	return comb(digits, k) * fact9(k);
}

long long AEZ(string S, int k)
{
	if(k == 0) return 1;
	
	long long s = S[0] - '0';
	int len = S.length();
	if(len == 1)
		if(k == 1) return s;
		else return 0;
	
	if(s == 0)
		return AEZ(S.substr(1), k);
	
	return AEZ(S.substr(1), k - 1) + AEZ9(len - 1, k - 1) * (s - 1) + AEZ9(len - 1, k);
}

int main()
{
	string S;
	int k;
	
	cin >> S >> k;
	
	cout << AEZ(S, k);
}


Measured memory_bytes: 256
#
# abc057 a
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """9 12"""
        output = """21"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """19 0"""
        output = """19"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """23 2"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    A, B = map(int, input().split())
    print((A+B) % 24)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16200
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main();
    }

    public Main() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Pair> list = new ArrayList<Pair>();
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            list.add(new Pair(a, b));
        }
        Collections.sort(list);
        int ans = 0;
        int x = 0;
        for (int i = 0; i < list.size(); i++) {
            Pair p = list.get(i);
            //System.out.println(">>>"+p.a+","+p.b);
            if (p.a >= x) {
                x = p.b;
                ans++;
            }
        }
        System.out.println(ans);
    }

    class Pair implements Comparable<Pair> {
        int a;
        int b;
        public Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        @Override
        public int compareTo(Pair p) {
            return this.b - p.b;
        }
    }
}


Measured memory_bytes: 61708
#include<bits/stdc++.h>
using namespace std;
long long aa;bool bb;char ch;
long long scan()
{
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	ch=='-'?(bb=1,aa=0):(bb=0,aa=ch-48);
	while(ch=getchar(),(ch>='0'&&ch<='9'))
		aa=aa*10+ch-48;
	return (bb?(-aa):(aa));
} 
//用树状数组求逆序数  
long long Length;
struct Node  
{  
    long long data;  
    long long pos;  
};  
Node seq[200010];  
long long TreeArray[200010]; 

long long LowBit(long long num)  
{  
    return num&(num^(num-1));  
}  
long long cmp(Node num1,Node num2)  
{  
	if(num2.data==num1.data)
		return num1.pos<num2.pos;
    return num1.data>num2.data;  
}  
long long sum(long long pos)  
{  
    long long result=0;  
    while (pos)  
    {  
        result+=TreeArray[pos];  
        pos-=LowBit(pos);  
    }  
    return result;  
}  
void INC(long long pos)  
{  
    while(pos<=Length)  
    {  
        TreeArray[pos]++;  
        pos+=LowBit(pos);  
    }  
}  
void insertNum(long long &reverseNum)  
{  
    for (long long i=1;i<=Length;i++)  
    {  
        reverseNum+=sum(seq[i].pos); 
        //cout<<i<<" "<<seq[i].data<<"\t"<<seq[i].pos<<"\t"<<reverseNum<<endl;
        INC(seq[i].pos);   
    }  
}  
long long n,k;
long long arr[200010];
int main()  
{  
	scanf("%lld%lld",&n,&k);
	Length=n+1;
	for(int i=1;i<=n;++i)
		arr[i]=scan()-k;
	for(int i=2;i<=n;++i)
		arr[i]=arr[i-1]+arr[i]; 
	seq[1].data=0;
	seq[1].pos=1;
    for(int i=1;i<=n;i++)  
    {  
        seq[i+1].data=-arr[i];  
    	
        seq[i+1].pos=i+1; 
    }  
    
    //从大到小排序
    sort(seq+1,seq+Length+1,cmp);
    
    //for(int i=1;i<=Length;i++)  
	//	cout<<seq[i].data<<" "<<seq[i].pos<<endl;
	//cout<<endl;
    long long reverseNum=0;  
    insertNum(reverseNum); 
    cout<<reverseNum<<endl;
    return 0;  
}  


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
//#include<math.h>
#include <unordered_map>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++)
    {
        cin>>h[n-1-i];
    }
    string ans="Yes";
    int temp;
    for(int i=1;i<n;i++)
    {
        if(h[i]-1>h[i-1])
        {
            ans="No";
            break;
        }
        else
        {
            if(h[i]-1==h[i-1])
            {
                h[i]--;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, Chan;
    scan(N, Chan);
    auto S = new long[](N);
    auto T = new long[](N);
    auto C = new long[](N);
    foreach (i; 0 .. N)
        scan(S[i], T[i], C[i]);
    zip(C, S, T).sort();
    auto used = new long[][](30, 2 * 10 ^^ 5 + 2);
    foreach (i; 0 .. N)
    {
        used[C[i] - 1][S[i] * 2 - 1] = 1;
        used[C[i] - 1][T[i] * 2] = -1;
    }
    foreach (i; 0 .. Chan)
        foreach (j; 0 .. 2 * 10 ^^ 5)
        {
            used[i][j + 1] += used[i][j];
        }
    long ans;
    foreach (i; 1 .. 2 * 10 ^^ 5 + 1)
    {
        long cnt1;
        foreach (j; 0 .. Chan)
            if (used[j][i] != 0)
                cnt1++;
        ans = ans.max(cnt1);
    }
    writeln(ans);
}


Measured memory_bytes: 53244
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << "\n";
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    vector<vector<ll>> graph(n);
    vector<ll> in(n);
    for(int i = 0; i < n-1+m; i++) {
        ll a,b;cin >> a >> b;
        a--;b--;
        graph[a].emplace_back(b);
        in[b]++;
    }
    ll root = -1;
    rep(i,0,n)if(in[i] == 0)root = i;
    vector<ll> par(n);
    par[root] = 0;
    queue<ll> que;
    que.emplace(root);
    while(!que.empty()){
        ll t = que.front();que.pop();
        for(auto &to : graph[t]){
            in[to]--;
            if(!in[to]){
                par[to] = t+1;
                que.emplace(to);
            }
        }
    }

    print(par);
}

Measured memory_bytes: 10296
n = int(input())

a = list(map(int, input().split()))
ans = [0] * (max(a) + 2)

for i in a:
  ans[i] += 1
  ans[i + 1] += 1
  if i - 1 >= 0:
    ans[i - 1] += 1
print(max(ans))

Measured memory_bytes: 20728
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7

void solve(){
	lli n; cin>>n; vl v(n); fore(i,0,n)cin>>v[i];
	lli mx=v[0];
	lli sum=0;
	fore(i,1,n){
		mx = max(mx,v[i]);
		sum+=mx-v[i];
	}
	cout<<sum<<ENDL;
}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<bool> pressed(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int now = 1;
  for (int i = 0; i < n; i++) {
    if (now == 2) {
      cout << i << endl;
      return 0;
    }
    pressed[now-1] = true;
    now = a[now-1];
    
    if (pressed[now-1]) {
      cout << -1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, 0, n) cin >> p[i];
    vector<int> flag;
    int ans = 0;
    for(int i = 0; i < n;) {
        int tmp;
        if(p[i] == i+1) {
            ans++;
            tmp = p[i+1];
            p[i+1] = p[i];
            p[i] = tmp;
            i+=2;
        }
        else i++;
    }
    if(p[n-1] == n) {
        ans++;
    }   
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
a,b,c = map(int,input().split())
if a%2==0 or b%2==0 or c%2==0:
    print(0)
else:
    if a==max(a,b,c):
        print(b*c)
    elif b==max(a,b,c):
        print(a*c)
    else:
        print(a*b)

Measured memory_bytes: 3060
n = int(input())
max_n = 100000
dp = [10000 for i in range(max_n+1)]
dp[0] = 0

for i in range(n+1):
  k = 1
  while k <= n:
    dp[i] = min(dp[i],dp[i-k]+1)
    k *=6
  k = 1
  while k <= n:
    dp[i] = min(dp[i],dp[i-k]+1)
    k*=9
print(dp[n])

Measured memory_bytes: 3992
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	n=II()
	A=[II() for _ in range(5)]
	print(5+(n-1)//min(A))









if __name__ == "__main__":
	main()


Measured memory_bytes: 27092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string o, e; cin >> o >> e;
  rep(i, e.size()) cout << o[i] << e[i];
  if(o.size() != e.size()) cout << o.back();
  cout << endk;
  return 0;
}


Measured memory_bytes: 3612
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    DMP(a);
    
    int ans = INF;
    for(int i = 0; i < N; i++){
    	
        int tmp = 0;
        while(a[i]){
        DMP(a[i],!(ans&1));
        	if(!(a[i]&1)) tmp++;
            else break;
        	a[i] >>= 1;
        }
        ans = min(ans, tmp);
    }
    
    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
in_ = [int(i) for i in input().split()]
L = in_[0]
R = in_[1]
mod_min = 100000
# L = L % 2019
# R = R % 2019
# tab = [[-1 for r in range(R+1)] for l in range(L+1)]
# print(tab)
i_list = []
j_list = []
for i in range(L, R):
    i_mod = i % 2019
    for j in range(i+1, R+1):
            j_mod = j % 2019
            mod = i_mod * j_mod % 2019
            if mod < mod_min:
                mod_min = mod
                if mod_min == 0:
                    break
    if mod_min == 0:
        break
print(mod_min)

Measured memory_bytes: 3064
N, M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
graph = {i:set() for i in range(1,N+1)}
for _ in range(M):
    a,b = [int(i) for i in input().split()]
    graph[a].add(b)
    graph[b].add(a)

c = 0
good = [-1]*N
for i in range(1,N+1):
    if good[i-1] == -1:
        h = H[i-1]
        for j in graph[i]:
            if h > H[j-1]:
                good[j-1] = 0
            else:
                good[i-1] = 0
                break
        else:
            good[i-1] = 1
            c += 1
# print(good)
print(c)

Measured memory_bytes: 53788
import math
from math import cos,pi,sqrt,radians

A, B, H, M = map(float, input().split())

m_theta = (M/60.0)*2*pi
h_theta = 1/12.0*(H + M/60.0) * 2* pi
mh_theta = abs(m_theta - h_theta)

x = A**2 + B**2 - 2*A*B*cos(mh_theta)
x = sqrt(x)
print(x)


Measured memory_bytes: 9412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	vector<string> s(3);
	rep(i, 3) {
		cin >> s.at(i);
	}
	string ans;
	rep(i, 3) {
		ans += s.at(i).at(0);
	}
	transform(ans.begin(), ans.end(),ans.begin(), ::toupper);
	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
x = gets.split.map(&:to_i)
pmin, pmax = x.minmax

dist = Hash.new(0)
pmin.upto(pmax) do |p|
  dist[p] = x.inject(0) do |sum, xi|
    sum + ((xi - p)**2)
  end
end

puts dist.values.min


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

int factorTwo(int n) {
    int cnt = 0;
    while (n % 2 == 0) {
        n /= 2;
        cnt++;
    }
    return cnt;
}

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

    int cnt = 0;
    rep(i, N) {
        int A;
        cin >> A;
        cnt += factorTwo(A);
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 1<<18;
int n, a[N][2];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, 1<<n) cin >> a[i][0];
  FOR(j, 0, n)FOR(i, 0, 1<<n)if(i&1<<j){
    int k = i^1<<j;
    maxs(a[i][1], a[i][0] + a[k][0]);
    maxs(a[i][0], a[k][0]);
  }
  int ans = 0;
  FOR(i, 1, 1<<n){
    maxs(ans, a[i][1]);
    printf("%d\n", ans);
  }
  return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 1010;


int main()
{
    string a, b, c;
    cin >> a >> b >> c;

    char now = 'a';
    int i = 0, j = 0, k = 0;
    while(true)
    {
        if(now == 'a') now = a[i++];
        else if(now == 'b') now = b[j++];
        else if(now == 'c') now = c[k++];

        if(i == a.size() && now == 'a')
        {
            puts("A");
            return 0;
        }
        else if(j == b.size() && now == 'b')
        {
            puts("B");
            return 0;
        }
        else if(k == c.size() && now == 'c')
        {
            puts("C");
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
int main(){
 double l;cin>>l;
 cout<<setprecision(7)<<(l/3)*(l/3)*(l/3)<<endl;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
using namespace std;
#define len(n) (int)n.length()
#define dump cout
#define pb push_back
#define ll long long

bool binarySearch(ll t, ll* s, ll n)
{
	ll left = 0;
	ll right = n;
	
	while(left < right)
	{
		ll mid = (left +right) / 2;
		if (s[mid] == t)
			return true;
		if (s[mid] > t)
		{
			right = mid;
		}
		else
		{
			left = mid + 1;
		}
	}
	return false;
}
int main()
{
	ios::sync_with_stdio(false);
		
	ll s[100000] = {0};
	ll t[50000] = {0};
	ll n,q;
	cin >> n;
	for (int i = 0; i < n; i++) {
	    cin >> s[i];
	}
	ll ans = 0;
	cin >> q;
	for (int i = 0; i < q; i++) {
		ll t;
		cin >> t;
	    if (binarySearch(t, s, n))
			ans++;
	}
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 3896
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int n;int x[58],y[58];
double sq(double d){
	return d*d;
}
double d(double X,double Y){
	double ret=0.0;
	rep(i,n){
		ret=max(ret,sqrt(sq(X-x[i])+sq(Y-y[i])));
	}
	return ret;
}
double cal(double X){
	double lo=0,hi=1000;
	rep(i,100){
		double m1=(lo+lo+hi)/3,m2=(lo+hi+hi)/3;
		if(d(X,m1)<d(X,m2)) hi=m2;else lo=m1;
	}
	return d(X,lo);
}
int main()
{
	cin>>n;rep(i,n) cin>>x[i]>>y[i];
	double lo=0,hi=1000;
	rep(i,100){
		double m1=(lo+lo+hi)/3,m2=(lo+hi+hi)/3;
		if(cal(m1)<cal(m2)) hi=m2;else lo=m1;
	}
	printf("%.12f\n",cal(lo));
}


Measured memory_bytes: 256
h,w = map(int,input().split())

C = []
for i in range(10):
    C.append(list(map(int,input().split())))

def warshall_floyd(d):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

trans_map = warshall_floyd(C)

ans = 0
for i in range(h):
    line = list(map(int,input().split()))
    for j in range(w):
        num = line[j]
        if num == -1:
            continue
        ans += trans_map[num][1]

print(ans)

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

int main() {
  int N; cin >> N;
  vector<int> cnt(4);
  for (int i = 0; i < N; i++) {
    string s; cin >> s;
    if (s == "AC") cnt.at(0)++;
    else if (s == "WA") cnt.at(1)++;
    else if (s == "TLE") cnt.at(2)++;
    else cnt.at(3)++;
  }
  cout << "AC x " << cnt.at(0) << endl;
  cout << "WA x " << cnt.at(1) << endl;
  cout << "TLE x " << cnt.at(2) << endl;
  cout << "RE x " << cnt.at(3) << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
// #define REP(i,n) for(int i = 0; i < (n); i++)
// #define P(x) cout << (x) << "\n"

// #define MOD 1000000007 // 1e9+7
// #define PI acos(-1.0)
// #define ll long long int // 10^18
// #define INF 1000000001 // 1e9+1

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

bool p[8][8]; int n,m,a,b;
int main(){
  // std::ios::sync_with_stdio(false);
  // std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());
  cin>>n>>m;
  for(int i=0; i<m; i++) {cin>>a>>b; a--; b--; p[a][b]=true; p[b][a]=true;}
  int G[8]={0,1,2,3,4,5,6,7};
  int cnt=0;
  do {
    if(G[0]!=0) continue;
    bool OK=true;
    for(int i=1; i<n; i++) {
      if(p[G[i-1]][G[i]]==false) OK=false;
    }
    if(OK==true) cnt++;
  } while(next_permutation(G,G+n));
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
set<pair<int,int> > s;
int a[105][105];
pair<int,int>num[10005];
bool com(pair<int,int>x,pair<int,int>y)
{
	return x.first>y.first;
}
int main()
{
	int h,w,n;
	cin>>h>>w>>n;
	for(int i=0;i<n;i++)
	{
		cin>>num[i].first;
		num[i].second=i;
	}
	sort(num,num+n,com);
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			s.insert(make_pair(j,i));
		}
	}
	int x=0,y=0;
	for(int j=0;j<n;j++)
	{
		int i=num[j].second;
//		int x=(*s.begin()).second,y=(*s.begin()).first;
		while(num[j].first--)
		{
			a[x][y]=i+1;
			s.erase(make_pair(y,x));
			if(s.find(make_pair(y-1,x))!=s.end())
			{
				y=y-1;
			}
			else if(s.find(make_pair(y,x+1))!=s.end())
			{
				x=x+1;
			}
			else if(s.find(make_pair(y,x-1))!=s.end())
			{
				x=x-1;
			}
			else
			{
				y=y+1;
			}
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}

Measured memory_bytes: 896
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
    long heightMemo = 0;
    long[] answer = new long[3];
    long[,] vertexes = new long[n,3];//ここに受け取る
    long checkOk = 0;
    for(long i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);//１行ごとに受け取る
      vertexes[i,0] = nums[0];
      vertexes[i,1] = nums[1];
      vertexes[i,2] = nums[2];
    }

    for(long i = 0; i<= 100; i++)
    {
      for(long j = 0; j <= 100; j++)
      {
      checkOk = 0;
        for(long k = 0; k < n; k++)
        {
          if(checkOk == 0 && vertexes[k,2] != 0)
          {
            heightMemo = vertexes[k,2]+(Math.Abs(vertexes[k,0]-i) + Math.Abs(vertexes[k,1]-j));
            checkOk = 1;
          }else if((checkOk == 1 && vertexes[k,2] != heightMemo-(Math.Abs(vertexes[k,0]-i) + Math.Abs(vertexes[k,1]-j))
            && heightMemo-(Math.Abs(vertexes[k,0]-i) + Math.Abs(vertexes[k,1]-j)) > 0)
            || (checkOk == 1 && vertexes[k,2] != 0
            && heightMemo-(Math.Abs(vertexes[k,0]-i) + Math.Abs(vertexes[k,1]-j)) <= 0)) break;
          if(k == n-1 && heightMemo >= 1)
          {
            answer[0] = i;
            answer[1] = j;
            answer[2] = heightMemo;
          }
        }
      }
    }
    
		Console.WriteLine(answer[0] + " " + answer[1] + " " + answer[2]);
	}
}

Measured memory_bytes: 11220
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>

using namespace std;

int complete[11], p[11], d, g, c[11];

int rec(int depth) {
    if (depth > d) {
        int sum = 0, cnt = 0;
        for (int i = 1; i <= d; i++) {
            if (!complete[i]) continue;
            cnt += p[i];
            sum += 100 * i * p[i] + c[i];
        }
        if(sum >= g) return cnt;
        for (int i = d; i > 0; i--) {
            if (complete[i]) continue;
            if (sum + p[i] * i * 100 < g) {
                return 1000000000;
            } else {
                return cnt + (g - sum + i * 100 - 1) / (i * 100);
            }
        }
    } else {
        int ret = 1000000000;
        complete[depth] = 0;
        ret = min(ret, rec(depth + 1));
        complete[depth] = 1;
        ret = min(ret, rec(depth + 1));
        return ret;
    }
}

int main() {
    cin >> d >> g;
    for (int i = 1; i <= d; i++) {
        cin >> p[i] >> c[i];
    }
    cout << rec(1) << endl;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var sum = 0d;
        var sumb = 0d;
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            if (line[1] == "JPY") sum += long.Parse(line[0]);
            else sumb += double.Parse(line[0]);
        }
        var ans = sum + sumb * 380000.0d;
        Console.WriteLine(ans   );
    }
}

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

int main() {
    int A, B;
    cin >> A >> B;

    int ans = 0;
    for (int i = A; i <= B; i++) {
        int s = i % 10, t = (i / 10000) % 10;
        int v = (i / 10) % 10, u = (i / 1000) % 10;
        if (s == t && v == u) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
while 1:
	inp = raw_input()
	if inp == "0": break
	q1,b,c1,c2,q2 = map(int,inp.split())
	buy1 = min(b/c1,q2)
	buy2 = (b - buy1 * c1) / c2
	while buy1 > 0  and (buy1 * c1 + buy2 * c2 > b or buy1 + buy2 < q1):
		buy1 -= 1
		buy2 = (b - buy1 * c1) / c2
	if buy1 > 0:
		print buy1, buy2
	else:
		print "NA"

Measured memory_bytes: 4204
for line in open(0).readlines():
    p, q = map(int, line.split())
    U = [0]*q
    d = 1
    ans = []
    while U[p] == 0 and p > 0:
        U[p] = d
        k, p = divmod(10*p, q)
        ans.append(str(k))
        d += 1
    print("".join(ans))
    if p:
        print(" "*(U[p]-1) + "^"*(d-U[p]))



Measured memory_bytes: 21456
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


class comb{
private:
    ll mod;
    ll mx;
    vector<ll> F;
    vector<ll> FR;
    
public:
    comb(ll mod=1000000007,ll mx=100000):mod(mod),mx(mx),F(mx+1,1),FR(mx+1,1){
        mk_F();
    }
    
    ll mod_pow(ll a,ll x){
        a%=mod;
        ll ans=1;
        while(x>0){
            if(x&1){ans*=a; ans%=mod;}
            a*=a;
            a%=mod;
            x>>=1;
        }
        return ans;
    }
    
    pll Ex_gcd(ll a,ll b){
        if(b==0){return {1,0};}
        pll ret=Ex_gcd(b,a%b);
        ret.F-=a/b*ret.S;
        return {ret.S,ret.F};
    }
    
    ll prime_R(ll a){
        return mod_pow(a,mod-2);
    }
    
    ll R(ll a){
        ll ret=Ex_gcd(a,mod).F;
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    void mk_F(){
        for(ll i=1;i<=mx;i++){F[i]=F[i-1]*i%mod; FR[i]=R(F[i]);}
    }
    
    ll c(ll n,ll k){
        if(n<k || n<0 || k<0){return 0;}
        if(n==k || k==0){return 1;}
        return F[n]*FR[n-k]%mod*FR[k]%mod;
    }
    
    //mod must be prime
    ll Lucas_C(ll n,ll m){
        ll ret=1;
        while(n>0 || m>0){
            ret*=c(n%mod,m%mod);
            ret%=mod;
            n/=mod; m/=mod;
        }
        return ret;
    }
    
    ll Stirling(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){
            if((k-i)%2){ret-=c(k,i)*mod_pow(i,n)%mod;}
            else{ret+=c(k,i)*mod_pow(i,n)%mod;}
            ret%=mod;
        }
        ret*=R(F[k]);
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    ll Bell(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){ret+=Stirling(n,i); ret%=mod;}
        return ret;
    }
};

comb C(MOD,1000000);


int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    for(int i=0;i<=k;i++){
        ll N=C.c(n+2*i,i)-C.c(n+2*i,n+i+1);
        N%=MOD;
        ll j=k-i;
        ll M=C.c(m+2*j,j)-C.c(m+2*j,m+j+1);
        M%=MOD;
        ans+=C.c(n+m+2*k,n+2*i)*N%MOD*M%MOD;
        ans%=MOD;
    }
    ans%=MOD;
    if(ans<0){ans+=MOD;}
    cout<<ans<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 18244
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;
ll ans=0,ans2=0;
ll a,b,c,d;
ll n;
int main() {
	cin>>a>>b;
	d=(a+b)/2;
	if((a+b)%2>0)++d;
	cout<<d<<endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;



typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[2][300005] = {};
ll B[300005] = {};
ll C[100][3005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[600005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;
queue<ll> ql;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}



double ab[20000];

ll ha[2];

ll x, y;

int main() {
	cin >> N;

	if (N < 100) {
		a = min(N,(ll)9);
	}
	else if (N < 10000) {
		b = min((ll)900, N - 99);
		a = 9 + b;
	}
	else {
		b = min((ll)90000, N - 9999);
		a = 909 + b;
	}

	cout << a << endl;
	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;


	
}


Measured memory_bytes: 14464
s = input()

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


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int x;
  cin >> x;
  x = 2000 - x;
  int ans = (x+199) / 200;
  cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int K = sc.nextInt();
		int ans;
		
		int amari = K % 2;
		int div = K / 2;
		if(amari == 1){
			ans = div *(div + 1);
		}else{
			ans = div * div;
		}
   		System.out.println(ans);
		
   		sc.close();
        return ;

    }
    
}



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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    int n; cin >> n;
    vector<int> v(n);
    for(auto &x : v) cin >> x;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            ans += v[i]*v[j];
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3624
// Problem : E - Red and Green Apples
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <algorithm>
using namespace std;
int p[100005],q[100005],r[100005];
int cp=1,cq=1,cr=1,tp,tq;
int x,y,a,b,c;
int get()
{
 int ans=max(p[cp]*(x>0),max(q[cq]*(y>0),r[cr]));
 if(ans==p[cp]&&x)
 {
  cp++,x--;
  return ans;
 }
 else if(ans==q[cq]&&y)
 {
  cq++,y--;
  return ans;
 }
 else
 {
  cr++;
  if(p[tp]<q[tq]&&x)x--,tp--;
  else y--,tq--;
 }
 return ans;
}
bool cmp(int x,int y)
{
 return x>y;
}
int main()
{
 long long ans=0;
 cin>>x>>y>>a>>b>>c;
 for(int i=1;i<=a;i++)
  cin>>p[i];
 for(int i=1;i<=b;i++)
  cin>>q[i];
 for(int i=1;i<=c;i++)
  cin>>r[i];
 tp=x,tq=y;
 sort(p+1,p+a+1,cmp);
 sort(q+1,q+b+1,cmp);
 sort(r+1,r+c+1,cmp);
 while(x+y)
  ans+=get();
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <vector>
#include <climits>
#include <cmath>
#include <stdlib.h>
using namespace std;


int main()
{
    long long x, k, d; cin >> x >> k >> d; x = abs(x);
    if ((float)x/d > k) cout << abs(x - k*d) << endl;
    else if ((float)x/d < k)
    {
        int t1 = x/d; int alpha = (k - t1)/2; 
        int k1 = (k - 2*alpha), k2 = k1 + 2, k3 = k1 - 2;
        cout << min(abs(x - k1 * d), min(abs(x - k2 * d), abs(x - k3 * d))) << endl;
    } 
    else cout << abs(x - k * d) << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Touitsu | diff Touitsu.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Touitsu.cpp && ./a.out

/*
 
 2/4/2019
 
 17:19-
 
 */

//const int MAX_N=1e2+1;
int N;
string A,B,C;

void solve() {
  int res=0;
  REP(i,N) {
    set<char> S;
    S.emplace(A[i]),S.emplace(B[i]),S.emplace(C[i]);
    if(SZ(S)==3) res+=2;
    if(SZ(S)==2) res+=1;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>A>>B>>C;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int n,a[maxn];
LL L[maxn],R[maxn];
int main(){
	int n; cin >> n; // n == 0
	for(int i = 0;i <= n; ++i) cin >> a[i];
	if(n == 0){
		if(a[0] == 1) return printf("%d",a[0]),0;
		else return puts("-1"),0;
	}
	L[n-1] = (a[n]+1)/2; R[n-1] = a[n];
	for(int i = n-2;i >= 0; --i){
		L[i] = (L[i+1]+a[i+1]+1)/2; R[i] = R[i+1]+a[i+1];
	}
	LL sum = 0,up = min(1ll-a[0],R[0]);
	if(up < L[0]) sum = -1;
	else sum += up;
	for(int i = 1;i < n && sum!=-1; ++i){
		LL r = min(R[i],up*2-a[i]);
		if(r < L[i]){
			sum = -1; break;
		}
		else{
			sum += r;
			up = r;
		}
	}
	if(sum == -1) puts("-1");
	else{
		for(int i = 0;i <= n; ++i) sum += a[i];
		cout << sum << '\n';
	}	 
    return 0;
}



Measured memory_bytes: 5560