akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] str = new String[n];
        String stush = sc.nextLine();
        for (int i = 0; i < n; i++) {
            str[i] = sc.nextLine();
        }
        boolean flag = true;
        for (int i = 0; i < n - 1; i++) {
            char a = str[i].charAt(str[i].length() - 1);
            char b = str[i + 1].charAt(0);
            if (!(a == b)) {
                flag = false;
            }
        }
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if (str[i].equals(str[j])) {
                    flag = false;
                }
            }
        }
        System.out.println(flag ? "Yes" : "No");
    }
}

Measured memory_bytes: 22996
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,K;
ll a[200010];
int main(){
    cin>>K>>N;
    for(ll i=0;i<N;i++){
    	cin>>a[i];
    }
	ll maxDif=0;
    ll sum=0;
    ll pre=-(K-a[N-1]);
    for(ll i=0;i<N;i++){
		sum+=a[i]-pre;
		maxDif=max(maxDif,a[i]-pre);
		pre=a[i];
	}
	cout<<sum-maxDif<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
typedef struct{char suit, value;}card;
void swap(card *a,card *b){
    card t=*a;
    *a = *b;
    *b = t;
    return;
}
void bubble(int n, card a[]){
    int i, j, flag;
    flag=1;
    for(i=0;flag;i++){
        flag=0;
        for(j=n-1;j>=i+1;j--){
            if(a[j].value < a[j-1].value){
                swap(&a[j], &a[j-1]);
                flag=1;
            }
        }
    }
    return;
}
void selectionSort(card a[], int N){
    int i, j, minj;
    card t;
    for(i = 0; i < N-1; i++){
        minj = i;
        for(j=i;j<N;j++){
            if(a[j].value < a[minj].value){
                minj=j;
            }
        }
        t = a[i];
        a[i] = a[minj];
        a[minj] = t;
    }
    return;
}
void str2Card(card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}
void print(card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}
int stable(card a[], card b[], int n){
    int i;
    for(i = 0; i < n; i++){
        if(a[i].suit != b[i].suit){
            return 0;
        }
    }
    return 1;
}
int main(void){
    card c1[100], c2[100];
    int i, n;
    char str[3];
    scanf("%d", &n);
    for(i= 0; i < n; i++){
        scanf("%s", &str);
        str2Card(&c1[i], str);
    }
    for(i = 0;i < n; i++){
        c2[i] = c1[i];
            }
    bubble(n, c1);
    selectionSort(c2, n);
    print(c1, n);
    printf("Stable\n");
    print(c2, n);
    if(stable(c1, c2, n)){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
    return 0;
}


Measured memory_bytes: 2048
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map (map int . words) . tail . lines
printer = unlines . (:[]) . show 

solver :: [[Int]] -> Int
solver (x:[]) = 0
solver (x:xs) = result + solver xs
  where
    result = length [ s |
      y<-xs ,
      let z= zipWith (-) x y ,
      let s= sum(zipWith (*) z z) ,
      (floor $ (sqrt $ fromIntegral s + 1e-8))^2 == s ]

  



Measured memory_bytes: 1020
#include<cstdio>
using namespace std;
unsigned long long mod = 998244353LL, T1[301][90001], T2[301][90001];
     
int main()
{
  unsigned long long n,sum = 0,a[300], ans = 1, i,j;
  scanf("%llu",&n);
      
  for(i = 0; i < n ; ++i) {
    scanf("%llu",&a[i]);
    sum += a[i];
    ans = ans * 3 % mod;
  }
     
  T1[0][0] = 1;
  T2[0][0] = 1;
  for(i = 1 ; i <= n ; ++i) {
    for(j = 0; j <= sum ; ++j) {
      T1[i][j] = T1[i - 1][j] * 2 % mod;
      T2[i][j] = T2[i - 1][j];
          
      if(j >= a[i-1]) {
        T1[i][j] = (T1[i][j] + T1[i-1][j-a[i-1]]) % mod;
        T2[i][j] = (T2[i][j] + T2[i-1][j-a[i-1]]) % mod;
      }
    }
  }
     
  for(j = (sum+1)/2 ; j <= sum ; ++j)
    ans = (ans + mod - T1[n][j] * 3 % mod) % mod;
     
  if (sum%2 == 0)
    ans = (ans + T2[n][sum/2] * 3) % mod;
     
  printf("%llu",ans);
      
  return 0;
}


Measured memory_bytes: 422784
#include<iostream>
using namespace std;
int main()
{
    char c;
    cin>>c;
    if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u')
    {
        cout<<"vowel"<<endl;
    }
    else
    {
        cout<<"consonant"<<endl;
    }
    return 0;
}


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

int main(){
    string s,t;
    cin >>s >> t;
    int a,b;
    cin >>a >> b;
    string u;
    cin >> u;
    if(u==s){
        a--;
    }else if(u==t){
        b--;
    }
    cout << a <<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <list>
#include <set>
using namespace  std;

#define int long long int

constexpr int INF = std::numeric_limits<int>::max();

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;

    cout << min(C, B / A) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<pair<long long ,long long >> vp;
typedef long long ll;
int main(){
int N,M;
cin>>N>>M;
vp a(N);
ll sum=0;
int cnt=M;
for(int i=0;i<N;i++){
    int num1,num2;
    cin>>num1>>num2;
    a[i].first=num1;
    a[i].second=num2;
}


sort(a.begin(),a.end());

for(int i=0;;i++){
    if((a[i].second)>cnt){
    sum+=cnt*(a[i].first)*1LL;
    cnt=0;
    }
    else {
        cnt-=(a[i].second);
        sum+=(a[i].first)*(a[i].second)*1LL;
    }
    if(cnt==0){
        cout<<fixed<<setprecision(0)<<sum;
        return 0 ;
    }

    }
}


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

/*** Typedef ***/
typedef long long ll;
typedef unsigned long long ull;

/*** Loops ***/
#define ffit(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)
#define ff1(i,a,b) for(ll i = a; i <b; i++)
#define ff2(i,a,b) for(ll i = b-1; i >= a; i--)
#define ff3(i,a,b,m) for(ll i = a; i <=b; i+=m)
#define ipar(ar,n) ll ar[n]; ff1(i,0,n) cin>>ar[i];
#define opar(ar,n) ff1(i,0,n) cout<<ar[i]<<" ";
#define foRev(num) for(ll i = num - 1; i >= 0; i--)
#define forIn(arr, num) for(ll i = 0; i < num; i++) sc1(arr[i]);
#define forIn1(arr, num) for(ll i = 1; i <= num; i++) sc1(arr[i]);
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define apnt(arr, num) for(ll i = 0; i < num; i++) cout << arr[i] << (i + 1 < num ? ' ' : '\n');

/*** Define Values ***/
//#define mod 1000000007
#define PI acos(-1.0)
#define eps 1e-7
#define size1 15

/*** STLs ***/
#define rsz(x...) resize(x)
#define ins(x...) insert(x)
#define ft() front()
#define bk() back()
#define eb(x...) emplace_back(x)
#define lb(x...) lower_bound(x)
#define ub(x...) upper_bound(x)
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mem(name, value) memset(name, value, sizeof(name))
#define endl " \n"

/*** STLs ***/
typedef vector <ll> vll;
#define vvll vector<vll>
typedef set <ll> sll;
typedef multiset <ll> msll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll, ll> > vpll;

///vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.

/*** Sorts ***/
#define all(v) (v).begin(), (v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtgrt(v) sort(all(v), greater<ll>())
#define prsrt greater<pair<int,int>>()
/*** Some Prints ***/
#define q2(n) (n%2)==0
#define ip(n) ll n; cin>>n;
#define en cout << '\n';
#define no cout << "NO" << '\n'
#define yes cout << "YES" << '\n'
#define case cout << "Case " << t++ << ": ";
#define ps(x,y)         fixed<<setprecision(y)<<x
#define inf             1e18
#define debug(x) cout << '>' << #x << ':' << x << endl;
//const ll N = 1e6 + 9;
#define w(x)             ll x; cin>>x; while(x--)
//#define SIZE_INT sizeof(int) * 4

int main()
{
    ip(n);ip(m);
    if(n<=8 && m<=8)
    {
        cout<<"Yay!";
    }
    else cout<<":(";
return 0;
}








Measured memory_bytes: 256
/*|In The Name Of Allah|*/
//This Month Will Be Expert ISA
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

const int mod = 1e9+7;

int n;
vector < int > A;
vector < int > B;

int getORD(vector < int > tmp){
    vector < int > me;
    for(int i= 1; i <= n; i++){
        me.push_back(i);
    }
    int ord = 1;
    do{
        if(me == tmp)
            return ord;
        ord++;
    }while(next_permutation(me.begin() , me.end()));
    return ord;
}

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        A.push_back(x);
    }
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        B.push_back(x);
    }
    int a = getORD(A);
    int b = getORD(B);
    cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $k);
fscanf(STDIN, "%d %d", $a, $b);

$i = 1;
while (true) {
  $num = $k * $i;


  if ($num >= $a && $num <= $b) {
    echo 'OK';exit;
  }

  if ($num >= 1000) {
    echo 'NG';exit;
  }
  $i++;
}


Measured memory_bytes: 16212
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> A(N);
    ll ans = 0;
    ll m = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i].first >> A[i].second;
    }
    sort(A.begin(), A.end());
    bool flag = false;
    for (int i = 0; i < N; i++)
    {
        while (A[i].second != 0)
        {
            m++;
            ans += A[i].first;
            A[i].second--;
            if (M <= m)
            {
                flag = true;
                break;
            }
        }
        if (flag)
        {
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

double stdev(int *scores, int n)
{
  double mean = 0;
  int i;
  for (i = 0; i < n; i++)
    mean += scores[i];
  mean /= n;
  double variance = 0;
  for (i = 0; i < n; i++)
    variance += pow(scores[i] - mean, 2);
  variance /= n;
  return sqrt(variance);
}
  

int main(void)
{
  int n, i;
  while (1)
    {
      scanf(" %d", &n);
      if (!n)
	return 0;
      int *scores = (int *) malloc(sizeof(int[n]));
      for (i = 0; i < n; i++)
	scanf(" %d", scores + i);
      printf("%lf\n", stdev(scores, n));
    }
  return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <cstdio>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <set>
#include <vector>
using namespace std;
#define ll long long
int main(){

int a,b;
    int n,m,x;
    cin>>n>>m;
    int ans = 1,cnt = 0;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        cnt += x;
        if(cnt <= m){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<iomanip>
#include<stdio.h>
using namespace std;

const double pi = 3.1415926535897932385;

int main()
{
	int direction = 0, distance = 0;
	double x = 0, y = 0, a = 0;
	while (scanf("%d,%d", &distance, &direction)!=EOF)
	{
		if (direction == distance && direction == 0)
		{
			cout << (int)y << '\n' << (int)x << endl;
			x = y = a = 0;
		}
		else
		{
			x += (distance*cos(a));
			y += (distance*sin(a));
			a += (double)direction / 180 * pi;
		}
	}
	return 0;
}


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

cnt = [0]*100001
for c in a:
    cnt[c] += 1

sm = sum(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    sm += (cnt[b]*(c-b))
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(sm)

Measured memory_bytes: 21036
#include<stdio.h>
int main()
{
	int a;
	while(scanf("%d",&a)!=EOF)
	{
		long long int max=0,min=0,sum=0,b[1000000]={0};
		scanf("%lld",&b[0]);
		sum=max=min=b[0];
		int i;
		for(i=1;i<a;i++)
		{
			scanf("%lld",&b[i]);
			if(min>b[i])
			{
				min=b[i];
			}
			if(max<b[i])
			{
				max=b[i];
			}
			sum+=b[i];
		}
		printf("%lld %lld %lld\n",min,max,sum);
	}
	return 0; 
}

Measured memory_bytes: 8420
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	int  matrixALine = scanner.nextInt();
	  	int  matrixARow = scanner.nextInt();
	  	int  matrixBRow = scanner.nextInt();
	  	long[][] arrayA;//配列確保
	  	long[][] arrayB;//配列確保
	  	long[][] arrayC;//配列確保
		arrayA = new long[matrixALine + 10][matrixARow + 10];
		arrayB = new long[matrixARow + 10][matrixBRow + 10];
		arrayC = new long[matrixALine + 10][matrixBRow + 10];
		long sum = 0;
  	
		//初期化
		
		// Aのデータ入力
		for (int i = 0; i < matrixALine; i++) {
			for (int j = 0; j < matrixARow; j++) {
				arrayA[i][j] = scanner.nextInt();
		    }
		}
		// Bのデータ入力
		for (int i = 0; i < matrixARow; i++) {
			for (int j = 0; j < matrixBRow; j++) {
				arrayB[i][j] = scanner.nextInt();
		    }
		}
		
		// Cのデータ作成
		for(int i = 0; i < matrixALine; i ++){
			for(int k  = 0; k <matrixBRow; k ++){
				for(int j = 0; j < matrixARow; j ++){
					sum += arrayA[i][j] * arrayB[j][k];
				}
				arrayC[i][k] = sum;
				sum = 0;
			}
		}
  		
		//出力
		for (int i = 0; i < matrixALine; i++) {
			for (int j = 0; j < matrixBRow; j++) {
		        if(j == (matrixBRow -1) )
					System.out.println(arrayC[i][j] );
		        else
					System.out.print(arrayC[i][j] + " ");
		    }
		}
		scanner.close();
	}
}



Measured memory_bytes: 54264
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<set>
#include<cstring>
#include<climits>
#include<queue>
using namespace std;

static int N, nums;
static map<int, int> hashs;
int main()
{
	while (scanf("%d", &N) != EOF)
	{
		hashs.clear();
		for (int i = 0; i < N; i++)
		{
			scanf("%d", &nums);
			hashs[nums]++;
		}
		long long ans = 0;
		for (auto it = hashs.begin(); it != hashs.end(); ++it)
		{
			if (it->second > it->first) ans += it->second - it->first;
			else if(it->second<it->first) ans += it->second;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4736
unittest
{
	assert( [ "101" ].solve == 4 );
	assert( [ "2" ].solve == -1 );
	assert( [ "999983" ].solve == 999982 );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto k = input.front.to!( long );
	
	auto ans = -1L;
	for( auto i = 0L, r = 0L; i <= k; i++ )
	{
		r = ( r + remainder!10( 7, i, k ) ) % k;
		if( r == 0 )
		{
			ans = 1 + i;
			break;
		}
	}
	return ans;
}

// ( a * B ^^ n ) % m を計算
auto remainder( long B )( long a, long n, long m )
{
	static long[][] memo;
	if( m <= 0 ) return 0L;
	if( memo.length <= m ) memo.length = m + 1;
	if( memo[ m ].length <= n )
	{
		if( memo[ m ].empty ) memo[ m ] = [ 1L % m ];
		auto i = memo[ m ].length.signed - 1;
		memo[ m ].length = n + 1;
		for( ; i < n; i++ )
		{
			memo[ m ][ i + 1 ] = ( memo[ m ][ i ] * B ) % m;
		}
	}
	return ( memo[ m ][ n ] * a ) % m;
}


Measured memory_bytes: 34060
#134

N = int(input())
A_max = 0
A_max_s = 0
flag = 0
A = []

for i in range(N):
    a = int(input())
    A.append(a)
    if a > A_max:
        A_max_s = A_max
        A_max = a
        ind_max = i
        flag = 0
    elif A_max_s < a < A_max:
        A_max_s = a
    elif a == A_max:
        flag += 1
        
if flag >= 1:
    for i in range(N):
        print(A_max)
elif flag == 0:
    for i in range(N):
        if i != ind_max:
            print(A_max)
        else:
            print(A_max_s)

    
    

Measured memory_bytes: 12532
package main

import (
	"fmt"
)

func main() {
	var (
		a, b, c, x, count int
	)

	fmt.Scan(&a, &b, &c, &x)

	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500 * i + 100 * j + 50 * k == x {
					count++
				}
			}
		}
	}

	fmt.Println(count)
}


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

int main()
{
    string s[3];
    REP(i, 3) cin >> s[i];

    int mbr_next;
    int mbr_prev = 0;

    do
    {
        mbr_next = s[mbr_prev].c_str()[0] - 'a';
        s[mbr_prev] = s[mbr_prev].substr(1, s[mbr_prev].size() - 1);
        mbr_prev = mbr_next;
    }
    while(s[mbr_next].size());
    
    if (mbr_next == 0) cout << "A" << endl;
    else if (mbr_next == 1) cout << "B" << endl;
    else cout << "C" << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef set<ll> si;
typedef map<string, ll> msi;
#define hell 1000000007
#define MAX 1000000000
#define max_int 1000000
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define pi 3.1415926536
#define r0 return 0
#define rep(i,a,b) for(ll i = a;i<b;i++)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll sum=0;
    if(a>=k)
    {
        sum+=k;
        cout<<sum;
        r0;
    }
    else
    {
        sum+=a;
        k-=a;
    }

    if(b>=k)
    {
        cout<<sum;
        r0;
    }
    else
    {
        k-=b;
    }
    sum-=k;
    cout<<sum;

    r0;
}
 

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

typedef long long ll;

void bfs(int n, vector<int> adj[], int ans[], bool noanswer){

    queue<int> q;
    q.push(1);
    bool visited[n+1];
    memset(visited, false, sizeof visited);
    visited[1]=true;

    while (!q.empty())
    {

        ll x = q.front();
        q.pop();

        for(auto y: adj[x]){
            if(!visited[y]){
                q.push(y);
                visited[y]=true;
                ans[y] = x;
            }
        }
    }

    for(int i=1; i<=n; i++){
        if(!visited[i]){
            noanswer=true;
            return;
        }
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    
    vector<int> adj[n+1];
    bool noanswer = false;
    int ans[n+1];

    int a, b;
    for(int i=0; i<m; i++){
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    bfs(n,adj, ans, noanswer);

    if(noanswer){
        cout << "No\n";        
    }else
    {
        cout << "Yes\n";
        for(int i=2; i<=n; i++){
            cout << ans[i] << '\n';
        }
    }

    return 0;
}


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

int X[11][11];
int main() {
	int N,D; cin >> N >> 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; i++) {
		for (int j=i+1; j<N; j++) {
			double kyori = 0.0;
			for (int k=0; k<D; k++) {
				kyori += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
			}
			double sqr = floor(sqrt(kyori));
			if (sqr*sqr == kyori) count++;
			
		}
	}
		
	cout << count << endl;
	
	return 0;
}


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

int main()
{
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i += 2)
    {
        if (S[i] == 'L')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = 1; i < S.size(); i += 2)
    {
        if (S[i] == 'R')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> A(N, { 0,0 });
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A[i] = { a, i+1 };
	}
	sort(A.begin(), A.end());
	for (int i = 0; i < N; i++) cout << A[i].second << " ";
	cout << endl;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
int main(){
	int N;
	P A[100000];
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i].first;
		A[i].second = i;
	}
	sort(A, A + N);
	int  cnt0 = 0, cnt1 = 0;
	for(int i = 0; i < N; i++){
		if(i % 2 == 0 && A[i].second % 2 != 0) cnt0++;
		else if(i % 2 == 1 && A[i].second % 2 != 1) cnt1++;
	}
	cout << max(cnt0, cnt1) << endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())

ans = ""

for i in range(1, 15):
    if n <= 26**i:
        # print(n)
        n -= 1
        for j in range(i):
            ans = chr(ord("a") + n % 26) + ans
            # print(ans)
            n //= 26
        break
    else:
        n -= 26**i

print(ans)


Measured memory_bytes: 9060
#include <stdio.h>

int main(){
  int N;
  int arr[100];
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&arr[i]);
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    bool ck=false;
    for(int j=0;j<i;j++){
      if(arr[j]==arr[i]) ck=true;
    }
    if(!ck) cnt++;
  }
  printf("%d",cnt);
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


char c;

int main() {

	cin >> c;
	c += 1;

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printyn(a) printf(a ? "Yes\n" : "No\n");
#define printYN(a) printf(a ? "YES\n" : "NO\n");
#define all(x) (x).begin(), (x).end()

using ll = long long;

#include <stdio.h>
#include <algorithm>
#include <string>
//#include <vector>

using namespace std;


int main() {

	int n;
	char tmp[100];
	string s[100];
	scanf("%d%*d", &n);
	rep(i, n) {
		scanf("%s", tmp);
		s[i] = tmp;
	}
	sort(s, s + n);
	rep(i, n)printf("%s", s[i].c_str());
	printf("\n");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 10000000000
#define pll pair<ll,ll>
#define magic ios_base::sync_with_stdio(false);cin.tie(nullptr)
using namespace std;
#define forn(i,n) for(ll i=1;i<=n;i++)
#define forRn(i,n) for(ll i=n;i>=1;i--)
#define forz(i,n) for(ll i=0;i<n;i++)
#define forRz(i,n) for(ll i=n-1;i>=0;i--)
#define forab(i,a,b) for(ll i=a;i<=b;i++)
#define mod 998244353
#define has 3
ll gcd(ll x,ll y){ return y==0?x:gcd(y,x%y); }
ll lcm(ll x,ll y){ return x/gcd(x,y)*y; }

string le,ri;

int main(void)
{
    magic;
    ll N,sz=0;
    cin>>N;
    ll arr[100005];
    forn(i,N) cin>>arr[i];
    reverse(arr+1,arr+N+1);
    forn(i,N){
        ll p = upper_bound(arr+1,arr+1+sz,arr[i])-arr;
        if(p==sz+1) sz++;
        arr[p] = arr[i];
    }
    cout<<sz;
}


Measured memory_bytes: 1024
n,m,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
b=[0]+list(map(int,input().split()))
for i in range(n):
	a[i+1]+=a[i]
for i in range(m):
	b[i+1]+=b[i]
from bisect import bisect_right
ans=0
for i in range(n+1):
	if k-a[i]>=0:
		r=bisect_right(b,k-a[i])
		ans=max(r+i-1,ans)
print(ans)


Measured memory_bytes: 39968
#include <iostream>
#include <vector>
using namespace std;
#define sz 12000000
vector<int> v[100005];
int tree[sz],lc[sz],rc[sz],root[100005],cn;
void build(int node,int st,int en)
{
	if (st!=en)
	{
		lc[node]=++cn;
		rc[node]=++cn;
		int mid=(st+en)/2;
		build(lc[node],st,mid);
		build(rc[node],mid+1,en);
	}
}
void update(int node,int node2,int st,int en,int idx,int val)
{
	tree[node]=tree[node2];
	if (st==en)
	tree[node]+=val;
	else
	{
		int mid=(st+en)/2;
		if (st<=idx && idx<=mid)
		{
			lc[node]=++cn;
			rc[node]=rc[node2];
			update(lc[node],lc[node2],st,mid,idx,val);
		}
		else
		{
			rc[node]=++cn;
			lc[node]=lc[node2];
			update(rc[node],rc[node2],mid+1,en,idx,val);
		}
		tree[node]=tree[lc[node]]+tree[rc[node]];
	}
}
int query(int node,int st,int en,int l,int r)
{
	if (st>r || en<l || r<l)
	return 0;
	if (l<=st && en<=r)
	return tree[node];
	int mid=(st+en)/2;
	return query(lc[node],st,mid,l,r)+query(rc[node],mid+1,en,l,r);
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	root[0]=++cn;
	build(root[0],0,m);
	for (int i=0;i<n;i++)
	{
		int l,r,tmp=root[0];
		scanf("%d%d",&l,&r);
		root[0]=++cn;
		update(root[0],tmp,0,m,r,1);
		v[l-1].push_back(r);
	}
	for (int i=1;i<=m;i++)
	{
		root[i]=root[i-1];
		for (int r:v[i-1])
		{
			int tmp=root[i];
			root[i]=++cn;
			update(root[i],tmp,0,m,r,-1);
		}
	}
	for (int i=1;i<=m;i++)
	{
		int ans=n;
		for (int j=0;j<=m;j+=i)
		ans-=query(root[j],0,m,j,j+i-1);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 136704
//
// Created by Tetsuya Shiota on 2019-04-13.
//

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(e, o) for (auto &&e : o)
#ifdef LOCAL
#define pp(x) cerr << __LINE__ << ' ' << #x << " = " << (x) << endl
#define dump(x)                                                                \
  cerr << __LINE__ << ' ' << #x << " : ";                                      \
  FOR(e, x) cerr << e << ' ';                                                  \
  cerr << endl;
#else
#define pp(x)
#define dump(x)
#endif

using namespace std;

using Int = long long;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int, Int>;

template <typename T> void reverse(vector<T> &v) {
	reverse(v.begin(), v.end());
}
template <typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T> &v) { sort(v.rbegin(), v.rend()); }
template <typename T> T sum(const vector<T> &v) {
	return accumulate(v.begin(), v.end(), T(0));
}
template <class T> void update_max(T &a, const T &b) { a = max(a, b); }
template <class T> bool update_min(T &a, const T &b) { a = min(a, b); }
vector<pair<char, Int>> merge_cont_char(const string &s) {
	vector<pair<char, Int>> ret;
	if (s.empty())
		return ret;
	ret.push_back(make_pair(s[0], 0));
	FOR(c, s) {
		if (ret.back().first == c)
			ret.back().second++;
		else
			ret.push_back(make_pair(c, 1));
	}
	return ret;
}

class Shakutori {
public:
	// 全体の範囲
	// [0, end)
	// 注目している範囲
	// [tail, head)
	Int head, tail, end = 0;
	bool moveHead() {
		if (head == end) {
			return false;
		}
		head++;
		return true;
	}
	void moveTail() { tail++; }
	bool valid() {
		if (head == tail)
			return true;
		// [tail, head)
		// が解として適当か検証する
		return true;
	}
	void solve() {
		head = tail = 0;
		Int ans = 0;
		while (moveHead()) {
			while (!valid()) {
				moveTail();
			}
			// ここで解を更新する
		}
	}
};

class Solver {
public:
	Int N, ans;
	string s;
	Solver() {}
	void input() {
		cin >> N;
		cin >> s;
	}
	void solve() {
		Int b, w;
		b = w = 0;
		FOR(c, s) {
			if (c == '#')b++;
			else w++;
		}
		Int nowB, nowW;
		nowB = nowW = 0;
		ans = N;

		ans = w;
		FOR(c, s) {
			if (c == '#')nowB++;
			else nowW++;

			update_min(ans, nowB + w - nowW);
		}
	}
	void output() { cout << ans << endl; }
};

void initilization() {
	struct BoolName : numpunct<char> {
		string t, f;
		BoolName(string t = "Yes", string f = "No") : t(t), f(f) {}
		string do_truename() const { return t; }
		string do_falsename() const { return f; }
	};
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(15) << boolalpha;
	cout.imbue(locale(cout.getloc(), new BoolName));
}

int main() {
#ifdef LOCAL
	while (1) {
		Solver s;
		s.input();
		if (cin.eof())
			break;
		s.solve();
		s.output();
	}
#else
	Solver s;
	s.input();
	s.solve();
	s.output();
#endif
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>

using namespace std;
long long cnt=0;
void insertionSort(int numbers[],int n,int g)
{
    for(int i=g;i<n;i++)
    {
        int v=numbers[i];
        int j=i-g;
        while(j>=0&&numbers[j]>v)
        {
            numbers[j+g]=numbers[j];
            j=j-g;
            cnt++;
        }
        numbers[j+g]=v;
    }
}
void shellSort(int numbers[],int n)
{
   // int m=2;
   //生成数列G int G[2]={4,1}
   vector<int> G;
   for(int i=1;i<=n;)
   {
       G.push_back(i);
       i=i*3+1;
   }
    for(int i=G.size()-1;i>=0;i--)
    {

        insertionSort(numbers,n,G[i]);
    }
    cout<<G.size()<<endl;
   for(int i=G.size()-1;i>0;i--)
   {
       cout<<G[i]<<" ";
   }
   cout<<G[0];
   cout<<endl;
}
int main()
{
    int n;
    cin>>n;
    int numbers[1000000];

    for(int i=0;i<n;i++)
    {
        cin>>numbers[i];
    }

    shellSort(numbers,n);
    cout<<cnt<<endl;
    for(int i=0;i<n;i++)
    {
        cout<<numbers[i]<<endl;
    }
}





Measured memory_bytes: 7064
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int a,b,x;
    cin>>x>>a>>b;
    if(b<=a)cout<<"delicious";
    else if(b<=a+x)cout<<"safe";
    else cout<<"dangerous";
	return 0;
}


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

int main(void) {
    vector<int> numList(3);
    int i = 0;
    while (i < 3) {
        cin >> numList[i];
        i++;
    }
    sort(numList.begin(), numList.end(), greater<int>());
    int answer = numList[0] * 10 + numList[1] + numList[2];
    cout << answer << endl;
}

Measured memory_bytes: 3572
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{

    int a, p;

    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');
        a = int.Parse(input[0]);
        p = int.Parse(input[1]);
        p += a * 3;


        Console.WriteLine(p / 2);
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


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

int T[222];
double V[222];
double M[44444];

int main(){
  int N; cin>>N;
  rep(i,44444) M[i]=101;
  rep(i,N) cin>>T[i];
  rep(i,N) cin>>V[i];
  
  int sum=0;
  rep(i,N){
    T[i]*=2;
    for(int j=sum;j<=sum+T[i];j++){
      M[j]=min(M[j],V[i]);
    }
    sum+=T[i];
  }
  M[0]=M[sum]=0;
  rep(j,sum) M[j+1]=min(M[j+1],M[j]+0.5);
  for(int j=sum-1;j>=0;j--) M[j]=min(M[j],M[j+1]+0.5);

  double ans=0;
  rep(i,sum) ans+=(M[i]+M[i+1]);
  cout<<setprecision(15);
  cout<<ans/4<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <string>
#include <map>
#include <list>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define LargeNum 1000000007

int main(){
    int N, K, tmp, count = 0;
    cin >> N >> K;
    int Sun[N];
    int d[K];
    rep(i, N) Sun[i] = 0;
    rep(i, K){
        cin >> d[i];
        rep(j, d[i]){
            cin >> tmp;
            Sun[tmp-1] = 1;
        }
    }
    rep(i, N) if (Sun[i] == 0) count++;
    cout << count << endl;
    return 0;
}


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

using namespace std;
#define rep(x, n)          for (int x = 0; x < n; x++)
#define REP(x, a, b)       for (int x = a; x <= b; x++)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define dmp(...) 0
#endif
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin>>k;
    string s;
    cin>>s; 
    if(sz(s)<=k)
        cout<<s<<'\n';
    else{
        cout<<s.substr(0,k)<<"...\n";
    }
    return 0;
}

Measured memory_bytes: 3648
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int, int> > py(m);
    rep(i, m) {
        cin >> get<0>(py[i]) >> get<1>(py[i]);
        get<2>(py[i]) = i;
    } 

    sort(py.begin(), py.end());

    int j=1;
    rep(i, m) {
        get<3>(py[i]) = j;
        if(i!=m-1 && get<0>(py[i]) == get<0>(py[i+1])) {
            ++j;
        } else {
            j=1;
        }
    }

    rep(i, m) {
        swap(get<2>(py[i]), get<0>(py[i]));
    }
    sort(py.begin(), py.end());

    rep(i, m) {
        printf("%06d%06d\n", get<2>(py[i]), get<3>(py[i]));
    }
}

Measured memory_bytes: 3072
from collections import Counter

from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()

count=Counter(a)
ans=0
for k,v in count.items():
  ans+=k*v

q=int(input())
for i in range(q):
  b,c=nii()

  b_cnt=count[b]

  if b_cnt!=0:
    count[b]=0
    if c in count:
      count[c]+=b_cnt
    else:
        count[c]=b_cnt

  t_ans=ans-(b*b_cnt)+(c*b_cnt)
  ans=t_ans
  print(t_ans)

Measured memory_bytes: 21292
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int i,j,k,m,n,w,h;
    int ansx,ansy;
    cin>>w>>h>>n;
    int x,y,a;
    int shang=h,xia=0,zuo=0,you=w;
    for(i=1; i<=n; i++)
    {
        cin>>x>>y>>a;
        
        if(a==1)
            zuo=max(x,zuo);
        if(a==2)
            you=min(x,you);
        if(a==3)
            xia=max(y,xia);
        if(a==4)
            shang=min(y,shang);
    }
    if((you-zuo)<0||(shang-xia)<0)
    {
        cout<<0<<endl;
        return 0;
    }
    cout<<(you-zuo)*(shang-xia)<<endl;
    return 0;
}



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

using namespace std;
using ll=long long;

int countDigits(ll N)
{
    int digits = 0;
    
    while (N > 0)
    {
        N /= 10;
        digits++;
    }
    
    return digits;
}

int main()
{
    ll N;
    cin >> N;
    
    auto answer = countDigits(N);
    
    for (ll A = 1LL; A*A <= N; ++A)
    {
        if (N % A != 0)
        {
            continue;
        }
        const ll B = N / A;
        
        const int current = max( countDigits(A), countDigits(B) );
        
        if (answer > current)
        {
            answer = current;
        }
    }
    
    printf("%d\n", answer);
    
    return 0;
}


Measured memory_bytes: 256
int_s = gets.to_i
s_arr = gets.split(" ").map(&:to_i).uniq.sort!
int_t = gets.to_i
t_arr = gets.split(" ").map(&:to_i).uniq.sort!
sum = 0

s_arr.each do |val|
  left = 0
  right = t_arr.count

  while left < right
    mid = (left + right) / 2

    if t_arr[mid] == val
      sum += 1
      break
    elsif t_arr[mid] < val
      left = mid + 1
    else
      right = mid
    end
  end
end

puts sum

Measured memory_bytes: 19136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false);
	int n;
	ll a[20000], b[20000];
	cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
		if(b[i]>=a[i]){
			sum+=(((b[i]-a[i])/2)*2);
		}
		else{
			sum-=(2*(a[i]-b[i]));
		}
	}
	if(sum>=0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define ok return 0;
#define MOAE                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
map<int, int> vis;
set<ll> s;
int main()
{
    MOAE;
    int n, k;
    cin >> n >> k;
    int K = k;
    int vis[n + 1];
    memset(vis, 0, sizeof(vis));
    while (K--)
    {
        int d;
        cin >> d;
        while (d--)
        {
            int a;
            cin >> a;
            vis[a]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (vis[i] == 0)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3664
n=int(input())
n4=n
n7=n
ans=0

while(1):
    if n4%4==0 or n7%7==0:
        ans=1
        break
    else:
        if n4>7:
            n4-=7
        if n7>4:
            n7-=4
    if n4<=7 and n7<=4:
        break

if ans==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
template<class T>inline int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
pair<pair<string,int>,int>A[105];
signed main(){
	cin>>N;
	rep(i,N){
		cin>>A[i].first.first>>A[i].first.second;
		A[i].first.second*=-1;
		A[i].second=i;
	}
	sort(A,A+N);
	rep(i,N)cout<<A[i].second+1<<"\n";
}


Measured memory_bytes: 3568
n = int(input())
S = [input() for i in range(n)]
check = set()

for i in S:
    for j in i:
        check.add(j)

check = sorted(check)
num_list = []
for i in check:
    num = float('inf')
    for j in S:
        num = min(num, j.count(i))
    num_list.append(num)

ans = [check[i] * num_list[i] for i in range(len(check))]

print(''.join(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define PB push_back

int main()
{
	int n, r;
	while (scanf("%d %d", &n, &r), n + r){
		vector<int> a;
		for (int i = n; i >= 1; i--){
			a.PB(i);
		}
		for (int i = 0; i < r; i++){
			int p, c;
			scanf("%d %d", &p, &c);
			vector<int> b;
			for (int i = p - 1; i < p + c - 1; i++){
				b.PB(a[i]);
			}
			for (int i = 0; i < p - 1; i++){
				b.PB(a[i]);
			}
			for (int i = p + c - 1; i < n; i++){
				b.PB(a[i]);
			}
			a = b;
		}
		printf("%d\n", a[0]);
	}
	
	return 0;
}

Measured memory_bytes: 1212
// ABC 157-E
// 2020.3.1 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	do *s = gc();
	while (*s++ > ' ');
	*(s-1) = 0;
}

void out(int n) { // 非負整数の表示（出力）
	int i; char b[30];

	if (!n) pc('0');
	else {
		//		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

#define MAX 500005
char S[MAX];
int a[26][MAX], sz[26];

// 見つからなければ、一つ大きい要素を返す。つまり、 >= x
int lower_bound(int id, int x) {
	int m, l = 0, r = sz[id];
    while (l < r) {
        m = (l+r) >> 1;
        if (a[id][m] < x) l = m + 1; else r = m;
    }
	return l;
}

void erase(int id, int x) {
	if (a[id][sz[id]-1] == x) sz[id]--;
	else {
		int l = lower_bound(id, x);
		memmove(a[id]+l, a[id]+l+1, (--sz[id]-l)*sizeof(int));
	}
}

void update(int id, int x) {
	if (sz[id] == 0 || a[id][sz[id]-1] < x) {
		a[id][sz[id]++] = x;
	} else {
		int l = lower_bound(id, x);
		memmove(a[id]+l+1, a[id]+l, (sz[id]++ -l)*sizeof(int));
		a[id][l] = x;
	}
}

int main()
{
	int i, id, l, r, N, Q;

	N = in(), ins(S);
	for (i = 0; i < N; ++i) {
		id = S[i] - 'a';
		a[id][sz[id]++] = i;
	}

	Q = in(); while (Q--) {
		id = (gc() == '1'), gc();
		if (id) {
			l = in()-1;
			int c = gc(); gc();
			if (S[l] != c) {
				erase(S[l]-'a', l);
				S[l] = c;
				update(c-'a', l);
			}
		} else {
			l = in()-1, r = in()-1;
			int ans = 0;
			for (i = 0; i < 26; ++i) {
				if (sz[i] && a[i][sz[i]-1] >= l) {
					int t = a[i][lower_bound(i, l)];
					ans += (t <= r);
				}
			}
			out(ans);
		}
	}
	return 0;
}


Measured memory_bytes: 49920
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    while (cin >> n, n) {
        int g[10][10];
        for (int i = 0; i < 10; i++) {
            fill(g[i], g[i]+10, 1010001000);
        }
        for (int i = 0; i < n; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            g[a][b] = c;
            g[b][a] = c;
        }
        for (int k = 0; k < 10; k++) {
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    g[i][j] = min(g[i][j], 
                            g[i][k] + g[k][j]);
                }
            }
        }
        int ans = 0, max = 1010001000;
        for (int i = 0; i < 10; i++) {
            int sum = 0;
            bool fl = false;
            for (int j = 0; j < 10; j++) {
                if (i == j) {
                    continue;
                }
                if (g[i][j] != 1010001000) {
                    fl = true;
                    sum += g[i][j];
                }
            }
            if (fl && max > sum) {
                max = sum;
                ans = i;
            }
        }
        cout << ans << " " << max << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
#include "bits/stdc++.h"

int main() {

    int N, A, B, C, D;
    std::cin >> N >> A >> B >> C >> D;
    std::string S;
    std::cin >> S;
    bool ans = true;
    bool swappable = false;
    int rock = 0;
    int none = 0;
    int bigger = std::max(C, D);
    for (int i = 0; i < N; ++i) {
        if (S[i] == '#') {
            none = 0;
            if (++rock > 1 && A - 1 < i && i < bigger)ans = false;
        }
        else {
            rock = 0;
            if (B - 2 <= i && i < D + 1)
                if (++none >= 3)swappable = true;
        }
    }
    if (D < C && ans)ans = swappable;
    std::cout << (ans ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 640
N = int(input())
AC, WA, TLE, RE = 0,0,0,0
for i in range(N):
	S = input()
	if S == "AC":
		AC += 1
	elif S == "WA":
		WA += 1
	elif S == "TLE":
		TLE += 1
	elif S == "RE":
		RE += 1
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 9204
x = int(input())
if x>=1800:
  y = 1
elif x>=1600:
  y = 2
elif x>=1400:
  y = 3
elif x>=1200:
  y = 4
elif x>=1000:
  y = 5
elif x>=800:
  y = 6
elif x>=600:
  y = 7
else:
  y = 8
print(y)


Measured memory_bytes: 61496
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
cnt = 0
for i,a in enumerate(A):
    if a<0:
        cnt += 1
        A[i] = -1*a
A = sorted(A)
print(sum(A)-2*A[0]*(cnt%2))

Measured memory_bytes: 20124
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;

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

  set<string> ss;
  rep(i, 0, s.size()) repe(j, 1, K) ss.insert(s.substr(i, j));

  vector<string> v;
  for (auto x : ss) v.push_back(x);
  sort(v.begin(), v.end());

  cout << v[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int main() {
    int a, b;
    cin >> a >> b;
    if (a != b) cout << max(a, b) + max(a - 1, b - 1) << endl;
    else cout << a + b << endl;
}

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

int N, K;
vector<vector<int> > tree;

// 頂点 v を根として、p のある側は切り落としてできる部分木について
// v から各頂点への距離を depth に格納する
// (特に p = -1 のときは、ツリー全体について v を根とすることを表す)
void rec(int v, int p, vector<int> &depth) {
    if (p != -1) depth[v] = depth[p] + 1;
    for (auto nv : tree[v]) {
        if (nv == p) continue;
        rec(nv, v, depth);
    }
}

int main() {
    cin >> N >> K;
    tree.assign(N, vector<int>());
    for (int i = 0; i < N-1; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    int res = N; // INF の気持ち
    vector<int> depth(N);

    if (K % 2 == 0) {
        for (int v = 0; v < N; ++v) {
            depth[v] = 0;
            rec(v, -1, depth);
            int num = 0;
            for (int i = 0; i < N; ++i) if (depth[i] > K/2) ++num;
            res = min(res, num);
        }
    }
    else {
        for (int u = 0; u < N; ++u) {
            for (auto v : tree[u]) {
                int num = 0;

                // u
                depth.assign(N, -1);
                depth[u] = 0;
                rec(u, v, depth);
                for (int i = 0; i < N; ++i) if (depth[i] > K/2) ++num;

                // v
                depth.assign(N, -1);
                depth[v] = 0;
                rec(v, u, depth);
                for (int i = 0; i < N; ++i) if (depth[i] > K/2) ++num;
                
                res = min(res, num);
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 512