akhauriyash/Code-Regression huggingface dataset:
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n=int(input())
x=list(map(int,input().split()))
y=sorted(x)
l=y[n//2 -1]
r=y[n//2]
for i in range(n):
    if x[i]<=l:
        print(r)
    else:
        print(l)

Measured memory_bytes: 25220
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int L[] = new int[N];
        for (int i = 0; i < N; i++)
            L[i] = scan.nextInt();

        Arrays.sort(L);

        long ans = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                for (int k = j+1; k < N; k++) {
                    if (L[i] != L[j] && L[i] != L[k] && L[j] != L[k]) {
                        if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[k] + L[j] > L[i]) {
                            ans++;
                        }
                    }
                }
            }
        }
        os.println(ans);
    }
}

Measured memory_bytes: 27708
#include<stdio.h>

int main()
{
	int N,n,d,p[201][2],i,j,my[4]={0,1,0,-1},mx[4]={-1,0,1,0},min[2],max[2];
	for(;scanf("%d",&N),N;)
	{
		p[0][0]=p[0][1]=0;
		min[0]=min[1]=10000000;
		max[0]=max[1]=-10000000;
		for(i=1;i<N;i++)
		{
			scanf("%d%d",&n,&d);
			p[i][0]=p[n][0]+my[d];
			p[i][1]=p[n][1]+mx[d];
		}
		for(i=0;i<N;i++)
			for(j=0;j<2;j++)
			{
				if(min[j]>p[i][j])min[j]=p[i][j];
				if(max[j]<p[i][j])max[j]=p[i][j];
			}
		printf("%d %d\n",max[1]-min[1]+1,max[0]-min[0]+1);
	}
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  string s;
  ll k;
  cin >> s >> k;
  ll count = 0;
  rep(i,(int)s.size()){
    if(i == (int)s.size()-1){
      cout << char(((s[i]-'a')+(k-count))%26+'a') << endl;
      break;
    }
    if('z'-s[i]+1 + count <= k && s[i] != 'a'){
      count += 'z'-s[i]+1;
      cout << "a";
    }else{
      cout << s[i];
    }
  }
	return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(3*n);
    cins(all(a));
    RSORT(a);
    ll cnt = 0;
    rep(i,n){
        cnt += a[i*2+1];
    }
    PRINT(cnt);
}




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

using namespace std;

const int N = 1e5 + 50;
const int INF = 0x3f3f3f3f;

int n;
int arr[N];
int dp[N];

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

    for(int i = 0; i < n; ++i)
        scanf("%d", arr + i);
}

void solve() {
    dp[0] = 0;
    dp[1] = dp[0] + abs(arr[0] - arr[1]);

    for(int i = 2; i < n; ++i)
        dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));

    printf("%d", dp[n - 1]);
}

int main() {
    memset(dp, INF, sizeof dp);

    load();
    solve();

    return 0;
}


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

int N, ans = 0;

void DFS(string s) {
    if(s.size()==10){
	return;
    }
    int tmp = stoi(s);
    if(tmp <= N){
	bool three=false, five=false, seven=false;
	for(int i=0; i<s.size(); i++){
	    if(s[i]=='3')
		three=true;
	    else if(s[i]=='5')
		five=true;
	    else if(s[i]=='7')
		seven=true;
	}
	if(three && five && seven)
	    ans++;
    }
    DFS(s+"3");
    DFS(s+"5");
    DFS(s+"7");
}

int main(){
    cin >> N;
    DFS("3");
    DFS("5");
    DFS("7");			    
    cout << ans << endl;
}




Measured memory_bytes: 256
#include<stdio.h>
int main (void){
 int a,b,n,i,j;

while(scanf("%d",&a) != EOF){

 scanf("%d",&b);
 n=a+b;i=1;
 while(9<n){
  n/=10;i++;
 }
printf("%d\n",i);
}

return 0;
}

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

using namespace std;

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

	string S;
	cin >> S;

	if(S.length() <= K) {
		cout << S << endl;
	} else {
		cout << S.substr(0, K) << "..." << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);

    int c[50][26] = {};
    for (int i = 0; i < n; ++i) {
        char s[51];
        scanf("%s", s);
        for (int j = 0; s[j] != '\0'; ++j)
            c[i][s[j] - 'a'] += 1;
    }

    for (int i = 0; i < 26; ++i) {
        int mi = 10000000;
        for (int j = 0; j < n; ++j)
            mi = min(mi, c[j][i]);
        for (int j = 0; j < mi; ++j)
            printf("%c", i + 'a');
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define eps 1e-8

auto sqd = [&](auto a, auto b, auto c, auto d) {
    return (a - c) * (a - c) + (b - d) * (b - d);
};

auto dist = [&](auto a, auto b, auto c, auto d) {
    return sqrt(sqd(a, b, c, d));
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    double x[n], y[n], c[n];
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> c[i];

    auto is1 = [&x, &y](int i, int j, double r1, double r2) {
        double dx = x[j] - x[i], dy = y[j] - y[i];
        double a = dx * dx + dy * dy + r1 * r1 - r2 * r2;
        a /= 2;
        double sq = dx * dx + dy * dy;
        double q = sq * r1 * r1 - a * a;
        if (q < 0) q = 0;
        double xx = a * dx + dy * sqrt(q);
        double yy = a * dy - dx * sqrt(q);
        return make_pair(xx / sq + x[i], yy / sq + y[i]);
    };

    auto is2 = [&x, &y](int i, int j, double r1, double r2) {
        double dx = x[j] - x[i], dy = y[j] - y[i];
        double a = dx * dx + dy * dy + r1 * r1 - r2 * r2;
        a /= 2;
        double sq = dx * dx + dy * dy;
        double q = sq * r1 * r1 - a * a;
        if (q < 0) q = 0;
        double xx = a * dx - dy * sqrt(q);
        double yy = a * dy + dx * sqrt(q);
        return make_pair(xx / sq + x[i], yy / sq + y[i]);
    };

    auto judge = [&x, &y, &c, &is1, &is2](double t, int n, int k) {
        vector<pair<double, double>> is;
        for (int i = 0; i < n; i++) {
            is.emplace_back(x[i], y[i]);
            for (int j = i+1; j < n; j++) {
                double id = t / c[i];
                double jd = t / c[j];
                if ((id + jd) < dist(x[i], y[i], x[j], y[j])) continue;
                is.push_back(is1(i, j, id, jd));
                is.push_back(is2(i, j, id, jd));
            }
        }
        bool ok = false;
        for (auto &p: is) {
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if (dist(p.first, p.second, x[i], y[i]) * c[i] <= t + eps) cnt++;
            }
            ok |= (k <= cnt);
        }
        return ok;
    };
    double lf = 0, rg = 1e9;
    for (int c = 0; c < 100; c++) {
        double mid = (lf + rg) / 2;
        if (judge(mid, n, k)) rg = mid;
        else lf = mid;
    }
    printf("%.12f\n", rg);
    return 0;
}

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

$pittari = $N %500;
$haraeru = $pittari - $A;

if($pittari == 0 || $haraeru < 0) {
    echo "Yes";
} else {
    echo "No";
}

?>

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll long long
#define MOD 1000000007
#define pll             pair<ll,ll>
#define pii             pair<int,int> 
#define mp(a,b)         make_pair(a,b)
#define pb 				push_back
#define vi				vector<int>
#define vl 				vector<long long>
#define vb 				vector<bool>
#define printv(v)		for(auto x : v) cout<<x<<' ';br;
#define FOR(i,a,b) 		for(ll i = a; i <= b ; i++)
#define forn(i,n) 		for(ll i = 0 ; i < n; i++)
#define br 				cout<<endl;
#define testc()			ll t;cin>>t;while(t--)
 
#define fast 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define INF				INT_MAX
#define INFL			LLONG_MAX
#define max1(x,y) (x)>(y)?(x):(y)
#define ss second
#define ff first
#define MAXN 100001

int main(){
    fast
    ll n;
    cin>>n;
    long double p[n+1]={0};
    p[0]=1;
    FOR(i,1,n){
        long double pr;
        cin>>pr;
        for(ll j=i;j>=0;j--){
            if(j==0)
            p[j]=p[j]*(1-pr);
            else
            p[j]=p[j-1]*pr+p[j]*(1.00-pr);
        }
        // forn(i,n+1){
        //     cout<<p[i]<<" ";
        // }
        // cout<<endl;
    }
    long double ans=0;
    for(ll i=n/2+1;i<=n;i++){
        ans+=p[i];
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

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

void dfs(vector<vector<int>> &es, vector<long long> &cnt, int par, int i) {
    for(size_t j = 0; j < es[i].size(); ++j) {
        int dst = es[i][j];
        if(dst == par) continue;
        cnt[dst] += cnt[i];
        dfs(es, cnt, i, dst);
    }
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> es(N);
    int a, b, p, x;
    vector<long long> cnt(N);
    for(int i = 0; i < N-1; ++i) {
        cin >> a >> b;
        --a; --b;
        es[a].push_back(b);
        es[b].push_back(a);
    }
    for(int i = 0; i < Q; ++i) {
        cin >> p >> x;
        --p;
        cnt[p] += x;
    }

    dfs(es, cnt, -1, 0);
    for(int i = 0; i < N; ++i) cout << cnt[i] << " ";
    cout << endl;

    return 0;
}

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

int main(void){
  int r, d, x;
  cin >> r >> d >> x;
  for(int i = 0; i < 10; i++){
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int d = sc.nextInt();
		String s = "Christmas";
		
		for(int i = d; i < 25; i++)
			s += " Eve";
		
		System.out.println(s);
	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


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

int main(){

  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;

  int ans = 2*n;
  for(int i=0; i<s.size(); i++){
    if( s[i] == t[0] ){
      int tmp = 0;
      bool f = true;
      for(int j=0; j<t.size()-i; j++){
        if( s[i+j] != t[j] ){
          f = false;
          break;
        }
        tmp++;
      }
      if( f && ans > 2*n - tmp) ans = 2*n - tmp;

    }
    // cerr << ans << endl;
  }

  cout << ans << endl;

  return 0;
}




// EOF


Measured memory_bytes: 256
def combi(num_str)
  if num_str.size >= 2
    (1..num_str.size - 1).each do |n|
      num1 = num_str[0, n].to_i
      num2 = num_str[n..num_str.size]
      combi(num2) do |c|
        yield num1 + c
      end
    end
  end
  yield num_str.to_i
end

S = gets.chomp

sum = 0
combi(S) do |result|
  sum += result
end

puts sum


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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m,k;
    cin>>n>>k;
    long double ans=0;
    long double nn=n;
    for(i=1;i<=n;i++)
    {
        if(i>=k)
        ans+=1.0;
        else
        {
            long double temp=1.0;
            ll cnt=i;
            while(cnt<k)
            {
                cnt*=2;
                temp=temp/2.0;
            }
            ans+=temp;
        }
    }
    cout<<setprecision(10)<<fixed<<ans/nn;
    return 0;
}

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

def main():
    n, m = map(int, input().split())
    guess = [-1] * n
    ans = 0

    for i in range(m):
        # print(guess)
        s, c = map(int, input().split())
        # print('s:{}, c:{}'.format(s, c))
        if guess[s-1] == -1:
            guess[s-1] = c
        else:
            if guess[s-1] != c:
                return -1

    # print('guess:{}'.format(guess))

    # 1桁の場合、先頭が0 もしくは指定なしなら ans = 0
    # 2桁以上の場合、先頭に0がついている場合、ans = -1。先頭が指定なしの場合 1を設定する
    if n == 1:
        if guess[0] > 0: return guess[0]
        else: return 0
    else:
        if guess[0] == 0:
            return -1
        elif guess[0] != -1:
            ans = guess[0]
        else:
            ans = 1

    for i in range(1, n):
        # print('ans:{}'.format(ans))
        if guess[i] != -1:
            ans = ans * 10 + guess[i]
        else:
            ans = ans * 10

    # print('ans:{}'.format(ans))
    return ans

if __name__ == "__main__":
    ans = main()
    print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    pair<int, int> p1, p2, p3, p4;
    cin >> p1.first >> p1.second >> p2.first >> p2.second;
    pair<int, int> v12, v23, v34;
    v12.first = p2.first - p1.first;
    v12.second = p2.second - p1.second;

    v23.first = -v12.second;
    v23.second = v12.first;
    
    v34.first = -v23.second;
    v34.second = v23.first;
    
    p3.first = p2.first + v23.first;
    p3.second = p2.second + v23.second;

    p4.first = p3.first + v34.first;
    p4.second = p3.second + v34.second;
    
    cout << p3.first << " " << p3.second << " " << p4.first << " " << p4.second;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int,int> PII;
typedef pair <ll, ll> PLL;
typedef pair <int,string> PIS;
typedef vector <int> vec;
typedef priority_queue<int> PQ;
#define endl '\n'
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fori(z,n)  for(int i=z;i<n;i++)
#define fork(z,n)  for(int k=z;k<n;k++)
#define forii(z,n) for(int i=z;i<=n;i++)
#define forkk(z,n) for(int k=z;k<=n;k++)
int maxElement(int arr[],int n)
{
    int maxi=arr[0];
    for(int i=1;i<n;i++)
    {
        if(arr[i]>maxi)
            maxi=arr[i];
    }
    return maxi;
}
int minElement(int arr[],int n)
{
    int mini=arr[0];
    for(int i=1;i<n;i++)
    {
        if(arr[i]<mini)
            mini=arr[i];
    }
    return mini;
}
string trim(const string& str)
{
    size_t first = str.find_first_not_of(' ');
    if (string::npos == first)
    {
        return str;
    }
    int last = str.find_last_not_of(' ');
    return str.substr(first, (last - first + 1));
}

const int mod = 1e9 + 7;

int main() 
{ 
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;cin>>n;
    vector<vector<int>> v(n,vector<int>(n));
    for(int i=0;i<n;i++)
        fork(0,n)
            cin>>v[i][k];
    int max_len = 1<<n;
    int dp[max_len];
    memset(dp, 0, sizeof(dp));
    dp[0]=1;
    for(int mask=0;mask<max_len-1;mask++)
    {
        int x = __builtin_popcount(mask);
        for(int i=0;i<n;i++)
        {
            if(!(mask & (1<<i)) && v[x][i])
            {
                int m2 = mask | (1<<i);
                dp[m2] = ((dp[m2] % mod) + (dp[mask]%mod))%mod;
            }
        }
    }
    cout<<dp[max_len-1]<<endl;
    cerr<<"Time elapsed"<<1.0*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}


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

int main()
{
	long int a[100001], x, i, k = 0, n;
	scanf("%ld %ld", &n, &x);

	for (i = 0; i < n; i++)
	{
		scanf("%ld", &a[i]);
		

	}
	if (a[0] > x)
	{
		k = k + (a[0] - x);
		a[0] = x;
	}

	for (i = 0; i < (n - 1); i++)
	{
		if ((a[i] + a[i + 1]) > x)
			{
				k = k + (a[i] + a[i + 1] - x);
				a[i + 1] = a[i + 1] - (a[i] + a[i + 1] - x);
			}

	}


	printf("%ld", k);

	return 0;

}

Measured memory_bytes: 896
#pragma target("avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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


Measured memory_bytes: 256
#!/usr/bin/env python3
x = int(input())
cnt = 0
cnt += x // (6 + 5) * 2
x %= (6 + 5)
if x >= 1:
    cnt += 1
    x -= 6
    if x >= 1:
        cnt += 1
        x -= 5
assert - 5 <= x <= 0
print(cnt)


Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
   int n,x,y,z;
    scanf("%d",&n);
    if(n>=1 && n<=10000)
    {
     if(n%1000==0)  
     {printf("0");}
     else
     {x=n/1000;
      y=(x+1)*1000;
      z=y-n;
      printf("%d\n",z);      
      }      
       }
return 0;     
    
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

int main()
{
  int n;
  string s;
  vector<int> s_count(4, 0);

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> s;
    if (s == "AC")
      s_count[0]++;
    else if (s == "WA")
      s_count[1]++;
    else if (s == "TLE")
      s_count[2]++;
    else if (s == "RE")
      s_count[3]++;
  }
  cout << "AC x " << s_count[0] << endl;
  cout << "WA x " << s_count[1] << endl;
  cout << "TLE x " << s_count[2] << endl;
  cout << "RE x " << s_count[3] << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> H(N+1);
  H.at(0) = 0;
  for(int i=1;i<=N;i++){cin >> H.at(i);}
  
  int ans = 0;
  int count = 0;
  for(int i=1;i<=N;i++){
    if(H.at(i)<=H.at(i-1)){
      count++; 
      if(count>ans){ans = count;}}
    
    else{count = 0;}
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3764
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int basePrice=sc.nextInt();
		int topPrice=sc.nextInt();
		int sumCal=sc.nextInt();
		int[] topCal=new int[n];
		int tmp=sumCal/basePrice;
		int next,cnt=0;
		for(int i=0;i<n;i++){
			topCal[i]=sc.nextInt();
		}
		java.util.Arrays.sort(topCal);
		for(int i=n-1;i>=0;i--){
			cnt++;
			sumCal+=topCal[i];
			next=sumCal/(cnt*topPrice+basePrice);
			if(tmp>next){
				break;
			}
			tmp=next;
		}
		System.out.println(tmp);
	}
}

Measured memory_bytes: 18264
s = input()
s = s[::-1]
n = len(s)
m = [0] * 2019
m[0] = 1
a = 0
d = 1
for i in range(n):
    a = (a + int(s[i]) * d) % 2019
    d = (d * 10) % 2019
    m[a] += 1
print(sum([int(x * (x - 1) / 2) for x in m if x > 1]))


Measured memory_bytes: 9352
#include<stdio.h>
int main(void){
	int i;
	
	
	int n;
	scanf("%d",&n);
	
	int d=100000;
	
	for(i=0;i<n;i++){
		d+=d/20;
		
		if(d%1000!=0){
			d=d/1000*1000+1000;
		}
	}
	
	printf("%d\n",d);
	
	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    ll e;
    while(1){
        cin>>e;
        if(e==0) break;
        ll x,y,z;
        ll min=inf;
        for(int i = 0;i < 101; i++){
            for(int j = 0;j < 1001; j++){
                int k=e-i*i*i-j*j;
                if((i>=0 && j>=0 && k>=0) && (i+j+k<min)) min=i+j+k;
            }
        }
        cout<<min<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using vpii = vector<pii>;

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

  int n = S.size() + 1;
  vvl dp(n, vl(13, 0));
  long MOD = 1000000007;
  dp[0][0] = 1;

  rep(i, n - 1){
    int c;
    if(S[i] == '?')
      c = -1;
    else
      c = S[i] - '0';

    rep(j, 10){
      if(c != -1 && c != j)
	continue;
      
      rep(k, 13)
	dp[i + 1][(10 * k + j) % 13] += dp[i][k];
    }
    rep(j, 13)
      dp[i + 1][j] %= MOD;
  }

  cout << dp[n - 1][5] << endl;
  
  return 0;
}

Measured memory_bytes: 13696
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template<typename T> using Graph = vector<vector<T>>;
template<typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template<typename T> struct is_pair : false_type{};
template<typename T1, typename T2> struct is_pair<pair<T1, T2>> : true_type{};
template<typename T> struct is_vector : false_type{};
template<typename T> struct is_vector<vector<T>> : true_type{};

template<typename T1, typename T2>
istream &operator >> (istream &istr, pair<T1, T2> &p) {
  istr >> p.first >> p.second;
  return istr;
} 
template<typename T1, typename T2>
ostream &operator << (ostream &ostr, const pair<T1, T2> &p) {
  ostr << p.first << " " << p.second;
  return ostr;
}
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) return ostr;
  bool vp = is_vector<T>() || is_pair<T>();
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    ostr << (vp ? "\n" : " ") << *itr;
  }
  return ostr;
}

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); }

int modpow(int a, long long n, int mod = MOD) {
  int ret = 1;
  do {
    if (n & 1) ret = 1LL * ret * a % mod;
    a = 1LL * a * a % mod;
  } while (n >>= 1);
  return ret;
}

template<typename T>
T GCD(T a, T b) { return b ? GCD(b, a%b) : a; }
template<typename T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

template<typename T1, typename T2>
bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) {
  return a.second != b.second ? a.second < b.second : a.first < b.first;
}
template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) return a.first < b.first;
  if (a.first == 0) return a.second >= 0 || b.first > 0;
  if (b.first == 0) return b.second < 0 && a.first < 0;
  return a.second * b.first < a.first * b.second;
}


/* -------- <templates end> -------- */


void solve() {
  int n, r; cin >> n >> r;
  if (n >= 10) cout << r << endl;
  else cout << r + 100 * (10 - n) << endl;
}


/* -------- <programs end> -------- */


signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


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

int main() {
    int n;
    cin >> n;

    int counter = 0;
    for (int i = 1; i <= n; ++i) {
        int temp;
        cin >> temp;

        if (i & 1 && temp & 1)
            ++counter;
    }

    cout << counter;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	ll n,d;
	cin>>n>>d;
	int count=0;
	while(n--){
		ll x,y;
		cin>>x>>y;
		if((ll)(x*x)+(ll)(y*y)<=(ll)(d*d)) ++count;
	}
	cout<<count;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

class mystack {
	private:
		int val[1000];
		int sp = -1;
	public:
		void push(int n) {
			sp++;
			val[sp] = n;
		}
		void pop() {
			if(sp >= 0)
			sp--;
		}
		int top() {
			return val[sp];
		}
};

int main() {
	string s;
	mystack t;
	while(cin >> s) {
		int op1 = t.top();t.pop();
		int op2 = t.top();t.pop();
		switch(s[0]) {
			case '+':
				t.push(op1+op2);
				break;
			case '-':
				t.push(op2-op1);
				break;
			case '*':
				t.push(op1*op2);
				break;
			default:
				t.push(op2);
				t.push(op1);
				t.push(atoi(s.c_str()));
				break;
		}
	}
	cout << t.top() << endl;
}



Measured memory_bytes: 3200
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,n,c,p,x,y;
	x=0;
	cin>>n>>c;
	n=n+1;
	for(i=0;i<c;i++){
		cin>>p;
		x=x+p;
	}
	y=x/n;
	if(x%n) y=y+1;
	cout<<y<<endl;
	return 0;
}



Measured memory_bytes: 3120
nA, nB, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = [0] + A
B = [0] + B


X = [[] for _ in range(M)]
Y = [[] for _ in range(M)]
C = [[] for _ in range(M)]

for i in range(M):
    X[i], Y[i], C[i] = map(int, input().split())

# indipendent
ans1 = min(A[1:]) + min(B[1:])

# set
ans2 = max(A) + max(B)
for x, y, c in zip(X, Y, C):
    ans2 = min(ans2, A[x] + B[y] - c)

print(min(ans1, ans2))

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

using namespace std;

string f(string x, string y) {
    for (int i = 0; i < x.length(); i++) {
        if (x[i] != y[i]) return "No";
    }
    return "Yes";
}

int main() {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    string x, y;
    cin >> x >> y;
    cout << f(x, y);


}



Measured memory_bytes: 3620
class Node():
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

class Tree():
    def __init__(self):
        self.root = None
        self.list = []

    def insert(self, node):
        y = None                 # x's parent    
        x = self.root
        while x is not None:
            y = x                # set parent
            if node.key < x.key:
                x = x.left
            else:
                x = x.right
        node.parent = y

        if y is None:
            self.root = node
        elif node.key < y.key:
            y.left = node
        else:
            y.right = node

    def parse_inorder(self, node):
        if node is None:
            return 
        self.parse_inorder(node.left)
        self.list.append(node.key)
        self.parse_inorder(node.right)

    def parse_preorder(self, node):
        if node is None:
            return
        self.list.append(node.key)
        self.parse_preorder(node.left)
        self.parse_preorder(node.right)

N = int(input())
T = Tree()
for i in range(N):
    order, *key = input().split()
    if order == "print":
        T.list = []
        T.parse_inorder(T.root)
        print(" " + " ".join(map(str, T.list)))
        T.list = []
        T.parse_preorder(T.root)
        print(" " + " ".join(map(str, T.list)))
    else:
        node = Node(int(key[0]))
        T.insert(node)



Measured memory_bytes: 144036
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    if(a==1 || b==1){
    	cout<<1;
    	return 0;
    }
    if(a%2 && b%2){
    	cout<<a*b/2 +1;
    }
    else{
    	cout<<a*b/2;
    }

    return 0;
}







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


#define NUM 1001

ll nCm[NUM][NUM];

int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	if(N > K){
		printf("0\n");
		return 0;
	}

	nCm[0][0] = 1;
	for(int n = 1; n <= K; n++){
		for(int m = 0; m <= N; m++){

			if(n == 0){

				nCm[n][m] = 1;

			}else{

				nCm[n][m] = nCm[n-1][m]+nCm[n-1][m-1];

			}
			nCm[n][m] %= MOD;
		}
	}

	printf("%lld\n",nCm[K][N]);

	return 0;
}



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

using namespace std;

int n, ans = 100000;

int power(int a, int b){
	if(b==0) return 1;
	if(b==1) return a;
	if(b%2 == 1) return power(a,b-1)*a;
	int q = power(a,b/2);
	return q*q;
}

int ss(int x){
	int p, res = 0;
	while(x > 0){
		p = 0;
		while(x - power(6, p) >= 0) p++;
		x -= power(6, p-1);
		res++;
	}
	return res;
}

int nn(int x){
	int p, res = 0;
	while(x > 0){
		p = 0;
		while(x - power(9, p) >= 0) p++;
		x -= power(9, p-1);
		res++;
	}
	return res;
}

int main(){
	cin >> n;
	for(int six = 0; six <= n; ++six){
		int nine = n-six;
		ans = min(ans, ss(six)+nn(nine));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())

    A = [0 for i in range(N+1)]
    B = [0 for i in range(N+1)]
    C = [0 for i in range(N+1)]

    for i in range(1,len(A)):
        a,b,c = map(int,input().split())

        A[i] = max(B[i-1],C[i-1]) + a
        B[i] = max(C[i-1],A[i-1]) + b
        C[i] = max(A[i-1],B[i-1]) + c

    print(max(A[-1],B[-1],C[-1]))
    
resolve()

Measured memory_bytes: 51244
package main

import ."fmt"

func f(n int) int {
	if n % 2 == 0 {
		return n / 2
	} else {
		return 3 * n + 1
	}
}

func ai(i, s int) int {
	if i == 1 {
		return s
	} else {
		return f(ai(i-1, s))
	}
}

func main() {
	var  s int
	Scanf("%d\n", &s)
	for m := 2; m < 1000000; m++ {
		for n := 1; n < m; n++ {
			if ai(m, s) == ai(n, s) {
				Printf("%d\n", m)
				return
			}
		}
	}
}


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

int ss[128];

int main(){
  string str;
  cin>>str;
  for(int i=0;i<str.size();i++){
    ss[str[i]]++;
  }
  int check = true;
  for(int i='a';i<='z';i++){
    if(ss[i] % 2) check = false;
  }
  cout<<(check ? "Yes" : "No")<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
//using i128 = i64;
//using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

template<class T>
void print(const T &a)
{
	for (auto x : a) printf("%d ", x); puts("");
}

const int MAXN = 888888;
const int MAXM = 26;
//const i64 INF = 1000000000000000000LL;
const int INF = 1000000000;
//const int MOD = 998244353;
const int MOD = 998244853;
const int INV2 = (MOD+1)/2;
const ld pi = 3.1415926535897932384626433;

int main()
{
	
	int M, D;
	cin >> M >> D;
	int ans = 0;
	for (int m = 1; m <= M; ++ m)
		for (int d = 1; d <= D; ++ d)
		{
			int d1 = d%10, d10 = d/10;
			ans += d1 >= 2 && d10 >= 2 && d1*d10 == m;
		}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#define N (1000000000+7)
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;


int main(void){
    string s,t;
    cin>>s>>t;
    for(char x='a';x<='z';x++){
        string u = s;
        u.push_back(x);
        if(u==t){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stack>
#include<iostream>
#include<stdlib.h>
#include<queue>
using namespace std;

stack<int> S1;
stack<pair<int, int> > S2;

int area = 0;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] == '\\') {
      S1.push(i);
    } else if (s[i] == '/') {
      if (S1.size() == 0) continue;
      int j = i - S1.top();
      area += j;
      int areas2 = 0;
      while (S2.size() > 0 && S2.top().first > S1.top()) {
        areas2 += S2.top().second;
        S2.pop();
      }
      S2.push(make_pair(S1.top(), j+areas2));
      S1.pop();
    }
  }
  printf("%d\n", area);
  printf("%lu", S2.size());
  stack<int> ans;
  while (S2.size() > 0) { ans.push(S2.top().second); S2.pop();}
  while (ans.size() > 0) {
    printf(" %d", ans.top());
    ans.pop();
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 3336
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int N; cin>>N;
  vector<tuple<string, int, int>> sp(N);
  for(int i=0; i<N; i++){
    cin>>get<0>(sp.at(i))>>get<1>(sp.at(i));
    get<1>(sp.at(i))*=(-1);
    get<2>(sp.at(i))=i+1;
  }
  sort(sp.begin(), sp.end());
  for(int i=0; i<N; i++){
    cout<<get<2>(sp.at(i))<<endl;
  }
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int x, t;
	cin >> x >> t;
	if (x-t > 0)
	{
		cout << x - t << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

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

int main() {
    int n;
    cin >> n;

    string str[n];
    int i,j;
    for(i=0;i<n;i++) cin >> str[i];

    int miss = 0;

    for(i=1;i<n;i++){
        if(str[i-1][str[i-1].size()-1] != str[i][0]) miss++;
        for(j=0;j<i;j++){
            if(str[i]==str[j]) miss++;
        }
    }

    if(miss == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
constexpr int INF = 100100100;

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  int N, K;
  string S;
  cin >> N >> K >> S;
  --K;
  S[K] += 32;
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <iomanip>

constexpr double E = 1e-8;
constexpr int INF = 99999999;

int main() {
    int n, k, t, u, v, l;
    std::vector<int> d;
    std::cin >> n >> k >> t >> u >> v >> l;
    for (int i = 0; i < n; i++) {
        int a; std::cin >> a;
        d.push_back(a);
    }

    double numTime = 0.0;
    int numOfCarrot = 0;
    double remaindSpeedUpTime = 0.0;
    int carrotIndex = -1;
    double pos = 0.0;
    while (1) {
        double nowSpeed = u;
        if (remaindSpeedUpTime > 0.0) nowSpeed = v;

        // 次の区切りを探す
        double nextCarrotTime = INF;
        double goalTime = (l - pos) / nowSpeed; // ゴールまでの時間

        // 次の人参までの時間
        if (carrotIndex < (int)(d.size()) - 1) {
            int remaindNextCarrotLen = (d[carrotIndex + 1] - pos);
            nextCarrotTime = remaindNextCarrotLen / nowSpeed;
        }

        // 区切りに合わせて
        // 次の人参取得イベが最も早い
        if (nextCarrotTime < goalTime && ((nextCarrotTime < remaindSpeedUpTime && remaindSpeedUpTime > 0.0) || remaindSpeedUpTime <= 0.0)) {
            pos = d[++carrotIndex];
            numTime += nextCarrotTime;
            remaindSpeedUpTime -= nextCarrotTime;
            // 人参取得
            numOfCarrot++;
            // もう持てないか人参切れなら食べる
            if (numOfCarrot > k || remaindSpeedUpTime <= 0.0) {
                numOfCarrot--;
                remaindSpeedUpTime = t;
            }
        }
        else if (remaindSpeedUpTime > 0.0 && remaindSpeedUpTime < goalTime) { // 人参切れを起こす
            pos += remaindSpeedUpTime * nowSpeed;
            numTime += remaindSpeedUpTime;
            remaindSpeedUpTime = 0;
            // 人参あるなら食べる
            if (numOfCarrot > 0) {
                numOfCarrot--;
                remaindSpeedUpTime = t;
            }
        }
        else { // ゴール
            pos = l;
            numTime += goalTime;
            break;
        }
    }
    std::cout << std::fixed << std::setprecision(9) << numTime << std::endl;

    return 0;
}


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

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

using namespace std;

int main(){
  int n,mm;cin>>n>>mm;
  map<int,int> m;
  rep(i,n){
    int k;cin>>k;
    rep(j,k){
      int tt;cin>>tt;
      m[tt]++;
    }
  }
  int result=0;
  for(auto p:m){
    if(p.second==n)result++;
  }

  cout<<result;
  return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  string A, B, C;
  cin >> A >> B >> C;
  if (A[A.length()-1] == B[0] && B[B.length()-1] == C[0])
  {
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    string s,t;
    cin >> s >> t;
    
    int n = s.length();
    for (int i = 0; i < n; i++) {
        string str="";
        str = s.substr(n-i,i) + s.substr(0,n-i);
        // cout << str << endl;
        if (str == t) {
            cout << "Yes" << endl;
            return;
        }
    }

    cout << "No" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

int main() {
  string n, s;
  getline(cin, n);
  getline(cin, s);
  if (s.find('Y') == string::npos) {
    cout << "Three" << endl; 
  }
  else {
    cout << "Four" << endl; 
  }
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_B&lang=jp
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int INF = numeric_limits<int>::max();
struct edge {
	int from, to, cost;
};
vector<int> dijkstra(int s, vector<vector<edge>>&graph) {//頂点sからほかのすべての頂点の最短距離を入れたvectorを返す
	//以下pair<int,int>はfirstは最短距離 secondは頂点番号
	int n = graph.size();
	priority_queue < pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>que;
	vector<int>d(n, INF);//頂点sからの最短距離
	d[s] = 0;//スタート地点からスタート地点の距離はゼロ
	que.push(pair<int, int>(0, s));
	while (!que.empty()) {
		pair<int, int>p = que.top();
		que.pop();
		int v = p.second;
		for (int i = 0; i < graph[v].size(); i++) {
			edge e = graph[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(pair<int, int>(d[e.to], e.to));
			}
	    }
	}
	return d;
}

int main() {
	int n;//頂点数
	cin >> n;
	vector<vector<edge>>graph;
	graph.resize(n);
	
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int to, cost;
			cin >> to >> cost;
			edge e;
			e.from = u;
			e.to = to;
			e.cost = cost;
			graph[u].push_back(e);
		}
	}
	vector<int> d=dijkstra(0, graph);
	for (int i = 0; i < n; i++) {
		cout << i << " " << d[i] << endl;
	}

}


Measured memory_bytes: 3236