akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,c=1;
  cin >> n;
  vector<int> d(n);
  for(int i=0; i<n; i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  a = d.at(0);
  for(int i=0; i<n; i++){
    if(!(a == d.at(i))) c++;
    a = d.at(i);
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> 
using namespace std ;
int main () {
	int a, b, c, d;
	double e ;
	cin >> a >> b ;           
	c = a / b ;
	d = a % b ;
	e = (double)a / b ;
	cout << fixed << setprecision(5) ;
	cout << c << " " << d << " " << e << endl ;
}


Measured memory_bytes: 3220
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum mod = 10L^^9 + 7;
enum inf = 10^^9;

void main() {
    string s;
    scan(s);
    auto n = s.length.to!int;

    auto dp = new long[][](n + 1, 4);
    dp[0][0] = 1;

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. 4) {
            dp[i+1][j] = s[i] == '?' ? dp[i][j]*3 % mod : dp[i][j];
        }

        if (s[i] == 'A' || s[i] == '?') {
            (dp[i+1][1] += dp[i][0]) %= mod;
        }
        if (s[i] == 'B' || s[i] == '?') {
            (dp[i+1][2] += dp[i][1]) %= mod;
        }
        if (s[i] == 'C' || s[i] == '?') {
            (dp[i+1][3] += dp[i][2]) %= mod;
        }
    }

    debug {
        writeln(dp);
    }

    long ans = dp[n][3];

    writeln(ans);
}



























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

main(){
  int n;
  int W;
  cin >> n;
  cin >> W;
  int weight[n];
  int value[n];
  for(int ii=0;ii<n;ii++){
    cin >> weight[ii];
    cin >> value[ii];
  }
  long dp[n+1][W+1];
  for(int ii=0;ii<n+1;ii++){
    for(int jj=0;jj<W+1;jj++){
      dp[ii][jj]=0;
    }
  }
  for(int ii=0;ii<W;ii++){
    dp[0][ii]=0;
  }
  for(int ii=0;ii<n;ii++){
    for(int jj=0;jj<=W;jj++){
      if(jj-weight[ii]>=0)dp[ii+1][jj]=max(dp[ii][jj],dp[ii][jj-weight[ii]]+value[ii]);
      else dp[ii+1][jj]=dp[ii][jj];
    }
  }
  cout << dp[n][W] << endl;
  // for(int ii=0;ii<n+1;ii++){
  //   for(int jj=0;jj<W+1;jj++){
  //     cout << dp[ii][jj] << " ";
  //   }
  //   cout<<endl;
  // }
}


Measured memory_bytes: 79104
UP = int(1e9)
s = set()
full = set('357')


def dfs(n):
    if n > UP:
        return
    if set(str(n)) == full:
        s.add(n)
    dfs(n * 10 + 3)
    dfs(n * 10 + 5)
    dfs(n * 10 + 7)


dfs(0)
l = list(s)
l.sort()
n = int(input())
ans = 0
for i in l:
    if i <= n:
        ans += 1
    else:
        break
print(ans)


Measured memory_bytes: 6256
Imports System.Collections.Generic
Imports System.Console

Module Program
    Dim dic As New Dictionary(Of String, Integer)

    Sub Main()
        Dim N As Integer = NextInt()
        Register(N, 1)
        Dim M As Integer = NextInt()
        Register(M, -1)

        Dim ans As Integer

        For Each v As Integer In dic.Values
            ans = Math.Max(ans, v)
        Next

        WriteLine(ans)
    End Sub

    Sub Register(n As Integer, t As Integer)
        For i As Integer = 0 To n - 1
            Dim s As String = ReadLine()
            If dic.ContainsKey(s) Then
                dic(s) += t
            Else
                dic(s) = t
            End If
        Next
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 22224
#include<stdio.h>
a[100],b[100],s,c;int main(){
	int i,j;
	int as=0;
	for(i=0;scanf("%d,%d",&a[i],&b[i])!=EOF;i++){
		s+=a[i]*b[i];as+=b[i];c++;
	}
	printf("%d\n%d\n",s,(int)((double)((double)as/(double)c)+0.5));
	exit(0);
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  int x[9] = {111,222,333,444,555,666,777,888,999};
  for(int i=0;i<9;i++){
    if(n%1000==x[i]){
      cout << "Yes" << endl;
      return 0;
    }
    if(n/10==x[i]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(n%1000==0){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


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

long long com[51][51];

void combination(int n){
  //combination
    com[0][0] = 1;
    for (int i = 1; i <=n; ++i) {
        for (int j = 0; j <= i; ++j) {
            com[i][j] += com[i-1][j];
            if (j > 0) com[i][j] += com[i-1][j-1];        
        }
    }
}

int main(void){
    int N, a, b; 
    cin >> N >> a >> b;
  
  combination(N);
  
    vector<long long> v(N);
  
    for (int i = 0; i < N; ++i) 
      cin >> v[i];
  
    sort(v.begin(), v.end(), greater<long long>());

    
    long long sum = 0;
  
    for (int i = 0; i < a; ++i){
      sum += v[i];
    }
  
    double ave = (double)(sum) / a;

    
    long long res = 0;
  
    int num = 0;
    for (int i = 0; i < N; ++i) if (v[i] == v[a-1]) ++num;
  
    if (v[0] == v[a-1]) {
        for (int j = a; j <= b; ++j) {
            res += com[num][j];
        }
    }
  
    else {
        int ans = 0;
        for (int i = 0; i < a; ++i) if (v[i] == v[a-1]) ans++;
        res = com[num][ans];
    }
  
    cout << fixed << setprecision(20) << ave << endl;
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 45;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - '0';}
char myitoc(int N) {return '0' + N;}

struct edge
{
  int to, cost;
  edge(int to, int cost) : to(to), cost(cost) {}
};

signed main()
{
  int N, M, P;
  cin >> N >> M >> P;
  vector<vector<edge>> G(N);
  for (int i = 0; i < M; i++)
  {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G.at(a).push_back(edge(b, P - c));
  }

  vector<int> d(N, INF);
  d.at(0) = 0;
  for (int i = 0; i < 2 * N; i++)
  {
    for (int v = 0; v < N; v++)
    {
      for (int k = 0; k < G.at(v).size(); k++)
      {
        edge e = G.at(v).at(k);
        if (d.at(v) != INF && chmin(d.at(e.to), d.at(v) + e.cost))
        {
          if (i >= N - 1)
          {
            d.at(e.to) = -INF;
          }
        }
      }
    }
  }

  if (d.at(N - 1) <= -INF)
    cout << -1 << endl;
  else
    cout << max((int)0, -d.at(N - 1)) << endl;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {

 public static void main(String[] args) {
   Scanner no=new Scanner(System.in);
   int n=no.nextInt();
   StringBuilder sb=new StringBuilder();
   String arr[]=new String[n];
   int m=no.nextInt();
   for(int i=0;i<n;i++){
     arr[i]=no.next();
   }
   Arrays.sort(arr);
   for(int i=0;i<n;i++){
     sb.append(arr[i]);
   }
   System.out.println(sb.toString());
  }

}
 

Measured memory_bytes: 37420
#include<bits/stdc++.h>
using namespace std;
int a[11];
char b[12];
int tg;
void dfs(int n,char a,int maxc);
int main()
{
	scanf("%d",&tg);
	dfs(1,'a',1);
}
void dfs(int n,char l,int maxc)
{
	int i;
	b[n]=l;
	if(n==tg)
	{
		
		for(i=1;i<=n;i++)
		printf("%c",b[i]);
		printf("\n");
		return;
	}
	for(i=0;i<maxc;i++)
	{
		dfs(n+1,'a'+i,maxc);
	}
	dfs(n+1,'a'+maxc,maxc+1);
}

Measured memory_bytes: 1536
n,m = map(int,input().split())
coins = list(map(int,input().split()))

# 0はdummy
dp = [50001 for _ in range(50001)]
dp[0] = 0

for i in range(0,50001):
    for j in range(m):
        if i+coins[j] <= n:
            dp[i+coins[j]] = min(dp[i+coins[j]],dp[i]+1)
            
print(dp[n])
        


Measured memory_bytes: 7384
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()

cnt = 0
cnt_b = []
for i_b in range(n):
    # if max(c) < b[i_b]:
    #     cnt_b.append(0)
    #     continue
    i_a = bisect.bisect_left(a, b[i_b]) - 1
    i_c = bisect.bisect_right(c, b[i_b])
    if i_a < 0 or n <= i_c:
        continue
    cnt += (i_a + 1) * (n - i_c)
    # print(i_a, i_b, i_c)

print(cnt)

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 1005;
ll n, a[MX], p[2], sr;
vi s[2], res;

void solve (vi s) {
	for (int i = n - 1; i > s.back(); i--)
		 res.pb(i);

	for (int i = int(s.size()) - 2; i >= 0; i--) {
		int m = (s[i] + s[i + 1]) / 2;
		int off = 0;
		forn (_, (s[i + 1] - s[i]) / 2) {
			res.pb(m - off);
			off++;
		}
	}

	forn (i, s[0])
		res.pb(0);
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	forn (i, n) {
		cin >> a[i];
		if (a[i] > 0) {
			p[i % 2] += a[i];
			s[i % 2].pb(i);
		}
	}

	if (!p[0] && !p[1]) {
		int ind = 0;
		forn (i, n) if (a[i] > a[ind]) ind = i;
		p[0] = p[1] = a[ind];
		for (int i = n - 1; i > ind; i--) res.pb(i);
		forn (i, ind) res.pb(0);
	} else if (p[0] > p[1]) {
		solve(s[0]);
	} else {
		solve(s[1]);
	}

	cout << max(p[0], p[1]) << endl;
	cout << res.size() << endl;
	for (int x : res) cout << x + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())

B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]

cnt = 0
for l in A:
    r = 0
    for j in range(M):
        r += l[j]*B[j]
    if r + C > 0:
        cnt+=1
        
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(){
	int n,m;
	cin>>n>>m;
	int cnt=0;

	vector<int> v(n+m);
	rep(i,n){
		v.at(i) = 2;
	}
	for (size_t i = n; i < n+m; i++)
	{
		v.at(i) = 1;
	}
	
	// rep(i,m+n){
	// 	cout<<v.at(i)<<endl;
	// }

	rep(i,n+m){
		for (size_t j = i+1; j < n+m; j++)
		{
			// cout<<i<<" "<<j<<" "<<v.at(i)<<" "<<v.at(j)<<endl;
			if ((v.at(i)+v.at(j))%2==0)
			{
				cnt++;
			}
			
		}
		
	}
	cout<<cnt;
}


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

A.append(0)
A.append(0)
A.insert(0, 0)
A.insert(0, 0)

d = [ [abs(A[i] - A[i+1]), abs(A[i] - A[i+2])] for i in range(len(A) - 2)]
d.append([0, 0])
d.insert(0, [0, 0])

fee = 0
for i in d:
    fee += i[0]

res = [d[i+1][0] + d[i][0] - d[i][1] for i in range(2, len(d)-2)]
for r in res:
    print(fee - r)

Measured memory_bytes: 27672
#include <bits/stdc++.h>
using namespace std;
const int Q=1<<20;
int ls[Q],rs[Q],ch[Q][3],laz[Q],n,tl=0,p3[123];
void Init(int &now,int dp,int bas)
{
	now=++tl;
	if(dp==n){
		ch[now][0]=bas;
		return;
	}
	for(int i=0;i<3;i++)
		Init(ch[now][i],dp+1,bas+i*p3[dp]);
}
void Pd(int now)
{
	laz[now]=0;
	swap(ch[now][1],ch[now][2]);
	for(int i=0;i<3;i++)
		laz[ch[now][i]]^=1;
}
char s[Q];
int ans[Q];
void Bd(int now,int dp,int bas)
{
	if(dp==n){
		ans[ch[now][0]]=bas;
		return;
	}
	if(laz[now])Pd(now);
	for(int i=0;i<3;i++)
		Bd(ch[now][i],dp+1,bas+i*p3[dp]);
}
void Ad(int now,int dp)
{
	if(dp==n)return;
	if(laz[now])Pd(now);
	swap(ch[now][1],ch[now][2]);
	swap(ch[now][1],ch[now][0]);
	Ad(ch[now][0],dp+1);
}
int main()
{
	p3[0]=1;
	for(int i=1;i<=12;i++)
		p3[i]=p3[i-1]*3;
	scanf("%d%s",&n,s);
	int qaq=strlen(s),rt=0;
	Init(rt,0,0);
	for(int i=0;i<qaq;i++)
		if(s[i]=='S')laz[rt]^=1;
		else Ad(rt,0);
	Bd(rt,0,0);
	for(int i=0;i<p3[n];i++)
		printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 18748
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	unsigned long long int n, T;
	string fn;
	cin >> n >> T >> fn;
	unsigned long long int sum = 0;
	for (int i = 0; i < fn.size(); ++i)
	{
		if (fn[i] == 'n' && fn[i + 1] == '^')
		{
			unsigned long long int temp = 1;
			for (int j = 0; j < fn[i + 2] - '0'; ++j)
			{
				temp *= n;
				if (temp > 1e9)
				{
					cout << "TLE" << endl;
					return;
				}
			}
			sum += temp;
		}
	}
	sum *= T;
	if (sum > 1e9)
	{
		cout << "TLE" << endl;
	}
	else
	{
		cout << sum << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int a, b, n, x, y;
int solve[25][25];
bool obs[25][25];

int dp(int i, int j) // i:x座標, j:y座標, 返り値:点(i, j)に行く最短経路の数
{
    if (solve[i][j] >= 0) return solve[i][j];
    
    if (obs[i][j]) solve[i][j] = 0;
    
    else if (i == 1 && j == 1) {
        solve[i][j] = 1;
    }
    else if (i == 1) {
        solve[i][j] = dp(i, j - 1);
    }
    else if (j == 1) {
        solve[i][j] = dp(i - 1, j);
    }
    else solve[i][j] = dp(i - 1, j) + dp(i, j - 1);
    
    return solve[i][j];
}

int main(void){
    
while (1) {
    cin >> a >> b;
    if (a == 0 && b == 0) return 0;
    
    cin >> n;
    
    for (int i = 1; i <= 16; i++) {
        for (int j = 1; j <= 16; j++) obs[i][j] = false;
    }
    
    for (int i = 1; i <= n; i++) {
        cin >> x >> y;
        obs[x][y] = true;
    }
    
    for (int i = 1; i <= a; i++) {
        for (int j = 1; j <= b; j++) solve[i][j] = -1;
    }
    
    cout << dp(a, b) << endl;
    
//    for (int i = 1; i <= n; i++) {
//        for (int j = 1; j <= i; j++) cout << dp(i, j) << " ";
//        cout << endl;
//    }

}
}



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

int main(void){
    string s;cin>>s;
    printf("%c", s[0]);
    string t;
    cin>>t;
    printf("%c", t[1]);
    string u;
    cin>>u;
    printf("%c\n", u[2]);
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
int search(int s[],int n,int t);

int search(int s[],int n,int t){
  int i=0;
  s[n]=t;
  while(s[i]!=t) i++;
  return i!=n;
}

int main(){
  int i,j,sum1,sum2,sum3=0,s[10000],t=0;
  scanf("%d",&sum1);
  for(i=0;i<sum1;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&sum2);
  for(j=0;j<sum2;j++){
    scanf("%d",&t);
    if(search(s,sum1,t)!=0) sum3++;
  }
  printf("%d\n",sum3);
  
  return 0;
}

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

int main(){

  while(1){
  int x,y;
  cin>>x>>y;
  if( x == 0 && y == 0) break;
  if( x > y) swap( x, y);

  cout<<x<<" "<<y<<endl;
  }

  return 0;

}



Measured memory_bytes: 3112
package main

import "fmt"

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	if len(a) > len(b) {
		fmt.Println("GREATER")
	} else if len(a) < len(b) {
		fmt.Println("LESS")
	} else if a > b {
		fmt.Println("GREATER")
	} else if a < b {
		fmt.Println("LESS")
	} else {
		fmt.Println("EQUAL")
	}
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	vector<long long int>a;
	int x;
	for (int i = 0; i < 3; i++) {
		cin >> x;
		a.push_back(x);
	}
	int k;
	cin >> k;
	sort(a.begin(), a.end());
	while (k--)a[2] *= 2;

	cout << a[0] + a[1] + a[2] << endl;

	return 0;
}

Measured memory_bytes: 256
import collections, math

local = False
if local:
    file = open("inputt.txt", "r")

def inp():
    if local:
        return file.readline().rstrip()
    else:
        return input().rstrip()

def ints():
    return [int(_) for _ in inp().split()]


N, K = ints()

if N == 0:
    print(N)
else:
    if K<N:
        N = N%K
    ans = min(N, abs(N-K))
    print(ans)

Measured memory_bytes: 38256
import java.util.*;

public class Main {

	

	static int k;
	static int arr[];
	static int n;
	static int ind;
	static int dp[][];
	public static void main(String[] args)
	{
		
		Scanner sc=new Scanner(System.in);
	      n=sc.nextInt();
	      k=sc.nextInt();
	     arr=new int[n];
	     for(int i=0;i<n;i++)
	     {
	    	 arr[i]=sc.nextInt();
	    	 
	     }
	     
	     dp=new int[1000005][5];
	     for(int i=0;i<dp.length;i++)
	     {
	    	 Arrays.fill(dp[i], -1);
	     }
	     
	     int tt=k;
	     int ans=rec(0,tt);
	    
	     if(ans==1)
	     {
	    	 System.out.println("First");
	     }else {
	    	 System.out.println("Second");
	     }
	}
	private static int rec(int chance, int tt) {
		// TODO Auto-generated method stub
		//System.out.println(tt+" "+chance);
		
		if(tt==0)
		{
			return chance==0?2:1;
		}
		int ans=chance== 0 ? 2:1;
		//System.out.println(tt+" "+chance+"  "+dp.length);
		if(dp[tt][chance]!=-1)
		{
			return dp[tt][chance];
		}
		for(int i=0;i<n;i++)
		{
			if(arr[i]<=tt)
			{
				
				ans=rec(chance^1,tt-arr[i]);
				
			}
			//System.out.println(tt+" "+chance+" "+ans+" "+i);
			if(chance==0&&ans==1)
			{
				dp[tt][chance]=1;
				return 1;
				
			}
			if(chance==1&&ans==2)
			{
				dp[tt][chance]=2;

				return 2;
			}
		}
		dp[tt][chance]=ans;
		return ans;
	}
	
	
	
}


Measured memory_bytes: 93124
import math

class Input():
	def readInt(self):
		return int(input())

	def readIntArray(self):
		return [int(x) for x in input().split(" ")]

	def readString(self):
		return input()

	def readStringArray(self):
		return input().split(" ")

	def readFloat(self):
		return float(input())

	def readFloatArray(self):
		return [float(x) for x in input().split(" ")]

def main():
	inp = Input()
	a, b = inp.readIntArray()
	ans = max([a+b, a-b, a*b])
	print(ans)
	

if __name__ == "__main__":
   main()


Measured memory_bytes: 3060
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int N, K;
    scan(N, K);

    auto x = new int[](N), y = new int[](N);

    iota(N).each!(i => scan(x[i], y[i]));

    auto xa = x.dup().sort(), ya = y.dup().sort();

    long ans = 1L * (xa[$ - 1] - xa[0]) * (ya[$ - 1] - ya[0]);

    foreach (xi ; 0 .. N) {
        foreach (xj ; xi + 1 .. N) {
            foreach (yi ; 0 .. N) {
                foreach (yj ; yi + 1 .. N) {
                    int xl = xa[xi], xr = xa[xj];
                    int yb = ya[yi], yt = ya[yj];

                    int cnt;
                    foreach (l ; 0 .. N) {
                        if (xl <= x[l] && x[l] <= xr && yb <= y[l] && y[l] <= yt) cnt++;
                    }

                    if (cnt >= K) {
                        ans = min(ans, 1L * (xr - xl) * (yt - yb));
                    }
                }
            }
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<map>
#include<stack>
using namespace std;
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
/*
int main()
{
	int r, c;
	cin >> r >> c;
	int sy, sx, gy, gx;
	vector<vector<char>>field(r,vector<char>(c));
	sy--, sx--, gy--, gx--;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> field[i][j];
		}
	}
	queue<pair<int,int>>q;
	q.push({ sx,sy });
	vector<vector<int>>d(c, vector<int> (r, -1));
	d[sx][sy] = 0;

	while (!q.empty())
	{
		pair<int, int>p = q.front;
		q.pop();
		for (int i = 0; i < 4; i++)
		{
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue;
			q.push({ nx,ny });
			d[nx][ny] = d[p.first][p.second] + 1;
		}
	}

	cout << d[gx][gy] << endl;
}*/


int main() 
{
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int sum = 0,sum2=0;

	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'a')
		{
			if (sum2 < a + b)
			{
				cout << "Yes" << endl;
				sum2 += 1;
			}

			else if (i >= a + b)
			{
				cout << "No" << endl;
			}
		}

		if (s[i] == 'b')
		{
			sum += 1;
			if (sum2 < a + b && sum <= b)
			{
				cout << "Yes" << endl;
				sum2 += 1;
			}

			else
			{
				cout << "No" << endl;
			}

		}

		if (s[i] == 'c')
		{
			cout << "No" << endl;
		}


	}
	



}



Measured memory_bytes: 3208
// In The Name Of God
#include <iostream>
#include <string.h>
#include <algorithm>
#include <set>
#include <vector>
#include <climits>
#include <map>
#include <queue>
#include <math.h>
#include <iomanip>

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define MP make_pair
#define BSZ  __builtin_popcount
#define ALL(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 1e5 + 20;
string s, t;
int q, a, b, c, d, A[2][N], B[2][N];
bool G[3][3][3][3];

int getA(int t, int l, int r) {
	if (l == 0)
		return A[t][r];
	return A[t][r] - A[t][l - 1];
}

int getB(int t, int l, int r) {
	if (l == 0)
		return B[t][r];
	return B[t][r] - B[t][l - 1];
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++) {
			int f = i, g = j;
			G[i][j][f][g] = 1;
			for (int k = 0; k < 7; k++) {
				f = (f + 2) % 3;
				g = (g + 2) % 3;
				G[i][j][f][g] = 1;
			}
		}
	cin >> s >> t >> q;
	int n = s.size(), m = t.size();
	for (int i = 0; i < n; i++) {
		if (s[i] == 'A')
			A[0][i] = 1;
		else
			B[0][i] = 1;
	}
	for (int i = 0; i < m; i++) {
		if (t[i] == 'A')
			A[1][i] = 1;
		else
			B[1][i] = 1;
	}
	for (int i = 1; i < n; i++) {
		A[0][i] += A[0][i - 1];
		B[0][i] += B[0][i - 1];
	}
	for (int i = 1; i < m; i++) {
		A[1][i] += A[1][i - 1];
		B[1][i] += B[1][i - 1];
	}
	while (q--) {
		cin >> a >> b >> c >> d;
		a--, b--, c--, d--;
		int cas = getA(0, a, b) % 3, cbs = getB(0, a, b) % 3;
		int cat = getA(1, c, d) % 3, cbt = getB(1, c, d) % 3;
		if (G[cas][cbs][cat][cbt])
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}






















Measured memory_bytes: 2512
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n,a,b,c,d;string s;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(n);
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s=="AC")a++;
		if(s=="WA")b++;
		if(s=="TLE")c++;
		if(s=="RE")d++;
	}
	printf("AC x %d\n",a);
	printf("WA x %d\n",b);
	printf("TLE x %d\n",c);
	printf("RE x %d\n",d);
	return 0;
}


Measured memory_bytes: 3712
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;


#define INF (1ll<<60)

int main(int argc, char const *argv[]) {
	int n;cin>>n;
	string a,b;cin>>a>>b;
	for(int i=0;i<=n;++i){
		bool ok = true;
		for(int j=i;j<n;++j){
			if(a[j]!=b[j-i])ok=false;
		}
		if(ok){
			cout<<n+i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;ll T;cin>>N>>T;
    vector<int> a(N);
    REP(i,N)cin>>a[i];
    ll mi=INF;
    ll ma=0;
    ll d=0;
    REP(i,N){
        if(a[i]<mi){mi=a[i];ma=a[i];}
        if(a[i]>ma){ma=a[i];}
        d=max(d,ma-mi);
    }
    int res=0;
    vector<pair<ll,int> > v;
	REP(i,N)v.push_back(make_pair(a[i],i));
	sort(all(v));
    REP(i,N){
        int ind=lower_bound(v.begin()+i,v.end(),make_pair(v[i].first+d,0))-v.begin();
        if(ind<N && v[i].second<v[ind].second)res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2804
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>

#define pi acos(-1)

#define Rep(i,x,y) for (int i=x,_Lim=y;i<=_Lim;i++)
#define Dep(i,x,y) for (int i=x,_Lim=y;i>=_Lim;i--)

using namespace std;

inline int read(){
	int f=1,res=0,ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;ch=getchar();
	}
	while (ch>='0' && ch<='9') res=res*10+ch-48,ch=getchar();
	return f*res;
}

typedef long long ll;

int n,Dat[2][105],f[105][2];
int main(){
	n=read();
	Rep(i,1,n) Dat[0][i]=read();
	Rep(i,1,n) Dat[1][i]=read();
	Rep(i,1,n) f[i][0]=f[i-1][0]+Dat[0][i];
	Rep(i,1,n) Rep(j,1,1){
		f[i][j]=max(f[i-1][j],f[i][j-1])+Dat[j][i];
	}
	printf("%d\n",f[n][1]);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + ( p ), ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

constexpr LL INF = LIM<>::max() / 2;

LL dp[ 1 << 17 ][2];

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

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

	VT< LL > A( N );
	for_each( ALL( A ), []( LL &a ){ scanf( "%lld", &a ); } );

	fill( AALL( dp, LL ), -INF );
	dp[0][0] = 0;

	REP( i, N )
	{
		REP( j, 2 )
		{
			const LL m = A[i] + j;
			const LL r = m % 2;

			if ( A[i] )
			{
				chmax( dp[ i + 1 ][ r ], dp[i][j] + m / 2 );
				chmax( dp[ i + 1 ][1], dp[i][j] + ( m - 1 ) / 2 );
			}
			else
			{
				chmax( dp[ i + 1 ][0], dp[i][j] + m / 2 );
			}
		}
	}

	printf( "%lld\n", max( dp[N][0], dp[N][1] ) );
	fflush( stdout );

	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int W, a, b;
	cin >> W >> a >> b;
	if (max(a,b) - min(a,b) - W > 0)
		cout << max(a,b) - min(a,b) - W;
	else
		cout << 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int l = sc.nextInt();
    String[] s = new String[n];
    for (int i = 0; i < n; i++) {
      s[i] = sc.next();
    }
    Arrays.sort(s);
    String ans = "";
    for (int i = 0; i < n; i++) {
      ans += s[i];
    }
    System.out.println(ans);
  }
}

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

int main(){
	long long n,k,ans=0;
	cin>>n>>k;
	if(k==0){
		cout<<n*n;
		return 0;
	}
	for(int i=k+1;i<=n;i++){
		ans+=(i-k)*(n/i);
		if(n%i>=k) ans+=(n%i)-k+1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> g[205];
bool used[205]={0},flag=false;
int col[205];

void dfs(int x,int color){
	if(used[x]){
		if(color%2!=col[x]%2) flag=true;
		return;
	}
	col[x]=color;
	used[x]=true;
	for(int i=0;i<g[x].size();i++){
		dfs(g[x][i],color+1);
	}
}

//Warshall-Floyd
const long long inf=1e15+7;
const int max_v=1000;
long long d[max_v][max_v]={0}; //最短距離
int v; //頂点数
void warshall_floyd() {
    for(int kk = 0; kk < v; kk++) {
        for(int ii = 0; ii < v; ii++) {
            for(int jj = 0; jj < v; jj++) {
                d[ii][jj] = min(d[ii][jj], d[ii][kk] + d[kk][jj]);
            }
        }
    }
}

int main (){
    int n,i,j;
    long long cmax=0;
    char s[205];
    cin >> n;
    v=n;
    for(i=0;i<n;i++) for(j=0;j<n;j++) if(i!=j) d[i][j]=inf;
    for(i=0;i<n;i++){
    	cin >> s;
    	for(j=0;j<n;j++){
    		if(s[j]=='1') g[i].push_back(j);
    		if(s[j]=='1') d[i][j]=1;
    	}
    }
    dfs(0,0);
    if(flag){
    	cout << "-1" << endl;
    	return 0;
    }
    warshall_floyd();
    for(i=0;i<n;i++) for(j=0;j<n;j++) cmax=max(cmax,d[i][j]);
    cout << cmax+1 << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  string s;
  cin >> s;
  if(s[0] == 'A' && s[1] == 'A' && s[2] == 'A')
    cout << "No" << endl;
  else if(s[0] == 'B' && s[1] == 'B' && s[2] == 'B')
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    list<int> L;
    while(cin >> n){
        L.push_front(n);
    }
    cout << *(L.begin());
    L.pop_front();
    while(!(L.empty())){
        cout << " " << *(L.begin());
        L.pop_front();
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
using namespace std;
int n;
int main()
{
	cin>>n;
	n%=10;
	switch (n)
	{
		case 2:
			cout<<"hon";
			return 0;
		case 4:
			cout<<"hon";
			return 0;
		case 5:
			cout<<"hon";
			return 0;
		case 7:
			cout<<"hon";
			return 0;
		case 9:
			cout<<"hon";
			return 0;
		case 0:
			cout<<"pon";
			return 0;
		case 1:
			cout<<"pon";
			return 0;
		case 6:
			cout<<"pon";
			return 0;
		case 8:
			cout<<"pon";
			return 0;
		case 3:
			cout<<"bon";
			return 0;
	}
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 #define rep1(i,N) for(int i=1;i<int(N);++i)
 #define all(a) (a).begin(),(a).end()
 #define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
 #define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
 
 typedef long long ll;
 
 template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
 const int INF = 1e9;
 const ll INFLL = 1e18;
 const ll MOD = 1e9+7;
 const double PI = acos(-1.0);
 
 const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
 const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
 int N;
 vector<vector<pair<int,int>>> G;
 vector<int> color;
 
 void dfs(int i, int pre, int pre_c){
     int cnt = 1;
     for(auto ni: G[i]){
         if(ni.first == pre)continue;
         if(cnt == pre_c){
             cnt++;
         }
         color[ni.second] = cnt;
         dfs(ni.first, i, color[ni.second]);
         cnt++;
     }
 }
 
 int main() {
     cin>>N;
     G.resize(N);
     color.resize(N-1);
     rep(i,N-1){
         int a,b; cin>>a>>b;
         a--;b--;
         G[a].push_back({b,i});
         G[b].push_back({a,i});
     }
     int maxc = 0;
     int start = 0;
     rep(i,N){
         if(maxc < (int)G[i].size()){
             chmax(maxc, (int)G[i].size());
             start = i;
         }
     }
     cout<<maxc<<endl;
 
     dfs(0, -1, -1);
     rep(i,N-1){
         cout<<color[i]<<endl;
     }
 }

Measured memory_bytes: 8320
from random import choice
from random import random
from time import time
start_time = time()
d = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
X = []
L = [-1 for j in range(26)]
for i in range(d):
    max_diff = -10**10
    best_j = 0
    for j in range(26):
        memo = L[j]
        L[j] = i
        diff = S[i][j] - sum([C[jj] * (i - L[jj]) for jj in range(26)])
        if diff > max_diff:
            max_diff = diff
            best_j = j
        L[j] = memo
    L[best_j] = i
    X.append(best_j)


def f(X):
    score = 0
    L = [-1 for j in range(26)]
    A = [0 for j in range(26)]
    for i in range(d):
        score += S[i][X[i]]
        A[X[i]] += (i - L[X[i]]) * (i - L[X[i]] - 1) // 2
        L[X[i]] = i
    for j in range(26):
        A[j] += (d - L[j]) * (d - L[j] - 1) // 2
        score -= C[j] * A[j]
    return score


max_score = f(X)
while time() - start_time < 1.8:
    t = (time() - start_time) / 2
    i = choice(range(d))
    j = choice(range(26))
    memo = X[i]
    X[i] = j
    score = f(X)
    if score > max_score:
        max_score = score
    elif random() < pow(2.7, (score - max_score) / pow(2000, 1 - t)):
        max_score = score
    else:
        X[i] = memo
    a = choice(range(7))
    i0 = choice(range(d - a))
    i1 = i0 + a
    memo = X[i0], X[i1]
    X[i0], X[i1] = X[i1], X[i0]
    score = f(X)
    if score > max_score:
        max_score = score
    elif random() < pow(2.7, (score - max_score) / pow(2000, 1 - t)):
        max_score = score
    else:
        X[i0], X[i1] = memo
for x in X:
    print(x + 1)


Measured memory_bytes: 106352
#include<stdio.h>
#include<iostream>

#define MAX 500000
#define SENTINEL 2000000000

using namespace std;

int L[MAX/2+2], R[MAX/2+2];
int cnt;
long long inv;

//[left, right)
void Merge(int A[], int n, int left, int mid, int right)
{
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0; i<n1; i++)
        L[i]=A[left+i];
    for(int i=0; i<n2; i++)
        R[i]=A[mid+i];
    L[n1]=R[n2]=SENTINEL;
    int i=0, j=0;
    for(int k=left; k<right; k++){
        cnt++;
        if(L[i]<=R[j]){
            A[k]=L[i];
            i++;
        }
        else{
            A[k]=R[j];
            inv+=(long long)(n1-i);
            j++;
        }
    }
}

void MergeSort(int A[], int n, int left, int right)
{
    if(left+1<right){
        int mid=(left+right)/2;
        MergeSort(A, n, left, mid);
        MergeSort(A, n, mid, right);
        Merge(A, n, left, mid, right);
    }
}

int main()
{
    int A[MAX], n, i;
    cnt=0;
    inv=0;

    cin>>n;
    for(int i=0; i<n; i++)
        cin>>A[i];

    MergeSort(A, n, 0, n);

    printf("%lld\n", inv);
    return 0;
}




Measured memory_bytes: 4796
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, b) for (int i = 0; i < (b); i++ )

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

const int INF = 100000000;
const double PI=acos(-1);

int main () {
    int N;
    cin >> N ;
    int C[N],S[N],F[N];

    rep(i,N-1) {
        cin >>C[i] >> S[i] >> F[i];
    }
    
    vector<int> a(N,0);

    rep(j,N-1) {
        for (int i = 0; i<=j; i++){
            if (max(a[i],S[j])%F[j]==0) {
                a[i] = max(a[i],S[j])+C[j];

            }
            else {
                int tmp = (max(a[i],S[j])+F[j])/F[j];
                a[i] = tmp*F[j]+C[j];
            }
        }
    }
    rep(i,N) {
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
#include<stack>
#include<iostream>
#include<algorithm>
using namespace std;
char s1[100000+10];
char s2[100000+10];
int map[6010][6010];
stack<char> s;
int n,t,num,tot=1,t_t=0;
int main()
{
	ios::sync_with_stdio(false);
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	int len1=strlen(s1+1);
	int len2=strlen(s2+1);
/*	if(len1>len2)
	{
		swap(len1,len2);
		swap(s1,s2);
	}
*/	for(register int i=1;i<=len1;i++)
	{
		for(register int j=1;j<=len2;j++)
		{
			if(s1[i]==s2[j])
			{
				map[i][j]=map[i-1][j-1]+1;
			}
			else map[i][j]=max(map[i-1][j],map[i][j-1]);
		}
	}
/*	for(int i=1;i<=len1;i++)
	{
		for(int j=1;j<=len2;j++)
		{
			cout<<map[i][j]<<' ';
		}
		cout<<endl;
	}*/
//	cout<<map[len1][len2]<<'\n';
	int ans=map[len1][len2];
	int xx=len1,yy=len2;
	while(ans)
	{
		int t=ans-1;
		ans--;
		if(xx-1>=0)
		{
			while(map[xx-1][yy]!=t)
			{
				xx--;
			}
		}
		if(yy-1>=0)
		{
			while(map[xx][yy-1]!=t)
			{
				yy--;
			}
		}
		s.push(s2[yy]);
		yy--;
	}
	while(!s.empty())
	{
		cout<<s.top();
		s.pop();
	}
	if(map[len1][len2]==0) cout<<" ";
	return 0;
}
/*
ababab
bab
*/

/*
ababab
cbabcc
*/

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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var h = inputLongArray[0];
            var w = inputLongArray[1];
            var k = inputLongArray[2];

            var hw = new char[h, w];

            for (int i = 0; i < h; i++)
            {
                string inputstr = Console.ReadLine();
                for (int j = 0; j < w; j++)
                {
                    hw[i, j] = inputstr[j];
                }
            }

            var iter = Math.Pow(2, h + w);
            var a = new bool[h + w];
            long ans = 0;
            for (int i = 0; i < iter; i++)
            {
                var tmp = new char[h, w];
                Array.Copy(hw, tmp, hw.Length);
                long cnt = 0;
                for (int j = 0; j < h + w; j++)
                {
                    a[j] = ((i >> j) & 1) == 1;
                }
                for (int hh = 0; hh < h; hh++)
                {
                    for (int ww = 0; ww < w; ww++)
                    {
                        if (tmp[hh,ww] != '#' || a[hh] || a[ww + h])
                        {
                            tmp[hh, ww] = 'R';
                        }
                        else
                        {
                            cnt++;
                        }
                    }
                }
                if (cnt == k)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}


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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int main(){
    ll n, m; cin>>n>>m;

    if(n == 1 && m == 1) cout << 1 << endl;
    else if(n == 1) cout << m - 2 << endl;
    else if(m == 1) cout << n - 2 << endl;
    else cout << (n - 2)*(m - 2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll n, m; 
ll a[300][300];
pair<ll, ll> po(bool *u){
	ll yo[m] = {};
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j < m; j++){
			if(u[a[i][j]]){
				yo[a[i][j]]++;
				break;
			}
		}
	}
	auto ret = pair<ll, ll>(0, 0);
	for(ll i = 0; i < m; i++)if(ret.first < yo[i]) ret = pair<ll, ll>(yo[i], i);
	return ret;
}
int main(){
	cin >> n >> m;
	if(n == 1){
		cout << "1\n";
		return 0;
	}
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j < m; j++){
			cin >> a[i][j];
			a[i][j]--;
		}
	}
	bool u[m];
	memset(u, 1, m);
	ll ans = 1145148931919810;
	for(ll i = 0; i < m - 1; i++){
		auto ret = po(u);
		ans = min(ret.first, ans);
		u[ret.second] = 0;
	}
	cout << ans << endl;
	return 0;
}

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

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

  vector<pair<ll, ll>> prime_factor;
  ll tmp = N;
  for (ll i = 2; i < sqrt(N) + 1; i++)
  {
    ll cnt = 0;
    while (tmp % i == 0)
    {
      cnt++;
      tmp /= i;
    }
    if (cnt != 0) prime_factor.push_back({i, cnt});
  }
  if (tmp != 1)
  {
    prime_factor.push_back({tmp, 1});
  }

  ll ans = 0;
  for (auto pf : prime_factor)
  {
    ll z = 1;
    for (ll i = 0; i < pf.second; i++)
    {
      z *= pf.first;
      if (N % z == 0)
      {
        ans++;
        N /= z;
      }
    }
  }

  cout << ans << endl;
}

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

int main(){
    int s[10];
    char c[10];
    int M, N;
    int i;
    int cnt = 0;
    cin >> N >> M;
    for(i = 0; i < M; i++){
        cin >> s[i] >> c[i];
    }
    string a(N, '*');

    for(i = 0; i < M; i++){
        if(a[s[i]-1] != '*' && a[s[i]-1] != c[i]) cnt = -1;
        else a[s[i]-1] = c[i];
    }
    if(a[0] == '*') a[0] = '1';
    for(i = 0; i < N; i++){
  	    if(a[i] == '*') a[i] = '0';
    }
    if(N != 1 && a[0] == '0') cnt = -1;
    if(N == 1 && M == 0) cnt = 0;
    
    if(cnt == -1) cout << -1 << endl;
    else if(N == 1 && M == 0) cout << 0 << endl;
    else cout << a << endl;
    return 0;
}

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    int d, e, f; cin >> d >> e >> f;
    int g, h, i; cin >> g >> h >> i;
    bool ok = a + e + i == b + f + g && b + f + g == c + d + h;
    bool ok2 = a + e == b + d && b + f == c + e
            && d + h == e + g && e + i == f + h;
    cout << (ok ? "Yes" : "No") << endl;
    assert(ok == ok2);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

int A = 0;
int B = 0; 
int C = 0;

scanf("%d %d",&A,&B);

if(0<=A && A<=100 && 0<=B && B<=100){
    C = A * B ;
    printf("%d",C);
}else{
printf("dekinaiyo");
}

return 0;

}

Measured memory_bytes: 1712
#include <iostream>
#include <cstdlib>
#include <cstdio>

int op(int n, int eo);

using namespace std;

int main(void) {
  char a, b, c, d;
  cin >> a >> b >> c >> d;

  int na, nb, nc, nd;
  na = a - '0';
  nb = b - '0';
  nc = c - '0';
  nd = d - '0';
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        int sum = na + op(nb, i) + op(nc, j) + op(nd, k);
        if (sum == 7) {
          printf("%d%+d%+d%+d=7\n", na, op(nb, i), op(nc, j), op(nd, k));
          return EXIT_SUCCESS;
        } else {
          ;
        }
      }
    }
  }
  return EXIT_SUCCESS;
}

int op(int n, int eo) {
  if (eo % 2 == 1) {
    return -n;
  } else {
    return n;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef int in;
typedef vector<in> VI;
typedef vector<VI> VVI;
string n;
in lm;
bool isok(in curext, in mxext, in mxcar, in cid){
  if(cid==sz(n))
    return 1;
  in cdg=n[cid]-'0';
  in bsext;
  if(cdg<=curext){
    bsext=cdg;
  }
  else{
    if(mxcar==0)
      return 0;
    bsext=cdg-1;
  }
  if(bsext>lm)
    return 0;
  in lif=((cdg-mxcar)%10+10)%10;
  in lft=(mxext-lif)/10;
  return isok(bsext,lif+10*lft,(mxcar+lif+10*lft)/10,cid+1);
}
bool ispo(in plm){
  lm=plm;
  return isok(lm,lm,0,0);
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n;
  reverse(all(n));
  in mn=0;
  in mx=1000009;
  in md;
  while(mx-mn>1){
    md=(mx+mn)/2;
    if(ispo(md*9))
      mx=md;
    else
      mn=md;
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 1172