akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    #define ull unsigned long long
    # define ll long long
    # define mod 1000000007LL 
    using namespace std;
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll r,g,b;
        cin>>r>>g>>b;
        ll k;
        cin>>k;
        while(g<=r && k!=0)
        {
            g=g*2;
            k--;
        }
        while(b<=g && k!=0)
        {
            b=b*2;
            k--;
        }
        if(b>g && g>r)
        cout<<"Yes";
        else
        {
            cout<<"No";
        }
        


        
        return 0;
    }

Measured memory_bytes: 3652
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N,K;
    N = sc.nextInt();
    K = sc.nextInt();
    int h[] = new int[N];
    for(int i=0; i<N; i++) h[i] = sc.nextInt();
    Arrays.sort(h);
    int ans = 1000000007;
    int tmp;
    for(int i=0; i<N-K+1; i++){
      tmp = h[i+K-1] - h[i];
      ans = Math.min(ans, tmp);
    }
    System.out.println(ans);
                               
  }
}

Measured memory_bytes: 50152
n, k = map(int, input().split())
p = [(1+int(x)) / 2.0 for x in input().split()]

ans = sum(p[0:k])
tmp = sum(p[0:k])

for i in range(0, n-k):
    tmp = tmp - p[i] + p[i+k]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 23588
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            // スペース区切りの整数の入力
            x[i] = sc.nextInt();
        }

        int cnt = 0;
        boolean b = true;
        while (b) {
            for (int i = 0; i < n; i++) {
                if (x[i] % 2 == 0) {
                    x[i] = x[i] / 2;
                } else {
                    b = false;
                    break;
                }
            }
            if (b) {
                cnt++;
            } else {
                break;
            }
        }

        // 出力
        System.out.println(cnt);
    }

}


Measured memory_bytes: 23124
#include<stdio.h>
int main(){ 
  int i,j,n,a[10000],d,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    d=1;
    for(j=2;j*j<=a[i];j++){
      if(a[i]%j==0){
	d=0;
	break;
      }
    }
    if(d==1)count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 628
// Submitted By Subhash Yadav
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Scanner;

import java.util.*;

public class Main {
	

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		char c[]=sc.next().toCharArray();
		if(c[0]=='R'&&c[1]=='R'&&c[2]=='R')System.out.println(3);
		else if((c[0]=='R'&&c[1]=='R')||(c[2]=='R'&&c[1]=='R'))System.out.println(2);
		else if(c[0]=='R'||c[1]=='R'||c[2]=='R') System.out.println(1);
		else System.out.println(0);
		
		
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}

Measured memory_bytes: 32588
#include <iostream>
using namespace std;
int main()
{
	int n,a;
	cin >> n;
	a = n / 100;
	if (a == 1) {
		if (n > 111)cout<<"222"<<"\n";
		else cout << "111" << "\n";
	}
	else {
		if (n / a == 111 && n%a == 0)cout << n << "\n";
		else if (n / a >= 111)cout << (++a) * 100 + a * 10 + a << "\n";
		else if (n / a < 111)cout << a * 100 + a * 10 + a << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(string.Join(" ", a));
        for (int i = 1; i < n; i++)
        {
            var v = a[i];
            int j;
            for (j = i - 1; 0 <= j && v < a[j]; j--)
            {
                a[j + 1] = a[j];
            }
            a[j + 1] = v;
            Console.WriteLine(string.Join(" ", a));
        }
    }
}


Measured memory_bytes: 18308
#include<stdio.h>
int main(void){
  int A;
  int B;
  scanf("%d",&A);
  scanf("%d",&B);
  if((A<=0)||(A>=10)||(B<=0)||(B>=10)){
    printf("-1");
  }
  if(((A>0)&&(A<10))&&((B>0)&&(B<10))){
    printf("%d",A*B);
  }
}

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

int main()
{
    int n;
    int a, b, c, d, e, f, g, h;
    while(cin >> n, n){
        for(int i = 0; i < n; ++i){
            cin >> a >> b >> c >> d >> e >> f >> g >> h;
            cout << a*e - b*f - c*g - d*h << ' '
                 << a*f + b*e + c*h - d*g << ' '
                 << a*g - b*h + c*e + d*f << ' '
                 << a*h + b*g - c*f + d*e << endl;
        }
    }
}

Measured memory_bytes: 1160
#include <stdio.h>
#define BLDG 4
#define FLOOR 3
#define ROOM 10

int main(int argc, char *argv[]){
  int i,j,k,n;
  int b,f,r,v;
  int house[BLDG][FLOOR][ROOM]={0};
  //get data
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d %d %d %d", &b, &f, &r, &v);
    house[b-1][f-1][r-1]+=v;
  }
  //show
  for(i=0; i<BLDG; i++){
    for(j=0; j<FLOOR; j++){
      for(k=0; k<ROOM; k++)
	printf(" %d", house[i][j][k]);
      printf("\n");
    }
    if(i<BLDG-1)
      printf("####################\n");
  }
  return(0);
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
string s,t;
std::cin >> s>>t;
rep(i,s.size()){
  if(s[i]!=t[i])x++;
}
std::cout << x << '\n';
}


Measured memory_bytes: 3920
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}
 
int par[100000];
void init(int n){
	rep(i,n){
		par[i]=i;
	}
}
 
int root(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x] = root(par[x]);
	}
}
 
void unite(int x,int y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}
 
 
 
struct a{
	ll a;
	int num;
	int par;
	bool use;
};
 
bool operator< (const a& left,const a& right){
        return left.a < right.a;
}

/*
rep(i,n){
	cin>>aa[i].a;
	aa[i].num=i;
}*/
 
 
 
int main(void){
	int n,m;
	cin >> n >> m;
	int a[100];
	int k,memo;
	rep(i,100){
		a[i] = 0;
	}
	rep(i,n){
		cin>>k;
		rep(j,k){
			cin>>memo;
			a[memo-1] += 1;
		}

	}
	int ans =0;
	rep(i,m){
		if(a[i]==n){
			ans+=1;
		}
	}
	cout<<ans<<endl;
 
	return 0;
}

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

using namespace std;

typedef long long ll;

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

    int N;
    cin >> N;
    int a = N % 3;
    int b = N - a;
    cout << b / 3;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		for(;;) {
		String a=scan.next();
		if(a.equals("-")) {
			break;
		}
		int b=scan.nextInt();
		for(int j=0;j<b;j++) {
			int c=scan.nextInt();
			a=a.substring(c,a.length())+a.substring(0,c);
		}
		System.out.println(a);
		}
	}
}


Measured memory_bytes: 26540
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>

using namespace std;

using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}

ll gcd(ll a, ll b) {    //最小公倍数
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {    //最大公約数
  return a * b / gcd(a, b);
}
 

int main(void){

    int n;
    cin>>n;

    if(n%2==0) cout<<0.5000000000<<endl;
    else{
        double x = ((n-1)/2.0 + 1.0)/(double)n;
        cout<<x<<endl;
    } 
    return 0;

}

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

int main()
{
    int q;
    cin >> q;
    int mas = 0;
    vector<pair<int, int>> query(q);
    for (int i = 0; i < q; i++)
    {
        int a, b;
        cin >> a >> b;
        mas = max(mas, b);
        query[i] = make_pair(a, b);
    }
    vector<int> like(mas);
    for (int i = 3; i <= mas; i++)
    {
        int cnt = 0;
        bool k = true, l = true;
        int s = sqrt(i);
        for (int j = 2; j <= s; j++)
        {
            if (i % j == 0)
                k = false;
        }
        s = sqrt((i + 1) / 2);
        for (int j = 2; j <= s; j++)
        {
            if ((i + 1) / 2 % j == 0)
                l = false;
        }
        if (k && l)
            cnt++;
        like[i] = like[i - 1] + cnt;
    }
    for (int i = 0; i < q; i++)
    {
        cout << like[query[i].second] - like[query[i].first - 1] << endl;
    }
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



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

	if (a < b&&b < c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  priority_queue<int,vector<int>,greater<int> > a;
  for(int i=0;i<n;i++){
    int x,y;
    cin >> x >> y;
    a.push(x+y);
  }
  //sort(a.begin(),a.end());
  int p1;
  while(!a.empty()){
    p1=a.top();a.pop();
    if(a.empty()){
      cout << p1 << " 0" << endl;
      break;
    }
    else if(p1==a.top()){
      a.pop();
      a.push(p1+1);
    }
    else{
      cout << p1 << " 0" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3372
# BIT使ってC問題ちゃんとやろうとしたけど1時間かけて無を生成したので諦める。ぷえwwwww
from random import randint
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split()))for _ in range(d)]
for i in range(d):s.append(s[i][:])
for i in range(d):s.append(s[i][:])
def xyz(start):
  ans=[0]*d
  score=0
  for i in range(start,start+d,26):
    dd=set()
    uu=set()
    h=[]
    for j in range(i,min(i+26,start+d)):
      for k in range(26):
        h.append([s[j][k],j,k])
    h.sort(reverse=1)
    if randint(0,10)==0:del h[0]
    for t,j,k in h:
      if j in dd or k in uu:continue
      score+=t
      ans[j%d]=k
      dd.add(j)
      uu.add(k)
  return [score,ans]
score,ans=xyz(0)
for i in range(1,d):
  ss,aa=xyz(i)
  if ss>score:
    score,ans=ss,aa
for i in ans:print(i+1)

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

int main(){
    int V, E;
    cin >> V >> E;
    vector<pair<int, int> > edge(E);
    for (int i = 0; i < E; i++) {
        cin >> edge[i].first >> edge[i].second;
    }
    vector<int> ans;
    vector<int> state(V, 0);

    for (int i = 0; i < E; i++) {
        state[edge[i].second]++;
    }
    for (int i = 0; i < state.size(); i++) {
        if (state[i] == 0) ans.push_back(i);
    }
    for (int i = 0; i < ans.size(); i++) {
        for (int j = 0; j < edge.size(); j++) {
            if (edge[j].first == ans[i]) {
                state[edge[j].second]--;
                if (state[edge[j].second] == 0) {
                    ans.push_back(edge[j].second);
                }
                edge[j] = edge.back();
                edge.pop_back();
                j--;
            }
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3408
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
using namespace std;
int main()
{
	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	string s;
	cin >> s;
	for ( a = 0; a < 4; a++)
	{
		if (s[a]=='+')
		{
			ans++;
		}
		else
		{
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int N;
	int a, b;
	cin >> a >> b;
	int ans = a - b * 2;
	ans = max(ans, 0);
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    int A, B;
    cin >> A >> B;
    if(13 <= A) {
        cout << B;
        return 0;
    }
    if(A <= 5) {
        cout << 0;
        return 0;
    }
    cout << B / 2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,A,B;
    cin >> N >> A >> B;
    vector<ll> coor(N);
    REP(i,N)cin >> coor[i];
    ll tired = 0;
    REP(i,N-1){
        tired += min((coor[i+1] - coor[i])*A,B);
    }
    cout << tired << "\n";
}

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

using namespace std;

#define ll				long long
#define pb				push_back
#define w(x)			int x; cin>>x; while(x--)
#define mp      		make_pair
#define mod     		1000000007
#define inf     		1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define endl	  		"\n"
#define sp 				" "
#define ca(x) 			"Case "<<x<<": "
#define all(x) 			x.begin(), x.end()
#define loop(i,a,n)		for (int i = a; i < (n); ++i)
#define rloop(i,a,n)	for (int i = n; i >= (a); --i)
#define in(n)			long long n ; scanf("%lli",&n);
#define yes				cout << "Yes"<<endl
#define no				cout << "No"<<endl

int main()
{
	int n; cin >> n;
	if (n >= 30) cout << "Yes";
	else cout << "No";


	return 0;
}



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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n, i, x;
	cin >> n;
	vector<ll>v(n), ans(n);
	for(i = 0; i < n; i++)cin >> v[i];
	rep(i,0,n){
		if(i&1)
			ans[0] -= v[i];
		else
		   	ans[0] += v[i]; 
	}
	rep(i,1,n){
		ans[i] = 2 * v[i - 1] - ans[i-1];
	}
	rep(i,0,n){
		cout << ans[i] << " ";
	}
}
int main() {
#ifndef ONLINE_JUDGE
//    freopen("input1.txt","r",stdin);
//    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 4780
def lower_bound(arr, v)
  l = -1; r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    if arr[m] <= v then l = m
    else r = m
    end
  end
  l
end
n = gets.to_i
arr = []
n.times{ arr << gets.to_i }
sum = Array.new(2*n+1, 0)
(2*n).times{ |i| sum[i+1] += sum[i] + arr[i%n] }
l = 0; r = sum[n] / 3
while l + 1 < r
  m = (l + r) / 2
  f = nil
  n.times do |i|
    a = lower_bound(sum[i,n], m + sum[i] - 1) + i + 1
    if a < i+n
      b = lower_bound(sum[a...i+n], m + sum[a] - 1) + a + 1
      if b < i+n && sum[i+n] - sum[b] >= m
        l = m
        f = true
        break
      end
    end
  end
  r = m unless f 
end
p l

Measured memory_bytes: 11348
N, X = map(int, input().split())

def ct(n, x):
    # print(n, x)
    if x == 1:
        if n == 0:
            return 1
        else:
            return 0
    elif x == L[n]//2+1:
        return P[n-1]+1
    elif x == L[n]:
        return P[n]
    elif x < L[n]//2+1:
        return ct(n-1,x-1)
    else:
        return P[n-1] + 1 + ct(n-1,x-(L[n]//2+1))

L = [1]
for i in range(50):
    L.append(L[-1]*2+3)
P = [1]
for i in range(50):
    P.append(P[-1]*2+1)

print(ct(N, X))


Measured memory_bytes: 38256
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

ab.sort(key = lambda x:x[1])
dropped = [ab[0][1]-1]
for i in range(1, M): #i番目の要望はこたえられている？
    if ab[i][0] > dropped[-1]:
        dropped += [ab[i][1]-1]

print(len(dropped))

Measured memory_bytes: 29084
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define M 36
void bubble(int);
void selec(int);
int isStable(int);
int isStabled(int);
char C[M][3],S[M][3],D[M][3];
int main()
{ 
  int i,j;
  scanf("%d",&i);
  for(j=0;j<i;j++)
    {
      scanf("%s",C[j]);
      strcpy(S[j],C[j]);
      strcpy(D[j],C[j]);
    }
  bubble(i);
  for(j=0;j<i-1;j++)
    {
      printf("%s ",C[j]);
    }
  printf("%s\n",C[i-1]);
  if(isStable(i)==1)
    printf("Stable\n");
  else
    printf("Not stable\n");
  selec(i);
  for(j=0;j<i-1;j++)
    {
      printf("%s ",D[j]);
    }
  printf("%s\n",D[i-1]);
  if(isStabled(i)==1)
    printf("Stable\n");
  else
    printf("Not stable\n");
  return 0;
}

void bubble(int N)
{
  int i,j;
  char pretend[3];
  for(i=0;i<N;i++)
    {
      for(j=N-1;j>i;j--)
	{
	  if(atoi(&C[j][1])<atoi(&C[j-1][1]))
	    {
	      strcpy(pretend,C[j]);
	      strcpy(C[j],C[j-1]);
	      strcpy(C[j-1],pretend);	     
	    }
	}
    }
}
void selec(int N)
{
  int i,j,minj;
  char pretend[3];
  for(i=0;i<N;i++)
    {
      minj=i;
      for(j=i;j<N;j++)
	{
	  if(atoi(&D[j][1])<atoi(&D[minj][1]))
	    {
	      minj=j;	      
	    }
	}
      if(minj==i)
	continue;
      strcpy(pretend,D[i]);
      strcpy(D[i],D[minj]);
      strcpy(D[minj],pretend);	
    }
}
int isStable(int N)
{
  int i,j,a,b,count=0;
  for(i=0;i<N;i++)
    {
      for(j=i+1;j<N;j++)
	{
	  for(a=0;a<N;a++)
	    {
	      for(b=a+1;b<N;b++)
		{
		  if(atoi(&S[i][1])==atoi(&S[j][1]) && S[i][0]==C[b][0] && S[j][0]==C[a][0] && atoi(&S[i][1])==atoi(&C[b][1]) && atoi(&S[j][1])==atoi(&C[a][1]))
		    {
		      return -1;
		    }
		   
		}
	    }
	}
    }
  return 1;
}
int isStabled(int N)
{
  int i,j,a,b,count=0;
  for(i=0;i<N;i++)
    {
      for(j=i+1;j<N;j++)
	{
	  for(a=0;a<N;a++)
	    {
	      for(b=a+1;b<N;b++)
		{
		  if(atoi(&S[i][1])==atoi(&S[j][1]) && S[i][0]==D[b][0] && S[j][0]==D[a][0] && atoi(&S[i][1])==atoi(&D[b][1]) && atoi(&S[j][1])==atoi(&D[a][1]))
		    {		     
		      return -1;
		    }
		}
	    }
	}
    }
  return 1;
}



Measured memory_bytes: 2068
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    String s = sc.next();
    if (a >=3200) {
      System.out.println(s);
    } else {
      System.out.println("red");
    }
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

struct Tree{
	int V;
	vector<int> G[200010];
	int dist[2][200010];
	void dfs(int v,int p,int t){
		dist[t][v] = dist[t][p]+1;
		for(int u: G[v]){
			if(u == p)continue;
			dfs(u,v,t);
		}
	}
	int calc_dia(){
		int x = 1;
		dist[0][0] = -1;
		dfs(x,0,0);
		int y = 1;
		for(int i = 1 ; i <= V ; i ++){
			if(dist[0][i] > dist[0][y])y = i;
		}
		dist[1][0] = -1;
		dfs(y,0,1);
		int ret = 0;
		for(int i = 1 ; i <= V ; i ++){
			ret = max( ret , dist[1][i] );
		}
		return ret;
	}
}tree;

int main(){
	int n,a,b;
	scanf("%d",&n);
	tree.V = n;
	rep(i,n-1){
		scanf("%d%d",&a,&b);
		tree.G[a].pb(b);
		tree.G[b].pb(a);
	}
	
	int d = tree.calc_dia();
	if(d%3 == 1)puts("Second");
	else puts("First");
}


Measured memory_bytes: 19712
import sys
readline = sys.stdin.readline
from math import factorial
MOD = 10 ** 9 + 7

def main():
    N, M = map(int, readline().rstrip().split())
    if abs(N-M) > 1:
        ans = 0
    elif N == M:
        ans = (factorial(N) % MOD) * (factorial(M) % MOD) * 2
    else:
        ans = (factorial(N) % MOD) * (factorial(M) % MOD)

    print(ans % MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int BIT[200201];
inline void add(int A) {
	while (A <= 200200) {
		BIT[A]++;
		A += A & -A;
	}
}

inline int query(int A) {
	int kotae = 0;
	while (A > 0) {
		kotae += BIT[A];
		A -= A & -A;
	}
	return kotae;
}

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

	int N = getint();
	int K = getint();

	pair<ll, int> B[200001] = {};
	int C[200001] = {};
	rep(i, N) {
		B[i + 1] = mp(B[i].first + getint() - K, i + 1);
	}
	sort(B, B + N + 1);
	int kazu = 0;
	int mae = 1e18;
	rep(i, N + 1) {
		if (mae != B[i].first) kazu++;
		C[B[i].second] = kazu;
	}

	ll kotae = 0;
	add(C[0]);
	rep1(i, N) {
		kotae += query(C[i]);
		add(C[i]);
	}
	co(kotae);

	Would you please return 0;
}

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };
    println!(
        "{}",
        if a.iter().filter(|&x| x % 2 == 1).count() % 2 == 1 {
            "NO"
        } else {
            "YES"
        }
    );
}


Measured memory_bytes: 6396
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string s;
  cin >> s;

  vector<int> l(K + 1), r(K + 1);
  {
    l[0] = -C - 1;
    int j = 0;
    rep(i, K) {
      while (s[j] == 'x' || j <= l[i] + C) {
        j++;
      }
      l[i + 1] = j;
    }
  }
  {
    r[K] = N + C;
    int j = N - 1;
    rrep(i, K) {
      while (s[j] == 'x' || j >= r[i + 1] - C) {
        j--;
      }
      r[i] = j;
    }
  }

  rep(i, K) {
    if (l[i + 1] == r[i]) {
      cout << r[i] + 1 << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 5092
#include "bits/stdc++.h"
	using namespace std;
	#include "string"
	#define int long long
	#define pi pair <int, int>
	#define ff first
	#define ss second
	#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
	#define endl '\n'

	int32_t main() {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int ans = max(a * c, b * d);
		ans = max(ans,max(a * d, b * c));
		cout << ans << endl;
	}

Measured memory_bytes: 3632
#include <stdio.h>
 #include <math.h>

#define PI 3.14159265358979323846264338327950L

 int main(void) {
 int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);
 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq));

 return 0;
 }

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

using namespace std;

int main()
{
	int n, a, b, x, r = 0;
	cin>>n>>a>>b;
	for(int i = 0; i < n; i++)
	{
		cin>>x;
		if (x < a || x >= b)
			r++;
	}
	cout<<r<<'\n';
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    bool f = false;
    REP(i,1,N+1) {
        if((108 * i) / 100 == N) {
            PR(i);
            f = true;
            break;
        }
    }
    if(!f) PR(":(");


    return 0;
}

/*


*/

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


int main() {
  ll n, m, s;
  cin >> n >> m >> s;
  ll max_a = 0;
  vector<vector<tuple<ll, ll, ll>>> G(n);  // (place, silver coin, minute)
  for (int i=0; i<m; i++) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    G[u].push_back(make_tuple(v, a, b));
    G[v].push_back(make_tuple(u, a, b));
    max_a = max(a, max_a);
  }

  vector<ll> C(n), D(n);
  for (int i=0; i<n; i++) {
    cin >> C[i] >> D[i];
  }

  const ll INF = 1e18;

  ll cost[n][max_a*n];    // minute [place][silver]

  for (int i=0; i<n; i++) {
    for (int j=0; j<max_a*n; j++) {
      cost[i][j] = INF;
    }
  }

  priority_queue<tuple<ll, int, ll>> Q;  // minutes, place, silver
  Q.push(make_tuple(0, 0, min(s, max_a*n-1)));
  cost[0][min(s, max_a*n-1)] = 0;


  while (!Q.empty()) {
    ll minute, silver;
    int x;
    tie(minute, x, silver) = Q.top();
    Q.pop();
    minute = -minute;

    for (auto t: G[x]) {
      int y;
      ll pay, take_minute;
      tie(y, pay, take_minute) = t;
      if (silver >= pay && take_minute + minute < cost[y][silver-pay]) {
        Q.push(make_tuple(-(take_minute + minute), y, silver-pay));
        cost[y][silver-pay] = take_minute + minute;
      }
    }

    if (silver + C[x] < max_a * n && minute + D[x] < cost[x][silver+C[x]]) {
      Q.push(make_tuple(-(minute + D[x]), x, silver + C[x]));
      cost[x][silver+C[x]] = minute + D[x];
    }
  }

  for (int i=1; i<n; i++) {
    ll ans = INF;
    for (int j=0; j<max_a*n; j++) {
      ans = min(ans, cost[i][j]);
    }
    cout << ans << endl;
  }

return 0;
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

bool f(string s) {
	string ss = s;
	reverse(ALL(ss));
	if(s == ss) {
		return true;
	}
	return false;
}

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

	int n = s.size();
	if(f(s) && f(s.substr(0, n/2)) && f(s.substr((n+3)/2-1, n-(n+3)/2+1) )) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;

}



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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define repi(i,a,n) for(int (i)=(a);(i)<(n);(i)++)

int main() {
  int n,d;
  cin>>n>>d;
  if(n%(2*d+1)==0) cout<<n/(2*d+1);
  else cout<<n/(2*d+1)+1;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,M;
  cin >> N >> M;
  
  if (N >= 2 && M >= 2){
    cout << (N-2)*(M-2) << endl;
  }
  else if (N == 1 && M == 1){
    cout << 1 << endl;
  }
  else {
    cout << N*M-2 << endl;
  }
}
  

Measured memory_bytes: 3596
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
sts = 0
for i in range(n):
    sts += B[A[i] - 1]
    if 0 < i and A[i] - A[i-1] == 1:
        sts += C[A[i] - 2]
print(sts)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void) {
  string s,p;
  bool flag = false;
  cin >> s;
  cin >> p;
  s += s;
  if(s.find(p) != string::npos)
    flag = true;
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3192
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        if(a%2 == 0){
            a /= 2;
            a *= a;
        }
        else{
            a /= 2;
            a *= (a+1);
        }
        System.out.println(a);
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    int maxpos=0;
    ll maxi=-1;
    Vi a(n);
    priority_queue<ll> que;
    rp(i,n){
        cin >> a[i];
        if(chmax(maxi,a[i])) maxpos=i;
        que.push(a[i]);
    }
    que.pop();
    rp(i,n){
        if(i!=maxpos) print(maxi);
        else print(que.top());
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int main() {
  int n, ans = 0;
  string s, t, u;
  cin >> n >> s;

  for (int i = 0; i < n; i++) {
    int tmp = 0;
    set<char> p, q;
    t = s.substr(0, i);
    u = s.substr(i);
    for (int j = 0; j < t.size(); j++) p.insert(t[j]);
    for (int j = 0; j < u.size(); j++) q.insert(u[j]);

    while (p.size()) {
      if (q.count(*begin(p))) tmp++;
      p.erase(*begin(p));
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    //system("chcp 65001");

    int N;
    cin >> N;

    if(N % 2 == 0)
    {
        cout << N;
    }
    else
    {
        cout << N * 2;
    }
    

    //cout << N;

    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left";
  } else if (A + B < C + D) {
    cout << "Right";
  } else {
    cout << "Balanced";
  }
  cout << endl;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});
/*
process.on('SIGINT', function(){
    input_stdin_array = input_stdin.split("\n");
    main();
    process.exit();
});
*/
process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////


function main() {
	var s = readLine();	
	var N = parseInt(s);
    s = readLine().split(" ");
	for (var i=0; i < N; i++){
		s[i]=parseInt(s[i]);
	}
	
	var ans = 200*200*200+1;
	
	for (var goal = -100; goal <= 100; goal++){
		var cost=0;
		for (var i=0; i < N; i++){
			cost += (s[i]-goal)*(s[i]-goal);
		}
		if (ans > cost){
			ans = cost;
		}
	}
	
	console.log(ans.toString());
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, k;
    cin >> n >> k;
    vector<ll> v(n+1, 0);
    REP(i, n){
        cin >> v[i+1];
    }

    vector<vector<ll>> dp(n+1, vector<ll>(n+1, INF));
    dp[0][0] = 0;

    FOR(y, 1, n+1){
        FOR(x, 1, n+1){
            if(x < y) continue;
            FOR(i, 0, x){
                chmin(dp[x][y], dp[i][y-1] + max(0LL, v[x] - v[i]));
            }        
        }
    }

    ll ans = INF;
    REP(i, n+1){
        chmin(ans, dp[i][n-k]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
// Circle.cc
// 半径 r の円の面積と円周の長さを求めるプログラムを作成して下さい。
// 【入力】
// １つの実数 r が与えられます。
// 【出力】
// 面積と円周の長さを１つの空白で区切って１行に出力して下さい。
// 出力は浮動小数点数とし、0.00001 以下の誤差を含んでもよいものとします。
// 【制約】
// 0 < r < 10,000
// 【例】
// 入力：2、出力：12.566371 12.566371
#include<cstdio>
#include<cmath>

int main( void) {
  double r;
  double area, circumference;
  double PI = acos(-1);

  scanf( "%lf", &r);

  area = r * r * PI;
  circumference = 2 * r * PI;

  printf( "%.6lf %.6lf\n", area, circumference);

  return 0;
}



Measured memory_bytes: 2716
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

long long power(long long x, long long N){
	if(N == 0) return 1LL;
	if(N == 1) return x;
	long long tmp = power(x, N/2);
	if(N%2 == 0) return tmp * tmp % MOD;
	else return tmp * tmp % MOD * x % MOD;
}

int N, M, s[5];
char c[5];
signed main(){
	cin >> N >> M;
	rep(i, M){
		cin >> s[i] >> c[i];
		s[i]--;
	}
	int N2 = power(10, N);
	for(int i=0; i<N2; i++){
		string S = to_string(i);
		if(S.size() != N) continue;
		bool flg = true;
		rep(j, M){
			flg &= (S[s[j]] == c[j]);
		}
		if(!flg) continue;
		cout << i << endl;
		return 0;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

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

void solve(int n) {
    int place[21][21];
    memset(place, 0, sizeof(place));
    rep(i,n) {
        int x,y; cin>>x>>y;
        place[y][x] = 1;
    }

    int m; cin >> m;
    int x=10, y=10;
    place[y][x] = 0;
    rep(i,m) {
        char d;
        int l;
        cin >> d >> l;
        rep(j,l) {
            if(d == 'N') y++; 
            if(d == 'S') y--;
            if(d == 'E') x++;
            if(d == 'W') x--;
            place[y][x] = 0;
        }
    }

    bool f = true;
    rep(i,21) rep(j,21) if(place[i][j] == 1) f = false;
    cout << (f ? "Yes" : "No") << "\n";
    return ;
}

int main() {
    for(int n;cin>>n && n;) solve(n);
    return 0;
}

Measured memory_bytes: 3032
#include<bits//stdc++.h>
using namespace std;
int n, v, ma = 0, mb = 0, ans = 0;
vector<int> a(100000), b(100000);
int main(){
    cin >> n;
    for (int i = 0; i < n;i++) {
        cin >> v;
        if (i % 2 == 0)
            a[v - 1]++;
        else
            b[v - 1]++;
    }
    for (int i = 0; i < 100000;i++) {
        ans = max(ans, a[i] + ma);
        ans = max(ans, b[i] + mb);
        ma = max(ma, b[i]);
        mb = max(mb, a[i]);
    }
    cout << n - ans << endl;
}

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

using namespace std;

#define topper top //XDDDDDDD

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

const ld EPS = 1e-9;
const ld PI = acos(-1);

const int N = 2e5+5;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

ll n, a[N], pref[N];
map<ll, ll> freq;

int main(){
  //freopen("in", "r", stdin);
  //freopen("out", "w", stdout);

  scanf("%lld", &n);
  for(int i=1; i<=n; i++) scanf("%lld", &a[i]);

  ll ans = 0;
  freq[0]++;
  for(int i=1; i<=n; i++) {
    pref[i] = pref[i-1] + a[i];

    ans += freq[pref[i]];
    freq[pref[i]]++;
  }

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



Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;

const int INF = 1 << 30;
const int MOD = 1e9 + 7;


int main() {
    int h, w; cin >> h >> w;
    vector<string> a(h); rep(i, h) cin >> a[i];
    vector<vector<int>> dp(h, vector<int>(w, 0));
    dp[0][0] = 1;

    rep(i, h) rep(j, w) {
        if (a[i][j] == '#') continue;
        if (j+1 < w && a[i][j+1] == '.') {
            dp[i][j+1] += dp[i][j];
            dp[i][j+1] %= MOD;
        }
        if (i+1 < h && a[i+1][j] == '.') {
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= MOD;
        }
    }

    cout << dp[h-1][w-1] << endl;



    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  for (int i=0; i<W+2 ; i++) {
    cout << "#";
  }
  cout << endl; 
  
  for (int i = 0; i < H; i++) {
    cout << "#";
    vector<char> pic(W);
    for (int j = 0; j < W ; j++) {
      cin >> pic.at(j);
    }
    for (int j = 0; j < W ; j++) {
      cout << pic.at(j);
    }
    cout << "#" << endl;
  }
  
   for (int i=0; i<W+2 ; i++) {
     cout << "#";
   }
   cout << endl; 
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;

vector<int> num(100000 + 5); //num[i]はiの自身を含まない連結成分の数
vector<int> numb(100000 + 5); //numb[i]はiの連結成分のうちで、ブロック関係にある人の数
vector<int> connection; //各人の連結成分
vector<int> connection2;
vector<bool> seen(100000 + 5);

//vの連結成分を見つける
void dfs(const Graph &G, int v) {
	if (seen[v]) return;
	
	seen[v] = true;
	connection.push_back(v);

	for (auto next_v : G[v]) {

		if (seen[next_v] == false) {
			dfs(G, next_v);
		}
	}
}

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	Graph Friend(N + 1);
	Graph Block(N + 1);

	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		Friend[A].push_back(B);
		Friend[B].push_back(A);
	}
	for (int i = 0; i < K; i++) {
		int C, D;
		cin >> C >> D;
		Block[C].push_back(D);
		Block[D].push_back(C);
	}

	for (int v = 1; v <= N; v++) {
		dfs(Friend, v);	//vの連結成分がconnectionに格納される

		//連結成分の各々の、連結成分の数（自身を除く）をメモ
		for (int i = 0; i < connection.size(); i++) {
			num[connection[i]] = connection.size() - 1;
		}

		//連結成分をsetに入れる
		set<int> S;
		for (int i = 0; i < connection.size(); i++) {
			S.insert(connection[i]);
		}

		int iCountBlo = 0; //vの連結成分のうちで、ブロック関係にある人の数
		
		//vの連結成分の各人の、連結成分内かつブロック関係にいる人の数を求める
		//vの連結成分の各人について、ブロック関係にある人を見て、Sに含まれるかを確かめる
		for (int i = 0; i < connection.size(); i++) {
			
			int ConneMan = connection[i];
			for (auto blo : Block[ConneMan]) {
				if (S.count(blo)) iCountBlo++;
			}
			numb[ConneMan] = iCountBlo;
			iCountBlo = 0; 
		}
      	connection = connection2;
	}
  
	vector<int> ans;
	for (int v = 1; v <= N; v++) {
		int iSubFriend = num[v] - Friend[v].size() - numb[v];
		ans.push_back(iSubFriend);
	}
  
	for (int i = 0; i < N; i++) {
		if (i == N - 1) cout << ans[i];
		else cout << ans[i] << " ";
	}

}

Measured memory_bytes: 17144
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
	char s;
	long long int ans=0;
	long long int ansn=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s=='I'){
			ansn++;
		}
		else if(s=='D'){
			ansn--;
		}
		ans=max(ans,ansn);
	}
	cout<<ans;
	return 0;
} 

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

int main()
{
    string str;
    cin >> str;
    string result = "None";
    for(int i = 0; i <= 'z'-'a'; ++i)
    {
        string::size_type num = str.find('a'+i);
        if(num == string::basic_string::npos)
        {
            result = 'a'+i;
            break;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
using namespace std;

int main(){
	string S;
	int posA = 0, posC = -1;
	bool result = true;
	cin >> S;

	if (S[0] != 'A')
		result = false;

	int c = 0;
	for (string::iterator itr = S.begin() + 2; itr != S.end() - 1; ++itr){
		if (*itr == 'C'){
			++c;
			posC = distance(S.begin(), itr);
		}

		if (c > 1){
			result = false;
			break;
		}
	}
	if (c == 0)
		result = false;

	for (string::iterator itr = S.begin(); itr != S.end(); ++itr){
		if (distance(S.begin(), itr) == posC || distance(S.begin(), itr) == posA)
			continue;

		if (*itr >= 'A' && *itr <= 'Z')
			result = false;
	}

	if (result)
		cout << "AC" << endl;
	else
		cout << "WA" << endl;

	return 0;
}

Measured memory_bytes: 256