akhauriyash/Code-Regression huggingface dataset:
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,a,b;
  cin >> n >> a >> b;

  cout << min(a*n,b) << endl;

  return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    int n,d;
    cin>>n>>d;
    vector<vector<int>> x(n,vector<int>(d));
    for(int i=0;i<n;++i){
        for(int j=0;j<d;++j){
            cin>>x[i][j];
        }
    }
    int count =0;
    for(int i=0;i<n-1;++i){
        for(int j=i+1;j<n;++j){
             double v = 0;
            for(int k=0;k<d;++k){
                v += abs(x[i][k] - x[j][k]) * abs(x[i][k] - x[j][k]);
            }
            v = sqrt(v);
            if(ceil(v) == floor(v)) count++;
            
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static boolean[][] pic;
	static int[] count = new int[80000];

	public static void main(String[] args) {
		for (int t = 0;; ++t) {
			int H = sc.nextInt();
			if (H == 0) break;
			pic = new boolean[H + 2][82];
			sc.nextLine();
			for (int i = 0; i < H; ++i) {
				char[] line = sc.nextLine().toCharArray();
				for (int j = 0; j < line.length; ++j) {
					pic[i + 1][j + 1] = line[j] == '*';
				}
			}
			Arrays.fill(count, 0);
			count();
			if (t > 0) System.out.println("----------");
			for (int i = 1; i < count.length; ++i) {
				if (count[i] > 0) {
					System.out.println(i + " " + count[i]);
				}
			}
		}
	}

	static void count() {
		boolean[][] visited = new boolean[pic.length][pic[0].length];
		for (int i = 0; i < pic.length; ++i) {
			for (int j = 0; j < pic[0].length; ++j) {
				if (pic[i][j] && pic[i][j + 1] && !visited[i][j]) {
					int r = j;
					while (true) {
						if (!pic[i][r]) break;
						visited[i][r] = true;
						++r;
					}
					int top = r - j;
					int cy = i;
					int cx = j;
					while (true) {
						if (pic[cy + 1][cx - 1]) {
							--cx;
						} else if (pic[cy + 1][cx]) {
							;
						} else if (pic[cy + 1][cx + 1]) {
							++cx;
						} else {
							break;
						}
						++cy;
						visited[cy][cx] = true;
					}
					int height = cy - i + 1;
					r = cx;
					while (true) {
						if (!pic[cy][r]) break;
						visited[cy][r] = true;
						++r;
					}
					int bottom = r - cx;
					++count[(top + bottom) * height / 2];
				}
			}
		}
	}

}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int A,B,K;
    cin >> A >> B >> K;
    vector<int> num;
    for(int i = 0;i < K && (B-A) >= i;i++){
        num.push_back(A+i);
        num.push_back(B-i);
    }
    sort(num.begin(), num.end());
    num.erase(unique(num.begin(), num.end()), num.end());
    for(auto i:num){
        cout << i << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a, b, c, t;
    cin >> a >> b >>c;
	
	if (a > b){
        t = a;
		a = b;
		b = t;
		t = 0;
	}
	if(b > c){
		t = b;
		b = c;
		c = t;
		t = 0;
	}
	if (a > b){
        t = a;
		a = b;
		b = t;
		t = 0;
	}
	
	cout << a << " " << b << " " << c << endl;
	return 0;
}

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

int main(){
    int a, b, n, x;
    cin >> n >> a >> b;
    x = a * n;
    if (x >= b ) {
        cout << b << endl;
    }
 /*   else if (x - y == 0) {
        cout << "Balanced" << endl;
    }*/
    else {
        cout << x << endl;
    }
}

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


//入力
int N;
using pint = pair<int,int>;//人の番号（0-indexed）と0（不明）1（正直者）
vector<vector<pint>> v;

bool check(int bit){//矛盾のチェック
    for(int i=0;i<N;i++){
        if(!(bit&(1<<i))) continue;
        
        for(pint xy:v.at(i)){
            int x = xy.first;
            int y = xy.second;

            if(!(bit&(1<<x))&&(y==1)) return false;

            if((bit&(1<<x))&&(y==0)) return false;
        }
    }
    return true;
}
int main(){
    //入力
    cin >> N;

    v.resize(N);

    for(int i=0;i<N;i++){
        int A;
        cin >> A;
        v.at(i).resize(A);
        for(int j=0;j<A;j++){
            cin >> v.at(i).at(j).first >> v.at(i).at(j).second;
            v.at(i).at(j).first--;//0-indexed
        }
    }

    //bit全探索
    int res;
    res=0;
    for(int bit=0;bit<(1<<N);bit++){
        if(check(bit)){
            int count=0;
            for(int i=0;i<N;i++){
                if(bit&(1<<i)) count++;
            }
            res=max(count,res);
        }
    }

    //出力
    cout << res << endl;

}

Measured memory_bytes: 256
def main():
    n, a, b = map(int, input().split())

    if (b - a) % 2 == 0:
        ans = (b - a) // 2
    else:
        if a - 1 < n - b:
            ans = a - 1 + 1 + (b - a + 1 - 1) // 2
        else:
            ans = n - b + 1 + (n - a - n + b) // 2

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		for(int i = 1; i <= 10000; i ++){
			int num = scanner.nextInt();
			if(num == 0){
				break;
			}else{
				System.out.println("Case " + i + ": " + num);
			}
		}
		
	}
}

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

int main(){
  int N;
  string S,T,M;
  cin>>N;
  cin>>S>>T;

  for(int i=0;i<N;i++){
    M = M + S[i] + T[i];
  }
  cout<<M<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(item) for item in input().split()]

def gcd(a,b):
 while b!=0:
   a,b=b,a%b
 return a

if n == 2:
    print(max(a))
    exit()

bad_id = 0
max_div = 1
for j in range(10):
    if j == 5:
        bad_id == 0
        a.reverse()
    bid = bad_id
    init = False
    for i, item in enumerate(a):
        if i == bid:
            continue
        if not init:
            val = item
            div = val
            init = True
        else:
            val = gcd(div, item)
            if val != div:
                bad_id = i
                div = val
    max_div = max(div, max_div)
    
print(max_div)

Measured memory_bytes: 14436
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr int MOD = 1000000007;

int main(){
    ll a;
    string s;
    cin >> a >> s;
    ll b = 0;
    ll ten = 1;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='.') continue;
        b += ten*(s[i]-'0');
        ten *= 10;
    }
    ll ans = a*b;
    ans /= 100;
    printf("%lld\n",ans);
}


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

lines = []
while line = gets 
    lines << line.chomp.split(' ').map(&:to_i)
end

manwithsweet =[]
for i in 0..(lines.length-1)
	if (i % 2 != 0)then
		manwithsweet << lines[i]
	end
end

puts n - manwithsweet.flatten.uniq.size

Measured memory_bytes: 14256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  if(a[0]==5&&a[1]==5&&a[2]==7) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

bool a[10],b[100],c[1000];

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,n){
    int tmp = s[i]-'0';
    rep(j,100){
      if(b[j]==1)c[j*10+tmp]=1;
    }
    rep(j,10){
      if(a[j]==1)b[j*10+tmp]=1;
    }
    a[tmp]= 1;
  }
  int ans=0;
  rep(i,1000){
    if(c[i]==1)ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long N = S.length + 1;
    auto d = new long[](N);

    foreach_reverse (i; 0 .. N - 1)
    {
        if (S[i] == '>')
        {
            d[i] = d[i + 1] + 1;
        }
    }
    foreach (i; 0 .. N - 1)
    {
        if (S[i] == '<')
        {
            d[i + 1] = max(d[i + 1], d[i] + 1);
        }
    }
    // writeln(d);
    d.sum().writeln();
}


Measured memory_bytes: 8464
# -*- coding: utf-8 -*-

def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))

    inner = 0
    outer = 0
    for i in range(0,N):
        for j in range(0,i):
            if A[i] > A[j]:
                outer += 1
        for j in range(i+1,N):
            if A[i] > A[j]:
                inner += 1
                outer += 1
    count = inner * K + outer * K * (K-1) // 2
    count = count % (10**9 +7)
    print(count)



if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
N = int(input())


def yakusuu(num):
    counter = 0
    for i in range(1, num + 1):
        if num % i == 0:
            counter += 1
    return counter


c = 0
for num in range(1, N + 1, 2):
    if yakusuu(num) == 8:
        c += 1

print(c)


Measured memory_bytes: 2940
<?php
fscanf(STDIN, "%d", $d);

switch ($d) {
    case $d === 22:
        echo 'Christmas Eve Eve Eve';
        break;
    case $d === 23:
        echo 'Christmas Eve Eve';
        break;
    case $d === 24:
        echo 'Christmas Eve';
        break;
    case $d === 25:
        echo 'Christmas';
        break;
}


Measured memory_bytes: 16196
//文字列を#で囲む
#include <bits/stdc++.h>
using namespace std;

    
int main() {
  int H=0,W=0;
  cin >> H >> W;

  vector<string> tate(H);
  for (int i=0;i<H;i++){
    cin >> tate.at(i);
   }


  for (int i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl; // 入力画面で改行したい時
  for (int i=0;i<H;i++){
//    cin >> tate.at(i);
    cout << "#"+tate.at(i)+"#" << endl;
  }

  for (int i=0;i<W+2;i++){
    cout << "#" ;
    }
  cout << endl; // 入力画面で改行したい時
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long result = 0;
		long nowHighestLength = 0;
		for (int i = 0; i < n; i++) {
			long numberILength = Long.parseLong(sc.next());
			if (nowHighestLength < numberILength) {
				nowHighestLength = numberILength;
			} else {
				result += nowHighestLength - numberILength;
			}
		}
		System.out.println(result);
		
		
	}	

}


Measured memory_bytes: 58252
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int n;
ll a[MAXN], A, B;

int check(ll u) {
	ll tot = 0;
	for (int i=0; i<n; i++) {
		ll l = 0, r = u, find = -1;
		while (l <= r) {
			ll mid = (l + r) >> 1;
			ll cur = A * mid + B * (u - mid);
			if (cur >= a[i]) {
				find = mid;
				r = mid - 1;
			}
			else l = mid + 1;
		}
		if (!~find) return 0;	
		tot += find;
		if (tot > u) return 0;
	}
	
	return 1;
}

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> n >> A >> B;
	for (int i=0; i<n; i++) cin >> a[i];
	
	ll l = 1, r = 1000000000, find = -1;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) {
			find = mid;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	
	cout << find;
	
	return 0;
}


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

int main()
{
    int n, h, w;
    cin >> n >> h >> w;
    int a[n], b[n];
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        if(a[i] >= h && b[i] >= w)
        {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define INF 100000000
#define uint unsigned int
using namespace std;

int largest_vector_location(vector<vector<int>> &vec) {

	int temp = -1;
	bool flag = false;

	rep(i, vec.size()) {
		if (!flag) {
			if (vec.at(i).at(0) == vec.at(i).at(1)) {
				flag = true;
				temp = i;
			}
		}
		else if (vec.at(i).at(0) == vec.at(i).at(1) && vec.at(i).at(0) > vec.at(temp).at(0)) {
				temp = i;
			}
	}
	
	return temp;
}

int main() {
	int N;
	cin >> N;
	vector<vector<int>> vec(N, vector<int>(2)); //at0にbi at1に番号1start
	int lvi = 0;


	rep(i, N) {
		cin >> vec.at(i).at(0);
		vec.at(i).at(1) = i + 1;

		if (vec.at(i).at(0) > i + 1) {
			lvi = -1;
			break;
		}

	}
	
	vector<int> output(N);

	if (lvi == 0) {
		rep(i, N) {
			//大きいの探し find largest i
			lvi = largest_vector_location(vec);

			//lvi(0start)番目のvectorが最大
			if (lvi >= 0) {

				output.push_back(vec.at(lvi).at(0));
				//最大以降の順番を-1
				for (int i = lvi; i < vec.size(); i++) {
					vec.at(i).at(1)--;
				}
				vec.at(lvi).at(0) = INF;
			}
			
			}
	}

	//output part
	if (lvi == -1) {
		cout << -1 << endl;
	}
	else {
		reverse(output.begin(), output.end());
		rep(i, N) {
			cout << output.at(i) << endl;
		}
	}
	
}


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

//s<t ならば-1，s==tならば0，s>tならば1を返す関数
int compare_string(char s[], char t[]){
  int ls = strlen(s), lt = strlen(t);

  for(int i = 0; i < ls && i < lt; i++){
    if(s[i] < t[i]){
      return -1;
    }else if(s[i] > t[i]){
      return 1;
    }
  }

  if(ls < lt){
    return -1;
  }else if(ls == lt){
    return 0;
  }else{
    return 1;
  }

}

int main(){
  int N, L;
  char S[110][110] = {};

  scanf("%d %d", &N, &L);
  for(int i = 0; i < N; i++){
    scanf("%s", S[i]);
  }

  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){

      if(compare_string(S[i], S[j]) == 1){
        char tmp[110] = {};
        for(int k = 0; k < L; k++){
          tmp[k] = S[i][k];
          S[i][k] = S[j][k];
          S[j][k] = tmp[k];
        }
      }

    }
  }

  for(int i = 0; i < N; i++){
    printf("%s", S[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 128
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

N = int(input())

T = [0]*N
for i in range(N):
    T[int(input())-1] = i

m = 0
streak = 1
for a,b in zip(T,T[1:]):
    if a < b:
        streak += 1
    else:
        m = max2(m, streak)
        streak = 1
m = max2(m, streak)

print(N-m)


Measured memory_bytes: 77688
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val l = sc.nextInt()
    println(problem159c(l))
}

fun problem159c(l: Int): Double {
    return (l / 3.toDouble()) * (l / 3.toDouble()) * (l / 3.toDouble())
}

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

int main() {
    long long N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    for (long long i = 0; i < N; i++) {
        if (i * C - (N - 1 - i) * D <= (B - A) &&
            (B - A) <= i * D - (N - 1 - i) * C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a=[['x']*(w+2)]
for i in range(h):
  tmp = ['x']
  tmp.extend(list(map(str,input())))
  tmp.append('x')
  a.append(tmp)
a.extend([['x']*(w+2)])
ans= []
for i in range(1,h+1):
  tmp=[]
  for j in range(1,w+1):
    if a[i][j] == '#':
      tmp.append('#')
    else:
      tmp.append([a[i-1][j-1],a[i-1][j],a[i-1][j+1],a[i][j-1],a[i][j+1],a[i+1][j-1],a[i+1][j],a[i+1][j+1]].count('#'))
  ans.append(tmp)
for i in range(h):
  print(*ans[i],sep='')

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

a.sort()
a[0], a[len(a)-1] = a[len(a)-1], a[0]

while a != sorted(a):
  a.sort()
  for i in range(len(a)):
    if a[i] % a[0] == 0:
      a[i] = a[0]
    else:
      a[i] = a[i] % a[0]

print(a[0])

Measured memory_bytes: 14252
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

// ALDS1_6_C
public class Main {
	Card SENTINEL = new Card("F", 1234567890);
	int sum = 0;
	void merge(Card[]A, int left, int mid, int right) {
		int n1 = mid - left + 1;
		int n2 = right - mid;
		Card[] L = new Card[n1 + 1];
		Card[] R = new Card[n2 + 1];
		for (int i = 0; i < n1; i++) {
			L[i] = A[left + i];
		}
		for (int i = 0; i < n2; i++) {
			R[i] = A[mid + 1 + i];
		}
		L[n1] = SENTINEL;
		R[n2] = SENTINEL;
		int i = 0;
		int j = 0;
		for (int k = left; k <= right; k++) {
			sum += 1;
			if (L[i].value <= R[j].value) {
				A[k] = L[i];
				i = i + 1;
			} else {
				A[k] = R[j];
				j = j + 1;
			}
	    }
	}

	void mergeSort(Card[] A, int left, int right) {
	    	if (left < right) {
	    		int mid = (left + right)/2;
	    		mergeSort(A, left, mid);
	    		mergeSort(A, mid + 1, right);
	    		merge(A, left, mid, right);
	  	}
	}
	
	int partition(Card[] A, int p, int r) {
		int x = A[r].value;
		int i = p-1;
		for (int j = p; j < r; j++) {
			if (A[j].value <= x) {
				i = i + 1;
				Card tmp = A[i];
				A[i] = A[j];
				A[j] = tmp;
			}
		}
		Card tmp = A[i + 1];
		A[i + 1] = A[r];
		A[r] = tmp;
		return i + 1;
	}
	
	void quickSort(Card[] A, int p, int r) {
		 if (p < r) {
			 int q = partition(A, p, r);
			 quickSort(A, p, q-1);
			 quickSort(A, q+1, r);
		 }
	 }
	
	void run() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Card[] A = new Card[n];
		Card[] B = new Card[n];
		for (int i = 0; i < n; i++) {
			String[] str = br.readLine().split(" ");
			A[i] = new Card(str[0], Integer.parseInt(str[1]));
			B[i] = new Card(str[0], Integer.parseInt(str[1]));
		}
		quickSort(A, 0, n-1);
		mergeSort(B, 0, n-1);
		boolean stable = true;
		for (int i = 0; i < n; i++) {
			if (!A[i].suit.equals(B[i].suit)) {
				stable = false;
				break;
			}
		}
		if (stable) System.out.println("Stable");
		else System.out.println("Not stable");
		for (int i = 0; i < n; i++) {
			System.out.println(A[i].suit + " " + A[i].value);
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}

class Card {
	String suit;
	int value;
	Card(String s, int v) {
		this.suit = s;
		this.value = v;
	}
}


Measured memory_bytes: 85768
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int N = 100;
int col[N], row[N];
char a[N][N];

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

    int h, w;
    cin >> h >> w;

    REP(i, h) REP(j, w) cin >> a[i][j];

    REP(i, h) REP(j, w) {
        if (a[i][j] == '#') {
            col[i] = 1;
            row[j] = 1;
        }
    }

    REP(i, h) {
        if (col[i]) {
            REP(j, w)
                if (row[j])
                    cout << a[i][j];
            cout << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;

int d[501][501];

int main(){
    int n, m, Q;
    cin >> n >> m >> Q;
    int l, r;
    rep(i, m) {
        cin >> l >> r;
        rep(j, 500-r+1) {
            d[l-1][j+r-1]++;
        }
    }
    int p, q;
    ll sum = 0;
    rep(i, Q) {
        cin >> p >> q;
        for(int j = p-1; j < q; j++) {
            //for(int k = j; k < q; k++) {
                sum += d[j][q-1];
                //cout << j << " " << d[j][q-1] << endl;
            //}
        }
        cout << sum << endl;
        sum = 0;
    }
    return 0;
}

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <queue>

int main() {
    int N, M;
    std::cin >> N >> M;

    std::vector<std::vector<int>> G(N * 3);
    for (int i = 0; i < M; i++) {
        int u, v;
        std::cin >> u >> v;

        G[u - 1].push_back(v - 1 + N);
        G[u - 1 + N].push_back(v - 1 + N * 2);
        G[u - 1 + N * 2].push_back(v - 1);
    }

    int S, T;
    std::cin >> S >> T;

    std::vector<int> dist(N * 3, -1);
    dist[S - 1] = 0;
    std::queue<int> que;
    que.push(S - 1);
    while (!que.empty()) {
        int u = que.front();
        que.pop();

        for (int v : G[u]) {
            if (dist[v] >= 0)
                continue;
            dist[v] = dist[u] + 1;
            que.push(v);
        }
    }

    int ans = dist[T - 1];
    if (ans >= 0)
        ans /= 3;
    std::cout << ans << "\n";
}

Measured memory_bytes: 17792
#include<stdio.h>
int N,K,i,j,c,p,q,r;
#define MAX_N 100
int uft[MAX_N],flg[MAX_N];
void init(int n){int i;for(i=0;i<=n;i++)uft[i]=i;}
int parent(int n){if(uft[n]==n)return n;else return uft[n]=parent(uft[n]);}
void unit(int p,int q){uft[parent(p)]=parent(q);}
int same(int p,int q){return parent(p)==parent(q);}

int main()
{
	scanf("%d%d",&N,&K);
	init(N);
	for(i=0;i<K;i++)
	{
		scanf("%d",&c);
		for(j=0;j<c;j++)
		{
			if(!j)
				scanf("%d",&p);
			else
			{
				scanf("%d",&q);
				unit(p,q);
			}
		}
	}
	for(scanf("%d",&K);K--;)
	{
		scanf("%d%d",&p,&q);
		if(p!=q&&same(p,q))flg[p]=flg[q]=1;
	}
	for(i=0;i<=N;i++)r+=flg[i];
	printf("%d\n",r);
	return 0;
}

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

Module Program
    Sub Main()
        Dim s As String = NextString()

        Write(s(0))
        Write(s.Length - 2)
        WriteLine(s(s.Length - 1))
    End Sub

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

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

End Module


Measured memory_bytes: 19920
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;
 
int main() {
    int d,t,s;
    cin >> d >> t >> s;
    cout << (t*s >= d ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    string s = "AGCT";
    char b;
    cin >> b;
    for(int i = 0; i < 4; i++){
        if(s[i] == b){
            cout << s[3 - i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include "math.h"
using namespace std;

bool is_single_sharp(std::vector<std::vector<bool>> maze, int i, int j) {
  if (i == 0) {
    if (maze[i + 1][j]) {
      // std::cout << "aa" << std::endl;
      return false;
    }
  } else if (i == maze.size() - 1) {
    if (maze[i - 1][j]) {
      // std::cout << "aa" << std::endl;
      return false;
    }
  } else {
    if (maze[i + 1][j]) {
      // std::cout << "aa" << std::endl;
      return false;
    }
    if (maze[i - 1][j]) {
      // std::cout << "aa" << std::endl;
      return false;
    }
  }

  if (j == 0) {
    if (maze[i][j + 1]) {
      // std::cout << "aa" << std::endl;
      return false;
    }
  } else if (j == maze[0].size() - 1) {
    if (maze[i][j - 1]) {
      // std::cout << "aa" << std::endl;
      return false;
    }
  } else {
    if (maze[i][j + 1]) {
      // std::cout << "aa" << std::endl;
      return false;
    }
    if (maze[i][j - 1]) {
      // std::cout << "aa" << std::endl;
      return false;
    }
  }
  // std::cout << "true" << std::endl;
  return true;
}

int main() {
  int h, w;
  cin >> h >> w;
  std::vector<std::vector<bool>> maze;
  maze.resize(h);
  for (int i = 0; i< h; i++) {
    maze[i].resize(w);
  }

  for (int i=0; i < h; i++) {
    std::string maze_line;
    std::cin >>maze_line;
    for (int j=0; j < h; j++) {
      if (maze_line[j] == '#')
        maze[i][j] = true;
      else {
        maze[i][j] = false;
      }
    }
  }
  bool success = true;
  for (int i=0; i < h; i++) {
    for (int j=0; j < h; j++) {
      if (maze[i][j]) {
        if (is_single_sharp(maze, i, j)) {
          success = false;
          break;
        }
      }
    }
  }
  if (success) {
    std::cout << "Yes";
  } else {
    std::cout << "No";
  }
  return 0;
}

Measured memory_bytes: 256
// A C++ program to count all possible paths 
// from top left to bottom right 
#include <iostream> 
#define mod 1000000007
using namespace std; 
int dp[1001][1001];

int numberOfPaths(int m, int n) 
{ 
	if(dp[0][0]==-1){
		return 0;
	}
	for(int i=0;i<m;i++){
		if(dp[i][0]==-1){
			break;
		}
		dp[i][0]=1;
	}
	for(int j=0;j<n;j++){
		if(dp[0][j]==-1){
			break;
		}
		dp[0][j]=1;
	}

	for(int i=1;i<m;i++){
		for(int j=1;j<n;j++){
			if(dp[i][j]==-1){
				continue;
			}
			dp[i][j]=0;
			if(dp[i][j-1]!=-1){
				dp[i][j]=dp[i][j-1]%mod;
			}
			if(dp[i-1][j]!=-1){
				dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
			}
			
		}
		
	}
	if(dp[m-1][n-1]==-1){
		return 0;
	}
	return dp[m-1][n-1];
	
} 

// Driver program to test above functions 
int main() 
{ 
	int r,c;
	cin>>r>>c;
	char ar[r][c];
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>ar[i][j];
			if(ar[i][j]=='#'){
					dp[i][j]=-1;
			}
		}
	}
	cout << numberOfPaths(r, c)<<endl; 
	return 0; 
} 


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

int main()
{
    int n;
    double sum = 0;
    cin >> n;
    vector<double> a(n);
    for (int i = 0; i < n;i++){
        cin >> a.at(i);
        sum += (1 / a.at(i));
    }
    //cout << sum << endl;
    cout << 1 / sum << endl;
}

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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()
#define precise cout<<fixed<<setprecision(12);

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

ld dp[2][3003];

void solve(){
	fr(i,0,2){
		fr(j,0,3003){
			dp[i][j]=0;
		}
	}
	int n;
	cin>>n;
	int t=0;
	ld p;
	dp[0][0]=1;
	fr(i,1,n+1){
		cin>>p;
		t^=1;
		fr(j,0,i+1){
			if(j==0){
				dp[t][0]=(dp[t^1][0]*(1.0-p));
			}
			else{
				dp[t][j]=(dp[t^1][j]*(1.0 -p) + dp[t^1][j-1]*p);
			}
		}
	}
	precise;
	ld ans=0;
	fri(j,n,(n+1)/2){ 	
		ans+=dp[t][j];
	}
	cout<<ans<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 3880
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

using ull = unsigned long long int;
using ll = long long int; 

int main(){
    int N;
    int max=0;
    int sec_max=0;
    int max_idx=0;
    int sec_max_idx=0;

    std::cin >> N;

    for(int i=0;i<N;i++){
        int a;
        std::cin >> a;
        if(i==0){
            max=a;
        }else if(i==1){
            if(max<a){
                sec_max=max;
                max=a;
                max_idx=1;
            }else if(max==a){
                sec_max=a;
                sec_max_idx=1;
            }else{
                sec_max=a;
                sec_max_idx=1;
            }
        }else{
            if(max<a){
                sec_max=max;
                sec_max_idx=max_idx;
                max=a;
                max_idx=i;
            }else if(sec_max<=a && max>=a){
                sec_max=a;
                sec_max_idx=i;
            }
        }
    }

    for(int i=0;i<N;i++){
        if(max_idx==i) std::cout << sec_max << std::endl;
        else std::cout << max << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;

int main()
{
    while (true) {
        string s;
        cin >> s;
        if (s == "#") {
            break;
        }
        int pos = 0;
        vector<bool> north;
        while (pos < s.size()) {
            if (s[pos] == 'n') {
                north.push_back(true);
                pos += 5;
            } else {
                north.push_back(false);
                pos += 4;
            }
        }
        reverse(north.begin(), north.end());
        const int size = north.size();
        int num = 1 << size;
        int bunbo = num;
        int sum = 0;
        if (not north[0]) {
            sum += num;
        }
        num /= 2;
        for (int i = 1; i < size; i++) {
            if (north[i]) {
                sum -= num;
            } else {
                sum += num;
            }
            num /= 2;
        }
        int bunsi = sum * 90;
        if (bunsi == 0) {
            cout << 0 << endl;
        } else {
            while (bunsi % 2 == 0 and bunbo % 2 == 0) {
                bunsi /= 2;
                bunbo /= 2;
            }
            if (bunbo == 1) {
                cout << bunsi << endl;
            } else {
                cout << bunsi << "/" << bunbo << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3136
//解説あり
#include <iostream>
#include <algorithm>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int ans;
int N, M;
int X[100005];
int L[100005]; //開区間(Xi, Xi+1)の移動距離Li 

int solve() {
	if ( N >= M ) return 0;

	REP(i, 0, M-1) L[i] = X[i+1] - X[i]; 

	REP(i, 0, M-1) ans += L[i];
	sort(L, L+M, greater<int>());

	REP(i, 0, N-1) ans -= L[i];

	return ans; 

}

int main(void) {
    scanf("%d %d", &N, &M);
    REP(i, 0, M) scanf("%d", &X[i]);
    sort(X, X + M);
    
    printf("%d\n", solve());

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <sys/mman.h>
#include <unistd.h>
typedef long long lint;
const int N=1e5+5;
int n,len,q,pos[N];
int turn_0,turn_1,cnt_0,cnt_1,buk_0[N],buk_1[N];

namespace IO{
	char *ibuf;
	struct _Init{
		_Init(){ibuf=(char*)mmap(0,lseek(0,0,SEEK_END),PROT_READ,MAP_PRIVATE,0,0);}
	}_init;
	inline int nxi(){
		int x=0;
		char c;
		while((c=*ibuf++)>'9'||c<'0');
		while(x=x*10-48+c,(c=*ibuf++)>='0'&&c<='9');
		return x;
	}
}
using IO::nxi;

int main(){
	n=nxi(),len=nxi(),q=nxi();
	int cyc=q/len,rest=q-cyc*len;
	lint dlt=0;
	for(int i=1; i<=n; ++i){
		int pos=nxi();
		if(nxi()==1){
			dlt+=cyc;
			int tgt=pos+rest;
			if(tgt>=len) ++dlt,tgt-=len;
			else turn_0=cnt_0+1;
			buk_0[++cnt_0]=tgt;
		}
		else{
			dlt-=cyc;
			int tgt=pos-rest;
			if(tgt<0){
				--dlt,tgt+=len;
				turn_1=cnt_1+1;
			}
			buk_1[++cnt_1]=tgt;
		}
	}
	for(int c=1,i=1,j=turn_0+1,k=1,l=turn_1+1; c<=n; ++c){
		int type=0,nval=1e9;
		if(i<=turn_0&&buk_0[i]<nval)
			nval=buk_0[i],type=1;
		if(j<=cnt_0&&buk_0[j]<nval)
			nval=buk_0[j],type=2;
		if(k<=turn_1&&buk_1[k]<nval)
			nval=buk_1[k],type=3;
		if(l<=cnt_1&&buk_1[l]<nval)
			nval=buk_1[l],type=4;
		pos[c]=nval;
		switch(type){
			case 1: ++i; break;
			case 2: ++j; break;
			case 3: ++k; break;
			case 4: ++l; break;
		}
	}
	dlt%=n;
	if(dlt<0) dlt+=n;
	for(int i=dlt+1; i<=n; ++i){
		printf("%d\n",pos[i]);
	}
	for(int i=1; i<=dlt; ++i){
		printf("%d\n",pos[i]);
	}
	return 0;
}

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

int main() {
  int n, a, b, c, d;
  cin >> n;
  a = n / 1000;
  b = (n - (a * 1000)) / 100;
  c = (n - (a * 1000 + b * 100)) / 10;
  d = (n - (a * 1000 + b * 100 + c * 10));
  if ((a == b && b ==c)||(b == c && c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int health = scan.nextInt();
        int damage = scan.nextInt();
        if(health%damage==0){
            System.out.println(health/damage);
        }   else{
            System.out.println(health/damage+1);
        }
    }
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  long long m=0,a=0,ans=0;
  for(int i=0;i<n;i++)
  {
    cin>>a;
    if(a<=m)
    {
      ans+=m-a;
    }
    else
    {
      m=max(m,a);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3592
ai, ao, at, aj, al, as, az = gets.split.map(&:to_i)
tmp = ai/2*2 + aj/2*2 + al/2*2
if [ai, aj, al].min > 0
    ai -= 1
    aj -= 1
    al -= 1
    tmp2 = ai/2*2 + aj/2*2 + al/2*2 + 3
    tmp = [tmp, tmp2].max
end
puts ao + tmp

Measured memory_bytes: 1788
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        double i = (double)(A + B) / 2;
        int k = (int)(Math.ceil(i));
        System.out.println(k);
    }
}

Measured memory_bytes: 21716
#include <stdio.h>
 
int main() {
	int n, i;
	long long *A, sum = 0, cnt = 0, min = 1000000000;

	scanf("%d", &n);
	A = (long long*)calloc(n, sizeof(long long));
	for (i = 0; i < n; i++) {
		scanf("%lld", &A[i]);
	}

	for (i = 0; i < n; i++) {
		if (A[i] < 0) {
			cnt++;
			A[i] = (-A[i]);
		}
		if (min > A[i]) min = A[i];
		sum += A[i];
	}

	if (cnt % 2 == 1)
		sum -= (min * 2);

	printf("%lld", sum);
 
	return 0;
}
 

Measured memory_bytes: 896
// https://atcoder.jp/contests/abc174/tasks/abc174_d

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 200000;

int N;
string c;

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

  int ans = 0;
  int s = 0;
  int t = N - 1;
  while (s < t) {
    if (c[s] == 'R') s++;
    else if (c[t] == 'W') t--;
    else {
      ans++;
      s++;
      t--;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 1e5;
vector<int> es[MAX_V];
ll a[MAX_V];

vector<ll> memo;
vector<bool> used(MAX_V, false);

void dfs(int now){
    used[now] = true;
    memo.pb(a[now]);
    for(auto &e: es[now]){
        if(!used[e]) dfs(e);
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, N) cin >> a[i];
    rep(i, M){
        int u, v; cin >> u >> v;
        es[u].pb(v), es[v].pb(u);
    }
    vector<vector<ll>> v;
    rep(i, N){
        if(!used[i]){
            dfs(i);
            v.pb(memo);
            memo.clear();
        }
    }
    int n = sz(v);
    if(2*(n-1) > N) {cout << "Impossible" << endl; return 0;}
    if(n == 1) {cout << 0 << endl; return 0;}
    ll ans = 0;
    vector<ll> rem;
    rep(i, n){
        sort(all(v[i]));
        ans += v[i][0];
        rep2(j, 1, sz(v[i])-1) rem.pb(v[i][j]);
    }
    sort(all(rem));
    rep(i, n-2) ans += rem[i];
    cout << ans << endl;
}

Measured memory_bytes: 9968
N,K = list(map(int,input().split(" ")))
A = [0 for u in range(N)]
okasi = []
for i in range(K):
  d = int(input())
  okasi.append(list(map(int,input().split(" "))))
for a in okasi:
  for m in a:
    A[m-1] += 1
print(A.count(0))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define lli long long int

using namespace std;

int main() {
    string s;
    cin>>s;
    if(s[0]=='S')
    {
        cout<<"Cloudy"<<endl;
    }
    else if(s[0]=='C')
    {
        cout<<"Rainy"<<endl;
    }
    else
    {
        cout<<"Sunny"<<endl;
    }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<vector>
#include<map>
#include<algorithm>
#define inf 0x3f3f3f3f
const int maxn= 1e5+5;
using namespace std;
struct stu{
	int num,a;
	bool operator<(stu& b)const{
		return a<b.a;
	}
}students[maxn];
int n;
int main(){
	std::ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>students[i].a;
		students[i].num=i;
	}
	sort(students+1,students+1+n);
	for(int i=1;i<=n;i++){
		cout<<students[i].num<<' ';
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
struct student{
    int v;
    int index;

    bool operator<(const student& S){
        return v < S.v;
    }
};

void solve(){
    int n;
    cin >> n;
    vector<student> a(n);
    for (int i = 0; i < n; i++){
        a[i].index = i;
        cin >> a[i].v;
    }

    sort(all(a));

    for (int i = 0; i < n; i++){
        cout << a[i].index+1 << ' ';
    }
    cout << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

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


int main(){
	int k,a,b,ans=0;
	cin >> k >> a >> b;
	for(int i=1;;i++){
		if(ans>b) break;
		ans=k*i;
		if(ans>=a && b>=ans){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3636
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans; 
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int x;
	cin>>x;
	cout<<(x+1)%2;
    return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b; cin >> a >> b;
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int N;
int a[100000];

int main(int argc, char **argv) {
	cin >> N;
	REP(i, N) {
		cin >> a[i];
		--a[i];
	}
	int res = 0;
	REP(i, N) if (a[a[i]] == i) ++res;
	cout << (res / 2) << endl;
	return 0;
}


Measured memory_bytes: 640