akhauriyash/Code-Regression huggingface dataset:
/**
 *   created: 28 April 2019  23:46:46
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
// #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int power(int n, int p){
	if(p==0)
		return 1;
	if(p%2==0)
		return power(n*n,p/2);
	return n*power(n,p-1);
}
int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		double n,k;
		cin>>n>>k;
		double prob=0;
		prob = max(n-k+1,(double)0)/n;
		// trace1(prob);
		rep(i,1,min(n+1,k)){
			int temp = 2;
			while(temp*i<k){
				temp *= 2;
			}
			prob += 1/(n*temp);
		}
		printf("%.10lf",prob);
	}
	return 0;
}





Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

k = 0
ans = 0
while k == 0:
	for i in range(n):
		if a[i] % 2 == 0:
			a[i] = int(a[i] / 2)
		else:
			k = 1
			break
	ans += 1


print(ans-1)


Measured memory_bytes: 3064
import math
n = int(input())
paths = []
for _ in range(n):
    paths.append(list(map(int, input().split(' '))))

ans = 0

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        ans += math.sqrt(math.pow(paths[i][0] - paths[j][0], 2) + math.pow(paths[i][1] - paths[j][1], 2))

mul = 1
for i in range(1, n):
    mul *= i
print(ans/n)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

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


Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
c = ["#"*(W+2)] + ["#" + input() + "#" for _ in range(H)] + ["#"*(W+2)]


def bfs(start):
	queue = deque([start])
	#visited = [[False for _ in range(W+2)] for _ in range(H+2)]
	tekazu = [[-1 for _ in range(W+2)] for _ in range(H+2)]
	tekazu[start[0]][start[1]] = 0
	num = 0
	while queue:

		label = queue.pop()
		
			#print(visited)
		if c[label[0] + 1][label[1]] == "." and tekazu[label[0] + 1][label[1]] < 0:
			queue.appendleft([label[0] + 1, label[1]])
			tekazu[label[0] + 1][label[1]] = tekazu[label[0]][label[1]] + 1
			num = max(num, tekazu[label[0] + 1][label[1]])

		if c[label[0] - 1][label[1]] == "." and tekazu[label[0] - 1][label[1]] < 0:
			queue.appendleft([label[0] - 1, label[1]])
			tekazu[label[0] - 1][label[1]] = tekazu[label[0]][label[1]] + 1
			num = max(num, tekazu[label[0] - 1][label[1]])

		if c[label[0]][label[1] + 1] == "." and tekazu[label[0]][label[1] + 1] < 0:
			queue.appendleft([label[0], label[1] + 1])
			tekazu[label[0]][label[1] + 1] = tekazu[label[0]][label[1]] + 1
			num = max(num, tekazu[label[0]][label[1] + 1])

		if c[label[0]][label[1] - 1] == "." and tekazu[label[0]][label[1] - 1] < 0:
			queue.appendleft([label[0], label[1] - 1])
			tekazu[label[0]][label[1] - 1] = tekazu[label[0]][label[1]] + 1
			num = max(num, tekazu[label[0]][label[1] - 1])

	return num

ans = 0
for h in range(1, H+1):
	for w in range(1, W+1):
		if c[h][w] == ".":
			ans = max(ans, bfs([h, w]))
print(ans)

Measured memory_bytes: 63728
def calc_sum(input_str):
    num_arr = input_str.split(" ")
    for i in range(0, len(num_arr)):
        num_arr[i] = int(num_arr[i])
    if sum(num_arr) >= 22:
        return "bust"
    return "win"

print(calc_sum(input("")))
        

Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#define N (500010)
#define P (998244353)
using namespace std;
int ksm(int a,int p){int res=1;for(;p;p>>=1,a=1ll*a*a%P)if(p&1)res=1ll*res*a%P;return res;}
int n,m,jc[N],inv[N],ans;
int C(int n,int m){return 1ll*jc[n]*inv[m]%P*inv[n-m]%P;}
int main(){
	scanf("%d%d",&n,&m),jc[0]=inv[0]=1;
	for(int i=1;i<=max(n,m);i++)jc[i]=1ll*jc[i-1]*i%P,inv[i]=ksm(jc[i],P-2);
	for(int i=0;i<=min(n,m);i++)(ans+=((i&1)?-1ll:1ll)*C(n,i)%P*C(m,i)%P*jc[i]%P*ksm(n+1,m-i)%P*ksm(m+1,n-i)%P)%=P;
	printf("%d\n",ans<0?ans+P:ans);
}

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

int digit_sum(int n) {
    int ret = 0;
    while (n > 0) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int d = digit_sum(i);
        if (a <= d && d <= b) {
            ans += i;
        }
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> seen(n, -1);
    seen[0]=1;

    queue<int> q;
    for(int i:G[0]){
        seen[i]=0;
        q.push(i);
    }

while(!q.empty()){
    int nex = q.front();
    q.pop();
    for(int i: G[nex]){
        if(seen[i] != -1) continue;
        seen[i] = nex;
        q.push(i);
    }
}

    rep(i, n){
        if(seen[i] == -1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i<n; i++){
        cout << seen[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10184
#include <bits/stdc++.h>
using namespace std;
bool mp[50][50];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int h,w;
int dfs(int y,int x){
  if(mp[y][x])return 0;
  int ret=1;
  mp[y][x]=1;
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx<0 || nx>=w || ny<0 || ny>=h) continue;
    ret+=dfs(ny,nx);
  }
  return ret;
}
  
int main(){
  string s;
  int si,sj;
  while(cin>>w>>h && w&&h){
    memset(mp,0,sizeof(mp));
    for(int i=0;i<h;i++){
      cin>>s;
      for(int j=0;j<w;j++){
        if(s[j]=='#') mp[i][j]=1;
        else if(s[j]=='@') {si=i;sj=j;}
      }
    }
    cout<<dfs(si,sj)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n,cap;
    cin>>n>>cap;
    long int wt[n];
    long int val[n];
    for(long int i=0;i<n;i++)
    cin>>wt[i]>>val[i];
    long long int dp[n+1][cap+1];
    for(long int i=0;i<n+1;i++)
    dp[i][0]=0;
    for(long int i=0;i<cap+1;i++)
    dp[0][i]=0;
    for(long int i=1;i<n+1;i++)
    {
        for(long int w = 1;w<cap+1;w++)
        {
            if(w>=wt[i-1])
            {
                dp[i][w] =(long long int)max(val[i-1]+dp[i-1][w-wt[i-1]],dp[i-1][w]);
            }
            else
            dp[i][w]=dp[i-1][w];
        }
    }
    cout<<dp[n][cap]<<endl;
    return 0;
}

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

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

  int N, M; cin >> N >> M;

  if (N <= M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

int main() {
    set<int> s;
    int N;  cin >> N;
    for (int i = 0; i < N; ++i) {
        int a;  cin >> a;
        s.insert(a);
    }
    cout << (s.size() == N ? "YES" : "NO") << endl;
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,j,train[500][3],t[500]={0};
    scanf("%d",&n);
    for (i=0;i<(n-1);i++)
    {
        scanf("%d %d %d",&train[i][1],&train[i][2],&train[i][3]);
    }
    for (i=0;i<(n-1);i++)
    {
        t[i]=train[i][1]+train[i][2];
        for (j=i+1;j<(n-1);j++)
        {
            if (t[i]<train[j][2]) t[i]=train[j][2];
            if (t[i]%train[j][3]!=0)
                t[i]=(t[i]/train[j][3]+1)*train[j][3];
            t[i]+=train[j][1];
        }
    }
    for (i=0;i<n;i++)
    {
        printf("%d\n",t[i]);
    }
    return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
*A, = map(int, input().split())

d = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6
}

c = [(i, d[i]) for i in A]
minpos = min(c, key=lambda x:x[1])[1]

dp = [0] * (N+1)
digit = [0] * (N+1)

for i in range(minpos, N+1):
    for n, cost in c:
        if i-cost<0 or 0<i-cost<minpos: continue
        a = dp[i]
        b = dp[i-cost] + n * (10**(digit[i-cost]))
        if a<b:
            dp[i] = b
            digit[i] = digit[i-cost] + 1

print(dp[N])

Measured memory_bytes: 52188
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    auto B = A;
    rep(i, N) { B[i] -= i + 1; }
    sort(All(B));
    ll res = 0;
    if(N % 2 == 1) {
        ll b = B[N / 2];
        rep(i, N) { res += abs(A[i] - (b + i + 1)); }
    } else {
        ll b = (B[N / 2] + B[N / 2 - 1]) / 2;
        ll b2 = (B[N / 2] + B[N / 2 - 1]) / 2;
        ll tmp = 0;
        rep(i, N) tmp += abs(A[i] - (b + i + 1));
        res = tmp;
        tmp = 0;
        rep(i, N) tmp += abs(A[i] - (b2 + i + 1));
        res = min(res, tmp);
    }
    cout << res << endl;
    return 0;
}

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

#define pii pair<int, int>
#define vii vector<pii>
#define ll long long
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)

int main() {
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	int counter = 0;
	for(int i = 0; i < n; i++) {
		int temp;
		scanf("%d", &temp);
		if(temp < a || temp >= b) {
			counter++;
		}
	}
	printf("%d\n", counter);
}

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

#define ll long long
#define ull unsigned long long
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)
#define DEBUG(x) cerr << #x << " = " << x << endl

const int MAX = 2e6 + 5, MOD = 1e9 + 7  , MAXLG = log2(MAX)+1;
const ll inf = 1e18 + 5;

int arr[MAX];
vector<ll>r,g,no;
int main(){

    fastio;
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll sum = 0;
    for(int i=0; i<a; i++){
        ll val;
        cin>>val;
        r.pb(val);
    }
    for(int i=0; i<b; i++){
        ll val;
        cin>>val;
        g.pb(val);
    }
    for(int i=0; i<c; i++){
        ll val;
        cin>>val;
        no.pb(val);
    }

    sort(r.begin(), r.end());
    sort(g.begin(), g.end());
    sort(no.begin(), no.end());

    deque<ll>nisi;
    int tx = x;
    int ty = y;
    while(tx--){
        nisi.pb(r.back());
        r.pop_back();
    }
    while(ty--){
        nisi.pb(g.back());
        g.pop_back();
    }

    sort(nisi.begin(), nisi.end());
    int baad = 0;
    while(1){
        if(baad == x+y) break;
        baad++;
        if(no.empty() || nisi.front() > no.back()) break;
        nisi.pop_front();
        nisi.pb(no.back());
        no.pop_back();
    }
    for(ll val: nisi) sum += val;
    cout<<sum<<"\n";

}


Measured memory_bytes: 4084
#include <iostream>
using namespace std;
signed main()
{
    int a, b, c; cin >> a >> b >> c;
    cout << min(a, min(b, c)) << " " << a+b+c - min(a, min(b, c)) - max(a, max(b, c)) << " " << max(a, max(b, c)) << endl;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
using l1 = long long;
#define rep(i,n) for(int i=0,i<(n);++i)]
int main(){
    int k;
    string s;
    cin>>k;
    cin>>s;

    if(k<s.length()){
        string a = s.substr(0,k);
        cout<<a<<"..."<<endl;
        return 0;
    }else{
        cout<<s;
        return 0;
    }
}

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

int main(){

    float L = 0;
    cin >> L;

    cout << fixed << setprecision(6) << pow(L/3, 3) << endl;

    return 0;
}

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

int main()
{
	int t;
	string num;
	while(1)
	{
		cin>>t>>num;
		if(t==0 && num=="0")
			break;
		if(to_string(t)==num)
		{
			cout<<num<<" "<<num<<endl;
			continue;
		}
		int keta=num.size()-1;//仕切りの数を求める
		//cerr<<keta<<" "<<(1<<keta)<<endl;
		int sum[1<<6];//それぞれの和
		fill(sum,sum+(1<<6),1e8-1);
		int m=0;
		int mind=-1;
		for(int bit=0;bit<(1<<keta);bit++)
		{
			//bitが1のときnumの以下に対応するところで切る
			//num 1 2 3 4 5 6
			//bit  4 3 2 1 0
			sum[bit]=0;
			int tmp=0;
			int cnt=1;
			int last=-1;
			for(int i=0;i<keta+1;i++)
			{
				tmp+=(num[i]-'0');
				if(bit&(1<<i))
				{
					sum[bit]+=tmp;
					tmp=0;
					cnt=0;
					last=i;
				}
				tmp*=10;
				cnt++;
			}
			//cerr<<bitset<4>(bit)<<" "<<last<<" "<<cnt<<endl;
			sum[bit]+=(tmp/10);
			if(sum[bit]>t)
				sum[bit]=1e8-1;
			if(sum[bit]!=1e8-1 && sum[bit]>m)
			{
				m=sum[bit];
				mind=bit;
			}
		}
		//cerr<<mind<<" "<<m<<endl;
		if(mind==-1)
		{
			cout<<"error"<<endl;
			continue;
		}
		//重複がないか確かめる
		bool f=false;
		for(int i=0;i<(1<<6);i++)
		{
			if(sum[i]==m && mind!=i)
			{
				cout<<"rejected"<<endl;
				f=true;
				break;
			}
		}
		if(f)
			continue;
		//構築
		cout<<m<<" ";
		for(int i=0;i<keta+1;i++)
		{
			cout<<num[i];
			if(mind&(1<<i))
				cout<<" ";
		}
		cout<<endl;
	}
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std; 
int main(){
//  freopen("text.in","r",stdin);
//  freopen("text.out","w",stdout);
	int n;
	cin>>n;
	int a1[n],a2[n]; 
	memset(a1,0,sizeof(a1)); 
	memset(a2,0,sizeof(a2)); 
	for(int i =0;i<n;i++){
		cin>>a1[i];
		a2[a1[i]-1]=i+1;
	}
	for(int i =0;i<n;i++){
		cout<<a2[i]<<" ";
	}
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define pq priority_queue
#define P pair<int, int>
#define P2 pair<int, P>
#define P3 pair<int, P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF = 1e9, MOD = 1e9+7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
const int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
const ld PI = abs(acos(-1));
const int sqrtN = 512;
const int logN = 32;
const ll LINF=1e18;

struct Node{
	int data;
	
	Node(int data) : data(data) {}
	
	Node operator*(const Node r) const{return Node(data + r.data);}
} e(0);

struct SqrtDecomposition{
	vector<Node> data;
	vector<Node> bucket;
	int N, K;
	
	SqrtDecomposition(int n) : N(n){
		K = (N + sqrtN - 1) / sqrtN;
		data.assign(K * sqrtN, e);
		bucket.assign(K, e);
	}
	
	void add(int k, int x){
		data[k] = data[k] * Node(x);
		k = k / sqrtN;
		
		Node ret = e;
		for(int i = k * sqrtN; i < (k + 1) * sqrtN; i++) ret = ret * data[i];
		bucket[k] = ret;
	}
	
	int get(int a, int b){
		int L = a / sqrtN, R = (b + sqrtN - 1) / sqrtN;
		Node ret = e;
		for(int k = L; k < R; k++){
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			
			if(a<=l&&r<=b) ret = ret * bucket[k];
			else for(int i = max(a, l); i < min(b, r); i++) ret = ret * data[i];
		}
		
		return ret.data;
	}
};

int main(){
	int n,q; cin >> n >> q;
	SqrtDecomposition data(n);
	for(int i = 0; i < q; i++){
		int a,b,c; cin >> a >> b >> c;
		
		if(a == 0) data.add(b, c);
		else cout << data.get(b, c + 1) << endl;
	}
	
	return 0;
}

//00:10 sec



Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include<chrono>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long N, std::vector<std::vector<long long>> A){
    chrono::system_clock::time_point start,end;
    start=chrono::system_clock::now();
    bool flag=false;
    ll cnt=0;
    ll last=N-1;
    ll sum=0;
    double time;
    vec(no,N);
    vec(th,N);
    while(1){
        end=chrono::system_clock::now();
        if(chrono::duration_cast<chrono::microseconds>(end-start).count()/1000.0>=1500.0){
            op(N*(N-1)/2);
            return;
        }
        if(sum>=(N-1)*N/2)break;
        rep(i,last){
            if(A[i][th[i]]==-2||A[i][th[i]]==-1){
                if(i==last-1&&A[i][th[i]]==-2){
                    last--;
                }
                continue;
            }
            
            
                if(A[A[i][th[i]]][th[A[i][th[i]]]]==i){
                    flag=true;
                    
                    A[A[i][th[i]]][th[A[i][th[i]]]]=-1;
                    A[i][th[i]]=-1;
                    sum++;
                }else{
                    no[A[i][th[i]]]=1;
                }
            
            
        }
        if(flag){
            cnt++;
            flag=false;
            rep(i,N){
                if(A[i][th[i]]==-1){
                    //A[i].erase(A[i].begin());
                    th[i]++;
                }
            }
        }else {
            op(-1)
            return;
        }
    }
    op(cnt)
//op(chrono::duration_cast<chrono::microseconds>(end-start).count()/1000.0)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::vector<long long>> A(N, std::vector<long long>(N));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N-1 ; j++){
            scanf("%lld",&A[i][j]);
            A[i][j]--;
        }
    }
    rep(i,N){
        A[i][N-1]=-2;
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std; typedef long long ll;
const int MAXN = 10 + 1e6;
const ll oo = 1 + 1e18, mod = 7 + 1e9;

int main(){
    #define TASK "ABC"
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp","r",stdin),freopen(TASK".out","w",stdout);
    #endif ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

    vector < ll > a(4);
    for (auto &x : a) cin >> x;

    ll ans = -oo;
    for (int i = 0; i < 2; i++){
        for (int j = 2; j < 4; j++){
            ans = max (ans, a[i] * a[j]);
        }
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 3648
S=int(input())
A=[0 for i in range(max(S+1,10))]
B=[0 for i in range(max(S+1,10))]
A[3]=1
B[3]=1
A[4]=1
B[4]=2
A[5]=1
B[5]=3
for i in range(6,S+1):
    A[i]=(B[i-3]+1)%(10**9+7)
    B[i]=(B[i-1]+A[i])%(10**9+7)
print(A[S])

Measured memory_bytes: 64900
#include <bits/stdc++.h>
 
using namespace std;
 
template< class t>
long long int gcd( t g,t h )
{
    return ( h==0 ? g : gcd(h,g%h) );
}
 

struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second > b.second;
  }

}comp_functor;
 
 
int main() 
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ;
    
    long long int i,j,ans=0,c,a[300005],n,f=0;
    
    string s;
    
    cin>>s;
    
    n=s.length();
    
    if(n==1)
    {
        cout<<"No";
    }
    
    for(i=1;i<n;i++)
    {
        if(s[i-1]=='A'&&s[i]=='C')
        {
            f=1;
        }
    }
    
    
    if(f==1)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
    return 0;
}
 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    char str1[11];
    char str2[11];
    char ch1;
    char ch2;
    ch1=a+'0';
    ch2=b+'0';
    int i;
    for(i=0;i<b;i++){
    	str1[i]=ch1;
	}
	str1[i]='\0';
	for(i=0;i<a;i++){
		str2[i]=ch2;
	}
	str2[i]='\0';
	if(strcmp(str1,str2)<=0) printf("%s",str1);
	else printf("%s",str2);
    return 0;
}

Measured memory_bytes: 128
class MyProc
  attr_accessor :num, :time
  def initialize(num, time)
    @num = num 
    @time = time 
  end
end

def solve(procs, q)
  res = []
  time = 0
  loop do
    break if procs.empty?
    _proc = procs.shift
    if _proc.time > q
      _proc.time -= q
      procs.push _proc
      time += q
    else
      time += _proc.time
      res << "#{_proc.num} #{time}"
    end
  end
  res
end

lines = STDIN.read.split(/\n/)
q = lines[0].split(/\s/)[1].to_i
procs = lines[1..-1].map do |line|
  ary = line.split(/\s/)
  MyProc.new(ary[0], ary[1].to_i)
end

puts solve(procs, q).join("\n")

Measured memory_bytes: 25804
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main(){
    string s; cin >> s;
    ll r = 0, b = 0;
    REP(i, s.size()){
        if(s[i] == '0') r++;
        else b++;
    }
    cout << 2 * min(r,b) << endstr;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

const ll DIVIDE = (1E+9)+7;
const ll MAX = (1E+5+1);

vvll edge(MAX);
vll white_num(MAX, -1);
vll black_num(MAX, -1);
vector<bool> flag(MAX, false);

int search(const ll N, const int pos){
  if(white_num[pos] + black_num[pos] >= 0) return (white_num[pos] + black_num[pos])%DIVIDE;

  flag[pos] = true;

  white_num[pos] = 1;
  black_num[pos] = 1;
  for(int i=0; i<edge[pos].size(); ++i){
    if(flag[edge[pos][i]]) continue;
    white_num[pos] *= search(N, edge[pos][i]);
    black_num[pos] *= white_num[edge[pos][i]];
    white_num[pos] %= DIVIDE;
    black_num[pos] %= DIVIDE;
  }

  //flag[pos] = false;

  return (white_num[pos] + black_num[pos])%DIVIDE;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;

  ll x, y;
  rep(i, 0, N-1){
    cin >> x >> y;
    edge[x-1].push_back(y-1);
    edge[y-1].push_back(x-1);
  }

  int ans = search(N, 0);

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
}


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

int main(){
ll N,M,tmp,ttt;
cin>>N>>M;
vector<ll> box(M+1,0);
for(ll i=0;i<N;i++){
  cin>>tmp;
  for(ll j=0;j<tmp;j++){
    cin>>ttt;
    box[ttt]++;
  }
}
tmp=0;
for(ll i=0;i<M+1;i++){
  if(box[i]==N)
  tmp++;
}
printf("%lld\n",tmp);
}


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

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

typedef long long ll;

using namespace std;

int arr[100005];

int n;

void solve() {
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
    }

    int cur = 0;

    for (int i = 1; i <= n + 1; ++i) {
        cur += abs(arr[i] - arr[i - 1]);
    }

    for (int i = 1; i <= n; ++i) {
        int del = abs(arr[i] - arr[i - 1]) + abs(arr[i + 1] - arr[i]);
        int add = abs(arr[i + 1] - arr[i - 1]);

        printf("%d\n", cur - del + add);
    }
}

int main() {
    #ifdef BThero
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // BThero

    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	fast_io();
	int a,b,t;
	cin >> a >> b >> t;
	int ans = 0;
	int ind = 1;
	while(a * ind <= t){
		++ind;
		ans+=b;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	set<int> can;
	vector<int> stka, stkb;
	int n, k; cin >> n >> k;
	if(k > (n + 1) / 2){
		cout << -1 << endl;
		return 0;
	}
	for(int i = k; i <= k + n - 1; i++){
		can.insert(i);
		can.insert(i + n);
		can.insert(i + 2 * n);
	}
	for(int i = k; i <= k + n - 1; i++) stka.push_back(i);
	for(int i = k; i <= k + n - 1; i++) stkb.push_back(i + n);
	for(int i = k + n - 1; i >= k; i--){
		int j = i + 2 * n;
		auto doit = [&](int a, int b, int c){
			if(a + b <= c){
				if(can.count(a) && can.count(b) && can.count(c)){
					can.erase(a);
					can.erase(b);
					can.erase(c);
					cout << a << " " << b << " " << c << endl;
				}
			}
		};
		doit(j - stkb.back(), stkb.back(), j);
		doit(stka.back(), j - stka.back(), j);
		doit(stka.back(), stkb.back(), j);
		while(!stka.empty() && !can.count(stka.back())) stka.pop_back();
		while(!stkb.empty() && !can.count(stkb.back())) stkb.pop_back();
	}
	return 0;
}


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

int main()
{
    int i,j,n,m,res;

    cin>>n>>m;

    res = 0;
    for(i=1;i<n;i++)
        res = res+i;

    for(i=1;i<m;i++)
        res = res+i;

    cout<<res<<endl;



    return 0;
}


Measured memory_bytes: 256
// let x = cin.double
// var c = 100.0
// var y = 0

// while x > c {
//     y += 1
//     c = floor(c * 1.01)
// }
// 974755271730884810
// 3758

let x = cin.int
var c = 100
var y = 0

while x > c {
    y += 1
    c = c + c/100
}

print(y)

import Foundation
#if os(Linux)
    import Glibc
#else
    import Darwin.C
#endif

enum cin {
    // 123
    static var int: Int { Int(readLine()!)! }
    // 123.0
    static var double: Double { Double(readLine()!)! }
    // 12 23
    static var pair: (Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!) }
    // 12 23 34
    static var triple: (Int, Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!, Int(line[2])!) }
    // AtCoder
    static var str: String { readLine()! }
    // At Coder
    static var arrayStr: [String] { str.components(separatedBy: " ") }
    // 1 2 3 4
    static var array: [Int] { str.components(separatedBy: " ").map { Int($0)! } }
    // 1
    // 2
    // 3
    static func v_array(count: Int) -> [Int] { (0..<count).map { _ in int } }
}

extension Int {
    // 123 -> [1, 2, 3]
    var digits: [Int] { Array(String(self)).map { Int(String($0))! } }
}

extension Array where Element == Int {
    // [2, 1, 3, 2] -> 8
    var sum: Int { self.reduce(0, +) }
    // [2, 1, 3, 2] -> [1, 2, 2, 3]
    var orderBy: [Int] { sorted() }
    // [2, 1, 3, 2] -> [3, 2, 2, 1]
    var orderByDesc: [Int] { sorted(by: { $0 > $1 }) }
    // [2, 1, 3, 2] -> [2, 1, 3]
    var distinct: [Int] { Array(Set(self)) }
}

extension String {
    // e.g. cin.line.regex(match: "^(dream|dreamer|erase|eraser)*$")
    func regex(match pattern: String) -> Bool {
        let regex = try! NSRegularExpression(pattern: pattern)
        return regex.firstMatch(in: self, range: NSRange(location: 0, length: self.count)) != nil
    }
    // "ABC"[1] -> "B"
    subscript(i: Int) -> Character {
        get {
            self[index(at: i)]
        }
        set(char) {
            var characters = Array(self)
            characters[i] = char
            self = String(characters)
        }
    }
    func index(at offset: Int) -> String.Index { index(startIndex, offsetBy: offset) }
    // "ABC".swapAt(0, 1) -> "BAC"
    mutating func swapAt(_ index1: Int, _ index2: Int) {
        var characters = Array(self)
        characters.swapAt(index1, index2)
        self = String(characters)
    }
}


Measured memory_bytes: 13008
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS
bool convertAndCheck(int n) {
    vector<int> number;
    while(n){
        number.push_back(n%10);
        n/=10;
    }
    for(auto vl : number) cout<<vl<<" ";
    return false;
}
vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int k;
cin>>k;
queue<unsigned int> q;
FOR(i,1,10) q.push(i);
int count = 0;
while(1) {
    count++;
    unsigned val = q.front();
    q.pop();
    // debug(count,val);
    if(count == k) {
        cout<<val;
        break;
    } 
    unsigned a = val*10 + val%10;
    unsigned b = 10*val + val%10 + 1;
    unsigned c = 10*val + val%10 -1;
    // debug(a,b,c);
    if(val%10 == 0) q.push(a),q.push(b);
    else if(val%10 == 9) q.push(c),q.push(a);
    else {
        q.push(c);
        q.push(a);
        q.push(b);
    }
}
// convertAndCheck(123124);
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 4780
count,total = list(map(int,input().split()))
ret1 = -1
ret2 = -1
ret3 = -1
NF = True
if total <= count * 10000:
	for i in range(count + 1):
		rCount = count - i
		if total-10000*i <= rCount * 5000:
			for j in range(rCount + 1):
				if (i*10000 + j*5000 + (count-i-j)*1000) == total:
					ret1 = i
					ret2 = j
					ret3 = count-i-j
					NF = False
					break
if NF:
	ret1 = -1
	ret2 = -1
	ret3 = -1
print(str(ret1) + " " + str(ret2) + " " + str(ret3))

Measured memory_bytes: 3064
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const int MAX_N=1e3+5;
char s[MAX_N],t[MAX_N];
int main()
{
	ss(s+1),ss(t+1);
	int ans=10000,ls=strlen(s+1),lt=strlen(t+1);
	repi(i,lt,ls){
		int res=0;
		repi(j,1,lt)if(t[j]!=s[i-lt+j]) res++;
		ans=min(ans,res);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0);
    ll n,c=0 ,f=0;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    while(1)
    {
        for(int i=0;i<n;i++)
        {
            if(a[i]%2==0)
                a[i]/=2;
            else
            {
                f=1;
                break;
            }
        }
        if(f==1)
        {
            cout<<c<<endl;
            return 0;
        }
        else
            c++;
    }
}




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

int main() {

    int sum, i, j, a;
    char c;
    stack<int> s;
    stack<pair<int, int> > t;
    sum = 0;
    for (i = 0; cin >> c; i++) {
        if (c == '\\') s.push(i);
        else if (c == '/' && s.size() > 0) {
            j = s.top(); s.pop();
            a = i - j;
            sum += a;
            while (t.size() > 0 && t.top().first > j) {
                a += t.top().second; t.pop();
            }
            t.push(make_pair(j, a));
        }
    }

    vector<int> arr;
    while (t.size() > 0) {
        arr.push_back(t.top().second);
        t.pop();
    }
    reverse(arr.begin(), arr.end());
    cout << sum << endl;
    cout << arr.size();
    for (i = 0; i < arr.size(); i++) {
        cout << " " << arr[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3176
o = input()
e = input()

a = len(o)-len(e)
s = ""

if a == 0:
    for i in range(len(o)):
         s += o[i] + e[i]
else:
    for i in range(len(o)-1):
        s += o[i] + e[i]
    s += o[len(o)-1]
print(s)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, ll>;

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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) cin >> s[i];

    for (int x = 0; x < h; ++x)
    {
        for (int y = 0; y < w; ++y)
        {
           
            if (s[x][y] == '#')
            {
                bool ok = false;
                for (int i = 0; i < 4; ++i)
                {
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;

                    if (s[nx][ny] == '#') ok = true;
                }
                if (!ok)
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 256
a = gets.chomp.chars.map(&:to_i)
op = ["+","-"]

op.each do |i|
  op.each do |j|
    op.each do |k|
      if eval "#{a[0]}#{i}#{a[1]}#{j}#{a[2]}#{k}#{a[3]} == 7"
        puts "#{a[0]}#{i}#{a[1]}#{j}#{a[2]}#{k}#{a[3]}=7"
        exit
      end
    end
  end
end


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

using namespace std;

string strrev(string s, int a, int b){
  string ans = "";
  for (int i = a; i <= b; i++) {
    ans = s[i] + ans;
  }
  return ans;
}

int main(){
  string s;
  int n;
  cin >> s >> n;
  while (n) {
    n--;
    string cmd;
    int a, b;
    cin >> cmd;
    cin >> a >> b;
    if (cmd == "replace") {
      string s1, s2, s3;
      cin >> s2;
      s1 = s.substr(0, a);
      s3 = s.substr(b+1);
      s = s1 + s2 + s3;
    } else if (cmd == "reverse") {
      string s1, s2, s3;
      s1 = s.substr(0, a);
      s2 = strrev(s, a, b);
      s3 = s.substr(b+1);
      s = s1 + s2 + s3;
    }
    else {
      for (int i = a; i < b+1; i++) cout << s[i];
      cout << endl;
    }
  }
  return 0;
}

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

int main() {
  int a,b,x,y;
  cin >> a >> b;
  x=a*b;
  y=x%2;
  if ( y == 0 ){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}
  

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

using namespace std;
int a[10010];
int ans[110][110];

int main()
{
    int h,w,n,ro=0,co=0;
    scanf("%d%d%d",&h,&w,&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        for(int ii=0;ii<a[i];ii++)
        {
            if(ro%2==0)
            {
                if(co==w-1)
                {
                    ans[ro][co]=i;
                    ro++;
                }
                else
                {
                    ans[ro][co]=i;
                    co++;
                }
            }
            else if(ro%2==1)
            {
                if(co==0)
                {
                    ans[ro][co]=i;
                    ro++;
                }
                else
                {
                    ans[ro][co]=i;
                    co--;
                }
            }
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            printf("%d ",ans[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int 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())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  ll ans = -INFL;
  int n;
  cin >> n;
  vector<int> f(n);
  rep(i, n) {
    f[i] = 0;
    rep(j, 10) {
      int tmp;
      cin >> tmp;
      if (tmp == 1) {
        f[i] += (1<<j);
      }
    }
  }

  vector<vector<ll>> p;
  p.reserve(n);
  rep(i, n) {
    vector<ll> tmp(11);
    rep(j, 11) {
      cin >> tmp[j];
    }
    p.push_back(tmp);
  }

  ll mina = INFL;
  for (int i = 1; i < pow(2, 10); i++) {
    ll tmp = 0;
    rep(j, n) {
      ll a = 0;
      int co = (i & f[j]);
      rep(k, 10) {
        if (co & 1<<k) {
          a++;
        }
      }
      chmin(mina, a);
      tmp += p[j][a];
    }
    chmax(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
while 1:
	n=input()
	if n==0:break
	p=raw_input().split()+["end"]
	sp=p[0]
	ans=[]
	for i in range(n):
		if str(int(p[i])+1)!=p[i+1]:
			if sp!=p[i]:
				ans.append(sp+"-"+p[i])
			else:
				ans.append(sp)
			sp=p[i+1]
	print " ".join(ans)

Measured memory_bytes: 4216
#define R register
#define ll long long
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5 + 5;
int n, a[maxn];
ll A, B, ans;

int main()
{
	scanf("%d%d%d", &n, &A, &B);
	for (R int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (R int i = 1; i < n; ++i)
		ans += min(B, (a[i + 1] - a[i]) * A);
	printf("%lld", ans);
}

Measured memory_bytes: 640
import java.util.Scanner;


public class Main{
    public  static void main(String[] args) {
    	try (Scanner sc = new Scanner(System.in)) {
    		int N=sc.nextInt();
    		int[] a=new int[N+1];
    		int turn=1;
    		for(int i=1; i<=N; i++) {
    			a[i]=sc.nextInt();
    		}
    		for(int i=1; i<=N; i++) {
    			for(int j=i+1; j<=N; j++) {
    				if(a[i]<a[j]) {
    					int num=a[j];
    					a[j]=a[i];
    					a[i]=num;
    				}
    			}
    		}//昇順に並び替える
    		for(int i=1; i<N; i++) {
    			turn++;
    			if(a[i]==a[i+1]) {
    				turn--;
    			}
    		}
    		System.out.println(turn);
    	}
    }
}

Measured memory_bytes: 23252