akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
typedef long long ll;

template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main()
{
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    int ans = 1e9;

    vector<tuple<int, int, int>> t1(N / 2), t2(N - N / 2);
    for (int i = 0; i < N; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        if (i < N / 2)
            t1[i] = {a, b, c};
        else
        {
            t2[i - (N / 2)] = {a, b, c};
        }
    }
    map<int, int> cnt;
    for (int bit = 0; bit < (1 << ((int)(t2.size()))); bit++)
    {
        int a = 0, b = 0, c = 0;
        for (int i = 0; i < (int)(t2.size()); i++)
        {
            auto [A, B, C] = t2[i];
            if (bit & (1 << i))
            {
                a += A;
                b += B;
                c += C;
            }
        }
        if (cnt.count(b * Ma - a * Mb) == 0)
        {
            cnt[b * Ma - a * Mb] = c;
        }
        else if(c>0)
            chmin(cnt[b * Ma - a * Mb], c);
        if(b*Ma-a*Mb == 0 and c>0)
            chmin(ans,c);
    }

    for (int bit = 0; bit < (1 << ((int)(t1.size()))); bit++)
    {
        int a = 0, b = 0, c = 0;
        for (int i = 0; i < (int)(t1.size()); i++)
        {
            if (bit & (1 << i))
            {
                auto [A, B, C] = t1[i];
                a += A;
                b += B;
                c += C;
            }
        }
        int d = a * Mb - b * Ma;
        if (cnt.count(d) == 1 and c + cnt[d] > 0)
        {
            chmin(ans, c + cnt[d]);
        }
        if(d==0 and c>0)
        chmin(ans,c);
    }
    if (ans != 1e9)
        cout << ans << endl;
    else
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n)
        cin >> a[i];

    vector<int> ans(n, 0);
    for(int i=n-1;i>=0;i--){
        int accum = 0;
        for(int j=2;(i+1)*j<=n;j++){
            accum = (accum + ans[(i+1)*j-1]) % 2;
        }
        ans[i] = (accum == a[i] ? 0: 1);
    }

    int m = 0;
    vector<int> out;
    REP(i, n){
        if(ans[i] == 1){
            m++;
            out.push_back(i+1);
        }
    }

    cout << m << endl;
    print_container(out);
    return 0;
}

Measured memory_bytes: 3064
n = int(input())
if n < 3:
    print(0)
    exit()

lst = [int(n) for n in input().split()]
ct = 0
for i in range(0, n-2):
    for j in range(i+1, n-1): 
        for k in range(j+1, n): 
            l = sorted([lst[i], lst[j], lst[k]])
            if len(set(l)) == 3:
                m = l.pop()
                if m < sum(l):
                    ct += 1
print(ct)


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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long int ll;
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);
#else
// online submission
#endif
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int i=0;
	while(a&&c){
		if(i%2){
			a=max(0,a-d);
		}
		else{
			c=max(0,c-b);
		}
		i++;
	}
	if(a==0){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

void selectionsort(vector<int> &a,int& cnt)
{
  int n=a.size();
  for (int i = 0; i < n; ++i)
  {
    int minj=i;
    for (int j = i; j < n; ++j)
    {
      if(a[j]<a[minj]) minj=j;
    }
    if(a[i]!=a[minj]) cnt++;
    swap(a[i],a[minj]);
  }
}

int main()
{
  int n,cnt=0;
  cin>>n;
  vector<int> a(n);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  selectionsort(a,cnt);
  for (int i = 0; i < a.size(); ++i)
  {
    if(i!=n-1) cout<<a[i]<<" ";
    else cout<<a[i]<<endl;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3108
#include <cstdio>
#include <algorithm>
#include <complex>
using namespace std;

#define FOR(i,a,b)  for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)    for (int i=0;i<(n);i++)
#define RREP(i,n)   for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
typedef complex<double> C;


double dot(C a, C b) {
    return real(conj(a) * b);
}

double cross(C a, C b) {
    return imag(conj(a) * b);
}

C triangle_circumcenter(C a, C b, C c) {
    a -= c;
    b -= c;
    C z = (abs(a) * abs(a) * b - abs(b) * abs(b) * a) / (conj(a) * b - a * conj(b));
    z += c;
    return z;
}

int main() {
    int n;
    scanf("%d", &n);
    while (n--) {
        double x1, y1, x2, y2, x3, y3;
        scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
        C a = C(x1, y1);
        C b = C(x2, y2);
        C c = C(x3, y3);
        C z = triangle_circumcenter(a, b, c);
        printf("%.3f %.3f %.3f\n", real(z), imag(z), abs(z-c));
    }
    return 0;
}

Measured memory_bytes: 2744
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()

ans = 0
M_tmp = M
for i, (Ai, Bi) in enumerate(AB):
    cnt = min(M_tmp, Bi)
    ans += Ai * cnt
    M_tmp -= cnt

print(ans)

Measured memory_bytes: 27844
A = [0, 4, 4, 9, 4, 7, 10, 18, 5, 21, 8, 16, 11, 11, 19, 19, 6, 14, 22, 22, 9, 9, 17, 17, 12,25, 12, 113, 20, 20, 20, 108, 7, 28, 15, 15, 23, 23, 23, 36, 10, 111, 10, 31, 18, 18, 18,106, 13, 26, 26, 26, 13, 13, 114, 114, 21, 34, 21, 34, 21, 21, 109, 109, 8, 29, 29, 29, 16, 16, 16, 104, 24, 117, 24, 16, 24, 24, 37, 37, 11, 24, 112, 112, 11, 11, 32, 32, 19, 32,19, 94, 19, 19, 107, 107, 14, 120, 27, 27, 27]

print(A[int(input())])

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

#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back

int main(){
    int n;
    cin >>n;
    int a[n];
    for (int i=0;i<n;i++){
        cin >>a[i];
    }
    int dp[n];
    dp[0]=0;
    for (int i=1;i<n;++i){
        if (i==1){
            dp[1]=dp[0]+abs(a[0]-a[1]);
            continue;
        }
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    //for (int i=0;i<n;++i){
     //   cout <<dp[i]<<endl;
   // }
    cout <<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
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)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N, M;
	cin>>N>>M;
	vector<bool> ans(N,true);
	vector<int> high(N,0);
	rep(i,N)cin>>high[i];
	rep(i,M){
		int a,b; cin>>a>>b;
		--a; --b;
		if(high[a]>high[b])ans[b] = false;
		if(high[a]<high[b])ans[a] = false;
		if(high[a]==high[b]){ans[a] = false; ans[b] = false;}
	}
	int res = 0;
	rep(i,N)if(ans[i])++res;
	cout<<res<<endl;
	return 0;
}

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

const int INF=1e9;
int cost[] = {0,2,5,5,4,5,6,3,7,6};
bool d[10] = {};
int main() {
    int n, m;
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int a;
        cin >> a;
        d[a] = 1;
    }

    vector<int> dp(n+1, -INF);
    dp[0]=0;
    for (int i=1; i<10; i++) {
        if ( !d[i] ) continue;
        for (int j=cost[i]; j<=n; j++) {
            int k = j-cost[i];
            if ( dp[k]==-INF ) continue;
            dp[j]=max(dp[j],dp[k]+1);
        }
    }
    int matches=n;
    string ans="";
    while ( matches>0 ) {
        for (int i=9; i>0; i--) {
            if ( !d[i] ) continue;
            if ( matches>=cost[i] && dp[matches]==dp[matches-cost[i]]+1 ) {
                ans+=(char)(i+'0');
                matches-=cost[i];
                break;
            }
        }
    }
    
    cout << ans << '\n';
    return 0;
}

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

int main(){
    long long N, K;
    long long H_tmp;
    long long sum = 0;
    long long sum_tgt = 0;

    std::cin >> N >> K;
    vector<long long> mons_list(N);
    if(K >= N){
        goto finish;
    }
    

    for(long long i = 0; i < N; i++){
        std::cin >> H_tmp;
        sum = sum + H_tmp;
        mons_list[i] = H_tmp;
    }

    std::sort(mons_list.begin(), mons_list.end(), std::greater<long long>());
    for(long long i = 0; i < K; i++){
        sum_tgt = sum_tgt + mons_list[i];
    }
    sum = sum - sum_tgt;
    
    finish:
    std::cout << sum;
}

Measured memory_bytes: 4744
import java.util.*;

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

        String S = sc.next();
        int L = S.length();

        boolean isPar = isParindorome(S);
        boolean isParLeft = isParindorome(S.substring(0, (L - 1) / 2));
        boolean isParRight = isParindorome(S.substring(((L + 3) / 2)-1, L));
        if (!isPar || !isParLeft || !isParRight) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }

    static Boolean isParindorome(String S) {
        int N = S.length();
        for (int i = 0; i < N / 2; i++) {
            if (S.charAt(i) != S.charAt((N - 1) - i)) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 21972
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*
数直線上で、sからs + wまでの位置を占めるブロックであると考える
所定の位置よりも左に配置することは可能
他のブロックと重ならないように並べる

s + w が小さいものから順に使うとしてよい
そのようにソートしておく

右端がk以内で、i番目のブロックまで使っているときの価値の最大を
x[i][k]

k - B[i].w > B[i].s のとき
x[0][k] = B[0].v
x[i][k] = max(x[i - 1][k], x[i][k - 1])

k - B[i].w >= 0 かつ k - B[i].w <= B[i].s のとき
x[0][k] = B[0].v
x[i][k] = max(x[i - 1][k - B[i].w] + B[i].v, x[i - 1][k], x[i][k - 1])

k - B[i].w < 0 のとき
x[0][k] = 0
x[i][k] = x[i - 1][k]

*/

void main(){
	long n = read.to!long;
	
	Block[] blocks;
	foreach(i; 0 .. n){
		blocks ~= new Block(read.to!long, read.to!long, read.to!long);
	}
	debug writeln("blocks:", blocks);
	
	blocks.sort!"a.s+a.w<b.s+b.w"();
	debug writeln("blocks:", blocks);
	
	long kmax = blocks[$ - 1].s + blocks[$ - 1].w + 10;
	debug writeln("kmax:", kmax);
	
	long[][] xs = new long[][](n, kmax);
	foreach(i; 0 .. n){
		foreach(k; 0 .. kmax){
			long l = k - blocks[i].w;
			if(l >= 0 && l <= blocks[i].s){
				if(i == 0) xs[i][k] = blocks[i].v;
				else xs[i][k] = max(xs[i - 1][l] + blocks[i].v, xs[i - 1][k], xs[i][k - 1]);
			}
			else if(l >= 0){
				if(i == 0) xs[i][k] = blocks[i].v;
				else if(k > 0) xs[i][k] = max(xs[i - 1][k], xs[i][k - 1]);
				else xs[i][k] = xs[i - 1][k];
			}
			else{
				if(i == 0) xs[i][k] = 0;
				else xs[i][k] = xs[i - 1][k];
			}
		}
	}
	debug writeln("xs:", xs);
	
	xs[n - 1][kmax - 1].writeln;
}


class Block{
	long w, s, v;
	this(long w, long s, long v){
		this.w = w;
		this.s = s;
		this.v = v;
	}
	override string toString(){
		return "(" ~ s.to!string ~ ", " ~ w.to!string ~ ", " ~ v.to!string ~ ")";
	}
}



Measured memory_bytes: 162172
#include<stdio.h>
int main()
{
    char s[200];

    scanf("%s",s);

    int len=0;

    for(int i=0; s[i]!=0;i++)
    len++;

    int count=0;
    for(int i=0,j=(len-1);i<=j;i++,j--)
    {
        if(s[i]!=s[j])
        count++;
    }
//iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiertfsdjhgsjklsdfwerqowert//wertwretwertrewwertwertwertwertertwerterrrt
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,ans=0;
    cin>>n;
    vector<int>l(n);
    for(int i=0;i<n;i++)cin>>l[i];
    l.push_back(10000);
    sort(l.begin(),l.end());
    for(int i=n-1;i>=0;i--){
        for(int j=i-1;j>=0;j--){
            //cout<<l[i]<<l[j]<<endl;
            int t=distance(l.begin(),lower_bound(l.begin(),l.begin()+j,l[i]+l[j]))-1;
            for(int k=t;k>=0;k--){
                if(l[i]<l[j]+l[k]&&l[j]<l[i]+l[k]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

struct coordinate {
    llong x, y;
};

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

    llong N;
    cin >> N;

    vector<coordinate> small(N);
    FOR(i, N) {
        cin >> small[i].x >> small[i].y;
    }

    vector<coordinate> big(N);
    FOR(i, N) {
        cin >> big[i].x >> big[i].y;
    }

    sort(small.begin(), small.end(), [](coordinate a, coordinate b){
        return a.y > b.y;
    });

    sort(big.begin(), big.end(), [](coordinate a, coordinate b){
        return a.x < b.x;
    });

    vector<bool> isMathced(N, false);
    llong ans = 0;

    FOR(i, N) {
        coordinate nowBig = big[i];

        FOR(j, N) {
            coordinate nowSmall = small[j];
            if(isMathced[j]) continue;
            if(nowSmall.x < nowBig.x and nowSmall.y < nowBig.y) {
                ans += 1;
                isMathced[j] = true;
                break;
            }
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; 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  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
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; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, m;
vector<pair<LL, LL>> v;

int main() {
	cin >> n >> m;
	inc(i, n) {
		LL a, b;
		cin >> a >> b;
		v.EB(a, b);
	}
	sort(ALL(v));
	
	LL ans = 0, c = 0;
	inc(i, n) {
		LL cc = min(m - c, v[i].SE);
		ans += cc * v[i].FI;
		c += cc;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

void enqueue(int index);
int dequeue(void);

int Q[1001];
int lastQ = 0;

char name[1001][11];
int time[1001];

main(){

  int i, index, n, q, elapsedTime = 0;

  scanf("%d %d",&n,&q);

  for(i=0; i<n; i++){
    scanf("%s %d",name[i],&time[i]);
    enqueue(i);
  }

  while(n!=0){

    index = dequeue();
    time[index] -= q;
    elapsedTime += q;

    if(time[index] <= 0){
      elapsedTime += time[index];
      printf("%s %d\n",name[index],elapsedTime);
      n--;
    }else{
      enqueue(index);
    }

  }

  return 0;

}

void enqueue(int index){
  Q[lastQ++] = index;
}

int dequeue(void){

  int i,tmp = Q[0];

lastQ--;

  for(i=0; i<lastQ; i++)
    Q[i] = Q[i+1];

  return tmp;

}

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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);




int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector<long long> arr (n);
    for(auto& x : arr)
        cin >> x;
    long long ans = 0;
    for(int i = 0; i < 60; i++)
    {
        int k = 0;
        for(int j = 0; j < n; j++)
            if(arr[j] & (1ll << i))
                k++;
        ans += ((1ll << i) % MOD * (1ll * k * (n - k) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int n;
int step(string s)
{
	int len=s.size();
	int count=0;
	while(1)
	{
		if(len==1)break;
		int k=(s[len-1]-'0')+(s[len-2]-'0');
		if(k>9)
		{
			s[len-2]='1';
			s[len-1]='0'+k%10;
			count++;
		}
		else
		{
			s[len-2]='0'+k;
			count++;
			len--;
		}
	}
	return count;
}
int main()
{
	cin >> n;
	string s;
	for(int i=0;i<n;i++)
	{
		cin >> s;
		if(step(s)%2==0)cout << "Audrey wins." << endl;
		else cout << "Fabre wins." << endl;
	}
	return 0;
}

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


int dp[100];

//最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  double w, h, x, y;
  cin >> w >> h >> x >> y;

  double ans = w*h / 2.0;
  int ans2 = 0;
  if(w / 2 == x && h / 2 == y) ans2 = 1;

  printf("%lf %d\n", ans, ans2);
}


/*





















*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e2 + 7;
int a[MAXN];
int main() {
    int n, cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            for (int k = j + 1; k <= n; k++) {
                if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k]) {
                    if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N;
    cin >> N;
    vector<ll> count(N);
    Loop(i, 1, 1 + sqrt(N))
    {
        Loop(j, 1, 1 + sqrt(N))
        {
            Loop(k, 1, 1 + sqrt(N))
            {
                ll now = i * i + j * j + k * k + i * j + j * k + k * i;
                if (now <= N)
                {
                    count[now - 1]++;
                }
            }
        }
    }
    loop(i, N) putout(count[i]);
    return 0;
}


Measured memory_bytes: 3588
import java.io.*;
import java.awt.geom.Point2D;

public class Main{
	public static void main(String args[]) throws IOException{
		double p[] = new double[4];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] str = br.readLine().split(" ");
		for(int i = 0; i < 4; i++)
			p[i] = Double.parseDouble(str[i]);
		
		System.out.println(Point2D.distance(p[0], p[1], p[2], p[3]));
	}
}

Measured memory_bytes: 24344
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    val a: String = sc.nextLine
    val b: String = sc.nextLine
    val c: String = sc.nextLine
    val d: String = sc.nextLine
    val e: String = sc.nextLine

    val partitioned = List(a, b, c, d, e).partition(item => item.last == '0')
    val ans: Int = (partitioned._2.sortBy(item => item.last).zipWithIndex.map {
      case (item, index) => if (index == 0) item.toInt
      else if (item.last == '0') item.toInt
      else {
        (((item.toInt / 10.0).toInt + 1) * 10.0).toInt
      }
    } ::: partitioned._1.map {
      _.toInt
    }).sum
    println(ans)


  }
}

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

int main() {
    int A, B;
    cin >> A >> B;
    if (A > 9 || B > 9)
    {
        cout << -1 << endl;
    } else
    {
        cout << A * B << endl;
    }
    
    
  return 0;
}


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

typedef long long ll;

int n;
string s;
ll mod = 1000000007, a[26], ans = 1;

int main()
{
    cin >> n >> s;
    for (int i = 0; i < n; i++)
        a[(int) (s[i] - 'a')]++;
    for (int i = 0; i < 26; i++)
        ans = (ans * (a[i] + 1)) % mod;
    cout << ans - 1 << endl;
    return 0;
}

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

int main()
{
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		vector<int>s(7);
		for (int b = 0; b < a; b++)
		{
			string c;
			cin >> c;
			if (c.length() == 1) { s[0]++; continue; }
			if (c[0] > 53) { s[6]++; continue; }
			if (c.length() == 3) { s[6]++; continue; }
			s[c[0] - 48]++;
		}
		for (int k : s)
			cout << k << endl;
	}
}

Measured memory_bytes: 3068
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n; cin >> n;
	int a, x, y;
	int tf[n][n] = {};
	REP(i, n) REP(j, n) tf[i][j] = -1;
	REP(i, n){
		cin >> a;
		REP(j, a){
			cin >> x >> y;
			tf[i][x-1] = y;
		}
	}
	/*
	REP(i, n){
		REP(j, n) cout << tf[i][j] << " ";
		cout << endl;
	}
	*/
	REP(k, 1 << n){
		bool ch = true;
		int now = 0;
		REP(i, n){
			if((1 << i) & k){
				now ++;
				REP(j, n){
					if(tf[i][j] == 1 && !(k & (1 << j))) ch = false;
					if(tf[i][j] == 0 && (k & (1 << j))) ch = false;
				}
			}
		}
		if(ch) ans = max(ans, now);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long n,k;
	cin>>n>>k;
	long ar[n+1],i;
	for(i=1;i<=n;i++)
	cin>>ar[i];
	long dp[n+1]={0},val,j;
	dp[2]=abs(ar[2]-ar[1]);
	for(i=3;i<=n;i++)
	{
		val=100000000000;
		for(j=i-1;j>=i-k && j>=1;j--)
		{
			val=min(dp[j]+abs(ar[i]-ar[j]),val);
		}
		dp[i]=val;
	}
	cout<<dp[n];
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        String[] all = sc.nextLine().split(" ");
        sc.close();

        String S = all[0];
        String T = all[1];

        StringBuilder result = new StringBuilder();

        for (int i = 0; i < N; i++) {
            result.append(S.charAt(i));
            result.append(T.charAt(i));
        }

        System.out.println(result.toString());
    }

}

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

int main(){
	while (true)
	{
		double l[11] = {}, v[3];
		int ans;
		char knm;
		for(int i=0;i<10;i++){
			cin >> l[i] >> knm;
			l[10] += l[i];
		}
		if (cin.eof()) { break; }
		cin >> v[0] >> knm >> v[1];
		v[2] = v[0] + v[1];
		l[10] = l[10] * v[0] / v[2];
		for(ans = 0; ans<10;ans++){
			l[10] -= l[ans];
			if(l[10]<=0){
				break;
			}
		}
		cout << ans + 1 << endl;
	}

}

Measured memory_bytes: 3116
#include <iostream>
using namespace std;
 
int main() {
	int H,W;
	while(1){
	cin >> H >> W;
	if(H==0 && W==0)break;
	for(int i=0; i < H; i++){
		for(int k = 0; k < W; k++){
			cout << "#";
		}
		cout << "\n";
	}
	cout << "\n";
	}
	return 0;
}

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

using namespace std;

int main()
{
   int order[5];
   int loss[5];
   int time = 0;

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

   for(int i=0;i<5;i++){
      int hoge;
      hoge = order[i];
      for(int j=0;j<=9;j++){
         if(hoge % 10 != 0){
            hoge++;
         }else{
            loss[i] = j;
            break;
         }
      }
   }

   size_t index[5];
   iota(index, index+5, 0);

   stable_sort(index, index+5, [&loss](size_t i1, size_t i2){
      return loss[i1] < loss[i2];
   });

   for(int i=0;i<5;i++){
      while(time % 10 != 0) time++;
      time += order[index[i]];
   }

   cout << time << endl;

   return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var x = Console.ReadLine().Split().Select(int.Parse).Select((v, i) => new { v, i }).OrderBy(_ => _.v).ToArray();

		int h = n / 2, b1 = x[h].v, b2 = x[h - 1].v;
		Console.WriteLine(string.Join("\n", x.Select((_, j) => new { _.i, b = j < h ? b1 : b2 }).OrderBy(_ => _.i).Select(_ => _.b)));
	}
}


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

using namespace std;

int main()
{
    long long int k, a, b;
    scanf("%lld %lld %lld", &k, &a, &b);

    if (k <= a || b - a <= 1)
        printf("%lld\n", k + 1);
    else
    {
        printf("%lld\n", a + ((k - a + 1) / 2) * (b - a) + ((k - a + 1) % 2));
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << x2 - (y2 - y1) << " " << y2 + (x2 - x1) << " " << x1 - (y2 - y1) << " " << y1 + (x2 - x1) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	ll t;
	cin >> t;
	map<string,int> my;
	while(t--)
	{
		string s;
		cin >> s;
		my[s]++;
	}
	cout << "AC" sp "x" sp my["AC"] << endl;
	cout << "WA" sp "x" sp my["WA"] << endl;
	cout << "TLE" sp "x" sp my["TLE"] << endl;
	cout << "RE" sp "x" sp my["RE"] << endl;
	return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<pair<int, int>> r(n);
    rep(i,n) cin >> r[i].first >> r[i].second;
    sort(ALL(r));
    int cnt = 0;
    int now = 0;
    int next = 1;
    while(now < n && next < n){
        if(r[next].first - r[next].second < r[now].first + r[now].second){
            cnt++;
            /*if(cnt == n-1) {
                cout << 1 << endl;
                return 0;
            }*/
            if(r[next].first + r[next].second > r[now].first + r[now].second){
                next++;
            }
            else{
                now = next;
                next++;
            }
        }
        else{
            now = next;
            next++;
        }
    }
    cout << n - cnt << endl;
}

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

int main(){
    int N,M;cin>>N>>M;
    vector<pair<int,int>> a(N);
    for(int i=0;i<N;i++)cin>>a.at(i).first>>a.at(i).second;
    sort(a.begin(),a.end());
    priority_queue<int> b;
    int ans=0;
    for(int i=1,j=0;i<=M;i++){
        while(a.at(j).first==i){
            b.push(a.at(j).second);
            if(j==N-1)break;
            j++;
        }
        if(b.size()){
            ans+=b.top();
            b.pop();
        }
    }
    cout<<ans<<endl;
    return 0;
}

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


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

    int n;
    cin >> n;
    vector<int> A(n), B(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());
    copy_n(istream_iterator<int>(cin), n, B.begin());
    set<int> C;
    for (const auto &b: B)
        C.insert(b);

    int diff = 0;
    vector<int> g, h;
    for (int i = 0; i < n; i++){
        if (C.count(A[i]) == 0){
            cout << "No" << endl;
            for (int j = 0; j < n; j++){
                if (i == j){
                    g.push_back(A[0]);
                    h.push_back(A[1]);
                } else {
                    g.push_back(A[0]);
                    h.push_back(A[0]);
                }
            }
            for (int i = 0; i < n - 1; i++){
                cout << g[i] << " ";
            }
            cout << g[n - 1] << endl;
            for (int i = 0; i < n - 1; i++){
                cout << h[i] << " ";
            }
            cout << h[n - 1] << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 8756
#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 s;
  cin >> s;
  int left = s / 100;
  int right = s % 100;
  if(1 <= left && left <= 12){
    if(1<=right && right<=12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }else {
    if(1<=right && right<=12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    for(int i=0; i<N; i++) cin >> C[i];

    for(auto& a : A) a = -a;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    ll ans = 0;
    for(int i=0; i<N; i++)
    {
        int numa = A.end() - upper_bound(A.begin(), A.end(), -B[i]);
        int numc = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        ans += 1LL * numa * numc;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4508
// C - Poll
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> vector<T> inarr(int s,int e, T init){
	vector<T> v;T x;
	for(int i=0;i<s;++i)v.push_back(init);
	for(int i=s;i<e;++i){cin>>x;v.push_back(x);}
	return v;
}

int N;
using VS = vector<string>;
VS S;

void solve(){
	map<string, int> M;
	int maxn = 0;
	rp(i,0,N) chmax(maxn, ++M[S[i]]);
	for(auto m:M) if(maxn == m.second) cout<< m.first<<endl;
}

int main(){
	cin>>N;
	S = inarr<string>(0,N,"");
	solve();
}

Measured memory_bytes: 26736
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as B
import           Data.Char             (isSpace)
import qualified Data.Vector.Unboxed   as V

main :: IO ()
main = do
  n <- readLn
  ls <- V.unfoldrN n parseInt <$> B.getLine
  putStrLn $ if solve n ls then "Yes" else "No"

solve :: Int -> V.Vector Int -> Bool
solve _ ls = m < V.sum (V.take i ls) + V.sum (V.drop (i + 1) ls)
  where i = V.maxIndex ls
        m = ls V.! i

parseInt :: B.ByteString -> Maybe (Int, B.ByteString)
parseInt = B.readInt . B.dropWhile isSpace


Measured memory_bytes: 508
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
ans = 0
for i in range(K,N):
    if T[i] == T[i-K]:
        T[i] = 'n'
score = {'r':P,'s':R,'p':S,'n':0}
for i in range(N):
    ans += score[T[i]]
print(ans)

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  vi p(n);
  rep(i, n){
    cin >> p[i];
    p[i]--;
  }

  vi a(n), b(n);
  rep(i, n) a[i] = b[n-1-i] = 30000*i+1;

  rep(i, n){
    a[p[i]] += i;
  }

  rep(i, n) cout << a[i] << " \n"[i == n-1];
  rep(i, n) cout << b[i] << " \n"[i == n-1];

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,flag=0;
    cin>>n;
    for (int i=0;4*i<=n;i++) {
        for (int j=0;7*j<=n;j++) {
            if (4*i+7*j==n) {
                cout<<"Yes"<<endl;
                flag=1;
                break;
            }
        }
        if (flag==1) {
            break;
        }
    }
    if (flag==0) {
        cout<<"No"<<endl;
    }
}


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

int main() {
    int n;
    cin>>n;
    int a[n];
    int b[n];
    for(int i = 0;i<n;i++){
        cin>>a[i];
        b[i] = a[i];
    }
    sort(b, b + n);
    int cnt = 0;
    for(int i = 0;i<n;i++){
        if(b[i] != a[i]){
            cnt++;
        }
    }
    if(cnt > 2) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 256
n,y = map(int,input().split())
y = y//1000

greed = 10*n
target = greed - y
if target<0:
    print(-1,-1,-1)
    exit()

for c in range(0,n+1):
    if (target-9*c)%5==0:
        b = (target-9*c)//5
        a = n - b - c
        if 0<=a and 0<=b:
            print(a,b,c)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static Map <String, ArrayList<Integer>>map = new HashMap <String, ArrayList<Integer>>();
	static PriorityQueue<String> queue = new PriorityQueue<String>();
	static String word;
	static int page;
	public static void main(String[] args) {
		while(read()){
			
		}
		solve();
	}

	static boolean read(){
		if(!sc.hasNext())return false;
		word = sc.next();
		page = sc.nextInt();
		if(map.containsKey(word)){
			map.get(word).add(page);
		}else{
			queue.add(word);
			ArrayList<Integer>list = new ArrayList<Integer>();
			list.add(page);
			map.put(word, list);
		}
		return true;
	}
	
	static void solve(){
		while(!queue.isEmpty()){
			String w = queue.poll();
			ArrayList<Integer>list = map.get(w);
			System.out.println(w);
			Collections.sort(list);
			boolean flag = true;
			for(int i : list){
				if(!flag)System.out.print(" ");
					flag = false;
					System.out.print(i);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
import itertools
import math
N = int(input())
P = N
XY = []
for n in range(N):
    xy = list(map(int, input().split()))
    XY.append(xy)
l = [i for i in range(N)]
L = itertools.permutations(l)
total = 0
cnt = 0
for i in L:
    p = list(i)
    for n in range(N-1):
        res = 0
        res = math.sqrt((XY[p[n+1]][0] - XY[p[n]][0])**2 + (XY[p[n+1]][1] - XY[p[n]][1])**2)
        cnt += res
G = cnt / math.factorial(P)
print(G)

Measured memory_bytes: 3064
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む
 
int main() {
    using std::cout;
    using std::endl;
    using std::cin;
    using std::string;

    int n, temp[4] = {0};
    cin >> n;

    temp[0] = n / 1000;
    temp[1] = (n - temp[0]*1000) / 100;
    temp[2] = (n - temp[0]*1000 - temp[1]*100) / 10;
    temp[3] = n % 10;
    
    if((temp[0]*2)==(temp[1]+temp[2]) || (temp[3]*2)==(temp[1]+temp[2])){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
//Int MOD = 998244353;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    COMinit();
    Int h, w, a, b;
    cin >> h >> w >> a >> b;
    Int res = 0;
    for (Int i = 1; i <= h - a; i++) {
        Int add = 1;
        add *= fac[i + b - 2]; add %= mod;
        add *= finv[i - 1]; add %= mod;
        add *= finv[b - 1]; add %= mod;
        add *= fac[h - i + w - b - 1]; add %= mod;
        add *= finv[h - i]; add %= mod;
        add *= finv[w - b - 1]; add %= mod;
        res += add; res %= mod; 
    }
    dump(res);
    return 0;  
}

Measured memory_bytes: 12160
from collections import Counter
N = int(input())
S = [list(input()) for _ in range(N)]
for i in range(N):
    S[i].sort()
    S[i] = ''.join(S[i])
C = Counter(S)
ans = 0
for i in C.values():
    ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 30612
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H.sort()
df = 0
min_h = H[K-1]-H[0]

for i in range(1, N-K+1):
    new_h = H[i+K-1]-H[i]
    if new_h < min_h:
        min_h = new_h

print(min_h)


Measured memory_bytes: 13260
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
      	String s = scn.next();
      	String t = scn.next();
      	if(s.length() == t.length() - 1){
        	if(s.equals(t.substring(0, s.length()))){
            	System.out.println("Yes");
            }else{
            	System.out.println("No");
            }
        }else{
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 35544
n,q=map(int,input().split())
l=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(lambda x:int(x)-1,input().split())
    l[a].append(b)
    l[b].append(a)
xl=[0 for i in range(n)]
for i in range(q):
    p,x=map(int,input().split())
    p-=1
    xl[p]+=x
#DFS
que=[0]
s=[-1 for i in range(n)]
s[0]=xl[0]
while len(que)>0:
    r=que.pop()
    for i in l[r]:
        if s[i]==-1:
            s[i]=s[r]+xl[i]
            que.append(i)
print(*s)

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

int main(){
    int N, T, A;
    cin >> N >> T >> A;

    int low = 1000000, ans = 0;
    for(int i = 1; i <= N; i++){
        int h, tmp;
        cin >> h;
        tmp = abs(A*1000 - (T*1000 - h*6));
        if(tmp < low){
            low = tmp;
            ans = i;
        }
    }
    cout << ans << endl;
}

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 n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
    if (A.size() == n+1) {
        int now = 0;
        rep(i,q) {
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main() 
{    
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(vector<int>(1,1));

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636