akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
const int maxnum = 1000;
int w[maxnum];			//w[i] -- the (i+1)th item's weight
int v[maxnum];			//v[i] -- the (i+1)th item's value
int maxvalue[999999]={0};
void knapsack(int N, int W, int *max, int *w);

int main()
{
	int N; //the total number of items
	int W; //the maximum load capacity
	cin>>N>>W;
	if( N<1 || N>100 || W<1 || W>10000)
	{
		cout<<"error"<<endl;
		return 1;
	}
	for(int i = 1;i <= N;i++)
	{
		cin>>v[i]>>w[i];
		if(v[i]<1 || v[i] > 1000 || w[i] < 1 || w[i] > 1000)
		{
			cout<<"error"<<endl;
			return 1;
		}
	}
	knapsack(N,W,maxvalue,w);
	cout<<maxvalue[W]<<endl;
	return 0;
}

void knapsack(int N, int W, int *maxvalue, int *w)
{
	for(int counter = 1;counter <= N;counter++)
	{
		for(int j=W;j>=0;j--)
		{
			if(j-w[counter] < 0)
			{
				break;
			}
			else
				if(maxvalue[j] <= maxvalue[j-w[counter]]+v[counter])
				{
					maxvalue[j] = maxvalue[j-w[counter]]+v[counter];
				}
				else
					maxvalue[j] = maxvalue[j];
		} 

	}
}

Measured memory_bytes: 3104
# -*- coding: utf-8 -*-
import numpy as np

def main():
    # 整数の入力
    N, L = map(int, input().split())
    each_aji = [L + i - 1 for i in range(1,N+1)]
    abs_arg_min = np.argmin(np.abs(each_aji))
    each_aji.pop(abs_arg_min)
    print(sum(each_aji))


if __name__=='__main__':
    main()


Measured memory_bytes: 12488
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int s=sc.nextInt();
		long[][] dp=new long[n][50*(n-1)+1];
		for(int i=0; i<n; i++){
			Arrays.fill(dp[i],Long.MAX_VALUE);
		}
		ArrayList<State>[] list=new ArrayList[n];
		for(int i=0; i<n; i++){
			list[i]=new ArrayList<>();
		}
		for(int i=0; i<m; i++){
			int u=sc.nextInt()-1;
			int v=sc.nextInt()-1;
			int a=sc.nextInt();
			long b=sc.nextLong();
			list[u].add(new State(v,a,b));
			list[v].add(new State(u,a,b));
		}
		int[][] cd=new int[n][2];
		for(int i=0; i<n; i++){
			cd[i][0]=sc.nextInt();
			cd[i][1]=sc.nextInt();
		}
		PriorityQueue<State> q=new PriorityQueue<>((x,y)->((x.time-y.time<0)?-1:1));
		if(s>50*(n-1)){
			s=50*(n-1);
		}
		q.add(new State(0,s,0));
		while(!q.isEmpty()){
			State ss=q.poll();
			if(ss.time>=dp[ss.to][ss.money]){
				continue;
			}else{
				dp[ss.to][ss.money]=ss.time;
			}
			if(ss.money+cd[ss.to][0]<=50*(n-1)){
				q.add(new State(ss.to,ss.money+cd[ss.to][0],ss.time+cd[ss.to][1]));
			}
			for(State i:list[ss.to]){
				if(ss.money-i.money>=0){
					q.add(new State(i.to,ss.money-i.money,ss.time+i.time));
				}
			}
		}
		for(int i=1; i<n; i++){
			long ans=Long.MAX_VALUE;
			for(int j=0; j<=50*(n-1); j++){
				ans=Math.min(ans,dp[i][j]);
			}
			System.out.println(ans);
		}
	}
	static class State{
		int to,money;
		long time;
		State(int to,int money,long time){
			this.to=to;
			this.money=money;
			this.time=time;
		}
	}
}

Measured memory_bytes: 64836
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

map <string, int> Mx;

char u[10050];
int main() {
	int N, M;
	scanf("%d", &N);
	while (N--) {
		scanf("%s", u);
		Mx[string(u)]++;
	}
	scanf("%d", &M);
	while (M--) {
		scanf("%s", u);
		Mx[string(u)]--;
	}

	int ans = 0;
	for (auto it : Mx) ans = max(ans, it.second);
	return !printf("%d\n", ans);
}

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

int main(){
  int num;
  const double PI=3.14159265;
  while(cin>>num){
    if(num==0) break;
    double area1=0.0,area2=0.0;
    int degree1=360,degree2=360;
    for(int i=0;i<num-1;i++){
      int d;
      cin>>d;
      area1+=1.0/2*sin(PI/180*d);
      degree1 -=d;
    }
    area1 += 1.0/2*sin(PI/180*degree1);

    cin>>num;
    for(int i=0;i<num-1;i++){
      int d;
      cin>>d;
      area2+=1.0/2*sin(PI/180*d);
      degree2 -=d;
    }
    area2 += 1.0/2*sin(PI/180*degree2);
    if(area1 > area2) cout<<1<<endl;
    else if(area1 < area2) cout<<2<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
package main

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

func main() {
	var n, m, k int
	fmt.Scan(&n, &m, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
	}
	bs := make([]int, m)
	for i := range bs {
		sc.Scan()
		bs[i], _ = strconv.Atoi(sc.Text())
	}

	sbs := make([]int, m+1)
	for i := range bs {
		sbs[i+1] += sbs[i] + bs[i]
	}

	var mi, mc int
	for i := 0; i <= n; i++ {
		ri := k - mi
		if ri < 0 {
			break
		}

		l := 0
		r := m + 1
		for r-l > 1 {
			mid := (l + r) / 2
			if sbs[mid] <= ri {
				l = mid
			} else {
				r = mid
			}
		}
		cnt := i + l
		mc = max(mc, cnt)
		if i < n {
			mi += as[i]
		}
	}
	fmt.Println(mc)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 9604
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  ll N,W;
  cin >> N >> W;
  vector<ll> w(N),v(N);
  rep(i,N)cin >> w[i] >> v[i];
  vector<vector<ll>> dp(110,vector<ll>(100010,INFL));

  for(int i = 1;i <= N;i++){
    dp[i][v[i-1]] = min(dp[i-1][v[i-1]],w[i-1]);
    for(int sumv = 0;sumv < 100010;sumv++){
      if(sumv >= v[i-1]){
        if(dp[i-1][sumv-v[i-1] != 0])dp[i][sumv] = min(dp[i][sumv],dp[i-1][sumv-v[i-1]]+w[i-1]);
        if(dp[i-1][sumv] != 0)dp[i][sumv] = min(dp[i][sumv],dp[i-1][sumv]);
      }else{
        if(dp[i-1][sumv] != 0)dp[i][sumv] = min(dp[i][sumv],dp[i-1][sumv]);
      }
    }
  }
  ll ans = 0;
  rep(sumv,100010){
    if(dp[N][sumv]<=W){
      ans = max(ans,sumv);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 87424
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
void abc042_a(){
    ll A,B,C; cin >> A >> B >> C;
    if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;}
    if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;}
    if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;}
    cout << "NO" << endl; return ;
}
// https://abc043.contest.atcoder.jp/tasks/abc043_a
void abc043_a(){
    ll N; cin >> N; cout << N*(N+1)/2 << endl;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    abc043_a();
	return 0;
}


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

const int INF = 1<<25;
int path[200][200] = {};

int main(){
    for(int i = 0; i < 200; i++){
        for(int j = 0; j < 200; j++){
            if(i == j)  continue;
            path[i][j] = INF;
        }
    }

    int n, m, R;
    cin >> n >> m >> R;
    
    int r[R];
    for(int i = 0; i < R; i++)  cin >> r[i];
    for(int i = 0; i < R; i++)  r[i]--;
    sort(r, r+R);

    int a, b, c;
    for(int i = 0; i < m; i++){
        cin >> a >> b >> c;
        a--; b--;
        path[a][b] = path[b][a] = c;
    }

    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(path[i][k] == INF || path[k][j] == INF)  continue;
                path[i][j] = min(path[i][j], path[i][k] + path[k][j]);
            }
        }
    }

    int ans = INT_MAX;
    do{
        int tmp = 0;
        for(int i = 0; i < R-1; i++){
            tmp += path[r[i]][r[i+1]];
        }
        ans = min(ans, tmp);
    }while(next_permutation(r, r+R));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define pb push_back
#define fst first
#define snd second
#define ALL(cont) cont.begin(), cont.end()
#define mset(a,b) memset(a,b,sizeof(a));
#define fore(i, a, b) for (int i = a, almo5t = b; i < almo5t; ++i)
#define SZ(x) ((int)x.size())
#define FIN ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int MOD = 1e9+7;
const int MAXN = 1e4+10;

string k;
int d;
ll dp[MAXN][110][2];

ll go(int pos, int mod, int menor){
    if(pos == SZ(k)) return mod ==0;
    ll &r = dp[pos][mod][menor];
    if(r!=-1) return r;
    r = 0;
    int act = k[pos]-'0';
    fore(i,0,10){
        if(menor || i<act)
            r+=go(pos+1,(mod+i+d)%d,1);
        else if(i==act){
            r+=go(pos+1,(mod+i+d)%d,0);
        }
        r%=MOD;
    }
    return r%MOD;
}

int main()
{
    FIN;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
#define endl '\n'
#endif

    cin>>k;
    cin>>d;
    mset(dp,-1);
    cout<<(go(0,0,0)-1+MOD)%MOD<<endl;
    return 0;
}


Measured memory_bytes: 21584
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstdlib>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#define fi first
#define se second
#define pb push_back
#define me(a,b) memset(a,b,sizeof(a))
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int MAX_N=200000+5;
const int INF=0x7fffffff;
const int inf=100000;
const double EPS=1e-6;
const ull base=123;
const ll mod=1e9+7;
const double pi=4*atan(1.0);
char chess[10][10];
int ans=0;
int n,m,k;
int used[10];
int pp=0;
void dfs(int r,int c,int sum)
{
    int i,j;
    int num=0;
    if(r==n&&c==m)
    {
        if(pp-sum==k)
            ans++;
        return;
    }
    if(r==n)
    {
        for(i=0; i<n; i++)
        {
            if(chess[i][c]=='#'&&(!used[i]))
            {
                num++;
            }
        }
        dfs(r,c+1,sum+num);
        dfs(r,c+1,sum);
    }
    else
    {
        for(i=0; i<m; i++)
        {
            if(chess[r][i]=='#')
            {
                num++;
            }
        }
        used[r]=1;
        dfs(r+1,c,sum+num);
        used[r]=0;
        dfs(r+1,c,sum);
    }
}
int main(void)
{

    cin>>n>>m>>k;
    int i,j;
    for(i=0; i<n; i++)
        scanf("%s",chess[i]);
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            if(chess[i][j]=='#')
            {
                pp++;
            }
        }
    }
    dfs(0,0,0);
    cout<<ans<<endl;
}

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

int main ()
{
    double w;
    while (cin >> w) {
        if (w <= 48.0) {
            cout << "light fly" << endl;
            continue;
        } else if (w <= 51.0) {
            cout << "fly" << endl;
            continue;
        } else if (w <= 54.0) {
            cout << "bantam" << endl;
            continue;
        } else if (w <= 57.0) {
            cout << "feather" << endl;
        } else if (w <= 60.0) {
            cout << "light" << endl;
            continue;
        } else if (w <= 64.0) {
            cout << "light welter" << endl;
            continue;
        } else if (w <= 69.0) {
            cout << "welter" << endl;
            continue;
        } else if (w <= 75.0) {
            cout << "light middle" << endl;
            continue;
        } else if (w <= 81.0) {
            cout << "middle" << endl;
            continue;
        } else if (w <= 91.0) {
            cout << "light heavy" << endl;
            continue;
        } else cout << "heavy" << endl;
    }

    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
 
using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl
 
template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }
 
const int INF = 1 << 30;
const ll INFL = 1LL << 60;
using pli = pair<ll, int>;
class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        map<int, vector<pii>> LRC;
        rep(i, M) {
            int l, r; ll c; cin >> l >> r >> c;
            l--; r--;
            LRC[l].push_back(pii(r, c));
        }
        priority_queue<pli, vector<pli>, greater<pli>> que;
        bool fail = false;
        for(pii p : LRC[0]) {
            que.push(pli(p.second, p.first));
        }
        repeat(i, 1, N-1) {
 
 
            if(not LRC.count(i)) continue;
            while(que.size() and que.top().second < i) {
                que.pop();
            }
            if(que.size() == 0) {
                fail = true;
                break;
            }
            ll now = que.top().first;
            for(pii p : LRC[i]) {
                que.push(pli(now + p.second, p.first));
            }
        }
        while(que.size() and que.top().second < N-1) {
            que.pop();
        }
        if(fail or que.size() == 0) cout << -1 << endl;
        else cout << que.top().first << endl;
        return 0;
    }
};
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

//何が、何回で残るか
pll calc(ll x, ll n) {
	if (n == 0)return pll(0, 0);
	if (n == 1)return pll(x,0);
	pll res = calc(x, n / 2);
	ll ans = 2 * res.second;
	deque<ll> deq;
	deq.push_back(res.first);
	if (n & 1)deq.push_back(x);
	deq.push_back(res.first);
	while (deq.size() >= 2) {
		ll next = deq.front();
		deq.pop_front();
		next += deq.front();
		deq.pop_front();
		ans++;
		if (next <= 9)deq.push_front(next);
		else {
			deq.push_front(next % 10);
			deq.push_front(next/10);
		}
	}
	return pll(deq.front(),ans);
}

pll calc(pll a, pll b) {
	deque<ll> deq;
	ll ans = 0;
	a = calc(a.first,a.second);
	deq.push_back(a.first);
	ans += a.second;
	b = calc(b.first, b.second);
	deq.push_back(b.first);
	ans += b.second;
	while (deq.size() > 1) {
		ll next = deq.front();
		deq.pop_front();
		next += deq.front();
		deq.pop_front();
		ans++;
		if (next <= 9)deq.push_front(next);
		else {
			deq.push_front(next % 10);
			deq.push_front(next / 10);
		}
	}
	return pll(deq.front(), ans);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll M;
	cin >> M;
	deque<pll> deq;
	for (ll m = 0; m < M; m++) {
		ll d, c;
		cin >> d >> c;
		deq.push_back(pll(d, c));
	}
	ll ans = 0;
	while (deq.size() > 1) {
		pll res = calc(deq.front(), deq[1]);
		deq.pop_front();
		deq.pop_front();
		ans += res.second;
		deq.push_front(pll(res.first, 1));
	}
	if (deq.front().second > 1) {
		pll res = calc(deq.front().first, deq.front().second);
		ans += res.second;
	}
	cout << ans << "\n";
	return 0;
}

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

ll A, B, C;

void agc014a() {
  if (A == B && B == C && C == A && A % 2 == 0) {
    cout << -1 << "\n";
    return;
  }
  ll res = 0;
  ll a = A, b = B, c = C;
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
    res++;
    ll a_tmp = a, b_tmp = b, c_tmp = c;
    a = b_tmp / 2 + c_tmp / 2;
    b = c_tmp / 2 + a_tmp / 2;
    c = a_tmp / 2 + b_tmp / 2;
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> A >> B >> C;
  agc014a();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long X, long long A){
  if(X<A)cout<<0<<endl;
  else cout<<10<<endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    solve(X, A);
    return 0;
}


Measured memory_bytes: 256
X = input()

Xzero = X.zfill(len(X)+3)
Xzero = Xzero[::-1]

simo = Xzero[0:2]
simo = int(simo[::-1])
kami = Xzero[2:len(Xzero)]
kami = int(kami[::-1])

n = 0
for i in range(20):
    if(simo <= i*5):
        break
    n += 1

if (kami >= n):
    print('1')
else:
    print('0')


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

nums=[0]*(10**5+1)
for i in a:
    nums[i]+=1

ans0=nums[0]+nums[1]+nums[2]
ans=ans0
for i in range(2,10**5-1):
    ans1=ans0-nums[i-2]+nums[i+1]
    ans=max(ans,ans1)
    ans0=ans1

print(ans)

Measured memory_bytes: 20560
#include <iostream>
using namespace std;
typedef long long ll;
int n;
ll a[100010];
ll b[100010];
ll c[100010];
ll d[100010];
ll h[2][100010];
const ll p = 1000000000+7;

int main(){
  cin >> n;
  for(int i=1;i<=n;++i)
    cin >> a[i];
  for(int i=1;i<=n;++i)
    cin >> b[i];
  ll ans = 1;
  for(int i=1;i<=n;++i){
    if(a[i]>a[i-1]){
      h[0][i] = a[i];
    }
    if(b[i]>b[i+1]){
      h[1][i] = b[i];
    }
  }
  bool f = true;
  if(a[n]!=b[1]) f = false;
  for(int i=1;i<=n;++i){
    if(h[0][i] && h[1][i] && h[0][i]!=h[1][i])
      f = false;
    if(!h[0][i] && !h[1][i])
      ans = (ans*min(a[i],b[i]))%p;
  }
  if(f){
    for(int i=1;i<=n;++i)
      if(!h[0][i])
	h[0][i] = h[1][i];
    for(int i=1;i<=n;++i){
      if(h[0][i]>min(a[i],b[i]))
	f=false;
    }
  }
  cout << f*ans << endl;
  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
main(){
  std::string s;
  std::cin>>s;
  bool c=false,f=false;
  for(auto x:s){
    if(x=='C')c=true;
    if(c&&x=='F')f=true;
  }
  std::cout<<(f?"Yes":"No")<<std::endl;
}

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

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a;
            string[] str = Console.ReadLine().Split(' ');
            x = int.Parse(str[0]);
            a = int.Parse(str[1]);
            if(x < a)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine("10");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e3 + 5, mod = 1e9 + 7;

int a[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n - 1; j++){
            int x = lower_bound(a + j + 1, a + n, a[i] + a[j]) - (a + j + 1);
            ans += x;
        }
    }
    cout << ans;

    return 0;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int a[8];
int P[8];
int Q[8];
int main(void){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> P[i];
  }
  for(int i = 0; i < N; i++){
    cin >> Q[i];
  }
  for(int i = 0; i < N; i++){
    a[i] = i + 1;
  }

  int p_ind;
  int q_ind;
  int perm_ind = 0;
  while(true){
    bool is_p = true;
    for(int i = 0; i < N; i++){
      if(a[i] != P[i]){
        is_p = false;
        break;
      }
    }
    if(is_p){
      p_ind = perm_ind;
    }

    bool is_q = true;
    for(int i = 0; i < N; i++){
      if(a[i] != Q[i]){
        is_q = false;
        break;
      }
    }
    if(is_q){
      q_ind = perm_ind;;
    }
    if(!next_permutation(a, a + N)){
      break;
    }
    perm_ind ++;
  }
  cout << abs(p_ind - q_ind) << endl;
  return 0;
}

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

int main() {
;
 long long  int a,b,c,d;
  
  cin >>a >> b >> c >> d;
  
  if(d < a){
    cout << d << endl;
  }
 
 else if(d <= a+b){
    cout << a << endl;
  }
    else{
      cout << a - (d-a-b) << endl;
    }
  
}
      
      
    


Measured memory_bytes: 3636
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String  S = sc.next();

        long sum = 0;
        for(int i=0;i<S.length();i++){
            sum += Integer.valueOf(S.charAt(i) - '0');
        }
        if(sum % 9 == 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}




Measured memory_bytes: 40280
<?php
fscanf(STDIN,"%d",$n);
$m_arr=explode(' ',trim(fgets(STDIN)));
$s_arr=array();
for($i=0;$i<$n;$i++){
	$s_arr[]=$i+1;
}

$chigau_arr=array();
for($t=0;$t<$n;$t++){
	if($m_arr[$t]<>$s_arr[$t]){
		$chigau_arr[]=$t;
	}
}

if(count($chigau_arr)==0){
	echo "YES";
}elseif(count($chigau_arr)==1){
	echo "NO";
}elseif(count($chigau_arr)<>2){
	echo "NO";
}else{
	echo "YES";
}
?>

Measured memory_bytes: 4728
<?php
fscanf(STDIN, "%s",$s);
$arr=str_split($s);
$n=count($arr);

$left = array_slice($arr, 0, ($n-1)/2);
$right = array_slice($arr,($n+1)/2);

function strong($list){
  $length = count($list);
  for($i=0;$i<=($length-1)/2;$i++){
    if($list[$i]==$list[$length-1-$i]){
      $bool=true;
    }else{
      $bool=false;
      break;
    }
  }
  return $bool;
};

$x=strong($arr);
$y=strong($left);
$z=strong($right);

if($x&&$y&&$z){
  echo "Yes";
} else {
  echo "No";
}

?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
  string s;
  cin >>n >>s >>k;
  for(int i=0;i<s.size();i++){
    if(s[i]!=s[k-1])s[i]='*';
  }
  cout << s <<endl;
}

Measured memory_bytes: 256
import itertools

n, m, q = map(int, input().split())
conds = [list(map(int, input().split())) for _ in range(q)]

elements = [i for i in range(1, m + 1)]
A = list(itertools.combinations_with_replacement(elements, n))

point_max = 0
for a in A:
    point = 0
    for c in conds:
        if a[c[1] - 1] - a[c[0] - 1] == c[2]:
            point += c[3]
    point_max = max(point_max, point)

print(point_max)

Measured memory_bytes: 21476
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long d = sc.nextLong();
        long D = d * d;
        int res = 0;
        for(int i = 0; i < n; i++){
            long x = sc.nextLong();
            long y = sc.nextLong();
            if(x * x + y * y > D)
                continue;
            else
                res++;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 60660
use input::Input;

fn main() {
    let mut input = Input::default();

    let a = input.parse();
    let ans = match a {
        'A'..='Z' => 'A',
        _ => 'a',
    };
    println!("{}", ans);
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


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

int main() {

  while(true) {

    int n,m,p,a,b;
    cin >> n >> m >> p >> a >> b;
    if ( n == 0 ) break;

    int input1,input2,input3;

    vector<int> t;
    for ( int i = 0; i < n; i++ ) {
      cin >> input1;
      t.push_back(input1);
    }

    int length[30][30] = {0};
    for ( int i = 0; i < p; i++ ) {
      cin >> input1 >> input2 >> input3;
      length[input1-1][input2-1] = input3;
      length[input2-1][input1-1] = input3;
    }

    double time[30][1<<8] = {0.0};

    for ( int i = 0; i < n; i++ ) {
      for ( int k = 0; k < (1<<n); k++ ) {
	int cnt = 0;
	int ticket = k;
	while( ticket != 0 ) {
	  if ( ( ticket & 1 ) != 0 ) cnt++;
	  ticket = ticket >> 1;
	}
	if ( cnt != i ) continue;
	ticket = k;

      for ( int j = 0; j < m; j++ ) {
	if ( ( j != a-1 || ticket != 0 ) && time[j][ticket] == 0.0 ) continue;

	for ( int x = 0; x < n; x++ ) {
	  if ( ( ticket & (1<<x) ) != 0 ) continue;

	  for ( int y = 0; y < m; y++ ) {
	    if ( length[j][y] == 0 ) continue;

	    double z = time[j][ticket] + 1.0 * length[j][y] / t[x];
	    if ( time[y][ticket+(1<<x)] == 0.0 || time[y][ticket+(1<<x)] > z ) time[y][ticket+(1<<x)] = z;

	  }
	}
      }
      }
    }

    double time_min = 0.0;
    for ( int i = 0; i < (1<<n); i++ ) {
      if ( time[b-1][i] != 0.0 && ( time_min == 0.0 || time_min > time[b-1][i] ) ) time_min = time[b-1][i];
    }
    if ( time_min != 0.0 ) {
      cout << fixed << time_min << endl;
    }else {
      cout << "Impossible" << endl;
    }

  }

  return 0;

}

Measured memory_bytes: 1356
maxLCM (a:b:xs) = maxLCM ([lcm a b] ++ xs)
maxLCM (a:[]) = a

sumAs as =
  let mx = maxLCM as
  in foldl (+) 0 . map (div mx) $ as

dived as =
  let mx = maxLCM as
  in map (div mx) $ as

main = do
  n <- getLine
  as <- (map read . words) <$> getLine
  print . flip mod 1000000007 . sumAs $ as

Measured memory_bytes: 12668
n,m,x=map(int,input().split())
n=[*range(1,n+1)];maxN=max(n)
a=list(map(int,input().split()))
count1,count2=0,0
for i in range(x,maxN+1):
  if i in a:
    count1+=1
for i in range(x,0,-1):
  if i in a:
    count2+=1
print(min(count1,count2))

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

int main() {

  int N , L;
  cin >> N >> L;

  vector<string> S(N);

  for(int i=0;i<N;i++){
    cin >> S[i];
  }

  sort(S.begin() , S.end());

  for(int i=0 ; i<N ; i++){
    cout << S[i] ;
  }
}

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

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

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

void enqueue(P x){
Q[tail]=x;
tail=(tail+1) % LEN;
}

P dequeue(){
P x=Q[head];
head=(head+1) % LEN;
return x;
}

int min(int a,int b){
return a < b ? a : b;
}

int main(){
int lap=0,c;
int i,q;
P a;
scanf("%d%d",&n,&q);

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

while(head != tail){
a=dequeue();
c=min(q,a.t);
a.t-=c;
lap+=c;
if(a.t > 0) enqueue(a);
else{
printf("%s %d\n",a.name,lap);
}
}
return 0;
}

Measured memory_bytes: 10752
N,M=map(int,input().split())
l=[]
for i in range(M):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())

ans=0
for t in range(2**N):
    tmp=[(t>>s)&1 for s in range(N)]
    light=True
    for i in range(M):
        cnt=0
        for j in range(len(l[i])):
            if tmp[l[i][j]-1]==1:
                cnt+=1
        if cnt%2 != p[i]%2:
            light=False
    if light:
        ans+=1

print(ans)

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

int main(){
    int N, M;
    std::cin >> N >> M;
    std::vector< int > L(M);
    std::vector< int > R(M);
    int Lmax = 0, Rmin = 1e9;
    for(int i=0; i<M; i++){
        std::cin >> L[i] >> R[i];
        
        if(Lmax < L[i]){
            Lmax = L[i];
        }
        
        if(Rmin > R[i]){
            Rmin = R[i];
        }
    }
    
    if(Lmax > Rmin){
        std::cout << 0 << std::endl;
    }else{
        std::cout << Rmin - Lmax + 1 << std::endl;
    }
    
    
    
    return 0;
    
}


Measured memory_bytes: 4044
#include<stdio.h>
int selectionsort(int a[],int n){
	int i,j,minj,t,count=0;
	for(i=0;i<n-1;i++)
	{
		minj=i;
		for(j=i;j<n;j++)
		{
			if(a[j]<a[minj])
			minj=j;
		}
		t=a[i];
		a[i]=a[minj];
		a[minj]=t;
		if(i!=minj)
		count++;
	}	
return count;	
}
int main(){
	int i,n,count;
	int a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	count=selectionsort(a,n);
	for(i=0;i<n;i++)
	{
		if(i>0)
		printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
	printf("%d\n",count);

	return 0;
	
} 


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    int a[N]={};
    int b[N]={};
    int A,t,q,counter=0;
   for(int i=0;i<M;i++){
   cin>>A>>t;
   if(A==1&&t==0){
   counter++;
   break;}
   else if(b[A-1]==0){
   a[A-1]=t;
   b[A-1]++;}
   else {
   if(a[A-1]==t){
   continue;}
   else{
   counter++;
   break;}}}
   if(N==1&&a[0]==0){
   cout<<0;}
   else if(counter==0){
   if(a[0]==0)
   a[0]=1;
   for(int i=0;i<N;i++){
   cout<<a[i];}}
   else
   cout<<-1<<endl;}
   


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
# define mp make_pair
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int n; cin >> n;
  vector<int> a(n), b(n);
  int maxi = 0;
  rep(i, n) {
    cin >> a[i];
    b[i] = a[i];
  }

  sort(ALL(b)); reverse(ALL(b));
  rep(i, n){
    if(a[i]==b[0]) cout << b[1] << endl;
    else cout << b[0] << endl;
  }
}


Measured memory_bytes: 4756
#include<bits/stdc++.h>
using namespace std;
char s[1234567];
char t[10]="keyence";
int main(){
    scanf("%s",s);
    int n=strlen(s);
    if (n<7) {puts("NO");return 0;}
    int l=0;
    while (l<7&&s[l]==t[l]) l++;
    int r=0;
    while (r<7&&s[n-1-r]==t[6-r]) r++;
    if (l+r>=7) puts("YES"); else puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define l long int
#define endl '\n'
#define pb push_back
#define pf pop.front()
using namespace std;
ll mod=1e9+7;


void solve()
{
l n;
cin>>n;
if(n == 1)
{
cout<<"0";
return;
}

ll a=1,b=1,c=1;
while(n--)
{
	a=(a*10)%mod;
	b=(b*9)%mod;
	c=(c*8)%mod;

}
ll ans =(a%mod+c%mod-(2*b)%mod)%mod;
if(ans<0)
ans+=mod;
cout<<ans<<endl;
}


int32_t main()
{
//FAST
l T=1;

while(T--)
{
solve();
}
}










Measured memory_bytes: 3584
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

for i in range(len(A)):
    A[i] -= 1

before = -100
manzoku = 0
for a in A:
    manzoku += B[a]
    if before == a - 1:
        manzoku += C[before]
    before = a

print(manzoku)


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

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

int n, A, B, C;
int l[8];

int dfs(int a, int b, int c, int cnt)
{
    if (cnt == n)
        if (min({a, b, c}) > 0)
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        else
            return 1e9;

    int ret0 = dfs(a, b, c, cnt + 1);
    int ret1 = dfs(a + l[cnt], b, c, cnt + 1) + 10;
    int ret2 = dfs(a, b + l[cnt], c, cnt + 1) + 10;
    int ret3 = dfs(a, b, c + l[cnt], cnt + 1) + 10;

    return min({ret0, ret1, ret2, ret3});
}

int main()
{

    cin >> n >> A >> B >> C;

    rep(i, n) cin >> l[i];

    OP(dfs(0, 0, 0, 0));
    return 0;
}

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,a;cin >> n >> a;

  cout << n * n - a;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include<stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))

int main(){
	int k,s,a,i,j;
	long ans=0;
	scanf("%d %d",&k,&s);
	a=(s+2)/3;
	for(i=a;i<=min(k,s);i++){
		if(s==i*3){
			ans++;
			continue;
		}
		j=0;
		if(s>=2*i) j++;
		if((s-i)%2==0) j++;
		ans+=3*j+6*(min(i,s-i)-(s-i+1)/2-j+1);
	}
	printf("%ld\n",ans);
	return 0;
}

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

#define ll long long 

int main(void)
{
    
   ll n,k,i,ans=9999999999;

   cin>>n>>k;
   std::vector<int> a(n+1,0);
   
   for(i=0;i<n;i++)cin>>a[i];

   vector<ll>dp(n+5,99999999);
   
   dp[0]=0;
   // dp[1]=abs(a[1]-a[0]);
   for(i=1;i<n;i++)
   {
    ll p=1;
    dp[i]=999999999;
    while(i-p>=0 && p<=k)
    {
      dp[i]=min(dp[i],dp[i-p]+abs(a[i]-a[i-p]));
      p++;
      // cout<<i<<" "<<p<<" "<<dp[i]<<endl;
    }
   }
   
   cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1408
from itertools import groupby
from statistics import median
from sys import exit

N = int(input())

line = ([(index, v) for index, v in enumerate(input())])


def types(line): return line[1]
def index(line): return line[0]


gp = groupby(sorted(line, key=types), types)

d = {}

for k, v in gp:
    indexes = set([i for i, value in v])
    d[k] = indexes

if 'R' not in d or 'G' not in d or 'B' not in d:
    print(0)
    exit()

delete = 0


for differ in range(1, N):
    for start in range(N):
        if start + differ*2 > N - 1:
            break

        i = line[start]
        j = line[start + differ]
        k = line[start + differ*2]

        if len({i[1], j[1], k[1]}) != 3:
            continue

        upper = max(i[0], j[0], k[0])
        lower = min(i[0], j[0], k[0])
        median_num = median([i[0], j[0], k[0]])
        if upper - median_num == median_num - lower:
            delete += 1

print(len(d['R']) * len(d['G']) * len(d['B']) - delete)


Measured memory_bytes: 80524
#include <iostream>

using namespace std;

int main(){
    int a[5];
    cin >> a[0];
    cin >> a[1];
    cin >> a[2];
    cin >> a[3];
    cin >> a[4];
    int max=0;
    int sum=0;
    max = a[0]%10;
    for(int i = 1; i<5;i++){
        if(max>a[i]%10&&a[i]%10!=0)max=a[i]%10;
  }
    
    for(int i = 0; i<5;i++){
    
    switch(a[i]%10){
        case 0:
          sum +=(a[i]);
          break;
        case 1:
          sum +=(a[i]+9);
          break;
        case 2:
          sum +=(a[i]+8);
          break;
        case 3:
          sum +=(a[i]+7);
          break;
        case 4:
          sum +=(a[i]+6);
          break;
        case 5:
          sum +=(a[i]+5);
          break;
        case 6:
          sum +=(a[i]+4);
          break;
        case 7:
          sum +=(a[i]+3);
          break;
        case 8:
          sum +=(a[i]+2);
          break;
        case 9:
          sum +=(a[i]+1);
          break;

        }

}
if(max==0){}
else  sum -= 10-max;


        cout << sum ;
    
    }


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int n, al = 0, bo = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    for(int i = 0; i < n; i++){
        sort(a.begin(), a.end());
        reverse(a.begin(), a.end());
    }
    for(int j = 0; j < n; j++){
        if(j% 2 == 0){
            al += a[j];
        }else{
            bo += a[j];
        }
    }
    cout << al - bo << endl;
    return 0;
}


Measured memory_bytes: 256
// Minesweeper
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int h,w;
    cin >> h >> w;
    string table[60];
    rep(i,h) cin >> table[i];
    // rep(i,h) cout << table[i] <<endl;

    //八方向を配列で埋め込む.
    vector<int> dx{1,1,0,-1,-1,-1,0,1};
    vector<int> dy{0,1,1,1,0,-1,-1,-1};

    rep(i,h){
        rep(j,w){
            if(table[i][j]=='#') continue;
            if(table[i][j]=='.'){
                int cnt = 0;
                rep(k,8){
                    int x = i + dx.at(k);
                    int y = j + dy.at(k);
                    if(x>=0 && x<h && y>=0 && y<w && table[x][y]=='#') ++cnt;
                }
                table[i][j] = char('0' + cnt);
            }
        }
    }
    rep(i,h) cout << table[i] <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main(void){
    string s;
    cin >> s;
    int start_point = 0, flag = 1;
    // cout << s.length() << endl;
    // cout << s.substr(start_point, 5) << endl;
    while(1) {
        if(s.length() == start_point){break;}
        else if(s.length() - start_point < 5){
            flag = 0;
            break;
        }
        //dreamがつく場合
        else if(s.substr(start_point, 5) == "dream"){
            //dream単体だと判定
            if(s.substr(start_point+5, 2) != "er" || s.substr(start_point+5, 5) == "erase" ){
                start_point += 5;
            }
            //dreamer単体だと判定
            else if(s.substr(start_point+5, 2) == "er" && s.substr(start_point+5, 5) != "erase"){
                start_point += 7;
            }
        }
        //eraseがつく場合
        else if(s.substr(start_point, 5) == "erase"){
            //erase単体だと判定
            if(s.substr(start_point+5, 1) != "r"){
                start_point += 5;
            }
            //eraser単体だと判定
            else if(s.substr(start_point+5, 1) == "r"){
                start_point += 6;
            }
        }
        else{
            flag = 0;
            break;
        }
    }

    if(flag == 1){cout << "YES" << endl;}
    else{cout << "NO" << endl;}
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, D, A, x, h;
plint arr[200000];
lint sums[200001];

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> D >> A;
	REP(i, N) {
		cin >> x >> h;
		arr[i] = { x, (h - 1) / A + 1 };
	}
	sort(arr, arr + N);
	lint cnt = 0, right_idx = 0;
	REP(i, N) {
		if (i != 0) sums[i] += sums[i - 1];
		lint damage = max(0ll, arr[i].second + sums[i]);
		sums[i] -= damage;
		cnt += damage;
		while (right_idx < N && arr[right_idx].first - arr[i].first <= 2 * D) {
			right_idx++;
		}
		sums[right_idx] += damage;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;  b--;  c--;  d--;
    string s;
    cin >> s;
    ll m = s.size();

    exrep(i, a, d-1) {
        if(s[i] == '#' && s[i+1] == '#') {
            out("No");
            re0;
        }
    }
    
    if(c < d) {
        out("Yes");
        re0;
    }
    else if(d < c) {
        exrep(i, b-1, min(m-3, d-1)) {
            if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') {
                out("Yes");
                re0;
            }
        }
        out("No");
        re0;
    }
    
    re0;
}

Measured memory_bytes: 640
n = int(input())
A = list(map(int, input().split()))
 
B = [0]*n
ans = []
 
for i in range(n-1,-1,-1):
    if sum(B[i::i+1])%2!=A[i]:
        B[i] = 1
        ans.append(i+1)
print(len(ans))
print(*ans)

Measured memory_bytes: 18240
# D
n = int(input()) 
ans_list = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]
print(' '.join(map(str, ans_list[:n])))

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

int main()
{
    std::string a,b;
    std::cin >> a >> b;
    if(a[0] == b[2] && a[1]==b[1]&&a[2] == b[0]){
        std::cout << "YES"<<std::endl;
    }else{
        std::cout <<"NO"<<std::endl;
    }
    return 0;
}

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

int main(){
int a,b;
cin >> a>> b;
if(a<b){
for(int i=0; i<b; i++)
cout << a ;}
else {for(int i = 0;i<a;++i) cout << b;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n, m, dp[100009];
vector<int> e[100009];

int dfs(int x) {
    if(!dp[x]) rep(i, e[x].size()) chmax(dp[x], dfs(e[x][i]) + 1);
    return dp[x];
}

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

    cin >> n >> m;
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        e[x].push_back(y);
    }

    int ans = 0;
    FOR(i, 1, n + 1) chmax(ans, dfs(i));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8192
def func():
    return

# n = int(input())
# s = input()
a, b, c, d = map(int, input().split())
# a = list(map(int, input().split()))
# a = input().split()

while True:
    c -= b
    if c <= 0:
        ans = "Yes"
        break

    a -= d
    if a <= 0:
        ans = "No"
        break

print(ans)

Measured memory_bytes: 61756
#include <stdio.h>

int abs(int a) {
	return a>0 ? a : -a;
}

int main() {
	int n, l;
	int N, M;

	int students[50][2];
	int points[50][2];

	scanf("%d %d", &N, &M);

	for (int i = 0; i<N; i++)
		scanf("%d %d", &students[i][0], &students[i][1]);

	for (int i = 0; i<M; i++)
		scanf("%d %d", &points[i][0], &points[i][1]);

	for (int i = 0; i<N; i++) {
		l = 2100000000;
		for (int j = 0; j<M; j++) {
			if (abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1])<l) {
				l = abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1]);
				n = j;
			}
		}printf("%d\n", n+1);
	}

	return 0;
}

Measured memory_bytes: 128