akhauriyash/Code-Regression huggingface dataset:
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-08-09 16:50:32
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll SIG = 26;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

int n , trieInd = 1 , cnt[SIG] , nxt[MAXN][SIG] , val[MAXN][SIG];
ll ans;
string s[MAXN];
vector<pll> vec;

void insert(string s){
    fill(cnt , cnt + SIG , 0);
    for(int i = 0 ; i < SZ(s) ; i++)    cnt[s[i] - 97]++;
    reverse(all(s));
    int x = s.back() - 97; s.pop_back();
    int cur = 0;
    for(int i = 0 ; i < SZ(s) ; i++){
        for(int j = 0 ; j < SIG ; j++){
            if(cnt[j])  val[cur][j]++;
        }
        if(nxt[cur][s[i] - 97] == 0)    nxt[cur][s[i] - 97] = trieInd++;
        cur = nxt[cur][s[i] - 97];
        cnt[s[i] - 97]--;
    }
    ans += val[cur][x];
    val[cur][x]++;
}

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

    cin >> n;
    for(int i = 0 ; i < n ; i++){
        cin >> s[i];
        vec.push_back({SZ(s[i]) , i});
    }
    sort(all(vec) , greater<pll>());
    for(pll i : vec){
        int ind = i.Y;
        insert(s[ind]);
    }
    cout << ans << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 238596
while True:
    h,w=map(int,input().split())

    if h==0 and w==0:
        break

    for i in range(h):
        wid=''
        if i%2==0:
            for l in range(w):
                if l%2==0:
                    wid+='#'
                else :
                    wid+='.'
            print(wid)
        else :
            for l in range(w):
                if l%2==0:
                    wid+='.'
                else :
                    wid+='#'
            print(wid)
    print("")



Measured memory_bytes: 5612
import sys

N = int(input())
li = [list(map(int,input().split())) for i in range(N)]

for i in range(len(li) - 2):
    if li[i][0] == li[i][1]:
        if li[i + 1][0] == li[i + 1][1]:
            if li[i + 2][0] == li[i + 2][1]:
                print("Yes")
                sys.exit()
print("No")

Measured memory_bytes: 62368
/*********************************************************************| 
|---------|    /\  ....                  ....                         |         
     |        /  \   \                    /  /------| ----- |-------| |
     |       /    \   \                  /  /           |   |         |
     |      /      \   \       /\       /  |            |   |         |
     |     /        \   \     /  \     /   |---|        |   |----|    |
     |    /__________\   \   /    \   /        |---|    |   |         |
     |   /            \   \ /      \ /              |   |   |         |
     |  /              \   |        |               /   |   |         |
     _ __              __ ...      ...      |------/  ----- _         |
                                                                      |  
        Md Tawsif Rahman                                              |
        Institute Of Information Technology                           |
        Jahangirnagar University                                      |                                                                         
                                                                      |
**********************************************************************/                 
#include<bits/stdc++.h>

using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define pii pair <int, int>
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii > 
#define inf  100000000 
#define f(i, c, n) for(i = c; i < n; i++)
#define fe(i, c, n) for(i = c; i <= n; i++)
#define fr(i, n, c) for(i = n - 1; i >= c; i--) 
#define vbe(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(vbe(a), x) - a.begin())
#define UB(a, x) (upper_bound(vbe(a), x) - a.begin())

#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
int i, j, temp;
// int convert_str_to_int(string s) {
//     stringstream str(s);
//     int x = 0;
//     str >> x;
//     return x;
// }


/********************|
                     |
   START HERE        |
                     |
*********************/
set < ll > s;
map < ll, ll > m;
vl v;
void func() {
    f(i, -200, 200) {
        s.insert(pow(i, 5));
        m[pow(i, 5)] = i;
        v.pb(pow(i, 5));
    }
}

void solve() {
    func();
    ll x; cin >> x;
    int n = v.size();
    ll a, b;
    f(i, 0, n) {
        b = v[i];
        a = b + x;
        if(s.find(a) != s.end()) {
            break;
        }
    }
    cout << m[a] << " " << m[b] << endl;
} 

int main() {
    fast;
    // int t; cin >> t; while(t--)
    solve(); 

}

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

int main()
{
  int H, A, result;
  cin >> H >> A;

  if (H % A == 0)
  {
    result = H / A;
  }
  else
  {
    result = H / A + 1;
  }

  cout << result << endl;
}

Measured memory_bytes: 256
W,H,N=map(int,input().split())
L=0
R=W
B=0
T=H
for i in range(N):
	x,y,a=map(int,input().split())
	if a==1:
		L=max(x,L)
	if a==2:
		R=min(R,x)
	if a==3:
		B=max(B,y)
	if a==4:
		T=min(T,y)
if R<L or  T<B:
	print(0)
else:
	print((R-L)*(T-B))

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

using one_info = std::pair<int64_t, int64_t>; // (x_i, y_j)

int64_t N;
std::vector<std::vector<one_info>> info; // A_iの証言すべて

bool judge(int64_t bit)
{
	for (int64_t i = 0; i < N; i++)
	{
		// i人目が不親切のときは調べる必要はない
		if (!(bit & (1 << i))) continue;

		for (one_info xy : info[i])
		{
			int64_t x = xy.first;
			int64_t y = xy.second;
			// y: 正直 x: 不親切で矛盾
			if (y == 1 && !(bit & (1 << x))) return false;
			// y: 不親切 x: 正直で矛盾
			if (y == 0 && (bit & (1 << x))) return false;
		}
	}
	// すべて矛盾がなければOK
	return true;
}

void solve()
{
    std::cin >> N;
	info.resize(N);
	for (int64_t i = 0; i < N; i++)
	{
		int64_t A;
		std::cin >> A;
		info[i].resize(A);
		for (int64_t j = 0; j < A; j++)
		{
			std::cin >> info[i][j].first >> info[i][j].second;
			info[i][j].first--; // 人の番号を0-originに
		}
	}

	int64_t ans = 0;
	for (int64_t bit = 0; bit < (1 << N); bit++)
	{
		if (judge(bit))
		{
			int cnt = 0;
			for (int64_t i = 0; i < N; i++)
			{
				if (bit & (1 << i)) cnt++;
			}
			ans = std::max<int64_t>(ans, cnt);
		}
	}

	std::cout << ans << std::endl;
}

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


Measured memory_bytes: 3660
package main

import (
	"fmt"
)

func main() {
	var n, t int
	fmt.Scan(&n, &t)
	min := 99999
	for i := 0; i < n; i++ {
		var c, k int
		fmt.Scan(&c, &k)
		if k <= t {
			if c < min {
				min = c
			}
		}
	}
	if min == 99999 {
		fmt.Println("TLE")
		return
	}
	fmt.Println(min)
}


Measured memory_bytes: 512
#include <set>
#include <cmath>
#include <stack>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <numeric>
#include <vector>
#include <ctime>
#include <queue>
#include <list>
#include <map>
#define pi acos(-1.0)
#define INF 0x3f3f3f3f
#define clr(x)  memset(x,0,sizeof(x));
#define clrto(x,siz,y)  for(int xx=0;xx<=siz;xx++)  x[xx]=y;
#define clrset(x,siz)  for(int xx=0;xx<=siz;xx++)  x[xx]=xx;
#define clr_1(x) memset(x,-1,sizeof(x));
#define clrmax(x) memset(x,0x3f,sizeof(x));
#define clrvec(x,siz) for(int xx=0;xx<=siz;xx++)  x[xx].clear();
#define fop2   freopen(".in","r",stdin); //freopen(".out","w",stdout);
#define fop   freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
#define myprogram By_135678942570
#define clrcpy(x,siz,y)  for(int xx=0;xx<siz;xx++)  x[xx]=y[xx];
#define pb push_back
#define eps 1e-8
using namespace std;
struct point
{
	double x,y;
	point(double a=0,double b=0)
	{
		x=a,y=b;
	}
	point operator + (point a)
	{
		return point(x+a.x,y+a.y);
	}
	point operator - (point a)
	{
		return point(x-a.x,y-a.y);
	}
	point operator * (double a)
	{
		return point(x*a,y*a);
	}
	point operator /(double a)
	{
		return point(x/a,y/a);
	}
};
double dis(point a,point b)
{
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
point go(point a,point b,double D)
{
	a=a-b;
	b.x=b.x+a.x*cos(D)-a.y*sin(D);
	b.y=b.y+a.x*sin(D)+a.y*cos(D);
	return b;
}
int main()
{
	// fop;
	int n;
	double d;
	while(scanf("%d%lf",&n,&d)>0)
	{
		if(n==0&&d==0)
			break;
		point left=point(-d,0);
		point right=point(d,0);
		for(int i=0;i<n;i++)
		{
			double v1,v2,t;
			scanf("%lf%lf%lf",&v1,&v2,&t);
			if(fabs(v1-v2)<eps)
			{
				point dir;
				dir.x=-right.y+left.y;
				dir.y=right.x-left.x;
				dir=dir/(sqrt(dir.x*dir.x+dir.y*dir.y));
				left=left+dir*t*v1*pi/180.0;
				right=right+dir*t*v2*pi/180.0;
			}
			else if(v1*v2>0)
			{	
				if(fabs(v1)>fabs(v2))
				{
					point O=right+(right-left)*fabs(v2)/(fabs(v1)-fabs(v2));
					left=go(left,O,-(v1*t*pi)/180.0/dis(left,O));
					right=go(right,O,-(v2*t*pi)/180.0/dis(right,O));
				}
				else
				{
					point O=left+(left-right)*fabs(v1)/(fabs(v2)-fabs(v1));
					left=go(left,O,(v1*t*pi)/180.0/dis(left,O));
					right=go(right,O,(v2*t*pi)/180.0/dis(right,O));
				}
			}
			else
			{
					point O=left+(right-left)*fabs(v1)/(fabs(v1)+fabs(v2));
					if(fabs(dis(left,O))>eps)
					left=go(left,O,-(v1*t*pi)/180.0/dis(left,O));
					if(fabs(dis(right,O))>eps)
					right=go(right,O,(v2*t*pi)/180.0/dis(right,O));
			}
		}
		point res=left+right;
		res=res/2.0;
		if(abs(res.x)<eps)
			res.x=0.0;
		if(abs(res.y)<eps)
			res.y=0.0;
		
		printf("%.14f\n%.14f\n",res.x,res.y);
	}
}

Measured memory_bytes: 1260
import copy
n = int(input())
x=list(map(int,input().split()))
l=copy.copy(x)
l.sort()
n1 = l[n//2-1]
n2 = l[n//2]
for i in range(n):
  if x[i]>n1:
    print(n1)
  else:
    print(n2)
    

  

Measured memory_bytes: 93128
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>

using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll X;
	cin >> X;
	ll t = floor((ld)X / 11) * 2;
	ll left = X % 11;
	if (1 <= left && left <= 6)t++;
	else if(left != 0) t += 2;
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int m,n;
char area[105][105];
char search(int i,int j)
{
	char sum='0';
	if(area[i][j]=='#')return '#';
	for(int x=i-1;x<=i+1;x++)
		for(int y=j-1;y<=j+1;y++)
			if(area[x][y]=='#')sum++;
	return sum;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",area[i]+1);
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			area[i][j]=search(i,j);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			printf("%c",area[i][j]);
		if(n-i)printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    char a,b;cin>>a>>b;
    if(a=='H'){
        cout<<b<<"\n";
    }else{
        if(b=='H')cout<<"D\n";
        else cout<<"H\n";
    }
}


Measured memory_bytes: 3580
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 5e5 + 100;
int n;
char s[maxn];

bool read() {
  if (scanf("%s", s) < 1) {
    return false;
  }
  return true;
}

void solve() {
  int cnt = 0;
  int len = strlen(s);
  for (int i = 0; s[i]; i++) {
    if (s[i] == 'S') {
      cnt++;
    } else {
      if (cnt > 0) {
        len -= 2;
        cnt--;
      }
    }
  }
  printf("%d\n", len);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)
ans=0
for v in range(1,n+1):
    for u in g[v]: #i番目の展望台から1本の道を通っていけるすべての展望台と高さを比較する
        if arr[u]>=arr[v]:
            break
    else: #i番目の展望台の高さが他のすべての展望台の高さより真に大きければ答えを1増やす
        ans+=1
print(ans)

Measured memory_bytes: 29476
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
int main()
{
	//code
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	
	long double rad=2*pi*((long double)h/12.0+((long double)m/60.0)/12.0-(long double)m/60.0);
	long double r=(long double)(a*a+b*b)-(long double)(2*a*b)*cosl(rad);
	printf("%20.20Lf\n",sqrtl(r));
 	return 0;
}



Measured memory_bytes: 4132
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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 = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll w, h, x, y;
  cin >> w >> h >> x >> y;
  printf("%f %d\n", (w * h) / 2.0, (x * 2 == w && y * 2 == h) ? 1 : 0);

  return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];



int main() {
    long long a,b;
    cin>>a>>b;
    long long p=1;
    rep(i,a){
        p*=100;
    }
    if(a==0){
        if(b==100){
            cout<<b+1<<endl;
        }
        else{
            cout<<b<<endl;
        }
    }
    else{
        if(b!=100){
            cout<<p*b<<endl;
        }
        else{
            cout<<p*(b+1)<<endl;
        }
    }

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int X = int.Parse(input[1])-1;
            int Y = int.Parse(input[2])-1;

            int[] res = new int[N];
            int dis = 0;

            for (int i = 0; i < N; i++)
                for (int j = i + 1; j < N; j++)
                {
                    dis = Math.Min(j - i, Math.Abs(i - X) + Math.Abs(j - Y) + 1);
                    res[dis]++;
                }

            for (int i=1;i<N;i++)
                Console.WriteLine(res[i]);
        }

    }
}


Measured memory_bytes: 11204
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#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>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n,a[205],ans;
bool flag=true;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	while(1){
		for(int i=1;i<=n;i++){
			a[i]/=2;
			if(a[i]%2==1){
				flag=false;
			}
		}
		if(flag==false){
			if(ans==0){
				cout<<0;
				return 0;
			}
			else{
				cout<<ans+1;
				return 0;
			}
		}
		else
		ans++;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int a = 0, b = 0, c = 0, d = 0;
	
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0 && s[i] == '0')a++;
		if (i % 2 == 0 && s[i] == '1')b++;
		if (i % 2 == 1 && s[i] == '0')c++;
		if (i % 2 == 1 && s[i] == '1')d++;
	}

	int ans = INF;
	ans = min(b + c, a + d);
	cout << ans << endl;
}

Measured memory_bytes: 512
n,W=map(int,input().split())
wv=[[int(j) for j in input().split()] for i in range(n)]
dp=[[0]*110000 for i in range(110)]
INF=10**10
for j in range(1,110000):
  dp[0][j]=INF

for i in range(1,n+1):
  for j in range(110000):
    dp[i][j]=dp[i-1][j]
    if j-wv[i-1][1]>=0:
      dp[i][j]=min(dp[i][j],
                   dp[i-1][j-wv[i-1][1]]+wv[i-1][0])
ans=0
for v in range(110000):
  if dp[n][v]<=W:
    ans=max(ans,v)
      
print(ans)

Measured memory_bytes: 129348
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int a[30]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};
  int i,n,j;

  for(i=0;i<28;i++){
    cin >> n;
    for(j=0;j<30;j++){if(a[j] == n)a[j]=0; }
      }

  for(i=0;i<30;i++){
    if(a[i] != 0)cout << a[i] << endl;

  }



}

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


int main(){
    int n ;
    cin >> n ;
    vector<string> str (n) ;
    rep(i, n){
        cin >> str[i];
    }
    vector<int> ans (4) ; 
    rep(i, n){
        if(str[i] == "AC"){
            ans[0]++ ;
        }
        if(str[i] == "WA"){
            ans[1]++ ;
        }
        if(str[i] == "TLE"){
            ans[2]++ ;
        }
        if(str[i] == "RE"){
            ans[3]++ ;
        }
    }
    cout << "AC" << " " << 'x' << " " << ans[0] << endl;
    cout << "WA" << " " << 'x' << " " << ans[1] << endl;
    cout << "TLE" << " " << 'x' << " " << ans[2] << endl;
    cout << "RE" << " " << 'x' << " " << ans[3] << endl;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i=0;i<N;i++)
    cin >> data.at(i);
  int count=0;
  for(int k=2;k<N;k++){
    for(int j=1;j<k;j++){
      for(int i=0;i<j;i++){
        if( i < j && j < k && data.at(i)!=data.at(j) && data.at(j)!=data.at(k) && data.at(k)!=data.at(i) && data.at(k)+data.at(j) > data.at(i) && data.at(i) + data.at(k) > data.at(j) && data.at(i) + data.at(j) > data.at(k) ){
          count++;
        }
      }
    }
  }
  cout << count;
}

Measured memory_bytes: 3624
/**
 * a.cxx - 2019-08-24 11:21
 *
 * Copyright © 2019 Libao Jin <jinlibao@outlook.com>
 * Distributed under terms of the MIT license.
 */

// #define LOCAL 1
#ifdef LOCAL
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int m, d;
  cin >> m >> d;
  int cnt = 0;
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= d; ++j) {
      int d10 = j / 10, d1 = j % 10;
      if (d1 >= 2 and d10 >= 2 and d1 * d10 == i) ++cnt;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 20090717
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-12;
const int N=100+10,maxn=10000+10,inf=0x3f3f3f3f;

struct edge{
    int to,Next;
    ll c;
}e[maxn<<1];
int cnt,head[N];
int dis[N];
void add(int u,int v,ll c)
{
    e[cnt].to=v;
    e[cnt].c=c;
    e[cnt].Next=head[u];
    head[u]=cnt++;
    e[cnt].to=u;
    e[cnt].c=0;
    e[cnt].Next=head[v];
    head[v]=cnt++;
}
void init()
{
    cnt=0;
    memset(head,-1,sizeof head);
}
bool bfs(int s,int t)
{
    memset(dis,-1,sizeof dis);
    dis[s]=0;
    queue<int>q;
    q.push(s);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        if(x==t)return 1;
        for(int i=head[x];~i;i=e[i].Next)
        {
            int te=e[i].to;
            if(dis[te]==-1&&e[i].c>0)
            {
                dis[te]=dis[x]+1;
                q.push(te);
            }
        }
    }
    return 0;
}
ll dfs(int x,ll mx,int t)
{
    if(x==t)return mx;
    ll flow=0;
    for(int i=head[x];~i;i=e[i].Next)
    {
        int te=e[i].to;
        ll f;
        if(e[i].c>0&&dis[te]==dis[x]+1&&(f=dfs(te,min(mx-flow,e[i].c),t)))
        {
            e[i].c-=f;
            e[i^1].c+=f;
            flow+=f;
        }
    }
    if(!flow)dis[x]=-2;
    return flow;
}
ll maxflow(int s,int t)
{
    ll ans=0,f;
    while(bfs(s,t))
    {
        while((f=dfs(s,inf,t)))ans+=f;
    }
    return ans;
}
ll a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    int s=n+1,t=n+2;
    init();
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>0)
        {
            ans+=a[i];
            add(i,t,a[i]);
        }
        else add(s,i,-a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=2*i;j<=n;j+=i)
        {
            add(i,j,1e13);
        }
    }
    cout<<ans-maxflow(s,t)<<endl;
    return 0;
}
/********************

********************/


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<functional>

constexpr int MAX_N = 100, INF = (int)1e8;

using P = std::pair<int, int>;

struct edge {
	int to, cost;
	edge() = default;
	edge(int _t, int _c) : to(_t), cost(_c) {}
};

int n;
std::vector<edge> G[2][MAX_N];//0:??????,1:??????

int d[MAX_N];

int dijkstra(int s, int g, int index) {
	std::fill(d, d + n, INF);
	d[s] = 0;
	std::priority_queue<P, std::vector<P>, std::greater<P>> que;
	que.emplace(d[s], s);
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		if (p.second == g)
			return d[g];
		if (d[p.second] > p.first)
			continue;
		for (int i = 0; i < G[index][p.second].size(); ++i) {
			edge e = G[index][p.second][i];
			if (d[e.to] > d[p.second] + e.cost) {
				d[e.to] = d[p.second] + e.cost;
				que.emplace(d[e.to], e.to);
			}
		}
	}
	return -1;
}

int main() {
	while (1) {
		int m;
		std::cin >> m >> n;
		if (m + n == 0)
			break;
		int a, b, c, t;
		for (int i = 0; i < m; ++i) {
			std::cin >> a >> b >> c >> t;
			--a;
			--b;
			G[0][a].emplace_back(b, c);
			G[0][b].emplace_back(a, c);
			G[1][a].emplace_back(b, t);
			G[1][b].emplace_back(a, t);
		}
		int q, r;
		std::cin >> q;
		int p[2];
		for (int i = 0; i < q; ++i) {
			std::cin >> p[0] >> p[1] >> r;
			--p[0];
			--p[1];
			std::cout << dijkstra(p[0], p[1], r) << std::endl;
		}
		for (int i = 0; i < 2; ++i) {
			for (int j = 0; j < n; ++j)
				G[i][j].clear();
		}
	}
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N;
  cin >> N;
  ll u[N-1];
  ll v[N-1];
  for (int i = 0; i < N-1; i++) {
    cin >> u[i] >> v[i];
    if (u[i] > v[i]) {
      swap(u[i],v[i]);
    }
  }
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    ans += i * (N - i + 1);
  }

  for (int i = 0; i < N-1; i++) {
    ans -= u[i] * (N - v[i] + 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6792
#include <iostream>
#include <map>

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

using namespace std;
using P = pair<string,int>;

int main()
{
    map<string,int> m;
    int N,M,ans=0;
    cin>>N;
    rep(i,N){
        string s;
        cin>>s;
        m[s]++;
    }
    cin>>M;
    rep(i,M){
        string s;
        cin>>s;
        m[s]--;
    }

    for(auto p : m){
        ans = max(ans,p.second);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// atcoder.cpp.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<stdio.h>
#include<string.h>
#include <math.h>
#include<stdlib.h>
#include<time.h>
#include<random>

using namespace std;
//std::random_device rnd;

//グロ変

int main()
{
     char enter[200000];
    cin >> enter;

    int t = 0;
    while (1) {
        if (enter[t] == '\0') {
            break;
        }
        if(enter[t] == '?'){
            enter[t] = 'D';
        }
        t++;
    }

   
    cout << enter;

}




Measured memory_bytes: 3204
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long k = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        if (b - a <= 2 || k - a < 1) {
            System.out.println(k + 1);
        } else {
            long count = (k - a + 1) / 2;
            System.out.println(a + count * (b - a) + (k - a + 1) % 2);
        }
    }

}


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

int main(){
	int x;
	cin >> x;
	if(x == 7 || x == 5|| x == 3){
		cout << "YES" << endl;
	}else cout << "NO" << endl;
	return 0;
}



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

int main(){
	long long b=100;
	long long x;
	cin>>x;
	for(int i=0;i<100000;i++){
		if(b>=x){
			cout<<i;
			return 0;
		}
		b*=1.01;
	}
	return 0;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    int diff = A - 2 * B;
    if (diff < 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << A - 2 * B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cmath>
#include <ctype.h>
using namespace std;
int N;
string S;
int main() {
    cin >> N >> S;
    int cnt=0, ans=0;
    for(int i=0; i<N; ++i){
        if(S[i]=='I') cnt++;
        else if(S[i]=='D') cnt--;
        if(ans<cnt) ans = cnt;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int N;
    double c=0;
    
    cin>>N;
    
    for(int i=1;i<=N;i++){
        if(i%2==1) c++;
    }
    
    printf("%.12f\n",c/N);
}


Measured memory_bytes: 3180
n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)

h = Hash.new(0)
a.each {|x| h[x] += 1}

ans = 0
h.values.sort.reverse.drop(k).each {|x| ans+= x }
p ans


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

int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;
    if (s.at(k - 1) == 'A')
        s.at(k - 1) = 'a';
    else if (s.at(k - 1) == 'B')
        s.at(k - 1) = 'b';
    else
        s.at(k - 1) = 'c';
    cout << s << endl;
}


Measured memory_bytes: 256
import math
s = int(input())
ans = 0
if s < 3:
  ans = 0
else:
  p = s // 3
  q = s % 3
  if q == 0:
    ans += 1
  elif q == 1:
    ans += p
  elif q == 2:
    if p == 1:
      ans += 1
    else:
      ans += p + math.factorial(p) // (math.factorial(p - 2) * math.factorial(2))
  for i in range(1, p):
    ans += math.factorial((s - 3 * (p - i)) + (p - i - 1)) // (math.factorial((s - 3 * (p - i))) * math.factorial(p - i - 1))
ans = ans % (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back 
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ll long long
int rd()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
}
int n,k;
int linkk[2010],t;
struct node{int n,y;}e[4010];
int x[2010],y[2010];
int ans,now;
void dfs(int x,int fa,int dep)
{
    if(dep > k) return;
    now++;
    for(int i = linkk[x];i;i = e[i].n)
    {
        int y = e[i].y;
        if(y == fa)continue;
        dfs(y,x,dep+1);
    }
}
int main()
{
    n = rd();k = rd();
    rep(i,1,n-1)
    {
        x[i] = rd(),y[i] = rd();
        e[++t].y = y[i];e[t].n = linkk[x[i]];linkk[x[i]] = t;
        e[++t].y = x[i];e[t].n = linkk[y[i]];linkk[y[i]] = t;
    }
    //偶数
    if(k%2==0)
    {
        k /= 2;
        rep(i,1,n)
        {
            now = 0;
            dfs(i,0,0);
            ans = max(ans,now);
        }
        printf("%d\n",n-ans);
    }
    else
    {
        k /= 2;
        rep(i,1,n-1)
        {
            now = 0;
            dfs(x[i],y[i],0);
            dfs(y[i],x[i],0);
            ans = max(ans,now);
        }
        printf("%d\n",n-ans);
    }
    return 0;
}

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

string s;

//[l, r)のハッシュ値を返す
int f(int a, int b, int c, int d, int l, int r){
    //num1 op num2を実行する
    int op;
    int num1, num2;
    if(s[l] != '['){
        if(s[l] == 'a') return a;
        if(s[l] == 'b') return b;
        if(s[l] == 'c') return c;
        if(s[l] == 'd') return d;
    }

    //cout << "l " << l << " r " << r << endl;
    if(s[l + 1] == '+') op = 0;
    else if(s[l + 1] == '*') op = 1;
    else op = 2;

    if(s[l + 2] == '['){
        int dpt = 1;
        for(int idx = l + 3; idx < r; idx++){
            if(s[idx] == '[') dpt++;
            else if(s[idx] == ']') dpt--;
            
            if(dpt == 0){
                num1 = f(a, b, c, d, l + 2, idx + 1);
                l = idx + 1;
                break;
            }
        }
    }else{

        if(s[l + 2] == 'a') num1 = a;
        if(s[l + 2] == 'b') num1 = b;
        if(s[l + 2] == 'c') num1 = c;
        if(s[l + 2] == 'd') num1 = d;
        l = l + 3;
    }

    if(s[l] == '['){
        int dpt = 1;
        for(int idx = l + 1; idx < r; idx++){
            if(s[idx] == '[') dpt++;
            else if(s[idx] == ']') dpt--;
            
            if(dpt == 0){
                num2 = f(a, b, c, d, l, idx + 1);
                break;
            }
        }
    }else{
        if(s[l] == 'a') num2 = a;
        if(s[l] == 'b') num2 = b;
        if(s[l] == 'c') num2 = c;
        if(s[l] == 'd') num2 = d;
    }

    int rec;
    if(op == 0) rec = num1 | num2;
    else if(op == 1) rec = num1 & num2;
    else rec = num1 ^ num2;
    //cout << num1 << " " << num2 << " " << op << endl;
    return rec;
}

int main(){

    //実験
    //s = "[*b[*[*cd]a]]";
    //cout << f(7, 7, 7, 7, 0, 13) << endl;


    while(1){
        cin >> s;
        if(s == ".") break;
        string pass; cin >> pass;
        int a = (int)(pass[0] - '0');
        int b = (int)(pass[1] - '0');
        int c = (int)(pass[2] - '0');
        int d = (int)(pass[3] - '0');
        int l = 0;
        int r = (int)s.size();
        int x = f(a, b, c, d, l, r);
        int cnt = 0;
        for(a = 0; a < 10; a++){
            for(b = 0; b < 10; b++){
                for(c = 0; c < 10; c++){
                    for(d = 0; d < 10; d++){
                        if(x == f(a, b, c, d, l, r)) cnt++;
                    }
                }
            }
        }

        cout << x << " " << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,l; cin >> n >> l;
	int sum = 0;
	int abs_min = 1e9;
	for(int i = 0; i < n;i ++){
		sum += l + i;
		abs_min = min(abs_min, abs(l + i));
	}
	if(l < 0)abs_min *= -1;
	cout << sum - abs_min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <int> b(n); 
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    /*for(int i=0;i<n;i++){
        if(b[i]>i+1) { cout<<-1<<endl; return 0;}
    }*/
    vector <int> ans;
    while(b.size()!=0){
        int p=-1;
        for(int i=0;i<b.size();i++){
            if(b[i]==i+1) p=i;
        }
        if(p==-1) {cout<<-1<<endl; return 0;}
        ans.push_back(b[p]);
        b.erase(b.begin()+p);
    }
    reverse(ans.begin(),ans.end());
    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
}


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

#define ll long long 
 
int main()
{
    ll t, i, j, k, ans, n, m, sum = 0, x;
 
    t = 1;
    while (t--)
    {
        cin>>n;
        ll cnt[10][10] = {0};
 
        for ( ll p = 1 ; p < n +1 ; p++)
		{
            ll l = p%10;
 
            k = p;
            while(k/10)k/=10;
            ll f = k;
            cnt[f][l]++;
        }
        ans=0;
        for (ll p = 1; p < 10 ; p++)
		{
			for ( ll q = 0 ; q < 10 ; q++)
            {
                ans += (cnt[p][q] * cnt[q][p]);
            }
        }
 
        cout<<ans;
    }
 
    return 0;
}

Measured memory_bytes: 3636
n,k,q = map(int, input().split())
list_a = [int(input()) for i in range(q)]

sn = [0]*n

for i in list_a:
  sn[i-1] += 1


for j in sn:
  if (k - (q-j)) > 0:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 56024
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin>>n;
  vector<signed long long int> vect(n);
  for(int i=0;i<n;i++) cin>>vect[i];
  vector<vector<signed long long int>> dp(n,vector<signed long long int>(n));
  for(int i=0;i<n;i++) dp[i][i]=vect[i];
  for(int l=n-1;l>=0;l--){
    for(int r=l+1;r<n;r++){
      dp[l][r]=max(vect[l]-dp[l+1][r],vect[r]-dp[l][r-1]);
    }
  }
  cout<<dp[0][n-1];
  return 0;
}

Measured memory_bytes: 70784
H,W=map(int,input().split())
board=[list(input()) for _ in range(H)]

dx=[1,1,0,-1,-1,-1,0,1]
dy=[0,1,1,1,0,-1,-1,-1]

for i in range(H):
    for j in range(W):
        if board[i][j]==".":
            cnt=0
            for k in range(8):
                x=i+dx[k]
                y=j+dy[k]
                if 0<=x<H and 0<= y <W:
                    if board[x][y]=='#':
                        cnt+=1
            board[i][j]=str(cnt)
        
        
for b in board:
    b = map(str, b)
    print("".join(b))

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

using namespace std;

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


int main(void)
{
  int n, m;
  cin >> n >> m;
  vector<int> a(m, 0);
  vector<int> b(m, 0);
  vector<int> count(n, 0);
  for (int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    count[a[i]-1]++;
    count[b[i]-1]++;
  }

  for(int i: count){
    cout << i << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;

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

// あきらかにKがループできる回数じゃないのでmodで判定？
// 座標原点を挟んで2K回移動しても位置は同じか。最初だけで決まる。
int main() {
  LL X, K, D; scanf("%lld %lld %lld", &X, &K, &D);
  LL ans = abs(X);
  if(ans/D>=K){
    ans = ans - K*D;
    K = 0;
  }else{
    LL used = ans/D;
    ans -= used*D;
    K -= used;
    ans -= D;
    K--;
  }

  if(K%2==0) cout << abs(ans) <<endl;
  else cout << abs(ans+D) << endl;
  return 0;
}



Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
// DP テーブル
long long dp[3100][3100];


//N-(j-i)が偶数の時先手、奇数の時後手、N=奇でも偶でも変わらない
//dp[i][i]はもう数列がないので０
int main() {
    // 入力受け取り
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // 初期条件
    for (int i = 0; i < N; ++i) dp[i][i] = 0;

    // DP
    for (int len = 1; len <= N; ++len) {
        //区間を抜き出していく
        for (int i = 0; i + len <= N; ++i) {
            int j = i + len;

            // 先手番
            if ((N - len) % 2 == 0)
                dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);

            // 後手番
            else
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);//後手は最小化したいので
        }
    }

    // 答え
    cout << dp[0][N] << endl;
}

Measured memory_bytes: 73984
n,q = map(int,input().split())
raw = input()
acu = [0]
for i in range(1,n):
  if raw[i-1:i+1] == 'AC':
    acu.append(acu[-1]+1)
  else:
    acu.append(acu[-1])
acu.append(0)
for _ in range(q):
  l,r = map(int,input().split())
  l -= 1
  r -= 1
  print(acu[r] - acu[l])

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

using namespace std;

int main(){
    vector<vector<int>> a(3,vector<int>(3));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin>>a[i][j];
        }
    }
    int n;
    cin>>n;
    vector<vector<bool>> f(3,vector<bool>(3));
    for (int i = 0; i < n; ++i) {
        int b;
        cin>>b;
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if(b==a[j][k])f[j][k]=true;
            }
        }
    }
    string ans="No";
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if(!f[i][j])break;
            if(j==2)ans="Yes";
        }
    }
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if(!f[j][i])break;
            if(j==2)ans="Yes";
        }
    }
    for (int i = 0; i < 3; ++i) {
        if(!f[i][i])break;
        if(i==2)ans="Yes";
    }
    for (int i = 0; i < 3; ++i) {
        if(!f[i][2-i])break;
        if(i==2)ans="Yes";
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())

white = 0  # 前者
black = 0  # 後者

ans = 1

mod = 10**9 + 7
que = []
for i in range(N):
    x = int(input())
    que.append((x, 0))
for i in range(N):
    y = int(input())
    que.append((y, 1))
que.sort(reverse=True)
for i in range(2*N):
    value, index = que[i]
    if index == 0:
        white += 1
        if black > 0:
            ans *= black
            ans %= mod
            black -= 1
            white -= 1
    else:
        black += 1
        if white > 0:
            ans *= white
            ans %= mod
            white -= 1
            black -= 1
print(ans)

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


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

    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;




    return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string x;
    cin>>x;
    if(x.find("AB")!=x.npos||x.find("BA")!=x.npos)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 384