akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

class ATheNumberOfEvenPairs {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N, M; in >> N >> M;
	    out << N*(N-1)/2 + M*(M-1)/2 << '\n';
	}
};


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

	ATheNumberOfEvenPairs solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> ar(h, vector<char>(w));
    rep(i,h) rep(j,w) cin >> ar[i][j];
    vector<vector<int>> co(h,vector<int>(w,INF));
    vector<P> k;
    rep(i,h) rep(j,w) if (ar[i][j] == '#'){
        k.emplace_back(P(i,j));
        co[i][j] = 0;
    }
    vector<int> dx = {0,1,0,-1};
    vector<int> dy = {1,0,-1,0};
    queue<P> qq;
    rep(i,k.size()) qq.push(k[i]);
    while (!qq.empty()){
        P pq = qq.front(); qq.pop();
        int x = pq.first;
        int y = pq.second;
        int c = co[x][y] + 1;
        rep(j,4){
            if (range(0,h,x+dx[j])&&range(0,w,y+dy[j])&&co[x+dx[j]][y+dy[j]]==INF){
                co[x+dx[j]][y+dy[j]] = c;
                qq.push(P(x+dx[j],y+dy[j]));
            }
        }
    }
    int ans = 0;
    rep(i,h) rep(j,w) ans = max(ans,co[i][j]);
    cout << ans << endl;
}

Measured memory_bytes: 21224
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,r=0,i,res=0;
  string s;
  cin >> n >> s;
  for(i=0;i<n;i++)
    if(s[i]=='R')
      r++;
  for(i=0;i<r;i++)
    if(s[i]=='W')
      res++;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3752
def main():
    d = int(input())
    a = []
    for _ in range(d):
        a.append(int(input()))

    for x in range(len(a)):
        print("Case ",end = "")
        print(x+1, end = "")
        print(":")
        for _ in range(10):
            a[x] = str("{0:08d}".format(a[x] ** 2))
            hoge = ""
            for y in range(2, 6):
                hoge += a[x][y]
            hoge = int(hoge)
            a[x] = hoge
            print(a[x])


if __name__ == "__main__":
    main()

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);

int main(){
	ll H,N;
	cin >> H >> N;
	vector<ll> A(N);
	FOR(i,0,N) cin >> A[i];

	FOR(i,0,N) H-=A[i];

	if(H<=0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}


}


Measured memory_bytes: 1024
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

private fun gcd(a: Long, b: Long): Long = if (b > 0) { gcd(b, a % b) } else { a }

private fun lcm(a: Long, b: Long): Long = a / gcd(a, b)* b

private fun solve() {
    val n = nextInt()
    val m = nextInt()
    val a = Array(n) { nextInt() / 2 }
    var l: Long = a[0].toLong()
    for (i in 1 until n) {
        l = lcm(l, a[i].toLong())
        if (l > m) {
            println(0)
            return
        }
    }
    for (i in 0 until n) {
        if (l / a[i] % 2 == 0L) {
            println(0)
            return
        }
    }
    println((m / l - 1) / 2 + 1)
}

fun main(args: Array<String>) {
    solve()
    out.close()
}

private var br = BufferedReader(InputStreamReader(System.`in`))
private var st: StringTokenizer? = null
private var out = PrintWriter(System.out)

@Throws(IOException::class)
private fun next(): String {
    while (st == null || !st!!.hasMoreTokens()) {
        st = StringTokenizer(br.readLine())
    }
    return st!!.nextToken()
}

@Throws(IOException::class)
private fun nextInt(): Int {
    return next().toInt()
}

@Throws(IOException::class)
private fun nextLong(): Long {
    return next().toLong()
}

Measured memory_bytes: 45820
#include <iostream>
#include <math.h> 


using namespace std;


int main()
{
	int N;
	cin >> N;
	int tmp;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		if(!(i%2) && tmp % 2)
			cnt++;
	}
	cout <<  cnt;
	return 0;
}

Measured memory_bytes: 3632
N = int(input())
A = sorted(map(int, input().split()))
sum_A = sum(A)
count = N
for i in range(N - 1, -1, -1):
    sum_A -= A[i]
    if (sum_A) * 2 >= A[i]:
        continue

    else:
        if (i == 0):
            continue
        count -= len(A[0:i])
        break

print(count)


Measured memory_bytes: 20468
#include<stdio.h>
int main()
{
int a[10];
int i,j,t;
for(i=0;i<10;i++){
  scanf("%d",&a[i]);}
for(j=0;j<9;j++){
  for(i=0;i<9-j;i++){
    if(a[i]<a[i+1])
      {t=a[i];a[i]=a[i+1];a[i+1]=t;}
                    }
                 }
for(i=0;i<3;i++){
   printf("%d\n",a[i]);}

return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;


int DP[200100][4];
int aoki[4];
int lim[4];

void add_aoki(int a){
    aoki[a] = min(aoki[a]+1, lim[(a+2)%4]);
}

int trans(char c){
    int ret;
    if(c == 'U') ret = 0;
    else if(c == 'R') ret = 1;
    else if(c == 'D') ret = 2;
    else if(c == 'L') ret = 3;
    return ret;
}

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    int sr, sc;
    cin >> sr >> sc;
    sr--, sc--;

    string S, T;
    cin >> S >> T;

    lim[0] = sr;
    lim[2] = H - sr - 1;
    lim[3] = sc;
    lim[1] = W - sc - 1;

    DP[0][trans(S[0])]++;
    for(int i = 1; i < N; i++){
        int t = trans(S[i]);
        int a = trans(T[i-1]);
        a = (a+2)%4;
        if(DP[i-1][a] > 0){
            DP[i][a] -= 1;
        }
        else
            add_aoki(a);

        DP[i][t] += 1;
        for(int j = 0; j < 4; j++){
            DP[i][j] += DP[i-1][j];

            int dp = DP[i][j];
            int a = aoki[j];
            if(dp > 0 && a > 0){
                DP[i][j]--;
                aoki[j]--;
            }
        }
    }

    bool ans = false;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 4; j++){
            int dp = DP[i][j];
            if(dp > lim[j]){
                ans = true;
            }
        }
    }

    if(ans){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 3848
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int n,k,s[200005],ans=0;
int main(){
	cin>>n>>k;
	for(int i=1,x;i<=n;i++)cin>>x,s[i]=s[i-1]+x;
	for(int i=k;i<=n;i++)ans=max(ans,s[i]-s[i-k]);
	printf("%.10lf\n",1.0*(ans+k)/2);
}


Measured memory_bytes: 1024
from collections import deque

n, m, k = map(int, input().split())

#listを組むより早い
friends = [set() for _ in range(n)]
blocks = [set() for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    friends[a-1].add(b-1)
    friends[b-1].add(a-1)

for i in range(k):
    c, d = map(int, input().split())
    blocks[c-1].add(d-1)
    blocks[d-1].add(c-1)

q = deque()
ans = [0] * n
visited = [0] * n

for i in range(n):
    if visited[i]:
        continue
    #集合を構築していく
    group = {i}
    visited[i] = 1
    q.append(i)
    while q:
        k = q.popleft()
        for j in friends[k]:
            if not visited[j]:
                q.append(j)
                group.add(j)
                visited[j] = 1
    
    # できた集合内でとりあえず計算
    for l in group:
        ans[l] = len(group) - len(blocks[l] & group) - len(friends[l] & group) - 1
print(*ans)
#print(*ans,sep="\n")

Measured memory_bytes: 80692
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n;
    static int[] aice;
    public static void main(String[] args) {
        while(read()){
            solve();
        }
    }

    static boolean read(){
        n = sc.nextInt();
        if(n == 0)return false;

        aice = new int[10];
        for(int i = 0; i < n; i++){
            aice[sc.nextInt()]++;
        }
        return true;
    }

    static void solve(){
        for(int i = 0; i < aice.length; i++){
            if(aice[i] == 0){
                System.out.print("-");
            }else for(int j = 0; j < aice[i]; j++)System.out.print("*");
            System.out.println();
        }
    }

}

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

int main()
{
	int i, x[100], count = 0;
	for (i=0; i<5; i++)
		cin>>x[i];
	for (i=0; i<5; i++)
	{
		count++;
		if (x[i] == 0)
			cout<<count<<"\n";
	}
}


Measured memory_bytes: 3620
#include <iostream>
#include <map>
using namespace std;
long long n;
map <long long,long long> mp;
inline long long f(long long x)
{
	if(mp[x]) return 0;
	mp[x]=1;
	if(x==1) return 0;
	long long t=n;
	while(t%x==0) t/=x;
	return t%x==1; 
}
int main(int argc, char** argv) {
	cin >> n;
	long long ans=0;
	for(long long i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ans+=f(i);
			if(i*i!=n) ans+=f(n/i); 
		}
	}
	for(long long i=1;i*i<=n-1;i++)
	{
		if((n-1)%i==0)
		{
			ans+=f(i);
			if(i*i!=n) ans+=f((n-1)/i);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vvll vector<ll>
#define vll(a) vector<ll> a(MAXN)
#define pb push_back
#define fo(a) for(auto&a1:(a))
#define fd(a,b) for(int i=(a);i>=(b);i--)
#define fk(a,b) for(int k=(a);k<(b);k++)
#define fj(a,b) for(int j=(a);j<(b);j++)
#define f(a,b) for(ll i=(a);i<(b);i++)
#define forni(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define fdk(a,b) for(int k=(a);k>=(b);k--)
#define fdj(a,b) for(int j=(a);j>=(b);j--)
#define ri(n) scanf("%d",&(n));
#define rll(n) scanf("%lld",&(n));
#define T(t) int t;scanf("%d",&(t));while((t)--)
#define MAXN 100005
#define MAXN2 10000005
#define pll pair<ll,ll>
#define PI 3.14159265
#define mset(a) memset((a),0,sizeof((a)))
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll mod=1000000007;
vector<ll> tr[MAXN];
ll vis[MAXN];
ll dfs(int node)
{
    if(vis[node])
    return vis[node];
    ll mx=1;
    fo(tr[node])
    mx=max(mx,1+dfs(a1));
    return vis[node]=mx;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    f(0,m)
    {
        ll t1,t2;
        cin>>t1>>t2;
        tr[t1].pb(t2);
    }
    ll ans=0;
    f(1,n+1)
    if(!vis[i])
    ans=max(ans,dfs(i));
    cout<<ans-1<<"\n";
    return 0;
}


Measured memory_bytes: 11724
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(long long N, std::vector<std::string> S){
  ll ac = 0,wa = 0,tle = 0 , re = 0;
  for (int i = 0; i < N; i++) {
    if(S[i] == "AC")ac++;
    if(S[i] == "WA")wa++;
    if(S[i] == "TLE")tle++;
    if(S[i] == "RE")re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

int main(){
    long long N;
				scanf("%lld",&N);
				std::vector<std::string> S(N);
				for(int i = 0 ; i < N ; i++){
								std::cin >> S[i];
				}
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 6432
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
int a[200010],b[200010];
int f[200010],g[200010];
int n,m;
int main(){
	cin>>n;
	rep(i,1,n)cin>>a[i];
	rep(i,1,n)if(i==0||a[i]!=a[i-1])m++,b[m]=a[i];
	n=m;
	rep(i,1,n)a[i]=b[i];
	f[0]=1LL,g[a[1]]=1LL;
	rep(i,1,n)f[i]=g[a[i]],g[a[i+1]]=(g[a[i+1]]+f[i])%1000000007;
	cout<<f[n]<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;


int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int N,M, W,w[200],v[200],dp[105][105][305];
	cin >> N >> M;
	if (abs(N - M) >= 2) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Brown" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int a,b,c;cin>>a>>b>>c;
    int _max=max({a,b,c});
    int diff=3*_max-a-b-c;
    if(diff%2==0)cout<<diff/2<<endl;
    else cout<<diff/2+2<<endl;
}

Measured memory_bytes: 3632
k = int(input())

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[k-1])


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
long long res,l;
int main()
{
  string s;
  cin>>s;
  l=s.size();
  rep(i,l)res+=((9*pow(10,l-1-i)-pow(2,l-1-i))/8)*pow(2,i)*(s[i]-'0');
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
 
/* short */
#define pb push_back
#define print(x) cout << x << '\n'
 
/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = INT_MAX;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}


signed main()
{
  ios::sync_with_stdio(false);
  int t; cin >> t;
  for (;t--;){
    int n; cin >> n;
    vi a(n);
    REP(i, n) cin >> a[i];
    int upT = 0, downT = 0;

    REPS(i, 1, n){
      if (a[i - 1] < a[i]){
        upT = max(upT, a[i] - a[i - 1]);
      } else {
        downT = max(downT, a[i - 1] - a[i]);
      }
    }
    cout << upT << " " << downT << endl;
  }

  return (0);
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin>>s;
  vector<int> n(4);
  for( int i=0; i<4; ++i){
    n[i] = stoi(s.substr(i,1));
  }
  for( int i=0; i < ( 1 << 3); ++i){
    int ans=n[0];
    for( int j=0; j<3; ++j){
      if( i & ( 1 << j)){
        ans += n[j+1];
      }
      else{
        ans -= n[j+1];
      }
    }
    if ( ans == 7){
      string t;
      t += to_string(n[0]);
      for( int j=0; j<3; ++j){
        if( i & ( 1 << j)){
          t += '+';
        }
        else{
          t += '-';
        }
        t += to_string(n[j+1]);
      }
      cout << t << "=7" << endl; break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int isPrime(int);

int main()
{
    int n,i,count=0,input;
    scanf("%d",&n);
   for ( i = 0; i < n; i++)
   {
       scanf("%d",&input);
       if (isPrime(input)==1)
       {
           count++;
       }
   }
   printf("%d\n",count);

   return 0;
}

int isPrime(int input)
{
    int i;
    if(input<2)
        return 0;
    if(input==2)
        return 1; 
    for(i=2;i<=sqrt(input);i++)
    {
     if(input%i==0)
        return 0;
    }
    return 1;
}


Measured memory_bytes: 2096
#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 <list>
#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(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#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<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int N;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	rep(i,N){
		int x,y,b,p;
		cin>>x>>y>>b>>p;
		int ans=x*b+y*p;
		ans=min(ans,(x*max(b,5)+y*max(p,2))/5*4);
		cout<<ans<<endl;
	}
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n; cin >> n;
    V<ll> a(n);
    for(int i = 0; i < n; i++){
        ll x; cin >> x;
        x -= (i + 1);
        a[i] = x;
    }

    sort(ALL(a));
    ll m = a[n / 2];
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += abs(a[i] - m);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 4756
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    if((B - A) % 2 == 0)
        cout << "Alice" << endl;
    else
        cout << "Borys" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process(int test_number)throws IOException
    {
        int x = ni();
        int kyu = 0;

        if(x >= 400 && x <= 599) kyu = 8;
        else if(x >= 600 && x <= 799) kyu = 7;
        else if(x >= 800 && x <= 999) kyu = 6;
        else if(x >= 1000 && x <= 1199) kyu = 5;
        else if(x >= 1200 && x <= 1399) kyu = 4;
        else if(x >= 1400 && x <= 1599) kyu = 3;
        else if(x >= 1600 && x <= 1799) kyu= 2;
        else kyu = 1;

        pn(kyu);
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 36488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define repins(a,n) vector<string> a(n);rep(i,n){cin>>a[i];}
#define repind(a,n) vector<double> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define ins(a) string a;cin>>a;
#define ind(a) double a;cin>>a;
template <class T>
inline void out(T a) { cout << a << endl; }
inline void out(double a) { printf("%.10f\n", a); }
#define all(x) (x).begin(), (x).end()
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define yes out("Yes");
#define no out("No");

int main()
{
    in(n);
    ins(s);

    if(n<=3){
        out(0);
        return 0;
    }

    ll r = 0, g = 0, b = 0;
    for (auto c : s) {
        if (c == 'R') ++r;
        else if (c == 'G') ++g;
        else ++b;
    }
    ll ans = r * g * b;

    rep(i,n){
        rep2(j,i+1,n){
            if (s[i] == s[j]) continue;
            ll k = j*2-i;
            if (k >= n || s[k] == s[i] || s[k] == s[j]) continue;
            --ans;
        }
    }
    out(ans);
}

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

n_ac = 0
n_wa = 0
n_tle = 0
n_re = 0

for i in range(n):
    x = input()
    if x == "AC":
        n_ac += 1
    elif x == "WA":
        n_wa += 1
    elif x == "TLE":
        n_tle += 1
    elif x == "RE":
        n_re += 1


print(
    "AC x " + str(n_ac) + "\n"
    + "WA x " + str(n_wa) + "\n"
    + "TLE x " + str(n_tle) + "\n"
    + "RE x " + str(n_re)
)

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

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

    ll N,R;
    cin >> N;
    cin >> R;

    if (N >= 10){
        cout << R;
    }
    else{
        cout << R + (100 * (10 - N));
    }
}

Measured memory_bytes: 256
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def calc_sum_of_power(N, coord):
    spot = round(sum(coord)/N)
    return sum([(x - spot)**2 for x in coord])

def main():
    N = int(input())
    coord = list(map(int, input().split()))
    print(calc_sum_of_power(N, coord))

if __name__ == "__main__":
    try:
        assert calc_sum_of_power(2, [1, 4]) == 5
        assert calc_sum_of_power(7, [14, 14, 2, 13, 56, 2, 37]) == 2354
    except:
        import traceback
        traceback.print_exc()
        exit()
    main()


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

using namespace std;

#define lli long long
#define ld long double
#define mod 1000000007 
#define set(n) cout << fixed << setprecision(n)    
#define fi first
#define se second
#define mp make_pair
#define pll pair<lli, lli>
#define endl '\n'

const double PI = acos(-1);
const double epsilon = 1e-7;  // floating point precision

signed main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int md = 0;
    for(int i = 0; i < s.length(); i++) {
        md = (md * 10 + ((int)(s[i] - '0')) % 9) % 9;
    }
    if(md == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3752
#include <iostream>

using namespace std;

class B {
	int n;
	int64_t a{ 2 }, b{ 1 }, tmp;
public:
	void solve()
	{
		cin >> n;
		if (n == 1) cout << 1 << endl;
		else 
		{
			for (int i{ 2 }; i <= n; i++)
			{
				tmp = a + b;
				a = b;
				b = tmp;
			}

			cout << tmp << endl;
		}
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	if(k>=n)cout<<n*x<<endl;
	else cout<<(k*x)+((n-k)*y)<<endl;
    return 0;
}


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

const int OTHERS = 0;
const int FRIEND = 1;
const int BLOCK = -1;

struct UnionFind
{
    vector<int> d;
    UnionFind(int n = 0)
    {
        d = vector<int>(n, -1);
    }
    int find(int x)
    {
        if (d[x] < 0)
        {
            return x;
        }

        return d[x] = find(d[x]);
    }

    bool unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return false;
        if (d[x] > d[y])
            swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int deg[100005];
vector<int> to[100005];
int main(void)
{
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        uf.unite(a, b);
        deg[a]++;
        deg[b]++;
    }

    for (int i = 0; i < k; i++)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    for (int i = 0; i < n; i++)
    {
        int ans = uf.size(i) - 1 - deg[i];
        for (int u : to[i])
        {
            if (uf.same(i, u))
            {
                --ans;
            }
        }
        cout << ans << " ";
    }
    return 0;
}

Measured memory_bytes: 6784
#include<algorithm>
#include<string>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
 
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    int ans = min(a,b) + min(c,d);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])
a0 = []
for _ in range(n):
    i = 0
    x = a[_]
    while 1:
        if x % 2 == 0:
            x = x / 2
            i += 1
        else:
            break
    a0.append(i)
print(sum(a0))


Measured memory_bytes: 3892
from itertools import accumulate

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

mod = 10 ** 9 + 7

dp = [0] * (K + 1)
dp[0] = 1

for i in range(N):
    acc_dp = [0] + list(accumulate(dp))

    cand_dp = [0] * (K + 1)
    for k in range(K + 1):
        cand_dp[k] = acc_dp[k + 1] - acc_dp[max(0, k - a_list[i])]
        cand_dp[k] %= mod
    dp = cand_dp
print(dp[K])


Measured memory_bytes: 120856
while True:
    a,b,c=input().split()
    a=int(a)
    c=int(c)
    if b=='?':
        break
    elif b=='+':
        print(a+c)
    elif b=='-':
        print(a-c)
    elif b=='*':
        print(a*c)
    else:
        print(a//c)


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

int main() {
  using LL = long long;

  int N;
  cin >> N;
  vector<LL> A(N);
  for(auto& i: A) cin >> i;

  const LL NG = -1e18;
  vector<map<int, LL>> memo(N);
  function<LL(int,int)> dfs = [&](int i, int n) {
    if(n == 0) return 0ll;
    if(N <= i) return NG;
    if(N < i+2*n-1) return NG;
    if(memo[i][n]) return memo[i][n];
    return memo[i][n] = max(dfs(i+1, n), A[i]+dfs(i+2, n-1));
  };

  cout << dfs(0, N/2) << endl;
}


Measured memory_bytes: 43912
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  int best = 0;
  for (int k = 0; k < (1 << n); ++k) {
    int cur = 0;
    for (int i = 0; i < n; ++i) {
      if (k & (1 << i)) cur += a[i] - b[i];
    }
    best = max(best, cur);
  }
  cout << best << endl;
  return 0;
}


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

int main()
{
    string S;
    cin >> S;

    for (int i = 0; i < S.size(); i++) {
        cout << 'x';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
from math import sin, cos, pi
a,b,c = [float(i) for i in input().split()]
print("{:.8f}".format(0.5*a*b*sin(pi/180*c)))
print("{:.8f}".format(a+b+(a**2+b**2-2*a*b*cos(pi/180*c))**0.5))
print("{:.8f}".format(b*sin(pi/180*c)))


Measured memory_bytes: 5716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    char s[100020],lowcmp[27]="bcdefghijklmnopqrstuvwxyza" ;
    int k,i;
    scanf("%s%d",s,&k);
    int p[strlen(s)];
    for (i=0; i<strlen(s); i++){
        for (int j=0; j<26; j++){
            if (s[i]==lowcmp[j]){
                p[i]=25-j;
            }
        }
    }
    for (int i=0; i<strlen(s); i++){
        if (k>=p[i]){
            k-=p[i];
            s[i]='a';
        }
    }
    k=k%26;
    while (k!=0){
        s[strlen(s)-1]++;
        k--;
    }
    printf("%s\n",s);
	return 0 ;
}

Measured memory_bytes: 768
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s =sc.next();
        int cnt=0;

        for(int i =0;i<=n-3;i++){
            if(s.substring(i,i+3).equals("ABC")){
                cnt++;
            }
            //System.out.println(s.substring(i,i+3));
        }
        System.out.println(cnt);

    }
}


Measured memory_bytes: 22868
#include<stdio.h>
int main(){
int a[100],i,n,ans=0;
  scanf("%d",&n);
  scanf("%d",&a[0]);
  for(i=1;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]==a[i-1]){a[i]=10001;ans++;}
  }
  printf("%d",ans);
  return 0;

  }

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

int n;
cin >> n;
vi a(n+1),b(n);
rep(i,n+1)cin >> a[i];
rep(i,n)cin >> b[i];
ll ans=0;
rep(i,n){
    ll temp=min(a[i],b[i]);
    ans+=temp;
    a[i]-=temp;
    b[i]-=temp;
    temp=min(a[i+1],b[i]);
    ans+=temp;
    a[i+1]-=temp;
    b[i]-=temp;
}
fin(ans);

//////////////////////////////////////////////////////
return 0;}

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

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

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

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

    while(q--){
        int a, b;
        cin >> a >> b;
        int ax = lower_bound(A.begin(), A.end(), a) - A.begin();
        int bx = upper_bound(A.begin(), A.end(), b) - A.begin();
        cout << bx - ax << endl;
    }

    return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;


int main() {
	int N;
	cin >> N;
	vector<int> D;
	for(int i=0; i<N; i++) {
		int p;
		cin >> p;
		D.push_back(p);
	}
	
	int zero = 0;
	vector<int> cnt(13, 0);
	for(int i=0; i<D.size(); i++) {
		cnt[D[i]] ++;
	}
	if(cnt[0] == 1) zero=1;
	for(int i=0; i<13; i++)
		if(cnt[i] > 2) zero = 1;
	if(zero) {
		cout << 0 << endl;
		return 0;
	} 
	
	
	int maxim = 0;
	for(int b=0; b<(1<<N); b++) {
		vector<int> res(25, 0);
		
		for(int i=0; i<N; i++) {
			if( (b & (1<<i)) > 0) res[D[i]] += 1;
			else res[24-D[i]] += 1;
		}
		int minim = 24;
		for(int i=0; i<24; i++)
			if(res[i] == 2) minim = 0;
			
		res[0]++;
		res[24]++;
		int prev = 0;
		for(int i=1; i<=24; i++) {
	//		cout << res[i] << " ";
			if(res[i] >= 1) {
				minim  = min(minim, i - prev);
				prev = i;
			}
		}
//		cout << endl;
		maxim = max(maxim, minim);
		
		
	}
	cout<< maxim << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n,cnt=0;
  string str,ans="YES";
  
  cin >> n;
  while(n--){
    
    cin >> str;
    
    if(str == "A") cnt++;
    
    else if(str == "Un"){
      cnt--;
      if(cnt < 0) ans = "NO";
    }
    
  }
  
  if(cnt != 0) ans = "NO";
  
  cout << ans << endl;
  return(0);
}



Measured memory_bytes: 3200
n = int(input())
l = [[i for i in input().split()] + [j + 1] for j in range(n)]
l.sort(key=lambda x:x[0])

k = [0]
for i in range(len(l) - 1):
    l[i][1] = int(l[i][1])
    if (l[i][0] != l[i + 1][0]):
        k.append(i + 1)
l[-1][1] = int(l[-1][1])
k.append(len(l))

out = []
for i in range(len(k) - 1):
    a = l[k[i]:k[i + 1]]
    a.sort(reverse=True, key=lambda x:x[1])
    out += a

for i in out:
    print(i[2])


Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>

int main(int argc, char ** argv)
{
  //
  int n;
  std::cin >> n;

  std::vector<int> a(n);
  std::map<std::string, int> m;
  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;
    m[std::to_string(a)]++;
  }

  bool flg = false;
  for (auto i = m.begin(); i != m.end(); i++) {
    int val = i->second;
    if (1 != val) {
      flg = true;
      break;
    }
  }

  if (flg == false) {
    std::puts("YES");
  } else {
    std::puts("NO");
  }
  return 0;
}


Measured memory_bytes: 16640
ai = lambda: list(map(int, input().split()))
 
h,w,d = ai()
ph = [0 for _ in range(h*w + 1)]
pw = [0 for _ in range(h*w + 1)]
 
for i in range(h):
    a = ai()
    for j in range(w):
        ph[a[j]] = i
        pw[a[j]] = j
 
 
score = [0 for _ in range(h*w + 1)]
for i in range(d+1, h*w+1):
    score[i] = score[i-d] + abs(ph[i]-ph[i-d]) + abs(pw[i]-pw[i-d])
 
 
q = int(input())
ans = []
for _ in range(q):
    l,r = ai()
    ans.append(score[r]-score[l])
print(*ans, sep='\n')

Measured memory_bytes: 14976
n, m = map(int, input().split())
h = list(map(int, input().split()))
bad_list = []

for i in range(m):
    a, b = map(int, input().split())

    if h[a-1] < h[b-1]:
        bad_list.append(a)
    elif h[a-1] > h[b-1]:
        bad_list.append(b)
    else:
        bad_list.append(a)
        bad_list.append(b)

x = set(bad_list)
print(n - len(x))

Measured memory_bytes: 19928
<?php
$input = trim(fgets(STDIN));
List($a, $op, $b) = explode(" ", $input);

while($op != "?") {
  switch($op) {
  case "+":
    $ans = $a + $b;
    break;
  case "-":
    $ans = $a - $b;
    break;
  case "*":
    $ans = $a * $b;
    break;
  case "/":
    $ans = floor($a / $b);
    break;
  }

  echo "{$ans}".PHP_EOL;

  $input = trim(fgets(STDIN));
  List($a, $op, $b) = explode(" ", $input);
}

Measured memory_bytes: 15296
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    // 大きい値から順に貪欲にペアを作成する
    let B = {
        let mut B = A.clone();
        B.sort();
        B
    };
    let mut s = std::collections::HashMap::new();
    for &a in &A { *(s.entry(a).or_insert(0)) += 1; }
    for &b in B.iter().rev() {
        let k = format!("{:b}", b).len();
        let c = (1 << k) - b;
        if b == c && *s.get(&b).unwrap_or(&0) >= 2 { *(s.entry(b).or_insert(0)) -= 2; }
        if b != c && *s.get(&b).unwrap_or(&0) > 0 && *s.get(&c).unwrap_or(&0) > 0 {
            *(s.entry(b).or_insert(0)) -= 1;
            *(s.entry(c).or_insert(0)) -= 1;
        }
    }
    let ans = (N - s.values().sum::<usize>()) / 2;

    println!("{}", ans);
}

Measured memory_bytes: 20464
#include <iostream>
#include <stdlib.h>

using namespace std;

int n;
int p[55], q[55];

bool check(int p[])
{
	for(int i = 1; i < n; i++){
		if(p[i] > p[i+1]) return false;
	}
	return true;
}

int main(void)
{
	cin >> n;
	for(int i = 1; i<= n; i++) cin >> p[i];
	
	if(check(p)){
		cout << "YES" << endl;
		return 0;
	}
	for(int i = 1; i<= n; i++){
		for(int j = 1; j <= n; j++){
			if(i >= j) continue;
			for(int k = 1; k <= n; k++) q[k] = p[k];
			swap(q[i], q[j]);
			if(check(q)){
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#define TEST_MODE false

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << endl
#else
const bool test = false;
#define dump(x) 
#endif

#else
const bool test = false;
#define dump(x) 
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

class Solver {
public:
    int a, b, c;

    int ans() {
        return min(a + b, min(b + c, c + a));
    }

    void solve()
    {
        cin >> a >> b >> c;
        cout << ans() << endl;
    }
};

signed main()
{
    cout << fixed << setprecision(20);
    auto ptr = new Solver();
    ptr->solve();
    delete ptr;
    // while (true) {
    //     solve();
    // }
    return 0;
}

// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'




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 n;
    cin>>n;
    vector<int>a(n+1);
    for(int i=1; i<=n; ++i){
        cin>>a[i];
    }
    int ans=0;
    for(int i=1; i<=n; ++i){
        if(i==a[a[i]])ans++;
    }
    cout<<ans/2<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, a, b; cin >> n >> a >> b;
  string s; cin >> s;
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') {
      if (x < a + b) cout << "Yes" << '\n', x++;
      else cout << "No" << '\n';
    } else if (s[i] == 'b') {
      if (x < a + b and y < b) cout << "Yes" << '\n', x++, y++;
      else cout << "No" << '\n';
    } else {
      cout << "No" << '\n';
    }
  }
}

Measured memory_bytes: 848