akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

map<int,int> mp;

template<class Type,class Type_k>
Type ipow(Type n,Type_k k){//n^k. O(log n).
	if(k==0) return 1;
	Type res=ipow(n*n,k/2);
	if(k&1) res*=n;
	return res;
}

/*素因数分解*/
template<class Type>
map<Type,int> prime_factor(Type n){
	map<Type,int> res;//自然数nの約数firstがsecond個ある.
	for(Type i=2;i*i<=n;++i){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1) res[n]=1;
	res[1]=1;
	return res;
}

bool dfs(vector<pii > vp,int i,int num,int ex){
	if(i==vp.size()){
		if(num==ex) return mp[num]>=2;
		return mp[num]>=1;
	}
	
	REP(j,vp[i].second+1){
		int tmp=ipow(vp[i].first,j);
		bool jud=dfs(vp,i+1,num*tmp,ex);
		if(jud) return true;
	}
	
	return false;
}

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	REP(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	sort(ALL(a));
	
	int ans=n;
	REP(i,n){
		map<int,int> tmp=prime_factor(a[i]);
		vector<pii > vp;
		for(auto elem:tmp) vp.emplace_back(elem.first,elem.second);
		
		if(dfs(vp,0,1,a[i])) ans--;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 32652
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
	cin>>n;
    for(int i=1;i<=9;i++){
    	for(int j=1;j<=9;j++){
        	if(n==(i*j)){
            	cout<<"Yes"<<endl;
              	return 0;
            }
        }
    }
  	cout<<"No"<<endl;
    return 0;
}


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

int main(){
	
	int a, b, c;
	cin>>a>>b>>c;
	
	if(a==b){
		cout<<c;
	}
	else if(b==c){
		cout<<a;
	}
	else if(a==c){
		cout<<b;
	}
	
	return 0;
	
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vll a(n+1), b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll ans = 0;
    rep(i, n) {
        ans += min(b[i], a[i]+a[i+1]);
        a[i+1] -= max(ll(min(b[i]-a[i], a[i+1])), 0LL);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

if s == "ABC":
    print("ARC")
else:
    print("ABC")

Measured memory_bytes: 9048
from collections import defaultdict
import heapq

V, E, r = map(int, input().split())
edges = defaultdict(list)
for _ in range(E):
    s, t, d = map(int, input().split())
    edges[s].append((t, d))

dists = {}  
q = [(0, r)]

while q:
    dist, node = heapq.heappop(q)
    if node in dists:
        continue
    dists[node] = dist
    for t, d in edges[node]:
        if t not in dists:
            heapq.heappush(q, (dist + d, t))

for i in range(V):
    if i in dists:
        print(dists[i])
    else:
        print('INF')




Measured memory_bytes: 112392
#include <stdio.h>
/*
  三角形をつくる
*/
int main(void)
{
  
  unsigned a, b, c, N;
  int i;

  scanf("%u", &N);

  for (i = 0; i < N; i++) {
    scanf("%u%u%u", &a, &b, &c);
    if (a * a == b * b + c * c)
      puts("YES");
    else if (b * b == c * c + a * a) 
      puts("YES");
    else if (c * c == a * a + b * b)
      puts("YES");
    else puts("NO");
  }
  return(0);
}

Measured memory_bytes: 580
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,M=pin()
    
    t=M//2
    if t<N:
        print(t)
        return
    M-=N*2
    ans=N
    ans+=M//4
    print(ans)
#%%submit!
resolve()

Measured memory_bytes: 38384
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second



int main(){
	int h,w;
	cin >> h >> w;
	string c;
	while(cin >> c){
		cout << c << endl;
		cout << c << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,M;
pair<int,pi> e[20010];
int flag[20010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>N>>M && N){
		rep(i,M){
			cin>>e[i].fir>>e[i].sec.fir>>e[i].sec.sec;
			e[i].sec.fir--;e[i].sec.sec--;
		}
		sort(e,e+M);
		memset(flag,0,sizeof(flag));
		flag[0]=1;
		rep(i,M){
			if(flag[e[i].sec.fir]){
				flag[e[i].sec.sec]=1;
			}
		}
		cout<<accumulate(flag,flag+N,0)<<endl;
	}
}

Measured memory_bytes: 1520
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(c: i64, mut xv: Vec<(i64, i64)>) -> i64 {
    use std::cmp::max;

    let n = xv.len();

    let mut av = vec![0; n+1];
    for (i, &(x,v)) in xv.iter().enumerate() {
        av[i+1] = av[i] + v;
    }

    let mut bv = vec![0; n+1];
    for (i, &(x,v)) in xv.iter().rev().enumerate() {
        bv[i+1] = bv[i] + v;
    }


    let mut g1 = vec![0; n+1];
    let mut g2 = vec![0; n+1];

    for a in 1..n+1 {
        let (oa,_) = xv[a-1];
        g1[a] = if g1[a-1] < av[a] - oa {
            av[a] - oa
        } else { g1[a-1] };

        g2[a] = if g2[a-1] < av[a] - 2*oa {
            av[a] - 2*oa
        } else { g2[a-1] };
    }

    let mut maxc = 0;

    for b in 0..n+1 {
        let ob = if b == 0 {0} else{
            let (x, _) = xv[n-b];
            c-x
        };

        let ab = max(bv[b] + g1[n-b] - 2*ob,
                     bv[b] + g2[n-b] - ob);

        if maxc < ab {
            maxc = ab;
        }
    }

    maxc
}

fn main() {
    let (n, c) = parse_line!(usize, i64);

    println!("{}", solve(c, (0..n).map(|_| parse_line!(i64, i64)).collect()));
}

#[test]
fn solve_test() {
    assert_eq!(solve(20, vec![(2,80), (9,120), (16, 1)]), 191);
    assert_eq!(solve(20, vec![(2,80), (9,1), (16, 120)]), 192);
    assert_eq!(solve(100000000000000, vec![(50000000000000, 1)]), 0);
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	while (1) {
		int n; cin >> n;
		if (!n) break;

		vi p(n), j(n - 1);

		int all = 0;
		rep(i, n) {
			cin >> p[i];
			all += p[i];
		}

		rep(i, n - 1) cin >> j[i];
		sort(DESC(j));
		ll ans = 0;
		rep(i, n) {
			if (i != 0) {
				all += j[i - 1];
			}

			ans = max(ans, (ll)all * (n - i));
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3272
//         ONLY FOR KING RAHMANI MASTER OF DP       \\

#include <bits/stdc++.h>
#define int long long
#define lb(a) ((a)&(-a))
using namespace std;

const int maxn=3e3+20;

double ans,dp[maxn][maxn],p[maxn];

int n;

int32_t main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cout<<setprecision(9);
    cout<<std::fixed;
 //   ifstream cin("input.txt");
 //   ofstream cout("output.txt");
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>p[i];
    dp[0][0]=1-p[0];
    dp[0][1]=p[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=dp[i-1][0]*(1-p[i]);
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=dp[i-1][j-1]*p[i];
            dp[i][j]+=(dp[i-1][j]*(1-p[i]));
        }
    }
    int m=n/2;
        m++;
    for(int i=m;i<=n;i++){

        ans+=dp[n-1][i];
    }
    cout<<ans;
	return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;
vector<string> DAY = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

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

    string s;
    cin >> s;

    int ans = 7 - distance(DAY.begin(), find(DAY.begin(), DAY.end(), s));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int from,to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
signed main(){
    string s;cin>>s;
    string ans;int al[26]={};
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout<<-1<<endl;
        return 0;
    }
    else {
        rep(i,0,s.size()){
            al[s[i]-'a']++;
        }cout<<endl;
        rep(i,0,26){
            if(!al[i]){
                s.push_back(i+'a');
                cout<<s<<endl;
                return 0;
            }
        }
                int key=0;
                rep(i,0,26){
                    if(s[i]-'a'<s[i+1]-'a')key=i;
                }
        string st=s;
                s.erase(s.begin()+key+1,s.begin()+s.size());
        bool n=true;
        while(n){
            n=false;
            s[key]++;
            int num[26]={};
            rep(i,0,s.size()){
                num[s[i]-'a']++;
                if(num[s[i]-'a']==2){
                    n=true;
                }
            }
        }
                cout<<s<<endl;
                return 0;
        
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
	fast;
	string name1,name2;
	cin>>name1>>name2;
	for(ll i=0;i<name1.length();i++)
		if(name1[i]==name2[i])
			continue;
		else
		{
			cout<<"No"<<endl;
		return 0;
			
		}
	cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> v(n),c(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  for(int i = 0; i < n; i++){
    cin >> c[i];
  }

  vector<int> t(n);
  for(int i = 0; i < n; i++){
    t[i] = v[i] - c[i];
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    if(t[i] > 0) ans += t[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split(" ")))

count=0
target=1
suc=0
for i in range(N):
    if a[i]!=target:
        count+=1
    else:
        suc+=1
        target+=1

if suc>0:
    print(count)
else:
    print(-1)



Measured memory_bytes: 26268
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;

int main(){
	string str;
	cin>>str;
	string temp="keyence";
	int st=0,ed=0;
	int n=str.size(),m=temp.size();
	while(str[st]==temp[st]&&st<min(n,m)){
		st++;
	}
	while(str[n-1-ed]==temp[m-1-ed]&&ed<min(n,m)){
		ed++;
	}
	//cout<<st<<" "<<ed<<endl;
	if(st+ed>=7)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	
}

Measured memory_bytes: 256
def examA():
    N, M = LI()
    l = 1; r = N
    for _ in range(M):
        L, R = LI()
        l = max(L,l)
        r = min(R,r)
    ans = max(0,r-l+1)
    print(ans)
    return

def examB():
    N = I()
    S = [I()for _ in range(N)]
    rest = []
    for s in S:
        if s%10==0:
            continue
        rest.append(s)
    if sum(S)%10==0:
        if not rest:
            print(0)
            return
        ans = sum(S) - min(rest)
    else:
        ans = sum(S)
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return read().rstrip().decode('utf-8')
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

int main() {
  string s;
  int i,ans;
  ans = 0;
  cin >> s;
  for(i = 0; i<s.size(); i++){
    if(s.at(i) == '+') ans++;
    else ans--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, m, c, ans = 0;
	cin >> n >> m >> c;

	vector<int> b(m);
	for(int i=0;i<m;i++) cin >> b.at(i);
	for(int i=0;i<n;i++){
		int sum = 0;
		for(int j=0;j<m;j++){
			int a;
			cin >> a;
			sum += b.at(j) * a;
		}
		if(sum+c>0) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>

int getMaxHappy(const std::vector<std::vector<int>> &points) {
  std::vector<std::vector<int>> dp(points.size());
  for (auto &row : dp) {
    row.resize(3, 0);
  }
  dp[0] = points[0];
  for (int i = 1; i <  static_cast<int>(points.size()); ++i) {
    dp[i][0] = std::max(dp[i - 1][1], dp[i - 1][2]) + points[i][0];
    dp[i][1] = std::max(dp[i - 1][0], dp[i - 1][2]) + points[i][1];
    dp[i][2] = std::max(dp[i - 1][0], dp[i - 1][1]) + points[i][2];
  }
  return *std::max_element(dp.back().begin(), dp.back().end());
}

int main() {
  int n;
  std::cin >> n;
  std::vector<std::vector<int>> points(n);
  for (int i = 0; i < n; ++i) {
    points[i].resize(3);
    for (int j = 0; j < 3; ++j) {
      std::cin >> points[i][j];
    }
  }
  std::cout << getMaxHappy(points) << std::endl;
  return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;

int main(){
	int weight[101], value[101];
	long long** dp = new long long*[102];
	for(int i=0; i<=102; i++)
		dp[i] = new long long[100001];
	for(int i=0; i<=101; i++)
		for(int j=0; j<=100000; j++)
			dp[i][j] = 0;
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, W;
	cin >> N >> W;
	
	for(int i=1; i<=N; i++){
		cin >> weight[i] >> value[i];
	}
	
	for(int objChk=1; objChk<=N; objChk++){
		for(int weightLeft=0; weightLeft<=W; weightLeft++){
			if(weightLeft<weight[objChk]) dp[objChk+1][weightLeft] = dp[objChk][weightLeft];
			else{
				dp[objChk+1][weightLeft] = max(
					dp[objChk][weightLeft],
					dp[objChk][weightLeft-weight[objChk]] + value[objChk]
				);
			}
		}
	}
	
	cout << dp[N+1][W] << '\n';
	
	return 0;
}

Measured memory_bytes: 80256
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
t = 0
mine = 0
k = [a,b,c,d,e]
for i in k:
  if i % 10 > 0:
    if mine%10 > i%10 or mine == 0:
      mine = i
if mine == 0:
  mine = a
k.remove(mine)
for i in k:
  t += math.ceil(i/10)*10
t += mine
print(t)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>


int main()
{
	char str[1001];

	while (1) {
		scanf("%s", str);
		if (str[0] == '0')break;
		int sum = 0;
		for (int i = 0; i < strlen(str); i++) {
			sum += (str[i] - '0');
		}

		printf("%d\n", sum);
	}
    return 0;
}



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

int main(){
    int N,M;
    int ma = 100000;
    cin >> N >> M;
    vector<vector<int>> v(ma+1);
    for(int i=0;i<N;i++){
        int a,b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    int ans = 0;
    priority_queue<int> Q;
    for(int i=1;i<=M;i++){
        for(auto x:v[i]) Q.push(x);
        if(Q.empty()) continue;
        ans += Q.top();
        Q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
import math
import itertools
lis=[]
N=int(input())
P=list(map(int, input().split()))
Q=list(map(int, input().split()))
l=[i+1 for i in range(N)]
"""
lP=[i+1 for i in range(N)]
lQ=[i+1 for i in range(N)]
#print(P,Q,lP,lQ)
bangoP=[]
bangoQ=[]
pnum=0
qnum=0
for i in range(N):
    j=0
    while True:
        if (lP[j]==P[i]):
            bangoP.append(j)
            #print(j)
            lP.pop(j)
            #print(lP)
            break
        j=j+1
for i in range(N):
    j=0
    while True:
        if (lQ[j]==Q[i]):
            bangoQ.append(j)
            #print(j)
            lQ.pop(j)
            #print(lQ)
            break
        j=j+1
#print(bangoP,bangoQ)

for i in range(N-1):
    #print(bangoP[i],bangoQ[i])
    pnum=pnum+math.factorial(N-1-i)*bangoP[i]
    qnum=qnum+math.factorial(N-1-i)*bangoQ[i]
print(abs(pnum-qnum))
"""
p_list=list(itertools.permutations(l))
for i in range(len(p_list)):
    if P==list(p_list[i]):
        pnum=i
    if Q==list(p_list[i]):
        qnum=i
print(abs(pnum-qnum))


Measured memory_bytes: 46064
#include<iostream>
#include<algorithm>
using namespace std;
int check(int n){
	int a[4];
	int s1=0,s2=0,s3;
	for(int i=0;i<4;i++){
		a[i]=n%10;
		n/=10;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			if(a[j]<a[j+1])swap(a[j],a[j+1]);
		}
	}
	for(int i=0;i<4;i++){
		int j=3-i;
		s1*=10;   s2*=10;
		s1+=a[i]; s2+=a[j];
	}
	s3=s1-s2;
	return s3;
}
int s[10005];
int main(){
	int n;
	int i=0,j=0;
	while(cin>>n && n){
		for(int k=0;k<10000;k+=1111){
			if(n==k){
				s[i]=-1;
				break;
			}
		}
		if(s[i]==-1){
			i++;
			continue;
		}
		while(1){
			if(n==6174)break;
			j++;
			n=check(n);
		}
		s[i]=j;
		j=0;
		i++;
	}
	for(j=0;j<i;j++){
		if(s[j]==-1){
			cout<<"NA"<<endl;
		}else{
			cout<<s[j]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1200
fun main(args: Array<String>) {

    val (n, k) = readLine()!!.split(" ").map { it.toInt() }

    // a, b, cがKの倍数の場合の数
    var count = 0L
    for (i in k..n step k) {
        count++
    }
    val ans1 = count * count * count

    // Kが偶数のとき、a+b, b+c, a+cがKの倍数の場合、
    // つまりa, b, cをKで割ったあまりが2/Kの場合の数
    var count2 = 0L
    if (k % 2 == 0) {
        count2 = (1..n).filter { it % k == k / 2 }.count().toLong()
    }
    val ans2 = count2 * count2 * count2

    println(ans1+ans2)
}

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


int main(){
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    for(auto &x: p) cin >> x;
    for(auto &x: q) cin >> x;
    for(auto &x: r) cin >> x;
    ll res=0;
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
    int total=0;
    int cnt_r=0, cnt_g=0;
    int a, b, c;
    a=b=c=0;
    while(total < X+Y){
        int maximum=0;
        if(cnt_r == X){
            maximum=max(q[b], r[c]);
            if(maximum == r[c]) c++;
            else b++, cnt_g++;
        }
        else if(cnt_g == Y){
            maximum=max(p[a], r[c]);
            if(maximum == r[c]) c++;
            else a++, cnt_r++;
        } 
        else{
            maximum=max(p[a], max(q[b], r[c]));
            if(maximum == r[c]) c++;
            else if(maximum == q[b]) b++, cnt_g++;
            else a++, cnt_r++;
        }
        total++;
        res+=maximum;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    if(a<k){
        ans+=a;
        k-=a;
        if(b<k){
            k-=b;
            ans-=k;
        }else k=0;
    }else{
        ans=k;
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 3612
H, W = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

ans = [[0] * W for _ in range(H)]

row_is_even = True

def next_grid(h, w):
	if h % 2 == 0:
		if w == W - 1:
			return h + 1, w
		else:
			return h, w + 1
	else:
		if w == 0:
			return h + 1, w
		else:
			return h, w - 1

def color(h, w, num, cnt):
	for _ in range(cnt):
		ans[h][w] = num
		h, w = next_grid(h, w)
	return h, w

h, w = color(0, 0, 1, a[0])
for i in range(1, n):
	h, w = color(h, w, i + 1, a[i])

for i in range(H):
	print(*ans[i])

Measured memory_bytes: 3956
from itertools import combinations
import math
#X = int(input())
#X = input()
N, D=map(int,input().split())
C = []
for i in range(N):
    C.append(list(map(int,input().split())))

count = 0
for i in C:
    if math.sqrt(i[0]*i[0]+i[1]*i[1]) <= D:
        count+=1
print(count)

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<pii, int> para;
const int inf = 1e9 + 7;
const int maxN = 5e6 + 5;

int a, b, c;
int main() {
	ios_base::sync_with_stdio(0);
	cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust";
	else cout << "win";	
	return 0;
}


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

int main()
{
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	
	vector<vector<int>> dp(n, vector<int>(m, 0));
	
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			if (s[i] == t[j])
			{
				if (i == 0 || j == 0)
					dp[i][j] = 1;
				else
					dp[i][j] = dp[i-1][j-1] + 1;
			}
			else
			{
				if (i != 0)
					dp[i][j] = max(dp[i][j], dp[i-1][j]);
				if (j != 0)
					dp[i][j] = max(dp[i][j], dp[i][j-1]);
			}
		}
	}
	
	string ans = "";
	n--; m--;
	while (n >= 0 && m >= 0)
	{
		if (s[n] == t[m])
		{
			ans += s[n];
			n--; m--;
		}
		else if (n == 0)
		{
			m--;
		}
		else if (m == 0)
		{
			n--;
		}
		else if (m == 0 || dp[n-1][m] > dp[n][m-1])
		{
			n--;
		}
		else
		{
			m--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
}


Measured memory_bytes: 35584
#include<cstdio>
using namespace std;
int main(void)
{
	int m,n,i,j,k,p,flg[1001];
	while(1)	{
		scanf("%d %d",&n,&m);
		if(n==0 && m==0)	break;
		for(i=1;i<=n;i++)	flg[i]=1;
		p=n;
		for(i=0;i<n-1;i++)	{
			j=0;
			while(j<m)	{
				p++;
				if(p>n)	p=1;
				if(flg[p]==1)	j++;
			}
			flg[p]=0;
		}
		for(i=1;i<=n;i++)	{
			if(flg[i]==1)	{
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1032
N=int(input())
Alist=list(map(int,input().split()))
sum=0
if N==1:
  print(0)
else:
  for i in range(1,N):
    if Alist[i]<=Alist[i-1]:
      sum=sum+Alist[i-1]-Alist[i]
      Alist[i]=Alist[i-1]
  print(sum)

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

#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)

typedef long long ll;
#define INF 1e9

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



int main(){
  int N, M;
  cin >> N >> M;
  ll ans = 1;
  if(N == M){ 
    FOR(i, 1, N+1){
      ans *= i;
      ans %= (ll)(1e9+7);
    }
    FOR(i, 1, M+1){
      ans *= i;
      ans %= (ll)(1e9+7);
    }
    ans *= 2;
    ans %= (ll)(1e9+7);
  }
  else if( N-M == 1 || M-N == 1){
    FOR(i, 1, N+1){
      ans *= i;
      ans %= (ll)(1e9+7);
    }
    FOR(i, 1, M+1){
      ans *= i;
      ans %= (ll)(1e9+7);
    }
  }
  else{
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def sort(a,b,c):
    l=[a,b,c]
    l.sort()
    return l

n=int(input())
s=input()
r=s.count('R')
g=s.count('G')
b=s.count('B')
sum=r*g*b
for i in range(n-2):
    for j in range(i+1,n-1):
        k=2*j-i
        if k<n and s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
            sum-=1
print(sum)

Measured memory_bytes: 68096
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int X=sc.nextInt();
		int Y=sc.nextInt();
		int ans=0;
		if(a+b>2*c) {
			int t=Math.min(X, Y);
			ans+=t*c*2;
			X-=t;Y-=t;
		}
		if(a>2*c) {
			ans+=X*c*2;
			X=0;
		}
		if(b>2*c) {
			ans+=Y*c*2;
			Y=0;
		}
		ans+=a*X+b*Y;
		p(ans);
		
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 22228
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long LL;
const LL N = 2005;
const LL M = 400005;

vector <LL> G[N];
LL vis[2][N][N],p[N],vi[N];
LL eu[M],ev[M],n,m;

void dfs_vis(LL u,LL rt){
	vis[0][rt][u] = 1;
	vi[u] = 1;
	for(LL i = 0;i < G[u].size();i ++){
		LL v = ev[G[u][i]];
		if(vi[v]) continue;
		dfs_vis(v,rt);
	}
}

void get_vis(){
	for(LL i = 1;i <= n;i ++){
		memset(vi,0,sizeof(vi));
		dfs_vis(i,i);
	}
}

void dfs_sol(LL u,LL col,LL pid,LL rt){
	if(pid) vis[1][rt][u] = (p[u] != col);
	else p[u] = col;
	vi[u] = 1;
	for(LL i = 0;i < G[u].size();i ++){
		LL v = ev[G[u][i]];
		if(vi[v]) continue;
		dfs_sol(v,col,pid,rt);
	}
}

void solve(LL u){
	memset(p,0,sizeof(p));
	memset(vi,0,sizeof(vi)); vi[u] = 1;
	for(LL i = 0;i < G[u].size();i ++) if(!vi[ev[G[u][i]]]) dfs_sol(ev[G[u][i]],i + 1,0,u);
	memset(vi,0,sizeof(vi)); vi[u] = 1;
	for(LL i = (LL)(G[u].size()) - 1;i >= 0;i --) if(!vi[ev[G[u][i]]]) dfs_sol(ev[G[u][i]],i + 1,1,u);
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(LL i = 1;i <= m;i ++){
		cin >> eu[i] >> ev[i];
		G[eu[i]].push_back(i);
	}
	get_vis();
	for(LL i = 1;i <= n;i ++) solve(i);
//	for(LL i = 1;i <= m;i ++) cout << ans[0][i] << ' ' << ans[1][i] << endl;
	for(LL i = 1;i <= m;i ++) cout << ((vis[0][ev[i]][eu[i]] ^ vis[1][eu[i]][ev[i]]) ? "diff" : "same") << '\n';
	return 0;
}

Measured memory_bytes: 44800
PROGRAM HandV
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 8
      integer(p) :: h,w,k
      character(6) :: s
      integer(p) :: i,j,ans=0, ii,jj
      logical,allocatable :: c(:,:),cc(:,:)
      
      read*,h,w,k
      allocate( c(h,w),cc(h,w) )
      do i = 1,h
        read*,s
        do j = 1,w
          if( s(j:j)=='#' )then
            c(i,j) = .true.
          else
            c(i,j) = .false.
          end if
        end do
      end do
      
      do ii = 0,2**h-1
        do jj = 0,2**w-1
          cc = c
          do i = 1,h
            if( btest(ii,i-1) ) cc(i,:) = .false.
          end do
          do j = 1,w
            if( btest(jj,j-1) ) cc(:,j) = .false.
          end do
          
          if( count(cc)==k ) ans = ans + 1
        end do
      end do
      
      print*,ans
      
      
      stop
      !debugg
      
      do i = 1,h
        print*,c(i,:)
      end do
      
      print*,count(c)
      
      END PROGRAM

Measured memory_bytes: 2864
#include <iostream>
#include <vector>
#include <queue>
#include <utility>

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

using namespace std;

typedef long long int lli;

struct Query {
    int v, d, c;
};

vector<vector<int>> G;

int memo[100010][15];
void func(int v, int d, int c) {
    if (memo[v][d]) return;
    memo[v][d] = c;
    if (d == 0) return;

    func(v, d - 1, c);
    for (int vertex : G[v]) {
        func(vertex, d - 1, c);
    }
}

int main () {
    int N, M;
    cin >> N >> M;
    G.resize(N);
    REP (i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int Q;
    cin >> Q;
    vector<Query> query(Q);
    REP (i, 0, Q) {
        cin >> query[i].v >> query[i].d >> query[i].c;
        query[i].v--;
    }
    for (int i = Q - 1; i >= 0; i--) {
        func(query[i].v, query[i].d, query[i].c);
    }
    REP (i, 0, N) {
        cout << memo[i][0] << endl;
    }
    return 0;
}


Measured memory_bytes: 13560
#include <stdio.h>

#define MAX 2000001
#define VMAX 10000

void countingsort(int,int);
int A[MAX],B[MAX],C[VMAX+1];
int n,i,k=0;


int main(){

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }

  countingsort(VMAX,n);

  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[n]);
  printf("\n");


return 0;
}

void countingsort(int k,int n){
  int j;

  for(i=0;i<=k;i++){
    C[i] = 0;
  }

  for(j=1;j<=n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=k;i++){
    C[i] = C[i] + C[i-1];
  }

  for(j=n;j>0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}



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


public class D{
	
	public static void Main(){
	
		string[] args;
		
		args = Console.ReadLine().Split(' ');
		long n = Int64.Parse( args[0] );
		long m = Int64.Parse( args[1] );
		
		args = Console.ReadLine().Split(' ');
		long[] a = new long[n+1L];
		for( long i = 1L; i <= n; i++ ){
			a[i] = Int64.Parse( args[i-1L] );
		}
		
		long[] b = new long[n+1L];
		b[0L] = 0L;
		for( long i = 1L; i <= n; i++ ){
			b[i] = b[i-1L] + a[i];
		}		
		
		Dictionary<long,long> dic = new Dictionary<long,long>();
		for( long i = 0L; i <= n; i++ ){
			long x = b[i] % m;
			if( dic.ContainsKey(x) ){
				dic[x]++;
			}else{
				dic[x] = 1L;
			}
		}
		
		long result = 0L;
		foreach( long key in dic.Keys ){
			result += (dic[key] * (dic[key]-1L)) / 2L;			
		}
		Console.WriteLine(result);
		
	}

}

Measured memory_bytes: 20320
using System;

namespace ABC142
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = decimal.Parse(Console.ReadLine());

            decimal count = 0;

            for (int i = 1; i <= N; i++)
            {
                var flg = i % 2 == 1;

                if (flg)
                {
                    count++;
                }
            }

            var result = count / N;

            Console.WriteLine(result);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int diff(string& s, string& t) {
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        ans += s[i] != t[i];
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string x, y;
    for(int i = 0; i < s.size(); i++) {
        (i % 2 ? x : y) += '0';
        (i % 2 ? y : x) += '1';
    }
    cout << min(diff(s, x), diff(s, y)) << endl;
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))
using namespace std;

int main(){
	int p,q;
	cin>>p>>q;
	q/=__gcd(p,q);
	int ans=1;;
	for(int i=2;i*i<=q;i++){
		if(q%i==0){
			ans*=i;
			while(q%i==0) q/=i;
		}
	}
	p(ans*q);
	return 0;
}

Measured memory_bytes: 3092
<?php
$n = trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));
sort($a);
$ans = 0;

$i = $n;
while($i < $n * 2){
$ans += $a[$i];
++$i;
}

$ex = 0;

$i = 1;
while($i <= $n){
$ex += $a[$n * 3 - $i * 2];
++$i;
}

echo max($ans,$ex);

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

int main() {
    ll x;
    std::cin >> x;
    if(x>=30){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


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

"""
本番終了後、ちょっと修正版
"""

from collections import defaultdict
from math import sqrt

# 素因数分解
def fact_prime(num):
    d = defaultdict(int)
    # 終点はルート切り捨て+1
    end = int(sqrt(num)) + 1
    for i in range(2, end+1):
        cnt = 0
        # 素因数分解：小さい方から割れるだけ割って素数をカウント
        while num % i == 0:
            num //= i
            d[i] += 1
        # 1まで分解したら終了
        if num == 1:
            break
    # 最後に残ったnumは素数(ただし1^1は1^0なので数に入れない)
    if num != 1:
        d[num] += 1
    return d

N, P = map(int, input().split())

d = fact_prime(P)
ans = 1
for k, v in d.items():
    ans *= k ** (v // N)
print(ans)


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

ll c[101][101];

int main() {
  int n;
  cin >> n;
  vector<vector<ll>> vec(n, vector<ll>(3));
  rep(i,n) cin >> vec[i][0] >> vec[i][1] >> vec[i][2];
  int a;
  rep(i,n) if(vec[i][2]!=0) {
    a = i;
    break;
  }
  rep(i,101)rep(j,101) c[i][j] = vec[a][2] + abs(i-vec[a][0]) + abs(j-vec[a][1]);
  rep(i,101)rep(j,101) {
    bool ok = true;
    rep(k,n) {
      if(max(c[i][j]-abs(i-vec[k][0])-abs(j-vec[k][1]), (ll)0) != vec[k][2]) ok = false; 
    }
    if(ok) cout << i << " " << j << " " << c[i][j] << endl;
  }
  return 0;
}

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

int main()
{
    int N;
    string S;
    cin >> N >> S;
    int ret = 0;
    for(int i = 0;i < S.length()-2;i++){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
            ret++;
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int fibonacci(int n){
  int i;
  int num1 = 1;
  int num2 = 1;
  int tmp = 1;

  for(i = 1; i < n; i++){
    tmp = num1 + num2;
    num1 = num2;
    num2 = tmp;
  }

  return tmp;
}

int main(){
  int n;

  scanf("%d",&n);

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

  return 0;
}

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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
const int maxn=2e5+10;
int a[maxn];
int n,k;

bool check(int x){
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(a[i]<=x)continue;
		int y=(a[i]-1)/x;
		cnt+=y;
	}
	return cnt<=k;
}

int main(){
	io;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	int l=1,r=a[n],ans=-1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)){ r=mid-1;ans=mid; }
		else l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4352
A, B, C, D =  (int(j) for j in input().split()) 
import fractions

n = B - A + 1

CD = (C*D//fractions.gcd(C,D))

if A == B:
  print(int(not( A%C==0 or A%D==0 )))
elif C != D:
  print( n- ( (B//C - (A-1)//C) + (B//D - (A-1)//D) - (B//CD - (A-1)//CD) ) )
else:
  print( n- ( (B//C - (A-1)//C) ) )
  

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

int isPrime(int x);

int main(){
	int i,n,A[10000],count=0;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
		count+=isPrime(A[i]);
	}
	printf("%d\n",count);
	return 0;
}

int isPrime(int x){
	int i=3;

	if(x==2){
		return 1;
	}

	if(x<2 || x%2==0){
		return 0;
	}

	while(i<=sqrt(x)){
		if(x%i==0){
			return 0;
		}
		i=i+2;
	}
	return 1;
}

Measured memory_bytes: 632
a = int(input())
n = list(map(int, input().split()))

print(*n)

for i in range(1, a):
    v = n[i]
    j = i - 1
    while j >= 0 and n[j] > v:
        n[j+1] = n[j]
        j -= 1
        n[j+1] = v
    print(*n)


Measured memory_bytes: 5984
line=require("fs").readFileSync("/dev/stdin","utf8").split("\n"),n=parseInt(line[0]),v=line[1].split(" ");for(var odds={},even={},i=0;i<v.length;i++)di=1&i?even:odds,di[v[i]]=di[v[i]]?di[v[i]]+1:1;var a=[],b=[];for(var k in odds)a.push({v:k,n:odds[k]});for(var k in even)b.push({v:k,n:even[k]});a.sort((n,i)=>i.n-n.n),b.sort((n,i)=>i.n-n.n),a[0].v!=b[0].v&&(b[1]=b[0]),log=console.log,log(n-Math.max(a[0].n+(b[1]?b[1].n:0),(a[1]?a[1].n:0)+b[0].n));

Measured memory_bytes: 36328
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long int ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x,K;
  cin >> x >> K;
  ll ans = x%K;
  ll first = ans;
  ll second = abs(ans-K);
  while(first > second){
    ans = second;
    first = second;
    second = abs(first - K);
  }
  cout << ans << endl;
}

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

char data[102][102];
void DFS(char key,int i,int j){
  if(data[i][j]!=key)
    return;
  data[i][j]='0';
  DFS(key,i,j-1);
  DFS(key,i,j+1);
  DFS(key,i+1,j);
  DFS(key,i-1,j);
}
int main(){
  int cnt;
  while(1){
    cnt=0;
    for(int i=0;i<102;i++){
      for(int j=0;j<102;j++){
        data[i][j]='0';
      }
    }
    int H,W;
    cin>>H>>W;
    if(!H&&!W)
      break;
    for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
        cin>>data[i][j];
      }
    }
    //cout<<endl;
    for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
        if(data[i][j]!='0'){
          DFS(data[i][j],i,j);
          cnt++;
          //cout<<cnt<<endl;
          /*for(int k=1;k<=H;k++){
            for(int z=1;z<=W;z++){
              cout<<data[k][z];
            }
            cout<<endl;
          }*/
          //cout<<endl;
        }
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}



Measured memory_bytes: 3412