akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC112C_cs2
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var SurveyPoints = new List<SurveyPoint>();
            for(int i = 0; i < n; i++)
            {
                var tmp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                SurveyPoints.Add(new SurveyPoint(tmp[0], tmp[1], tmp[2]));
            }
            for(int x = 0; x <= 100; x++)
            {
                for (int y = 0; y <= 100; y++)
                {
                    var AssumedSummitPoint = new AssumedSummitPoint(x, y);
                    var AssumedHeight = AssumedSummitPoint.AssumedSummitHeight(SurveyPoints);
                    if (SurveyPoints.All(tmp => tmp.MatchTheAssumedSummit(AssumedSummitPoint, AssumedHeight)))
                    {
                        Console.WriteLine("{0} {1} {2}", x, y, AssumedHeight);
                    }

                }
            }
        }
    }
    public static class Height
    {
        public static int GetVal(int H, int X, int CX, int Y, int CY)
        {
            return Math.Max(H - Math.Abs(X - CX) - Math.Abs(Y - CY), 0);
        }
    }
    public class SurveyPoint
    {
        public readonly int x;
        public readonly int y;
        public readonly int h;

        public SurveyPoint(int x, int y, int h)
        {
            this.x = x;
            this.y = y;
            this.h = h;
        }
        public bool IsHPositive()
        {
            return this.h > 0;
        }
        public bool MatchTheAssumedSummit(AssumedSummitPoint aSummitPoint, int AssumedHeight)
        {
            return Height.GetVal(AssumedHeight, this.x, aSummitPoint.x, this.y, aSummitPoint.y) == this.h;
        }
    }

    public class AssumedSummitPoint
    {
        public readonly int x;
        public readonly int y;
        public AssumedSummitPoint(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public int AssumedSummitHeight(List<SurveyPoint> a)
        {
            SurveyPoint survey = a.First(tmp => tmp.IsHPositive());
            return Math.Abs(survey.x - this.x) + Math.Abs(survey.y - this.y) + survey.h;
        }
    }

}


Measured memory_bytes: 15444
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



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

  ll D,T,S; cin>>D>>T>>S;
  if(D-T*S<=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

int main(){
    char s[201];
    scanf("%s", s);
    while(s[0]!='-'){
        int m, h, x=strlen(s)+1;
        char t[x];
        t[x-1]='\0';
        scanf("%d", &m);
        for(int i=0; i<m; i++){
            scanf("%d", &h);
            strncpy(t, s+h, x-1-h);
            strncpy(t+x-1-h, s, h);
            for (int j = 0; j < x-1; j++)
            {
                s[j]=t[j];
            }
            
        }
        printf("%s\n", t);
        scanf("%s", s);
    }
}


Measured memory_bytes: 2036
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;

void stack_op(vector<int> &S, int a){
	int tmp;
	int minus[3] = {2, 1, 0};
	int mul[3][3] = {{0, 0, 0}, {0, 1, 1}, {0, 1, 2}};
	int add[3][3] = {{0, 1, 2}, {1, 1, 2}, {2, 2, 2}};

	switch(S[S.size()-1]){
	case -1:
		S.push_back(a);
		break;
	case 4:
		S.pop_back();
		stack_op(S, minus[a]);
		break;
	case 5:
		S.pop_back();
		tmp = S[S.size()-1];
		S.pop_back();
		stack_op(S, mul[tmp][a]);
		break;
	case 6:
		S.pop_back();
		tmp = S[S.size()-1];
		S.pop_back();
		stack_op(S, add[tmp][a]);
		break;
	}
}

int cal(string str, int p, int q, int r){
	vector<int> S;
	int tmp;

	S.push_back(-1);
	for(int i=0;i<str.length();i++){
		switch(str[i]){
		case '(':
			S.push_back(-1);
			break;
		case ')':
			tmp = S[S.size()-1];
			S.pop_back();
			S.pop_back();
			if((S[S.size()-1] >= 4) && (S[S.size()-1] <= 6))
				stack_op(S, tmp);
			else
				S.push_back(tmp);
			break;
		case '-':
			S.push_back(4);
			break;
		case '*':
			S.push_back(5);
			break;
		case '+':
			S.push_back(6);
			break;
		case 'P':
			stack_op(S, p);
			break;
		case 'Q':
			stack_op(S, q);
			break;
		case 'R':
			stack_op(S, r);
			break;
		case '0':
			stack_op(S, 0);
			break;
		case '1':
			stack_op(S, 1);
			break;
		case '2':
			stack_op(S, 2);
			break;
		}
	}
	return S[S.size()-1];
}

int count(string str){
	int count = 0;
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				if(cal(str, i, j, k) == 2)
					count++;
	return count;
}

int main(){
	while(1){
		string str;

		getline(cin, str);
		if(str == ".")
			break;
		
		cout<<count(str)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
int main(){
  int n,x=0,m=0,i;
  char s[101];
  scanf("%d%s",&n,s);
  for(i=0;i<n;i++){x+=1-2*(s[i]=='D');m=m<x?x:m;}
  printf("%d",m);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;  cin>>str;
    map<char,int> m;
    for(int i =0;i<str.length();i++)
    m[str[i]]++;
    if(m.size()==2){
        for(auto it:m){
            if(it.ss != 2){
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
    }
    else{
        cout << "No";
    }


    return 0;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+5;
char s[50];
int main()
{
    string a;
    while(cin>>a)
    {
        int n = a.size();
        int res = 0;
        for(int i = 0; i < n; ++i)if(a[i] == 'o')res++;
        res += 15-n;
        if(res >= 8)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

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

int main() {
  int n,m;cin>>n>>m;
  int c,t;
  const int inf = 100000;
  int ans =inf;
  for(int i=0;i<n;++i){
    cin>>c>>t;
    if(t<=m){
      if(c<ans)ans = c;
    }
  }
  if(ans < inf) cout<< ans <<endl;
  else cout<<"TLE"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);

		int alice = 0;
		int bob = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (i % 2 == (n - 1) % 2) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		}

		pr.println(alice - bob);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

int main() {
    int n; cin >> n;
    vector<int> p(n);
    for (auto &pi: p) cin >> pi;
    vector<int> q(n);
    for (auto &qi: q) cin >> qi;
    vector<vector<int>> v; {
        vector<int> a(n);
        iota(a.begin(), a.end(), 1);
        do {
            v.emplace_back(a);
        } while (next_permutation(begin(a), end(a)));
    }
    int ans = abs(
        lower_bound(begin(v), end(v), p) - lower_bound(begin(v), end(v), q)
    );
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t; cin >> s >> t;
    sort(_all(s));
    sort(_all(t), greater<char>());

    cout << (s < t ? "Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()

int main() {
    int d, n;
    scanf("%d %d", &d, &n);
    int ans = (n == 100 ? 101 : n);
    rep(i,d) ans *= 100;
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
    vector<long long> par; 
    vector<long long> n;

    UnionFind(long long N) : par(N),n(N) {
        for(long long i = 0; i < N; i++) {par[i] = i;n[i]=1;}
    }
 
    long long root(long long x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(long long x, long long y) { 
        long long rx = root(x);
        long long ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
        n[ry]+=n[rx];
    }
    bool same(long long x, long long y) {
        long long rx = root(x);
        long long ry = root(y);
        return rx == ry;
    }
    long long count(long long x){
        return n[root(x)];
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N,M;
    cin>>N>>M;
    UnionFind tree(N);
    vector<long long>A(M),B(M);
    for(long long i=0;i<M;i++){
        cin>>A[i]>>B[i];
        A[i]--,B[i]--;
    }
    vector<long long>sub(M);
    long long num = N*(N-1)/2;
    for(long long i=M-1;i>=0;i--){
        sub[i]=num;
        if(!tree.same(A[i],B[i])){
            num-=tree.count(A[i])*tree.count(B[i]);
        }
        tree.unite(A[i],B[i]);
    }
    for(long long i=0;i<M;i++){
        cout<<sub[i]<<endl;
    }
}

Measured memory_bytes: 5248
n,m = map(int, input().split())
scl = []
for _ in range(m):
    s,c = map(int, input().split())
    scl.append((s,c))

for i in range(0, 1000):
    si = str(i)
    if len(si) != n: continue
    for sc in scl:
        s,c = sc
        if si[s-1] != str(c):
            break
    else:
        print(i)
        exit()
else:
    print(-1)

Measured memory_bytes: 62604
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(ll i = 0; i < (ll) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

vector<vector<ll>> dp(1100, vector<ll>(10100, INF));
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, N; cin >> H >> N;
    vector<ll> A(N), B(N);
    for(ll i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
    }
    for(ll i = 0; i <= N; i++) dp[i][0] = 0;
    for(ll i = 0; i <= N; i++)
    {
        for(ll j = 0; j <= H; j++)
        {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if(j - A[i] >= 0)
            {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i + 1][j - A[i]] + B[i]);
            }
            else
            {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i + 1][0] + B[i]);
            }
        }
    }
    cout << dp[N][H] << endl;
    return 0;
}

Measured memory_bytes: 87296
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  string S;

  cin >> S;

  vector<int> A(S.length(), 0);

  int rcnt = 0, lcnt = 0;
  bool inR = true;
  int idxR = 0, idxL = 0;
  for (int i=0; i < S.length(); i++) {
    if (inR) {
      if (S[i] == 'R') {
        rcnt++;
      }
      else {
        idxR = i-1;
        idxL = i;
        lcnt = 1;
        inR = false;
      }
    } else {
      if (S[i] == 'L')
        lcnt++;
      else {
        //cout << idxR << " " << idxL << endl;
        //cout << rcnt << " " << lcnt << endl;
        //cout << ceil((float)rcnt/2) << " " << floor((float)rcnt/2) << " " << ceil((float)lcnt/2) << " " << floor((float)lcnt/2) << endl;
        A[idxR] = ceil((float)rcnt/2) + lcnt/2;
        A[idxL] = rcnt/2 + ceil((float)lcnt/2);

        inR = true;
        lcnt = 0;
        rcnt = 1;
      }
    }
  }

  /*
  cout << idxR << " " << idxL << endl;
  cout << rcnt << " " << lcnt << endl;
  cout << ceil((float)rcnt/2) << " " << floor((float)rcnt/2) << " " << ceil((float)lcnt/2) << " " << floor((float)lcnt/2) << endl;
  */
  A[idxR] = ceil((float)rcnt/2) + lcnt/2;
  A[idxL] = rcnt/2 + ceil((float)lcnt/2);

  bool isfirst = true;
  for (int i=0; i < S.length(); i++) {
    if (isfirst) {
      cout << A[i];
      isfirst = false;
    } else
      cout << " " << A[i];
  }

  cout << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        String[] list = new String[N];
        for(int i = 0; i < N; i++) {
            String city = sc.next();
            int point = sc.nextInt();
            list[i] = city + "_" + (200 - point) + "_" + (i+1);
        }
        Arrays.sort(list);

        for(int i = 0; i < N; i++) {
            String ans = list[i].split("_")[2];
            System.out.println(ans);
        }   
    }
}

Measured memory_bytes: 23892
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0102&lang=jp
"""
import sys


def solve(data):
    for d in data:
        d.append(sum(d))

    v_sum = [0] * len(data[0])
    for d in data:
        for x, n in enumerate(d):
            v_sum[x] += n
    data.append(v_sum)
    return data


def main(args):
    # data = []
    # data.append([52, 96, 15, 20])
    # data.append([86, 22, 35, 45])
    # data.append([45, 78, 54, 36])
    # data.append([16, 86, 74, 55])
    while True:
        num = int(input())
        if num == 0:
            break
        data = []
        for _ in range(num):
            data.append([int(x) for x in input().split(' ')])
        result = solve(data)
        for row in result:
            for n in row:
                print('{:5d}'.format(n), end='')
            print('')


if __name__ == '__main__':
    main(sys.argv[1:])

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

int main() {
  int a, b;
  cin >> a >> b;
  vector<int> veca;
  vector<int> vecb;
  for(int i = 1; i <= 1000; i++) {
    if(floor(i*0.08) == a) veca.push_back(i);
    if(floor(i*0.1) == b) vecb.push_back(i);
  }
  int ans = 10000;
  rep(i,veca.size()) rep(j,vecb.size()) {
    if(veca.at(i) == vecb.at(j)) ans = min(ans, veca.at(i));
  }
  if(ans == 10000) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7;
using namespace std;
ll t;
ll arr[200005];
int main()
{
    ll a,b,c,d,e,f,i,j;
    d=0;
    f=0;
    for(i=0;i<5;i++)
    {
        cin>>a;
        if(a%10!=0)
        {
            b=a%10;
            b=10-b;
            d=max(d,b);
            a=a/10;
            ++a;
            a*=10;
        }
        f+=a;
    }
    f-=d;
    cout<<f<<endl;


return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

P channel[30];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	long long N;
	cin >> N;

	long long ans = 0;
	for (int i = 1; i < N; ++i) {
		ans += i;
	}

	cout << ans << endl;
}


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

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    while(1){
        if(a % 2 != 0){
            a--;
        }
        a = a / 2;
        b += a;
        k--;
        if(k == 0) break;
        if(b % 2 != 0){
            b--;
        }
        b = b / 2;
        a += b;
        k--;
        if (k == 0) break;
        // cout << a << " " << b << endl;
    }
    cout << a << " " <<  b << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    VPLL x(n);
    REP(i,n){
        cin>>x[i].first;
        x[i].second=i;
    }
    SORT_ASC(x);

    VL result(n);
    REP(i,n){
        if(i<n/2){
            result[x[i].second]=x[n/2].first;
        }
        else{
            result[x[i].second]=x[n/2-1].first;
        }
    }
    REP(i,n){
        cout<<result[i]<<endl;
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int main() {
    int n;
    cin >> n;
    int k;
    int a(0) , b(0) , c(0);
    for(int i = 1 ; i<= n ; i++ ){
        cin >> k;
        if(k % 4 == 0){
            a ++;
        }else{
            if(k % 2 == 0){
                b ++;
            }else{
                c++;
            }
        }
    }
    //cout << a << " " << b << " " << c << endl;
    if(c + a == n){
        if( c > a + 1){cout << "No";}else{
            cout << "Yes";
        }
    }else{
    if( c <= a ){
        cout << "Yes";
    }else{ cout << "No";}
    }
    return 0;
}


Measured memory_bytes: 256
// C++ program to print all prime factors 
#include <bits/stdc++.h> 
using namespace std;
int main () {
  long long int n,k,sum=0;cin>>n>>k;
  long long int a[n];
  for (long long int i=0;i<n;i++) {cin>>a[i];}
  sort(a,a+n);
  for (long long int i=0;i<n-k;i++) {
      sum+=a[i];
  }
   cout<<sum<<endl;








}


Measured memory_bytes: 1792
import Control.Monad

main :: IO ()
main = do
  n <- readLn :: IO Int
  ds <- concat <$> replicateM n (map read . words <$> getLine)  :: IO [Int]
  print $ solve ds

solve :: [Int] -> Int
solve [] = 0
solve (x:y:ys) = (y-x+1) + solve ys

Measured memory_bytes: 1660
#include <stdio.h>
int main(void){
    int N,L,S=0,max=0;
    scanf("%d",&N);
    for (int i=0 ; i<N; i++) {
        scanf("%d",&L);
        S+=L;
        if(L>max){
            max=L;
        }
    }
    if(S-(2*max)>0){
        printf("Yes");
    }
    else{
        printf("No");
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;


public class Main {
	
	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int p = sc.nextInt();
			if(n == 0 && m == 0 && p == 0){
				break;
			}
			else calc(n,m,p);
		}
	}
	public void calc(int n, int m, int p){
		int sum = 0;
		int x = 0;
		for(int i = 1; i < n + 1; i++){
			int xi = sc.nextInt();
			sum = sum + xi;
			if(m == i) x = xi;
		}
		if(x == 0) System.out.println(0);
		else{
			int ans = (sum * 100 * (100 - p) / 100) / x;
			System.out.println(ans);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 27708
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> k >> n;
    rep(i, n) {
        cin >> x;
        k -= x;
    }

    if(k >= 0)
        cout << k << endl;
    else
        cout << -1 << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb   push_back
#define T int time;        scanf("%d", &time); while(time--)
   ll add(ll x,ll &y){y+=x;}
    struct s{ll a,b;};
    s ar[10000];
    bool com(s i,s j){if(i.a<=j.a)return true;return false;}

    struct a{
        ll x,y;
    };
     /* ll power(ll n,ll a){
        ll result=1;
        while(a>0){
            if(a&1){
                result*=n;
                a--;
            }
            else 

            

        }
      }*/

     int main(){
       ll d,t,s;
       cin>>d>>t>>s;
       if(t*s>=d)cout<<"Yes"<<endl;
       else cout<<"No"<<endl;
    
     }

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int H, W, ans;
    cin >> H >> W;
    char S[H][W];
    REP(int,j,0,H){
        REP(int,i,0,W) cin >> S[j][i];
    }
    ans = 0;
    int L[H][W];
    int R[H][W];
    int U[H][W];
    int D[H][W];
    REP(int,j,0,H){
        REP(int,i,0,W){
            if ( S[j][i] == '#' ) L[j][i] = 0;
            else if ( i == 0 ) L[j][i] = 1;
            else L[j][i] = L[j][i-1] + 1;
        }
    }
    REP(int,i,0,W){
        REP(int,j,0,H){
            if ( S[j][i] == '#' ) U[j][i] = 0;
            else if ( j == 0 ) U[j][i] = 1;
            else U[j][i] = U[j-1][i] + 1;
        }
    }
    REP(int,j,0,H){
        for ( int i = W - 1; i >= 0; i-- ){
            if ( S[j][i] == '#' ) R[j][i] = 0;
            else if ( i == W - 1 ) R[j][i] = 1;
            else R[j][i] = R[j][i+1] + 1;
        }
    }
    REP(int,i,0,W){
        for ( int j = H - 1; j >= 0; j-- ){
            if ( S[j][i] == '#' ) D[j][i] = 0;
            else if ( j == H - 1 ) D[j][i] = 1;
            else D[j][i] = D[j+1][i] + 1;
        }
    }

    REP(int,j,0,H){
        REP(int,i,0,W){
            ans = max(ans,L[j][i]+R[j][i]+U[j][i]+D[j][i]-3);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 66688
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)2e5 + 10;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;


int n, m, dp[maxn], s, ans = inf * inf;
vpii g[maxn], gr[maxn];
int t[4 * maxn], lz[4 * maxn];
void push(int v, int tl, int tr){
	if(!lz[v]) return;
	t[v] += lz[v];
	if(tl != tr)
		lz[v + v] += lz[v], lz[v + v + 1] += lz[v];
	lz[v] = 0;
}
void upd(int l, int r, int x, int v = 1, int tl = 0, int tr = n){
	push(v, tl, tr);
	if(l > r || tr < l || tl > r)
		return;
	if(l <= tl && tr <= r){
		lz[v] += x;
		push(v, tl, tr);
		return;
	}
	int tm = (tl + tr) >> 1;
	upd(l, r, x, v + v, tl, tm);
	upd(l, r, x, v + v + 1, tm + 1, tr);
	t[v] = min(t[v + v], t[v + v + 1]);
}                        
int get(int l, int r, int v = 1, int tl = 0, int tr = n){
	push(v, tl, tr);
	if(l > r || tr < l || tl > r)
		return inf * inf;
	if(l <= tl && tr <= r){
		return t[v];
	}
	int tm = (tl + tr) >> 1;
	return min(get(l, r, v + v, tl, tm), get(l, r, v + v + 1, tm + 1, tr));
}
main () {
	cin >> n >> m;
	forn(i, 1, m){
		int l, r, a;
		cin >> l >> r >> a;
		s += a;
		g[r].pb(mp(l, a));
	}
	forn(i, 1, n + 1){
		for(auto x : g[i - 1]){
			upd(0, x.f - 1, x.s);
		}
		dp[i] = get(0, i - 1);
		upd(i, i, dp[i]);
		ans = min(ans, dp[i]);
	}
	cout << s - ans;
}

Measured memory_bytes: 29952
#include<bits/stdc++.h>
using namespace std;
#define max1 1000005
#define sz1 100001
#define mod 1000000007
#define moda 421412341324321ll
#define inf 1e18
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
typedef pair<ll,ll> pr;
#define rte cout<<"Correct";exit(0);
int intlog(double x) {
    return (int)(log(x) / log(2));
}
double max(double x,double y)
{
    if(x>=y)
    {
        return x;
    }
    else
    {
        return y;
    }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  ll n;
  cin>>n;
  for(ll i=1;i<=9;i++)
  {
    if(n%i==0)
    {
        ll x=n/i;
        if(x>=1&&x<=9)
        {
            cout<<"Yes\n";
            return 0;
        }
    }
  }
  cout<<"No\n";
} 

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N,T,A,i,h,num=0;
	double t,td,min=9999;
	scanf("%d%d%d",&N,&T,&A);
	for(i=0;i<N;i++)
	{scanf("%d",&h);
	t=T-h*0.006;
	td=A-t;
	if(td<0)td=-td;
	if(td<=min){min=td;num=i;
	}
	}
	printf("%d\n",num+1);
		return 0;

 } 

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

int main(){
	int n;
	cin >> n;
	vector<pair<double, double>> p(n);
	rep(i,n){
		cin >> p[i].first >> p[i].second;
	}
	vector<int> d;
	rep(i,n) d.push_back(i);
	
	double sum = 0;
	double count = 0;
	
	do{
		rep(i,n-1){
			ll dx = p[d[i+1]].first - p[d[i]].first;
			ll dy = p[d[i+1]].second - p[d[i]].second;
			sum += sqrt(dx*dx + dy*dy);
		}
		count++;
	}while(next_permutation(d.begin(),d.end()));
	double ans = sum / count;
	printf("%.12f", ans);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int v[N];
    REP(i, N) cin >> v[i];

    priority_queue<double, vector<double>, greater<double>> pq;
    REP(i, N) pq.push((double)(v[i]));

    while (pq.size() != 1) {
        double f = pq.top();
        pq.pop();
        double s = pq.top();
        pq.pop();
        pq.push((f + s) / 2);
    }
    cout << pq.top() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int H,A;
   cin>>H>>A;
   int c=0;
   if (H>A){
    for(int i=0;H>0;i++){
            H-=A;
    c++;
    }
    }
    else c=1;
    cout<<c;

    return 0;

}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
        t: chars
    }
    let s: Vec<&char> = s.iter().chain(s.iter()).collect();
    for i in 0..s.len() {
        let mut k = i;
        let mut cnt = 0;
        for j in 0..t.len() {
            if k >= s.len() {
                break;
            }
            if *s[k] == t[j] {
                k += 1;
                cnt += 1;
            } else {
                break;
            }
            if cnt == t.len() {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstring>
#include<algorithm>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if(n<1200)
		printf("ABC\n");
	else if(n<2800)
		printf("ARC\n");
	else
		printf("AGC\n");
}

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

int main(){
  int n;
  int a,b;
  cin>>n>>a>>b;
  string s;
  cin>>s;
  int cnt=0;
  int cntB=0;
 
  for(int i=0;i<s.size();i++){
    //  cout<<s[i]<<endl;
      if(s[i]=='a'){
	if(cnt<a+b){
	  cout<<"Yes"<<endl;
	  cnt++;
	}else  cout<<"No"<<endl;
      }else if(s[i]=='b'){
	if(cnt<a+b && cntB<b){
	    cout<<"Yes"<<endl;
	  cnt++;
	  cntB++;
	}else cout<<"No"<<endl;
	}else cout<<"No"<<endl;
      }

    
  return 0;
}


Measured memory_bytes: 896
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string S;
  cin >> S;
  vector<char> vec(S.size());
  REP(i, S.size()) {
    vec[i] = S[i];
  }
  int ans = 0;
  REP(i, S.size() - 1) {
    if (vec[i] != vec[i+1]) {
      vec[i+1] = vec[i+1];
    } else {
      vec[i+1] = vec[i+1] == '0' ? '1' : '0';
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int n,c = 0;
	int i, j;
	int num[5];
	char a[8][5];
	char abacus[8][10] = {
		"*****     ",
		"     *****",
		"==========",
		" **** ****",
		"* **** ***",
		"** **** **",
		"*** **** *",
		"**** **** ",
	};
	
	while (scanf("%d", &n) != EOF){
		for (i = 0; i < 5; i++){
			num[4 - i] = n % 10;
			n /= 10;
		}
		for (i = 0; i < 8; i++){
			for (j = 0; j < 5; j++){
				a[i][j] = abacus[i][num[j]];
			}
		}
		
		if (c != 0){
			printf("\n");
		}
		
		for (i = 0; i < 8; i++){
			for (j = 0; j < 5; j++){
				printf("%c", a[i][j]);
			}
			printf("\n");
		}
		c++;
	}
	
	return (0);
}

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

int main(){
    while (1){
        int H,W,i,j;
        cin>>H>>W;
        if (H==0 and W==0){
            break;
        }else{
            for ( i=0; i< H;i++ ){
                for (j=0; j<W;j++ ){
                    if ((i+j)%2==0){ 
                     cout<<"#" ; 
                    }else{
                        cout<<".";
                    }
                }
                cout<<endl;
            }
            cout<<endl;
        }
    }
}



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const LL N = 50;

LL k, ans[N];

int main() {
	cin >> k;
	
	inc(i, N) {
		int j = k % N;
		ans[i] = N - 1 + (k / N) + (i <= (N - 1 - j) ? -j : N + 1 - j);
	}
	
	cout << N << endl;
	inc(i, N) {
		cout << (i == 0 ? "" : " ") << ans[i];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
a,b,c,x,y=[int(s) for s in input().split()]
if x<=y:
  A=a
  B=b
  C=c
  X=x
  Y=y
else:
  A=b
  B=a
  C=c
  X=y
  Y=x
#print([Y*2*C,X*2*C+(Y-X)*B,X*A+Y*B])
print(min([Y*2*C,X*2*C+(Y-X)*B,X*A+Y*B]))


Measured memory_bytes: 3060
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a;

	cin >> a;

	if (a >= 1200){
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;

	}

	
}



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

int main(void) {
  int i, j, k, now = 0;
  char a[1100], ans[1100], shi[10] = {'w', 'a', 'k', 's', 't', 'n', 'h', 'm', 'y', 'r'};
  scanf("%s", a);
  for(i = 0; i < strlen(a); i += 2) {
   if(a[i] >= '1') {
     if(a[i] != '1') {
       ans[now] = shi[a[i] - '0'];
       ++now;
     }
     if(a[i + 1] == 'T') ans[now] = 'a';
     else if(a[i + 1] == 'L') ans[now] = 'i';
     else if(a[i + 1] == 'U') ans[now] = 'u';
     else if(a[i + 1] == 'R') ans[now] = 'e';
     else if(a[i + 1] == 'D') ans[now] = 'o';
     now++;
   } else {
     if(a[i + 1] == 'T') ans[now] = 'w', ans[now + 1] = 'a';
     else if(a[i + 1] == 'D') ans[now] = 'w', ans[now + 1] = 'o';
     else if(a[i + 1] == 'U') ans[now] = 'n', ans[now + 1] = 'n';
    now += 2;
    }
  }
  ans[now] = 0;
  printf("%s\n", ans);
  return 0;
}


Measured memory_bytes: 2604
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b != c)
    {
        cout << "Yes\n";
    }
    else if (a == c && b != c)
    {
        cout << "Yes\n";
    }
    else if (b == c && a != b)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
total = sum(b)
for i in range(1,n):
    if a[i] == a[i-1] + 1:
        total += c[a[i]-2]
print(total)

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

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

    ll a,b;
    a = b = 0;
    rep(i,N){
        if ((i+1)%K==0) {
            a++;
        }
        if ((i+1)%K==K/2 and K%2==0) {
            b++;
        }
    }
    ll ans = pow(a,3) + pow(b,3);
    cout << ans << endl;
}


Measured memory_bytes: 4020
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(void) {
  const char *dirs = "NSWE";
  int cnt[4] = {};
  static char s[1010];
  scanf("%s", s);
  for (int i = 0; s[i]; ++i) {
    ++cnt[strchr(dirs, s[i]) - dirs];
  }
  if ((cnt[0] == 0) == (cnt[1] == 0) && (cnt[2] == 0) == (cnt[3] == 0)) {
    puts("Yes");
  } else {
    puts("No");
  }
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  string a;
  string b;
  string str;
  cin>>n;
  cin>>a>>b;
  for(int i=0;i<n;i++){
    str+=a[i];
    str+=b[i];
  }
  cout<<str<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int h,m,s;
  cin >> s;
  h = s / 3600;
  m = (s - h*3600) / 60;
  s -= h*3600 + m*60;
  cout << h << ":" << m << ":" << s << "\n";
  return 0;
}


Measured memory_bytes: 3096
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc	= new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	
	if((a+b)<10){
		System.out.println(a+b);
	}else {
		System.out.println("error");
	}
	}
}


Measured memory_bytes: 21716
n = int(input())
s = input()

ans = [0]*1000

l = [0]*10
r = [s.count(str(i)) for i in range(10)]

l[int(s[0])]+=1
r[int(s[0])]-=1

for i in range(1,n-1):
    r[int(s[i])]-=1
    for j in range(10):
        if l[j]>=1:
            for k in range(10):
                if r[k]>=1:
                    ans[j*100+int(s[i])*10+k]=1
    l[int(s[i])]+=1
print(ans.count(1))



Measured memory_bytes: 42600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;
typedef pair<int, int> PI;

const ll inf = 1e15;
const ll mod = 1000 * 1000 * 1000 + 7;
const double eps = 1e-9;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}

void solve(int R, int C){
  vector<PI> U;
  vector<int> SR(R), SC(C);
  
  REP(i, R + 1) REP(j, C + 1){
    string str;
    cin >> str;
    if (str == "?"){
      U.push_back(PI(i, j));
    } else {
      int value = atoi(str.c_str());
      if (i < R) SR[i] += (j == C ? value : -value);
      if (j < C) SC[j] += (i == R ? value : -value);
    }
  }

  if (U.size() > SR.size() + SC.size()) {
    cout << "NO" << endl;
  } else {
    int n = U.size();
    vector<vector<double> > M(R + C, vector<double>(n + 1, 0));
    REP(i, R) M[i + 0][n] = SR[i];
    REP(i, C) M[i + R][n] = SC[i];
    REP(i, n) M[U[i].first][i] = M[U[i].second + R][i] = 1;

    REP(i, n){
      int pivot = i;
      REP2(j, i, R + C) if (abs(M[j][i]) > abs(M[pivot][i])) pivot = j;
      
      if (abs(M[pivot][i]) < eps) {
        cout << "NO" << endl;
        return;
      }

      swap(M[pivot], M[i]);
      REP(j, R + C) REP2(k, i + 1, n + 1) if (j != i){
        M[j][k] -= M[j][i] / M[i][i] * M[i][k];
      }
      REP2(k, i + 1, n + 1) M[i][k] /= M[i][i];
      REP(j, R + C) M[j][i] = j == i;
    }
    
    REP(i, n) cout << (int)(M[i][n] > 0 ? M[i][n] + 0.5 : M[i][n] - 0.5) << endl;
  }
}


int main(){
  int R, C, T = 0;
  while (cin >> R >> C){
    if (T > 0) cout << endl;
    solve(R, C);
    T++;
  }
  return 0;
}

Measured memory_bytes: 1336
N = int(input())
a = [int(input()) for _ in range(N)]

next_light = 1
li = [0]
count = 0
for i in range(N):
    next_light = a[next_light-1]
    count += 1
    if 2 == next_light:
        break
if N == count:
    print(-1)
else:
    print(count)


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RREP(i,n) RFOR(i,0,n)

const int _N = 3e5 + 100;
int bitcount[] = {0,1,1,2,1,2,2,3};

int h,n;
bool b[4][10000];
int dp[2][1<<3];

int main(){
	cin >> h >> n;
	REP(i, n){
		int x,y;
		cin >> x >> y;
		b[x][y] = true;
	}
	REP(y, h-1){
		int *prev = dp[0];
		int *now = dp[1];
		REP(i, 1 << 3){
			now[i] = 0;
			REP(j, 1 << 3){
				bool flag = false;

				// check i(y) height block
				REP(x, 3)REP(dx, 2)REP(dy, 2)
					if((i & (1 << x)) && b[x + dx][y + dy])
						flag = true;

				// check j(y-1) height block
				if(y>=1)REP(x, 3)REP(dx, 2)REP(dy, 2)
					if((j & (1 << x)) && b[x + dx][y - 1 + dy])
						flag = true;

				// check hit i and j
				REP(x, 2)REP(dxi, 2)REP(dxj, 2)
					if((i & (1 << (x + dxi))) && (j & (1 << (x + dxj))))
						flag = true;

				// check in only i and in only j
				REP(x, 2)if((i & (1 << (x + 1))) && (i & (1 << x)))
					flag = true;
				REP(x, 2)if((j & (1 << x)) && (j & (1 << (x + 1))))
					flag = true;

				if(flag)continue;
				now[i] = max(now[i], prev[j] + bitcount[i]);
			}
		}
		swap(dp[0], dp[1]);
	}
	int ans = 0;
	REP(i, 1<<3)
		ans = max(ans, dp[0][i]);
	cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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 INF=(ll)1e19;
//const int INF=(1<<30);
//const int INF=(1<<29);

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

  for(ll h=1; h<=3500; h++){
    for(ll n=1; n<=3500; n++){
      ll x=N*h*n;
      ll y=4*h*n-N*n-N*h;

      if(y!=0 && x%y==0 && x/y>0){
        cout << h << " " << n << " " << x/y << endl;
        return 0;
      }

    }
  }
}



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

int main() {
  int max = 0, n, flag = 0;
  cin >> n;
  vector <int> h(n);
  for(int i = 0;i < n;i++) {
    cin >> h.at(i);
    if(i != 0) {
      if(h.at(i-1) >= h.at(i)) {
        flag++;
      }
      else if(max < flag) {
        max = flag;
        flag = 0;
      }
      else {
        flag  = 0;
      }
    }
  }
  if(max < flag) {
    max = flag;
    flag = 0;
 }
 cout << max << endl;
  return 0;
}


Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


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

	int i=1,j=0,k=0;
	char ch = 'a';
	while(1)
	{
		if(ch == 'a')
		{
		    if(i == a.size())
    		{
    			cout << "A";
    			return 0;
    		}
			ch = a[i];
			i++;
		}
		else if(ch == 'b')
		{
		    if(j == b.size())
    		{
    			cout << "B";
    			return 0;
    		}
    		
			ch = b[j];
			j++;
		}
		else if(ch == 'c')
		{
		    if(k == c.size())
    		{
    			cout << "C";
    			return 0;
    		}
			ch = c[k];
			k++;
		}
		
	}
	return 0;
}

Measured memory_bytes: 256