akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<numeric>
using namespace std;

long long  gcd(long long a, long long b) {
  return b != 0 ? gcd(b, a % b) : a;
}
long long lcm(long long a, long long b) {
  return a * b / gcd(a, b);
}

long long dividableCount(long long diviser,long long n){
    return n/diviser;
}
long long undividableCount(long long diviser,long long n){
    return n - dividableCount(diviser,n);
}

int main(){
    long long a,b,c,d,ans;
    cin >> a >> b >> c >> d;
    long long LCM = lcm(c,d);

    long long undiv_ac = undividableCount(c,a-1);
    long long undiv_ad = undividableCount(d,a-1);
    long long undiv_bc = undividableCount(c,b);
    long long undiv_bd = undividableCount(d,b);
    long long undiv_alcm = undividableCount(LCM,a-1);
    long long undiv_blcm = undividableCount(LCM,b);

    long long undiv_a_cORd = undiv_ac + undiv_ad - undiv_alcm;
    long long undiv_b_cORd = undiv_bc + undiv_bd - undiv_blcm;

    cout << undiv_b_cORd - undiv_a_cORd << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	cin >> a >> b;

	c = a + b;

	if (c == 24){
		c = 0;
	}
	else if (c > 24){
		c = c - 24;
	}
	
	cout << c << endl;	
}


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

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int[] n = new int[3]; 
        for(int i=0; i<3; i++){
            n[i] = sc.nextInt();
        }
        Arrays.sort(n);
        System.out.println(n[0]+" "+n[1]+" "+n[2]);

    }
}



Measured memory_bytes: 26300
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//FUNCTION
void DFS(int depth,string str,vector<int> & data,int flag1,int flag2 ,int flag3)
{
  if(depth != 0)
  {
  
  if(flag1*flag2*flag3>0)
  data.push_back(stol(str));
  }
  // DEBUG(str);
  if(depth == 10)return;
  DFS(depth+1,str + '3',data,flag1+1,flag2,flag3);
  DFS(depth+1,str + '5',data,flag1,flag2+1,flag3);
  DFS(depth+1,str + '7',data,flag1,flag2,flag3+1);
  return;
}

void solve(void)
{
  int N;
  cin>>N;
  vector<int> data;
  DFS(0,"",data,0,0,0);
  sort(ALL(data));
  cout<<distance(data.begin(),upper_bound(ALL(data),N));
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 1528
#include <stdio.h>

int main(){
    char s[200];
    char S[100];
    int slen,Slen;

    scanf("%s",s);
    scanf("%s",S);

    for(int i=0;;i++)
        if(s[i]=='\0'){
            slen=i;
            break;
        }
    for(int i=0;;i++)
        if(S[i]=='\0'){
            Slen=i;
            break;
        }
    
    for(int i=0;i<slen;i++){
        s[i+slen]=s[i];
    }
    s[2*slen]='\0';

    int flag=0;
    for(int i=0;i<slen;i++){
        for(int f=0;f<Slen,s[i+f]==S[f];f++){
            if(f==Slen-1)
                flag=1;
        }  
    }  

    if(flag==1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }       
}


Measured memory_bytes: 2100
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	string o, e;
	cin >> o;
	cin >> e;

	for(int i=0; i<o.length()-1; i++){
		cout << o.at(i) << e.at(i);
	}

	if(e.length() == o.length()) cout << o.at(o.length()-1) << e.at(o.length()-1) << endl;
	else cout << o.at(o.length()-1) << endl;

	return 0;
}

Measured memory_bytes: 256
n,t = map(int,input().split())
c = []
for i in range(n):
    c1,t1 = map(int,input().split())
    if t1 <= t:
        c.insert(i,c1)
if len(c) == 0:
    print("TLE")
else:
    c.sort(key=int)
    print(c[0])

Measured memory_bytes: 8956
#include<stdio.h>
int main()
{
    int x,r, d, i;
    scanf("%d%d%d", &r,&d,&x);
    if(r>=2&&r<=5&&d>=1&&d<=100)
    {
        for(i=1;i<=10;i++)

        {
            x=x*r-d;
            printf("%d\n", x);
        }
    }
    return 0;
}


Measured memory_bytes: 128
// Problem : C - Maximum Volume
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

/*
 * author :Sadik Hassan
 * 
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
	double x,y=1.0/3.0,xx;
	cin>>x;
	xx=pow(x/3,3);
	printf("%.12lf",xx);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#define ull unsigned long long
using namespace std;
ull ans=0,a,b;
int main(){
	scanf("%llu%llu",&a,&b);
	for(ull i=a;i<=b;i*=2)ans++;
	printf("%llu",ans);
	return 0;
}

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

using namespace std;

const int MAXN = 2E5;
int a[MAXN + 1];
long long pre[MAXN + 1];

long long getSum(int l, int r)
{
    if (l > r)
        return 0;
    return pre[r] - pre[l - 1];
}

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        pre[i] = pre[i - 1] + a[i];
    }
    long long ans = 1E18;
    for (int i = 3; i <= n - 1; i++)
    {
        long long half = pre[i - 1];
        int x = 1;
        for (int jump = i / 2 + 1; jump > 0; jump /= 2)
        {
            while (x + jump <= i - 3 && pre[x + jump] <= half - pre[x + jump])
                x += jump;
        }
        if (abs(getSum(1, x) - getSum(x + 1, i - 1)) > abs(getSum(1, x + 1) - getSum(x + 2, i - 1)))
            x++;
        int y = i;
        half = getSum(1, n) - half;
        for (int jump = (n - i) / 2 + 1; jump > 0; jump /= 2)
        {
            while (y + jump <= n - 2 && getSum(i, y + jump) <= half - getSum(i, y + jump))
                y += jump;
        }
        if (abs(getSum(i, y) - getSum(y + 1, n)) > abs(getSum(i, y + 1) - getSum(y + 2, n)))
            y++;
        long long minn, maxx;
        minn = maxx = getSum(1, x);
        minn = min(minn, getSum(x + 1, i - 1));
        maxx = max(maxx, getSum(x + 1, i - 1));
        minn = min(minn, getSum(i, y));
        maxx = max(maxx, getSum(i, y));
        minn = min(minn, getSum(y + 1, n));
        maxx = max(maxx, getSum(y + 1, n));
        ans = min(ans, maxx - minn);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
# 昇順でソートされている前提
def priority_push(array:, num:)
  index = array.bsearch_index { |i| i <= num}
  if index.nil?
    array.push(num)
  else
    array.insert(index, num)
  end
end

# 昇順でソートされていて、indexに値がある前提
def priority_update(array:, index:, num:)
  array.delete_at(index)
  priority_push(array: array, num: num)
end

N = gets.to_i
arr = N.times.map{ gets.to_i }
stacks = [arr.shift]

arr.each do |i|
  overwrite_index = stacks.bsearch_index { |target| target < i }
  if overwrite_index.nil?
    priority_push(array: stacks, num: i)
  else
    priority_update(array: stacks, index: overwrite_index, num: i)
  end
end
puts stacks.count

Measured memory_bytes: 4020
#include <stdio.h>
#define MOD 2019

int main(){
  int L,R;
  int l,r;
  int min = MOD*MOD;
  
  scanf("%d %d",&L,&R);
  l = L % MOD;
  r = R % MOD;
  if(R-L>=MOD) r+=MOD;
  if(l>r) r += MOD;

  
  for(int i=l;i<r;i++)
    for(int j=i+1;j<=r;j++)
      if(min > (i*j)%MOD)
	min = (i*j)%MOD;


  printf("%d\n",min);
  
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

int a[100010];

int main()
{
	//freopen("read.in","r",stdin);
	//freopen("write.out","w",stdout);
	
	int n,last=10001,ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);

	for(int i=0;i<n;i++)
	{
		if(last==a[i]&&a[i+1]!=a[i]+1)
		{
			a[i]=a[i]+1;
			last=a[i];
			ans++;
		}
		else if(last==a[i]&&a[i+1]==a[i]+1)
		{
			a[i]=a[i]+2;
			last=a[i];
			ans++;
		}
		else last=a[i];
	}
	
	printf("%d",ans);

	//fclose(stdin);
	//fclose(stdout);
	return 0;
} 

Measured memory_bytes: 128
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():

    S =input()
    prime =753
    ans =1000
    for i in range(len(S)-2):
        ans =min(ans, abs(prime-int(S[i:i+3])))

    print(ans)





if __name__ == "__main__":
    main()


Measured memory_bytes: 61856
#include<iostream>
#include<cstring>
#include<sstream>
using namespace std;

int main() {

	int n;
	double x;
	double sum = 0;
	double numa = 1;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> x;
		sum = sum + numa / x;

	}
	sum = 1 / sum;
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
	
		int A[] = new int[Q];
		for(int i = 0; i < Q; i++) {
			A[i] = sc.nextInt();
		}
		
		int pointOfA[] = new int[N];
		for (int i = 0; i < N; i++) {
			pointOfA[i] = 0;
		}
		
		for (int i = 0; i < Q; i++) {
			pointOfA[A[i] - 1]++;
		}
		
		for (int i = 0; i < N; i++) {
			if(pointOfA[i] < Q - K + 1) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		}
			
	}
}

Measured memory_bytes: 71880
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int ms = a * b;
		int ns = a * 2 + b * 2;
		
		System.out.println(ms + " " + ns);
	}
}


Measured memory_bytes: 26328
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		a[0] = sc.nextInt();
		a[1] = sc.nextInt();
		a[2] = sc.nextInt();
		
		java.util.Arrays.sort(a);
		System.out.println(a[0]+" "+a[1]+" "+a[2]);
		
	}
}


Measured memory_bytes: 26188
#include <cstdio>
#include <cstring>

int main(void) {
	while(true) {
		int n;
		scanf("%d", &n);
		if(n == 0)
			break;
		int sold[10];
		memset(sold, 0, sizeof(sold));

		for(int i = 0; i < n; i++) {
			int t;
			scanf("%d", &t);
			sold[t]++;
		}
		for(int i = 0; i <= 9; i++) {
			if(sold[i] == 0)
				printf("-\n");
			else {
				for(int j = 0; j < sold[i]; j++)
					printf("*");
				printf("\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
int main(){
  int n;
  char s[100001];
  scanf("%d",&n);
  scanf("%s",s);
  int a=n;
  for(int i=0;i<n-1;i++){
    if(s[i]==s[i+1])a--;
  }
  printf("%d\n",a);
  return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> max(N+1);
  max[0]=0;
  for(int i=0;i<N;i++) {
    max[i+1]=max[i];
    if(S[i]=='I') max[i+1]++;
    if(S[i]=='D') max[i+1]--;
  }
  sort(max.begin(), max.end());
  cout << max[N] << endl;
}

Measured memory_bytes: 256
var input = ""; 
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (chunk) => {
  input += chunk
})

process.stdin.on('end', function(){
 
 var arr = input.split('\n').map(Number);

  for (var i = 0; i < arr.length && arr[i] != 0; i++) {
    console.log('Case %d: %d', i + 1, arr[i]);
  }
})




Measured memory_bytes: 23652
n = int(input())
A = list(map(int,input().split()))
idx = [i+1 for i in range(n)]
B = [i-j for i,j in zip(A, idx)]
C = [-(i+j) for i,j in zip(A, idx)]
looked = {}
ans = 0
for b,c in zip(B, C):
    if b in looked.keys():
        ans += looked[b]
    if c in looked.keys():
        looked[c] += 1
    else:
        looked[c] = 1
print(ans)

Measured memory_bytes: 58024
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  for(int i = 0; 2 * i < s.size(); i++){
    cout << s[2 * i];
  }
  cout << endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    static int N, A, B, C;
    static int[] L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        L = new int[N];
        for (int i = 0; i < N; i++) L[i] = sc.nextInt();

        System.out.println(dfs(0, 0, 0, 0));
        sc.close();
    }

    static public int dfs(int idx, int a, int b, int c){
        int ret;
        if(idx < N){
            int ret0 = dfs(idx+1, a, b, c);
            int ret1 = dfs(idx+1, a+L[idx], b, c)+10;
            int ret2 = dfs(idx+1, a, b+L[idx], c)+10;
            int ret3 = dfs(idx+1, a, b, c+L[idx])+10;
            ret = Math.min(Math.min(ret0, ret1), Math.min(ret2, ret3));
        }else{
            if(a > 0 && b > 0 && c > 0){
                ret = Math.abs(A - a) + Math.abs(B - b) + Math.abs(C - c) -30;
            }else{
                ret = Integer.MAX_VALUE/10;
            }
        }
        return ret;
    }
}


Measured memory_bytes: 23508
n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)

ans=1
for num in a:
    if num==0:
        last_cnt=3
    else:
        last_cnt=d[num-1]

    tmp = last_cnt - d[num]
#    if tmp <= 0:
#        tmp=1
    ans*=tmp
    ans%=1000000007
    d[num]+=1

print(ans)

Measured memory_bytes: 62124
import numpy as np
N, K = map(int, input().split())
h = np.array(input().split(), dtype='int32')
dp = np.zeros(N, dtype='int32')

for i in range(1, N):
  start = 0 if i < K else i-K
  dp[i] = np.min(dp[start:i] + np.abs(h[i]-h[start:i]))

print(dp[-1])

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

int main()
{
	string s;

	cin >> s;

	if (s == "SUN") cout << 7;
	else if (s == "MON") cout << 6;
	else if (s == "TUE") cout << 5;
	else if (s == "WED")cout << 4;
	else if (s == "THU")cout << 3;
	else if (s == "FRI")cout << 2;
	else if (s == "SAT")cout << 1;
	return 0;
}

Measured memory_bytes: 256
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

H,W,K=gets.chomp.split(' ').map{|n| n.to_i}
DP = Array.new(H){Array.new(W){0}} # 0 indexed
FIB = Array.new(W) # FIB[i] : upto i ladders
if(W==1)
	puts 1
	exit(0)
end
# precomputation
FIB[0] = 1
FIB[1] = 2
for i in 2..(W-1)
	FIB[i] = FIB[i-1] + FIB[i-2]
end
if(H==1)
	if(K==1)
		puts FIB[[W-2,0].max]
	elsif(K==2)
		puts FIB[[W-3,0].max]
	end
	exit(0)
end
# DP
DP[0][0] = FIB[W-2]
DP[0][1] = FIB[W-3]
for i in 1..(H-1)
	for j in 0..(W-1)
		DP[i][j] += DP[i-1][j-1] * FIB[[j-2,0].max] * FIB[[W-1-j-1,0].max] if j > 0
		DP[i][j] += DP[i-1][j]   * FIB[[j-1,0].max] * FIB[[W-1-j-1,0].max]
		DP[i][j] += DP[i-1][j+1] * FIB[[j-1,0].max] * FIB[[W-1-j-2,0].max] if j < W-1
		DP[i][j] %= 1000000007
	end
end
puts DP[H-1][K-1]

# pp DP


Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  int Q;
  cin >> Q;
  vector<LL> A(Q), B(Q);
  rep(i,Q) cin >> A[i] >> B[i];
  rep(i,Q){
    LL ans=0;
    LL a=A[i], b=B[i];
    if(a<b) swap(a,b);
    LL score=ceil(sqrt(a*b))-1;
    if(a-b==1){
      cout << (score-1)*2 << endl;
      continue;
    }
    if(a==b){
      cout << score*2 << endl;
      continue;
    }
    ans+=score*2-1;
    if(score*(score+1)>=a*b) ans--;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[5];
int n;
int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;++i){
		scanf("%d",&x);
		++f[x%4];
	}f[1]+=f[3];
	if(f[2]==0&&f[0]>=f[1]-1||f[0]>=f[1])puts("Yes");else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
long long n;
long long x[100];
long long y[100];
long long p,q;
long long f;
long long ans;
long long aans;
int main()
{
    cin>>n;
    rep(i,n)
    {
        cin>>x[i]>>y[i];
    }
    rep(xx,n)rep(yy,n)
    {
        aans=0;
        if(xx==yy)continue;
        p=x[yy]-x[xx];
        q=y[yy]-y[xx];
        rep(i,n)
        {
            f=1;
            rep(j,n)
            {
                if(x[i]+p==x[j]&&y[i]+q==y[j])f=0;
            }
            aans+=f;
        }
        if(ans==0||ans>aans)ans=aans;
    }
    if(ans==0)cout<<1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc177
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc177B();
            Console.Out.Flush();
        }

        public static void solve_abc177B()
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int min = 10001;
            for (int i = 0; i < s.Length - t.Length + 1; i++)
            {
                int cnt = 0;
                int j = 0;
                while (j < t.Length)
                {
                    if (s[i + j] != t[j])
                    {
                        cnt++;
                    }
                    j++;
                }
                min = Math.Min(min, cnt);
            }

            Console.WriteLine(min);
        }

        public static void solve_abc177A()
        {
            int[] dts = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int d = dts[0];
            int t = dts[1];
            int s = dts[2];
            double taken = (double)d / s;
            Console.WriteLine(taken > t ? "No" : "Yes");
        }

        public static int binSerachLeft(int[] a, int x)
        {
            int l = -1;
            int r = a.Length;
            while (r > l + 1)
            {
                int m = (l + r) / 2;
                if (a[m] <= x)
                {
                    l = m;
                }
                else
                {
                    r = m;
                }
            }
            return l;
        }
    }
}

Measured memory_bytes: 26824
#include <bits/stdc++.h>
using namespace std;
int N;
long long C, x[100005], v[100005], sum[100005], sumb[100005];
long long maxi[100005], maxidb[100005], ans;
int main()
{
#ifdef _noname
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%lld", &N, &C);
	for (int i = 1; i <= N; i++) scanf("%lld%lld", x + i, v + i);
	sum[0] = sumb[N + 1] = 0;
	for (int i = 1; i <= N; i++) sum[i] = sum[i - 1] + v[i];
	for (int i = N; i >= 1; i--) sumb[i] = sumb[i + 1] + v[i];
	maxi[0] = maxidb[0] = 0;
	for (int i = 1; i <= N; i++)
	{
		maxi[i] = max(maxi[i - 1], sum[i] - x[i]);
		maxidb[i] = max(maxidb[i - 1], sum[i] - x[i] * 2);
	}
	ans = maxi[N];
	for (int i = N; i >= 1; i--)
	{
		ans = max(ans, (sum[N] - sum[i - 1] - (C - x[i])) + maxidb[i - 1]);
		ans = max(ans, (sum[N] - sum[i - 1] - (C - x[i]) * 2) + maxi[i - 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long x;
	cin >> x;

	long long n=100;
	for(int i=1; i<=3760; ++i){
		n *= 1.01;
		if(n>=x){
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N, K;
  string S;

  cin >> N >> K >> S;

  int ans = 0;
  int t = 0;

  for(int i=0; i<N-1; i++) {
    if (S[i] == S[i+1]) ans++;
    else t++;
  }

  ans += min(K*2, t);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
struct UnionFind {
	vector<int> rank, parent, num;
	UnionFind() {};
	UnionFind(int size) :rank(size, 0), parent(size, 0), num(size, 0) {
		for (int i = 0; i < size; i++)makeset(i);
	}

	void makeset(int x) {
		parent[x] = x;
		rank[x] = x;
		num[x] = 1;
	}

	bool same(int x, int y) {
		return findset(x) == findset(y);
	}

	int findset(int x) {
		if (x != parent[x]) {
			parent[x] = findset(parent[x]);
		}
		return parent[x];
	}

	void unite(int x, int y) {
		int tmpx = num[findset(x)];
		int tmpy = num[findset(y)];
		link(findset(x), findset(y));
		num[findset(x)] = tmpx + tmpy;
	}

	void link(int x, int y) {
		if (rank[x] > rank[y])parent[y] = x;
		else {
			parent[x] = y;
			if (rank[x] == rank[y])rank[y]++;
		}
	}
};
int main() {
	cin >> N >> M;
	vector<int>A(M), B(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
	}
	UnionFind uf(N + 1);
	vector<ll>res(M+1,0);
	for (int i = M - 1; i >= 0; i--) {
		if (uf.same(A[i], B[i])) {
			res[i] = ans;
			continue;
		}
		int a = uf.findset(A[i]);
		int b = uf.findset(B[i]);
		ans += uf.num[a] * uf.num[b];
		uf.unite(A[i], B[i]);
		res[i] = ans;
	}
	ll tmp = N * (N - 1) / 2;
	for (int i = 1; i <= M; i++)cout << tmp-res[i] << endl;
}

Measured memory_bytes: 4096
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl
#define F first
#define S second
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, t;
string a, b;
map<string, int> id;
vi rail[50000], cost[50000];
vector<pi> pos[100000];
bool trans[100000]; //respect fra2

inline int get(const string &s){
	if(id.count(s)) return id[s];
	int n = id.size();
	return id[s] = n;
}
int main(){
	cin >> n >> t >> a >> b;
	int st = get(a), gl = get(b);
	rep(i, n){
		int k, l;
		cin >> k;
		rep(j, k){
			string s;
			cin >> s;
			l = get(s);
			rail[i].pb(l);
			pos[l].pb(mp(i, j));
		}
		rep(j, k - 1){
			cin >> l;
			cost[i].pb(l);
		}
	}
	set<pi> s;
	priority_queue<pair<pi, pi> > q;
	rep(i, pos[st].size()) q.push(mp(mp(0, 0), pos[st][i]));
	while(!q.empty()){
		pi cur = q.top().S, co = q.top().F;
		int cid = rail[cur.F][cur.S]; q.pop();
		if(s.count(cur)) continue;
		s.insert(cur);
		
		if(cid == gl){
			cout << -co.F << " " << -co.S << endl;
			return 0;
		}
		if(!trans[cid]){
			trans[cid] = 1;
			rep(i, pos[cid].size()) rep(d, 2){
				pi nxt = pos[cid][i], nco = co;
				nxt.S += d ? 1 : -1;
				if(nxt.S < 0 || nxt.S >= rail[nxt.F].size() || s.count(nxt)) continue;
				if(pos[cid][i] == cur) continue;
				nco.S--;
				nco.F -= t + cost[nxt.F][nxt.S - d];
				q.push(mp(nco, nxt));
			}
		}
		rep(d, 2){
			pi nxt = cur, nco = co;
			nxt.S += d ? 1 : -1;
			if(nxt.S < 0 || nxt.S >= rail[nxt.F].size() || s.count(nxt)) continue;
			nco.F -= cost[nxt.F][nxt.S - d];
			q.push(mp(nco, nxt));
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 19292
//  Created by ZJYelizaveta on 2017年09月16日 星期六 20时43分16秒
//  Copyright (c) 2017年 ZJYelizaveta. All rights reserved.

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

typedef long long ll;
typedef unsigned long long ull;
template<typename T> T readIn() {
	T x(0), f(1);
	char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}
const int MAX_N = 100 + 3;
const int MAX_K = 100 + 3;
const int INF = 0x3f3f3f3f;
int n, k;
int a[MAX_N];

int main()
{
	n = readIn<int>(), k = readIn<int>();
	for (int i = 1; i <= n; ++i) a[i] = readIn<int>();
	int mid = k / 2;
//	printf("%d\n", mid);
    int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] <= mid) ans = ans + a[i] * 2;
		else ans = ans + (k - a[i]) * 2;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
N,K,L=map(int,input().split())
G=[[] for i in range(N)]
H=[[] for i in range(N)]
#T=[-1 for i in range(N)]
#B=[-1 for i in range(N)]
for i in range(K):
    p,q=map(int,input().split())
    G[p-1].append(q-1)
    G[q-1].append(p-1)
for i in range(L):
    r,s=map(int,input().split())
    H[r-1].append(s-1)
    H[s-1].append(r-1)
def dfs(A):
    k=1
    q=[]
    reached=[0 for i in range(N)]
    res=[0 for i in range(N)]
    for i in range(N):
        if reached[i]==1:
            continue
        q.append(i)
        while(len(q)>0):
            r=q[-1]
            q.pop()
            res[r]=k
            for p in A[r]:
                if reached[p]==1:
                    continue
                q.append(p)
                reached[p]=1
        k+=1
    return res
T=dfs(G)
B=dfs(H)
TB=[(T[i],B[i]) for i in range(N)]
D=dict()
for i in range(N):
    if TB[i] in D:
        D[TB[i]]+=1
    else:
        D[TB[i]]=1
ans=[str(D[TB[i]]) for i in range(N)]
print(" ".join(ans))


Measured memory_bytes: 99380
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

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

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    long long S; cin >> S;
    long long e9 = 1e9;
    if (S <= 1e9) {
        cout << "0 0 " << S << " 0 " << "0 1" << endl;
    } else {
        cout << "0 " << S/e9 << " " << e9 << " " << (S+e9-1)/e9 << " " << S%e9 << " " << 0 << " " << endl; 
    }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    }
    let r = a - b;
    if r < c {
        println!("{}", c - r);
    } else {
        println!("{}", 0);
    }
}


Measured memory_bytes: 4352
//人正是因为度过了一段阴暗岁月，才会更渴求黎明的曙光
//青春不能回头。所以青春也没有终点。
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <memory.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

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

const int MAXN = 0;

int main(void) {
	int N,M;
	cin >> N >> M;
	cout << N*(N-1)/2+M*(M-1)/2 << endl;
	return 0;
}




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

int main() {
    string s;
    cin >> s;
    int ans = 700;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'o') ans += 100;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <vector>
#include <valarray>
#include <queue>
#include <iostream>
#include <numeric>
#include <string>
#include <stack>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(int i = (a); i >= (b); --i)
#define rREP(i, n) rFOR(i, n-1, 0)
#define AND &&
#define OR ||
#define IN(x, min, max) (min <= x AND x < max)
#define VEC(type) vector<type>
#define DVEC(type) vector<vector<type>>
#define VAL(type) valarray<type>
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
#define HOGE printf("%s\n", "hoge");
#define DUMP(p) cout << p << endl;
const int INF = 2323232323;
using namespace std;
typedef pair<int, int> P;

int main(){
    char _X[200001];
    scanf("%200000s", _X);
    string X = _X;
    int n = X.size();
    stack<char> s;
    int erase = 0;
    REP(i, n){
        if (X[i] == 'S') {
            s.push(X[i]);
            ++erase;
        } else {
            if (s.empty()) {
                continue;
            } else {
                s.pop();
                ++erase;
            }
        }
    }
    printf("%d\n", (X.size()-erase)+s.size());
    return 0;

}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int main() {
    int n = iin();
    iout(n * (n + 1) / 2);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; i++) {
    cin >> s.at(i);
  }
  bool ans = true;
  for(int i=1; i<n; i++) {
    int m = s.at(i-1).size();
    if(s.at(i).at(0) != s.at(i-1).at(m-1)) {
      cout << "No" << endl;
      return 0;
    }
  }
  sort(s.begin(), s.end());
  for(int i=1; i<n; i++) {
    if(s.at(i) == s.at(i-1)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

struct Edge{
    int a, b, i, c;
};

int main(){
    int N;
    cin >> N;
    vector<vector<Edge>> G(N);
    vector<int> Edge_color(N - 1), P_color(N);

    rep(i, N - 1){
        Edge e;
        cin >> e.a >> e.b;
        e.a--;
        e.b--;
        e.i = i;
        G[e.a].push_back(e);
    }

    P_color[0] = -1;
    int K = 1;
    queue<int> que;
    que.push(0);

    while(!que.empty()){
        int a = que.front();
        que.pop();
        int p = P_color[a];
        int color = 0;
        for(Edge e : G[a]){
            color++;
            if(color == p) color++;
            e.c = color;
            Edge_color[e.i] = color;
            P_color[e.b] = color;
            que.push(e.b);
        }
        K = max(K, color );
    }

    cout << K << endl;

    rep(i, N - 1){
        cout << Edge_color[i] << endl;
    }
}

Measured memory_bytes: 6144
#include <algorithm>
#include <atcoder/dsu>
#include <iomanip>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  // N = 2e5;
  vector<tuple<int, int, int>> XY(N);
  rep(i, N) {
    int x, y;
    cin >> x >> y;
    // x = i + 1;
    // y = i / 2 + 1 + (i % 2) * 1e5;
    XY[i] = {x, y, i};
  }
  sort(XY.begin(), XY.end());

  map<int, int> before;
  before[get<1>(XY[0])] = get<2>(XY[0]);
  atcoder::dsu answer(N);
  for (int i = 1; i < N; ++i) {
    auto& [x, y, j] = XY[i];
    auto itr = before.lower_bound(y);
    // int smaller = distance(before.begin(), itr);
    // int larger = (N - y) - (i - smaller);
    if (itr != before.begin()) {
      answer.merge(j, before.begin()->second);
      auto itr2 = before.begin();
      itr2++;
      while (itr2 != itr) {
        answer.merge(j, itr2->second);
        before.erase(itr2++);
      }
    }
    before[y] = j;
  }

  rep(i, N) { cout << answer.size(i) << endl; }
  return 0;
}


Measured memory_bytes: 11052
#include <cstdio>
#include <algorithm>
#include <cctype>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e2+5, P = 1e9+7;
int n, a[N], f[N][N][N], ans;
void add(int &x, int y) { x = x+y<P?x+y:x+y-P; }
int main()
{
    n = read(); for(int i = (n<<1)-1; i; --i) a[i] = read();
    sort(a+1, a+(n<<1));
    f[n][1][0] = 1;
    for(int i = n-1; i; --i)
    {
        int al = a[i] != a[i+1], ar = a[(n<<1)-1-i] != a[(n<<1)-i];
        for(int l = 1; l <= (n<<1)-1; ++l)
            for(int r = 0; l+r <= (n<<1)-1; ++r)
                if(f[i+1][l][r])
                {
                    int h = f[i+1][l][r];
                    for(int dl = 1; dl <= l+al; ++dl) add(f[i][l+al-dl+1][r+ar+(dl > 1)], h);
                    for(int dr = 1; dr <= r+ar; ++dr) add(f[i][l+al+1][r+ar-dr], h);
                }
    }
    for(int l = 1; l <= (n<<1)-1; ++l)
        for(int r = 0; l+r <= (n<<1)-1; ++r)
            add(ans, f[1][l][r]);
    printf("%d\n", ans);
    return 0;
}  

Measured memory_bytes: 3456
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


s,w=mii()
if w>=s:
    print("unsafe")
else:
    print("safe")




Measured memory_bytes: 72492
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int[] s = new int[count];
        for (int i = 0; i < count; i++) {
            s[i] = sc.nextInt();
        }
        selectionSort(s);
    }

    private static int[] selectionSort(int[] a) {
        int count = 0;
        for (int i = 0; i < a.length; i++) {
            int min = i;
            for (int j = i; j < a.length; j++) {
                if (a[j] < a[min]) {
                    min = j;
                }
            }
            if (i != min) {
                int tmp = a[i];
                a[i] = a[min];
                a[min] = tmp;
                count++;
            }
        }
        printArray(a);
        System.out.println(count);
        return a;
    }

    private static void printArray(int[] array) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < array.length; i++) {
            sb.append(array[i]);
            if (i != array.length - 1) {
                sb.append(" ");
            }
        }
        System.out.println(sb);
    }
}

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



int main(){
    int N,M,X;
    cin >> N >> M >> X;//N冊，Mアリゴリズム，X目標理解度
    vector<int> cost(N); //値段を取得
    vector<vector<int>> book(N,vector<int>(M));
    
    rep(i,N){
        cin >> cost[i];
        rep(j,M){
            cin >> book[i][j];
        }
    }
    
    int ans=1e7;
    //ビット全探索
    for(int tmp = 0; tmp < (1 << N); tmp++) {
        bitset<12> s(tmp);
        // ビット列を出力
        //cout << s << endl;
        
        //理解度を足していく,costも
        vector<int> rikai(M,0);
        int sum_money = 0;
        for (int i = 0; i < N; i++) {
          if (s.test(i)) {
              for(int j = 0; j<M; j++){
                rikai[j] += book[i][j];  
              }
              sum_money += cost[i];
          }
        }
        
        bool rikai_flg=true;
        for(int i = 0; i<M; i++){
            if(rikai[i] < X){
                rikai_flg=false;
            }
        }
        
        if(rikai_flg){
            ans = min(ans, sum_money);
        }
    }
    
    //最小コストを出力
    if(ans==1e7){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 3600
#include <iostream>


int main(void){

	int a, b, x;
	std::cin >> a >> b >> x;

	if(a > x || (a + b) < x){
		std::cout << "NO" << std::endl;
	}
	else{
		std::cout << "YES" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
int main()
{
    timesave;
    int n,i,a;
    map<int,int>mp;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>a;
        mp[a]++;
    }
    for(i=1;i<=n;i++)
        cout<<mp[i]<<endl;
}






Measured memory_bytes: 13032
import java.util.*;

public class Main{

    private static void Count(int[] A, int K){
        Map<Integer, Integer> count = new HashMap<Integer, Integer>();
        int kind = 0;
        for(int i = 0; i < A.length; i ++){
            if(!count.containsKey(A[i])){
                count.put(A[i], 1);
                kind ++;                
            } 
            else{
                count.put(A[i], count.get(A[i]) + 1);
            }
        }
        if(kind <= K) System.out.println(0);
        else{
            int[] Value = new int[kind];
            int i = 0;
            for(Integer key : count.keySet()){
                Integer value = count.get(key);
                Value[i] = value;
                i ++;
            }
            Arrays.sort(Value);
            int change = 0;
            for(int j = 0; Value.length - j > K; j ++){
                change += Value[j];
            }
            System.out.println(change);
        }
    }
    
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int K = input.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i ++){
            A[i] = input.nextInt();
        }
        input.close();
        Count(A, K);
    }
}

Measured memory_bytes: 68016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e5+7;
vector<int> v[maxn];
map<pii,int> mp;pii e[maxn];
int col[maxn];
int ans=0;
int main()
{
	int n;cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
		if(x>y) swap(x,y);
		e[i]=make_pair(x,y);
	}
	queue<pii> q;
	q.push(make_pair(1,0));int ans=0;
	while(!q.empty())
	{
		pii tmp=q.front();q.pop();
		int u=tmp.first,fa=tmp.second;
		int now=1;
		for(int i=0;i<v[u].size();i++)
		{
			int vv=v[u][i];
			if(vv==fa) continue;
			q.push(make_pair(vv,u));
			if(now==mp[make_pair(fa,u)]) now++;
			mp[make_pair(u,vv)]=now;
			now++;
		}
		ans=max(ans,now-1);
	}
	printf("%d\n",ans);
	for(int i=1;i<n;i++)
	{
		printf("%d\n",mp[e[i]]);
	}
	return 0;
}

Measured memory_bytes: 13056
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int a,b;
	scanf("%d %d",&a,&b);

	string A,B;

	for(int i = 0; i < b; i++){

		A += '0'+a;
	}
	for(int i = 0; i < a; i++){

		B += '0'+b;
	}

	if(A <= B){

		printf("%s\n",A.c_str());

	}else{

		printf("%s\n",B.c_str());
	}

	return 0;
}


Measured memory_bytes: 256