akhauriyash/Code-Regression huggingface dataset:
#include <climits>
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

int main() {
	int N, K, ans = INT_MAX, i = 0;
	cin >> N >> K;
	vector<int> a(N);
	for (int& j : a) cin >> j;
	unordered_map<int, int> b;
	for (int j = 0; j < N; ++j) {
		while (K != b.size() && N != i) {
			if (K >= a[i]) ++b[a[i]];
			++i;
		}
		if (K == b.size()) ans = min(ans, i - j);
		if (i == j) ++i;
		else {
			if (b.end() != b.find(a[j])) {
				--b[a[j]];
				if (!b[a[j]]) b.erase(a[j]);
			}
		}
	}
	if (INT_MAX == ans) ans = 0;
	cout << ans << endl;
}


Measured memory_bytes: 7284
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
int n,a[200010];bool f;
std::deque<int>que;
template<class T>
inline void read(T&a){
	char c=getchar();
	for(a=0;c<'0'||c>'9';c=getchar());
	for(;c>='0'&&c<='9';c=getchar())a=a*10+c-'0';
}
int main(){
	read(n);
	for(int i=1;i<=n;i++){
		read(a[i]);
		if(!f)que.push_back(a[i]);
		else que.push_front(a[i]);
		f^=1;
	}
	if(n&1)while(!que.empty())printf("%d ",que.back()),que.pop_back();
	else while(!que.empty())printf("%d ",que.front()),que.pop_front();
	puts("");
	return 0;
}

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

int d,ans[365],c[26],s[365][26],last[26];
const int INF=1e9;

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

void FIN(int a){
  if(a){
    ofstream fout("output.txt");
    REP(i,d)fout<<ans[i]<<endl;
    fout.close();
    return;
  }
  REP(i,d)cout<<ans[i]<<endl;
  return;
}

signed main(){
  memset(last,-1,sizeof(last));
  cin>>d;
  REP(i,26)cin>>c[i];
  REP(i,d)REP(j,26)cin>>s[i][j];
  REP(day,d){
    vector<int> minus(26);
    REP(j,26)minus[j]=c[j]*(day-last[j]);
    int A=-INF,idx=0;
    REP(j,26){
      int tmp=s[day][j]+minus[j];
      if(A<tmp)A=tmp,idx=j;
    }
    ans[day]=idx+1;
    last[idx]=day;
  }
  FIN(0);
}


Measured memory_bytes: 3668
/**
 *    author:  math2do
 *    created: 27.04.2020 22:12:06 IST
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool taka = false;
  int turn = 0;
  while (true) {
    if (turn == 0) {
      c = c - b;
      if (c <= 0) {
        taka = true;
        break;
      } 
    } else {
      a = a - d;
      if (a <= 0) {
        taka = false;
        break;
      }  
    }
    turn ^= 1; 
  } 
  cout << (taka ? "Yes" : "No") << endl;
  return 0;
}


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

int main(){
    int  N, K, ans=0, tmp, tmp2;
    priority_queue<int, vector<int>, greater<int>> desc;
    cin >> N >> K;
    vector<int> V(N);
    for(int i=0; i<N; i++){
	cin >> V[i];
    }

    for(int i=0;i<=K&&i<=N;i++){
        for(int j=0;j<=K&&j<=N;j++){
	    tmp=0;
	    tmp2=i+j;
	    if(tmp2>K ||tmp2>N)
	    	continue;	    
	    for(int k=0; k<i; k++){
		desc.push(V[k]);
	    }
	    for(int k=0; k<j; k++){
		desc.push(V[N-1-k]);
	    }
	    while(!desc.empty()){
		
		if(desc.top()<0 && tmp2<K)
		    tmp2++;
		else
		    tmp+=desc.top();
		desc.pop();
	    }

	    ans = max(ans, tmp);
	}	
    }
    cout << ans << endl;
}



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

int n;

int main() {
    cin >> n;
    vector<int> a(n);
    vector<bool> pushed(n, false);
    rep(i, n) {
        cin >> a.at(i);
        a.at(i)--;
    }
    int p = 0, count = 0;
    while(!pushed.at(p)) {
        if(p == 1) {
            cout << count << endl;
            return 0;
        }
        pushed.at(p) = true;
        p = a.at(p);
        count++;
    }
    cout << -1 << endl;
    return 0;
}

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

int dp[100000]={0};
std::vector<int> v;

int rec(int i,int k){
  if(i<=0)
    return 0;
  if (i==1) 
    return abs(v[1] - v[0]);
   if(dp[i]!=-1){
     return dp[i];
   }
  else {
    int a=INT_MAX;
    for(int j=1;j<=k;j++){
      if(j<=i){
        a=min(a,abs(v[i]-v[i-j])+rec(i-j,k));
      }
    }
    dp[i]=a;
    return dp[i];
  }
}

int main(){
  //freopen("input.txt","r",stdin);
  long long n,k,x;
  cin>>n>>x;
  for(long long i=0;i<n;i++){
    cin>>k;
    v.push_back(k);
  }
  memset(dp, -1, sizeof(dp)) ;
  cout<<rec(n-1,x);
  return 0;
}

Measured memory_bytes: 11956
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<string.h>

using namespace std;

int main(){
  int n, d, x, ans = 0;
  cin >> n >> d >> x;
  int a[n];
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n; i++){
    ans += (d-1)/a[i] + 1;
  }
  ans += x;
  cout << ans << endl;
  return 0;
}


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



 int main()
{
	int n;
	cin>>n;
	vector<int> arr(1000001);
	for(int i=0;i<n;i++){
		int a;cin>>a;
		arr[a]++;
	}
	int count=0;
	for(int i=1;i<1000001;i++){
		if(arr[i]){
			if(arr[i]==1) count++;
			for(int j=i;j<1000001;j+=i){
				arr[j]=0;
			}
		}
	}
	
	cout<<count;
	
}


Measured memory_bytes: 7216
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

x = ni()

ans = x // 500 * 1000
x %= 500
ans += x // 5 * 5

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main(void){
  int a, b, c;
  
  cin >> a >> b;
  
  if(a < b){
    swap(a, b);
  }
  if((a + b) % 2 == 0){
    cout << b + (a - b) / 2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}

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

long long a[3], ta = 0, mu = 0;

signed main(){
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] % 2 == 1 && a[1] % 2 == 1 && a[2] % 2 == 1) {
		cout << a[0] * a[1] << endl;
		return 0;
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
/*
AT2705 Yes or No
n为yes的题数，m为no的题数
当n>m的时候，猜yes
当n<m的时候，猜no
这样猜一定能保证猜对max(n,m)次
考虑n=m时猜对的期望
猜对的概率（对答案的贡献）是n/(n+m)=1/2
考虑走到(i,i)这个点的方案数
C(2i,i)*(n-i+m-i,n-i)
前2i步钦定i步向右走（剩余i步向上走）
后n-i+m-i步钦定n-i步向右走（剩余m-i步向上走），以免走出网格
故走到(i,i)的概率是sigma(C(2i,i)*(n-i+m-i,n-i))/C(n+m,n)
C(n+m,n)是总方案数 
当n=m时的期望贡献是(1/2)*sigma(C(2i,i)*(n-i+m-i,n-i))/C(n+m,n) i=1~min(n,m)
*/ 
#include <cstdio>
typedef long long ll;
#define ri register int
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast") 
const int N=1000005,mod=998244353;
int fac[N],inv[N];
inline int C(ri n,ri m){
	return (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;
}
inline int max(ri x,ri y){
	return x>y ? x:y;
}
inline int min(ri x,ri y){
	return x<y ? x:y;
}
inline void add(int &x,ri y){
	x+=y;
	if(x>=mod) x-=mod;
}
inline int Pow(ri a,ri b){
	ri ans=1;
	for(;b;b>>=1,a=(ll)a*a%mod)
		if(b&1) ans=(ll)ans*a%mod;
	return ans;
}
int main(){
	ri n,m,i,sum,yes;
	scanf("%d%d",&n,&m);
	sum=n+m;
	fac[0]=inv[0]=1;
	for(i=1;i<=sum;++i) fac[i]=(ll)fac[i-1]*i%mod;
	inv[sum]=Pow(fac[sum],mod-2);
	for(i=sum-1;i;--i) inv[i]=(ll)inv[i+1]*(i+1)%mod;
	yes=0;
	for(i=min(n,m);i;--i) add(yes,(ll)C(2*i,i)*C(n-i+m-i,n-i)%mod);
	yes=(ll)yes*Pow(C(n+m,n),mod-2)%mod*inv[2]%mod;
	add(yes,max(n,m));
	printf("%d\n",yes);
    return 0;
}

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

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		boolean a[] = new boolean [123456*2+1];
		Arrays.fill(a, true);
		a[0]=a[1]=false;
		for(int i=2; i*i<=123456*2; i++)
		{
			if(!a[i])
				continue;
			for(int j=i*2; j<=123456*2; j+=i)
				a[j]=false;
		}

		while(sc.hasNext())
		{
			int ans =0;
			int n = sc.nextInt();
			if(n==0)
				return;

			for(int i =n+1; i<=n*2; i++)
				if(a[i])
					ans++;

			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 13000
# B
N, M = map(int, input().split())
r_list = [0]*M
for _ in range(N):
    A_list = list(map(int, input().split()))[1:]
    for a in A_list:
        r_list[a-1] += 1
        
res = 0
for r in r_list:
    if r == N:
        res += 1
print(res)

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<vector<pair<int, int>>> adj(n);
	for (int i = 0, u, v; i < n-1; ++i)
	{
		cin >> u >> v;
		--u, --v;
		adj[u].push_back({ v, i });
		adj[v].push_back({ u, i });
	}

	vector<int> ans(n-1);

	function<void(int, int, int)> dfs = [&](int u, int p, int c)
	{
		int col = 1;
		for (auto v : adj[u])
			if (v.F != p)
			{
				if (col == c) ++col;
				ans[v.S] = col;
				dfs(v.F, u, col);
				++col;
			}
	};

	dfs(0, -1, -1);
	cout << *max_element(ans.begin(), ans.end()) << "\n";
	for (auto &i : ans)
		cout << i << "\n";

	return 0;
}


Measured memory_bytes: 9216
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 A[202020];

bool succ(vector<pair<i64, int>> &rle, int K)
{
	int tail = 0;
	for (int i = rle.size() - 1; i >= 0; --i) {
		if (rle[i].second != K - 1) {
			if (rle[i].first >= 2) {
				rle[i].first -= 1;
				rle.push_back({1LL, 1});
			} else {
				rle[i].second += 1;
			}
			if (tail > 0) rle.push_back({(i64)tail, 0});
			return false;
		} else {
			++tail;
			rle.pop_back();
		}
	}
	return true;
}
bool test(int K)
{
	i64 len = 0;
	vector<pair<i64, int>> rle;

	//printf("%d:\n", K);
	for (int i = 0; i < N; ++i) {
		if (len < A[i]) {
			rle.push_back({A[i] - len, 0});
			len = A[i];
		} else {
			// shrink
			while (len > A[i]) {
				auto b = rle.back();
				if (len - b.first >= A[i]) {
					len -= b.first;
					rle.pop_back();
				} else {
					rle.back().first -= len - A[i];
					len -= len - A[i];
				}
			}
			// succ
			if (succ(rle, K)) return false;
		}
		//for (auto a : rle) printf("%lld,%d ", a.first, a.second);
		//puts("");
	}
	return true;
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%lld", A + i);

	// is 1?
	bool flg = true;
	for (int i = 1; i < N; ++i) if (A[i - 1] >= A[i]) flg = false;
	if (flg) {
		puts("1");
		return 0;
	}

	int left = 2, right = N;
	while (left < right) {
		int mid = (left + right) / 2;
		if (test(mid)) {
			right = mid;
		} else {
			left = mid + 1;
		}
	}
	printf("%d\n", left);
	return 0;
}


Measured memory_bytes: 3816
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		for(int i = 1; i <= num; i++){
			if(i % 3 == 0 || Integer.toString(i).contains("3")){
				System.out.printf(" %d", i);
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

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

    u64 sum = 0;
    u64 ans = 0;

    for(u64 i=0; i<S.size(); i++) {
        sum = (S[i] == 'R') ? sum + 1 : 0;
        ans = max(sum, ans);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  int H, W;
  string a[200];
  int x[200], y[200];
  cin >> H >> W;
  for(int i=0;i<H;i++)cin >> a[i];
  for(int i=0;i<H;i++){
    bool f=true;
    for(int j=0;j<W;j++)if(a[i][j]=='#')f=false;
    if(f)x[i]=1;
    else x[i]=0;
  }
  for(int i=0;i<W;i++){
    bool f=true;
    for(int j=0;j<H;j++)if(a[j][i]=='#')f=false;
    if(f)y[i]=1;
    else y[i]=0;
  }
  for(int i=0;i<H;i++){
    if(x[i]==1)continue;
    for(int j=0;j<W;j++){
      if(y[j]==0)cout << a[i][j];
    }
    puts("");
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	int a, b;
	cin >> a >> b;
	int ans = max(0, a - 2 * b);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = 10 ** 4
l = [0] * (a + 1)
#print(l)

for x in range(1,100):
    for y in range(1,100):
        for z in range(1, 100):
            if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x > a:
                break
            else:
                l[x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x] += 1

for i in range(1, n + 1):
    print(l[i])

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

int main(){
    using namespace std;
    unsigned long X, x, k;
    cin >> X;
    const auto& nibutan = [&X](long k){
        const auto& check = [&X, &k](long x) -> bool{
            long ret = (x + k) * (x + k) * (x + k) * (x + k) * (x + k) - x * x * x * x * x;
            if(ret == X){
                cout << x + k << " " << x << endl;
                exit(0);
            }
            return X < ret;
        };
        long L{-k / 2}, R{1000};
        check(L);
        check(R);
        while(L + 1 < R){
            long M{(L + R) / 2};
            (check(M) ? R : L) = M;
        }
    };
    for(unsigned long i{1}; i * i <= X; ++i)if(X % i == 0)nibutan(i);
    for(unsigned long i{1}; i * i < X; ++i)if(X % i == 0)nibutan(X / i);
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

vector<string> mat;
pair<int, int> cur;

int move(char direction, int dis) {
    int tmp = 0;
    rep(i, dis) {
        if (direction=='N') cur.second++;
        if (direction=='S') cur.second--;
        if (direction=='E') cur.first++;
        if (direction=='W') cur.first--;
        if (mat[cur.first][cur.second]=='1') {
            tmp++;
            mat[cur.first][cur.second]='0';
        }
    }
    return tmp;
}

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

    while (true) {
        int n; cin >> n;
        if (n==0) break;
        mat.assign(21, string(21, '0'));
        rep(i, n) {
            int x, y;
            cin >> x >> y;
            mat[x][y] = '1';
        }
        int achieved = 0;
        int m; cin >> m;
        cur = make_pair(10, 10);
        rep(i, m) {
            char d; int dis;
            cin >> d >> dis;
            achieved += move(d, dis);
        }

        if (achieved == n) puts("Yes");
        else puts("No");
    }
}


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

#define mp(x, y) make_pair((x), (y))

typedef long long ll;

int n;
int s;
int ans;

int main()
{
	scanf("%d", &n);
	s=1234567890;
	for(int i=0; i<n; i++) {
		int u;
		scanf("%d", &u);
		ans+=u;
		if(u%10) s=min(s, u);
	}
	if(ans%10) {
		printf("%d\n", ans);
	} else if(s<1234567890) {
		printf("%d\n", ans-s);
	} else {
		printf("0\n");
	}

	return 0;
}

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

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	long ans;
	foreach (i; 0..N)
	{
		auto l = RD;
		auto r = RD;
		ans += r - l + 1;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 380
//AtCoder ABC048 C - Boxes and Candies
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    lli N,x;
    cin>>N>>x;
    vector<lli> atbl(N);
    for(auto&& a:atbl){
        cin>>a;
    }
    lli ans=0;
    for(lli i=1;i<N;++i){
        lli diff=max(atbl[i]+atbl[i-1]-x,(lli)0);
        auto r = min(atbl[i],diff);
        diff -= r;
        auto l = min(atbl[i-1],diff);
        ans += (l+r);
        atbl[i] -= r;
        atbl[i-1] -= l;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	int N;
	long a, sum = 0;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a;
		while(!(a%2)){a/=2; sum++;}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		for(;;){
			int n = in.nextInt();
			if( n == 0 ) return ;
			int ns[] = new int[10];
			for(int i=0; i<n; i++)
				ns[in.nextInt()]++;
			for(int i=0; i<10; i++){
				for(int j=0; j<ns[i]; j++)
					System.out.print('*');
				System.out.println(ns[i]==0?"-":"");
			}
		}
	}

}

Measured memory_bytes: 12000
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

import bisect
ans=0
for mid in b:
    ind_t = bisect.bisect_left(a,mid)
    ind_b = bisect.bisect_right(c,mid)
    ans+=ind_t*(n-ind_b)

print(ans)

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

using ll=long long; 

bool used[100010];

void solve(){
	int n;
	cin>>n;
	memset(used, 0, sizeof used);
	vector<int>a(n);
	for(int i=0; i<n; i++){
		cin>>a[i];
		a[i]--;
	}
	int cnt=0;
	for(int i=0; i<n; i++){
		if(used[i])continue;
		used[i]=1;
		//cout<<a[i]<<" "<<i<<endl;
		if(!used[a[i]]&&a[a[i]]==i){
			used[a[i]]=1;
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N; cin >> N;
  ll cnt = 0;
  for(int i = 0; N > 0; i++) {
    N /= 2;
    cnt++;
  }
  cout << pow(2, cnt - 1) << endl;
}

Measured memory_bytes: 4292
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	long long a,b,ans;
	cin >> a >> b;

	if (a == 1)
	{
		if (b == 2)
			ans = 3;
		else ans = 2;
	}
	else if (a == 2)
	{
		if (b == 1)
			ans = 3;
		else ans = 1;
	}
	else {
			if (b == 2)
				ans = 1;
			else ans = 2;
	}
	
	cout << ans << std::endl;
}

Measured memory_bytes: 256
//
// Created by ?????°?????? on 2016/03/27.
//

#include <iostream>
#include <vector>
using namespace std;

//quicksort
int partition(pair<char,int>A[],int p,int r){
    int x = A[r].second;
    int i = p -1;
    for (int j = p; j < r ; j++) {
        if(A[j].second <= x){
            i ++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i + 1;
}

void quicksort(pair<char,int> A[] ,int p,int r){
    if(p < r) {
        int q = partition(A, p, r);
        quicksort(A, p, q - 1);
        quicksort(A, q + 1, r);
    }
}

//mergesort
const int MAX = 500000;
const int SENTINEL = 2000000000;
pair<char,int> S[MAX/2 + 2],T[MAX/2 + 2];

void merge(pair<char,int> P[],int alpha,int gamma,int beta){
    int n1 = gamma - alpha;
    int n2 = beta - gamma;
    for (int i = 0; i < n1 ; ++i)S[i] = P[alpha + i];
    for (int i = 0; i < n2 ; ++i)T[i] = P[gamma + i];
    S[n1].second = SENTINEL;
    T[n2].second = SENTINEL;
    int i=0; int j=0;
    for (int k = alpha; k < beta ; ++k) {
        if(S[i].second <= T[j].second){
            P[k] = S[i];
            i++;
        }else{
            P[k]= T[j];
            j++;
        }
    }
}

void mergesort(pair<char,int> P[],int alpha,int beta){
    if(alpha + 1 < beta){
        int gamma = (alpha + beta)/2;
        mergesort(P,alpha,gamma);
        mergesort(P,gamma,beta);
        merge(P,alpha,gamma,beta);
    }
}
bool isStable(pair<char,int>A[],pair<char,int>B[],int n){
    for (int i = 0; i < n ; ++i) {
        if(A[i] != B[i]) return false;
    }
}

int main () {
    int n;
    pair <char,int> A[100000];
    pair <char,int> B[100000];
    cin >> n;

    for (int i = 0; i < n; ++i) cin >> A[i].first >> A[i].second;
    for (int i = 0; i < n ; ++i) B[i] = A[i];

    quicksort(A,0,n-1);
    mergesort(B,0,n);

    if(isStable(A,B,n)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    for (int i = 0; i < n ; ++i) cout <<  A[i].first << " " << A[i].second << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    const int inf=(1<<30);
    const int lim=2000000;
    int n;
    cin >> n;
    vector<array<int,2>> a(n);
    string dir(n,'$');
    for(int i=0;i<n;i++)
    {
        cin >> a[i][0] >> a[i][1] >> dir[i];
        a[i][0]*=10;
        a[i][1]*=10;
    }
    int res=inf;
    //One
    vector<array<int,4>> v(n);
    for(int i=0;i<n;i++) v[i]={a[i][0]+a[i][1],a[i][0],a[i][1],i};
    sort(v.begin(),v.end());
    int one=0;
    while(one<n)
    {
        int r=-1,d=-1;
        int two=one;
        while(two+1<n&&v[two][0]==v[two+1][0]) two++;
        for(int i=one;i<=two;i++)
        {
            if(dir[v[i][3]]=='L') if(d!=-1) res=min(res,v[i][1]-d);
            if(dir[v[i][3]]=='U') if(r!=-1) res=min(res,v[i][1]-r);
            if(dir[v[i][3]]=='R') r=v[i][1];
            if(dir[v[i][3]]=='D') d=v[i][1];
        }
        one=two+1;
    }
    //Two
    for(int i=0;i<n;i++) v[i]={a[i][0]+(lim-a[i][1]),a[i][0],a[i][1],i};
    sort(v.begin(),v.end());
    one=0;
    while(one<n)
    {
        int r=-1,u=-1;
        int two=one;
        while(two+1<n&&v[two][0]==v[two+1][0]) two++;
        for(int i=one;i<=two;i++)
        {
            if(dir[v[i][3]]=='L') if(u!=-1) res=min(res,v[i][1]-u);
            if(dir[v[i][3]]=='D') if(r!=-1) res=min(res,v[i][1]-r);
            if(dir[v[i][3]]=='R') r=v[i][1];
            if(dir[v[i][3]]=='U') u=v[i][1];
        }
        one=two+1;
    }
    //Three
    vector<array<int,3>> b; //y,x,L|R
    auto ch=[&]()
    {
        sort(b.begin(),b.end());
        for(int i=0;i<(int)b.size();i++) if(b[i][0]==b[i+1][0]&&b[i][2]==1&&b[i+1][2]==0) res=min(res,(b[i+1][1]-b[i][1])/2);
    };
    for(int i=0;i<n;i++) if(dir[i]=='L'||dir[i]=='R') b.push_back({a[i][1],a[i][0],(dir[i]=='R')});
    ch();
    b.clear();
    for(int i=0;i<n;i++) if(dir[i]=='D'||dir[i]=='U') b.push_back({a[i][0],a[i][1],(dir[i]=='U')});
    ch();
    if(res==inf) cout << "SAFE\n";
    else cout << res << "\n";
    return 0;
}


Measured memory_bytes: 11220
module Main where

    import Debug.Trace

    readLine:: IO [Int]
    readLine = fmap (map read . words) getLine
    
    while :: Int -> Int -> IO ()
    while n i = if n /= 0 
        then do
            putStrLn $ "Case "++show i++": "++ show n
            [n']    <- readLine
            while n' (i+1)
        else return ()

    main :: IO() 
    main = do
        let i = 1
        [n]    <- readLine
        while n i
    


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

int main(){
    int n;
    while(cin>>n,n){
        string str;
        map<string,int>M[26];
        cin.ignore();
        while(n--){

            getline(cin,str);
            str+=" ";
            int prev=0,cur=1;
            while(prev<str.size()){
                while(str[prev+cur]!=' ')cur++;
                string s=str.substr(prev,cur);
                M[s[0]-'a'][s]++;
                prev+=cur+1;
                cur=1;
            }
        }
        char c;
        cin>>c;
        int a=c-'a';
        if(M[a].size()==0){
            cout<<"NA"<<endl;
            continue;
        }
        vector<pair<int,string> >V;
        for(map<string,int>::iterator it=M[a].begin();it!=M[a].end();it++){
            V.push_back(pair<int,string>(-it->second,it->first));
        }
        sort(V.begin(),V.end());
        for(int i=0;i<min((int)V.size(),5);i++){
            if(i)cout<<" ";
            cout<<V[i].second;
        }
        cout<<endl;
    }


    return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>

long long maxMy(long long a, long long b){
    if(a > b){
        return a;
    }
    else{
        return b;
    }
}

long long DP[3001][3001][4];
long long Gift[3001][3001];
long long r,c,k;

int main(){
    scanf("%lld %lld %lld", &r,&c,&k);
    int i;
    for(i=0; i<=r; i++){
        for(int j = 0;j <= c; j ++){
            DP[i][j][0] = 0;
            DP[i][j][1] = 0;
            DP[i][j][2] = 0;
            DP[i][j][3] = 0;
            Gift[i][j] = 0;
        }
    }
    for(i = 0; i < k; i ++){
        long long rt, ct, vt;
        scanf("%lld %lld %lld",&rt,&ct,&vt);
        Gift[rt][ct] = vt;
    }
    for(i=1; i<=r; i++){
        for(int j = 1;j <= c; j ++){
            DP[i][j][0] = maxMy(maxMy(maxMy(DP[i-1][j][0],DP[i-1][j][1]),maxMy(DP[i-1][j][2],DP[i-1][j][3])),DP[i][j-1][0]);
            DP[i][j][1] = DP[i][j-1][1];
            DP[i][j][2] = DP[i][j-1][2];
            DP[i][j][3] = DP[i][j-1][3];
            DP[i][j][3] = maxMy(DP[i][j][3],DP[i][j][2] + Gift[i][j]);
            DP[i][j][2] = maxMy(DP[i][j][2],DP[i][j][1] + Gift[i][j]);
            DP[i][j][1] = maxMy(DP[i][j][1],DP[i][j][0] + Gift[i][j]);
        }
    }
    printf("%lld",maxMy(maxMy(DP[r][c][0],DP[r][c][1]),maxMy(DP[r][c][2],DP[r][c][3])));
}

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

// #include <string>

#define tenp3 1000
#define tenp5 100000
#define tenp6 1000000
#define tenp9 1000000000
#define infinity 100000000000000000
#define mod 1000000007

typedef long long ll;
typedef vector<long long int> vll;
typedef vector<int> vi;
typedef pair<long long int, long long int> pll;
typedef pair<int, int> pi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef priority_queue<long long int> pqll;
typedef vector<pair<long long int, long long int>> vpll;
typedef vector<pair<int, int>> vpii;


// datatypes

// calc
#define isOdd(x) (x) % 2 == 1
#define isEven(x) (x) % 2 == 0
// #define mat

#define pushb push_back
#define popb pop_back
#define F first
#define S second
#define mp make_pair

#define repe(i, a, b) for (long long int i = (long long int)(a); i < (long long int)(b); i++)
#define repi(i, a, b) for (long long int i = (long long int)(a); i <= (long long int)(b); i++)
#define repv(x, y) for (auto x : y)
#define repit(it, x) for (auto it = x.begin(); it != x.end(); it++)
#define justSort(x) sort(x.begin(), x.end())
#define justSortR(x) sort(x.rbegin(), x.rend())
#define vec(typeOfVec, nameOfVec, sizeOfVec)      \
    vector<typeOfVec> nameOfVec(sizeOfVec);       \
    for (long long int i = 0; i < sizeOfVec; i++) \
    {                                             \
        cin >> nameOfVec[i];                      \
    }
#define print(x) cout << (x) << "\n";

#define lb(x, y) lower_bound(x.begin(), x.end(), (y))
#define ub(x, y) upper_bound(x.begin(), x.end(), (y))
#define bs(x, y) binary_search(x.begin(), x.end(), (y))
#define rev(x) reverse(x.begin(), x.end())
#define copy(x, y) copy(x.begin(), x.end(), back_inserter(y));

// matices
#define mat(nameOfMat, typeOFMat, rows, cols, intitialValue) vector<vector<typeOFMat>> nameOfMat(rows, vector<typeOFMat>(cols, intitialValue));
#define gmat(nameOfMat, typeOFMat, rows, cols) vector<vector<typeOFMat>> nameOfMat(rows, vector<typeOFMat>(cols, 0)); for (long long int i = 0; i < rows; i++) {for (long long int j = 0; j < cols; j++){cin >> nameOfMat[i][j];}}
#define pmat(nameOfMat) for (long long int i = 0; i < nameOfMat.size(); i++) {for (long long int j = 0; j < nameOfMat[0].size(); j++){cout <<nameOfMat[i][j]<<" ";}cout<<"\n";}cout<<"\n";

//
#define preSum(fromArray,newArray,dataType) vector<dataType> newArray(fromArray.size()+1);newArray[0]=0;for(long long int  qw = 0; qw < fromArray.size(); qw++){newArray[qw+1]=newArray[qw]+fromArray[qw];}



int solve(int tn)
{
 
    string s,t;
    cin>>s>>t;
    ll ans=t.length();
    repi(i,0,(s.length()-t.length())){
        ll cunt=0;
        repe(j,0,t.length()){
            if(t[j]!=s[i+j]){
                cunt++;
            }
        }
        ans=min(ans,cunt);
    }
    cout<<ans<<"\n";
    return 0;

}

int main()
{
    ll t=1;
    // cin >> t;
    repe(w, 1, t + 1)
    {
        solve(w);
    }
    return 0;
}


Measured memory_bytes: 3580
N, M = map(int, input().split())
kss = [list(map(int, input().split())) for _ in range(M)]
ps = list(map(int, input().split()))

answer = 0
for i in range(1 << N):
    for (_, *ss), p in zip(kss, ps):
        okay = True
        if sum([(i >> s-1) & 1 for s in ss]) % 2 != p:
            okay = False
            break
    if okay:
        answer += 1

print(answer)


Measured memory_bytes: 41712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  string S;
  cin >> S;
  rep(i, S.size()) cout << 'x';
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<string.h>
#include<ctype.h>
using namespace std;

int main(){
  long long m, n;
  cin >> n >> m;
  if (n >= 2 && m >= 2){
    cout << (n-2)*(m-2);
  } else if (m == 1 && n == 1){
    cout << "1" << endl;
  } else {
    cout << max(n, m) - 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
using static Read;

class Program
{
    public static void Main()
    {
        var n = IntArray();
        Sort(n);
        if(n[0] == n[1] + n[2] || n[0] + n[1] == n[2])
        {
            WriteLine("Yes");
        }
        else
        {
            WriteLine("No");
        }
    }
}

static class Read
{
    static Queue<string> queue = new Queue<string>();
    static void Enqueue()
    {
        ReadLine().Split(' ').ToList().ForEach(a => queue.Enqueue(a));
    }
    public static int Int()
    {
        if(queue.Count == 0)
            Enqueue();
        return int.Parse(queue.Dequeue());
    }
    public static long Long()
    {
        if(queue.Count == 0)
            Enqueue();
        return long.Parse(queue.Dequeue());
    }
    public static double Double()
    {
        if(queue.Count == 0)
            Enqueue();
        return double.Parse(queue.Dequeue());
    }
    public static string String()
    {
        if(queue.Count == 0)
            Enqueue();
        return queue.Dequeue();
    }
    public static int[] IntArray()
    {
        return ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static long[] LongArray()
    {
        return ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
    }
    public static double[] DoubleArray()
    {
        return ReadLine().Split(' ').Select(a => double.Parse(a)).ToArray();
    }
    public static string[] StringArray()
    {
        return ReadLine().Split(' ');
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
bool prime[d5];
void era(){
    for(int i=0;i<d5;i++)prime[i]=true;
    prime[0]=prime[1]=false;
    for(int i=0;i<d5;i++){
        if(!prime[i])continue;
        for(int j=2*i;j<d5;j+=i)prime[j]=false;
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    era();
    int n;
    cin>>n;
    int cnt=0;
    int s=0;
    for(int i=3;i<d5;i++){
        if(prime[i]){
            if(i%5==1){
                cout<<i<<' ';
                cnt++;
            }
            if(cnt==n){
                return 0;
            }
        }
    }
}

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

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

	scanf("%d%d%d%d", &a, &b, &c, &d);
	printf(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d) ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 128
N ,K = map(int, input().split())

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min1 = 0
max1 = max(A) + 1

while True:
    X = (min1 + max1)//2
    for i in range(N):
        if A[i] % X == 0:
            d[i] = A[i]//X - 1
        else:
            d[i] = A[i]//X
    if sum(d) <= K:
        max1 = X 
    else:
        min1 = X
    #print(min1, max1)

    if max1 - min1 <= 1:
        print(int(max1))
        break


Measured memory_bytes: 30980
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll unsigned long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
// #define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];

void solve()
{
	char ch;
	cin >> ch;
	ch++;
	cout << ch << endl;
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

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


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  int ans = 0;
  rep(i,N){
    ans += A[i] - 1;
  }
  cout << ans<< endl;
}


Measured memory_bytes: 256
def resolve():
    import math

    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a

    n = int(input())
    p = prime_factorize(n)
    if len(p) == 0:
        print(0)
        return

    pn = list(set(p))
    ans = 0
    for m in pn:
        i = 1
        k = p.count(m)
        while(k > 0):
            k -= i
            i += 1
            if k >= 0:
                ans += 1
    print(ans)

resolve()

Measured memory_bytes: 9232
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <queue>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,b,a) for(int i=(b);i>=(a);i--)
#define forn(i,n) rep(i,1,n)
#define rep0(i,n) rep(i,0,n-1)
using namespace std;
typedef pair<int,int>pii;
const LL mod=1e9+7;
int head[100010];
int ne;
struct edge{
	int to,nt,w;
}e[500004];
queue<int>q;
int dis[100004];
void dijkstra(){
	memset(dis,127/3,sizeof(dis));
	dis[1]=0;
	while(!q.empty()){
		int x=q.front();q.pop();
		for(int i=head[x];i;i=e[i].nt){
			if( dis[e[i].to]>dis[x]+e[i].w){
				dis[e[i].to]=dis[x]+e[i].w;
				q.push(e[i].to);
			}
		}
	}
}
void add(int u,int v,int w){
	 e[++ne].to=v;
	 e[ne].nt=head[u];
	 e[ne].w=w;
	 head[u]=ne;
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		add(i,(i+1)%n,1);
		add(i,(i*10)%n,0);
	}
	q.push(1);
	dijkstra();
	cout<<dis[0]+1<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;
//絶対値
ll ze(ll x,ll y){
    return max(x,y)-min(x,y);
};
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int mx = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) continue;
            if(mx < ze(a[i],a[j])) mx = ze(a[i],a[j]);
        }
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int sum = 1;

		for(int i = 0; i < n; i++) {
			if (i == 0) {
				sum *= k;
			} else {
				sum *= k-1;
			}
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 21844
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String ans = "";
		for(int i = 0; i < a.length(); i = i + 2) {
			String b = "";
			b = a.charAt(i) + ans;
			System.out.print(b);
		}
		
	}
}

Measured memory_bytes: 33104
n = int(input()) # 変数が何表すか見にくい……
k = int(input())
x = int(input())
y = int(input())
if n - k <= 0 : # 宿泊日数nがk泊よりも多いかどうか
    print(n * x) # 宿泊日数のほうが少なければ単純に掛ければいい
else:
    print((x * k) + (y * (n - k))) # k泊目まではx円、それ以降はy円

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
ll n, m, x = 0, y,z,w,h, sum= 0, ans = 0;
vector<ll> a;
void prime(ll n) {
    ll m = n,k = 0;
    while (n % 2 == 0) {
        n /= 2; k++;
    }if (k > 0) {
        a.push_back(k);
    }
    for (ll i = 3; i * i <= m; i += 2) {
        k = 0;
        while (n % i == 0) {
            k++; n /= i;
        }
        if (k > 0) a.push_back(k);
    }
    if (n * n >= m|| sqrt(m) < n) a.push_back(1);
}
int main(void) {
    cin >> n; 
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }
    prime(n);
    for (ll i : a) {
        ll cnt = 1, k = 1;
        while (i >= cnt) {
            k++; cnt += k;
        }ans += (k - 1);
    }cout << ans << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
string S, T[100000], U, V[1000][1000], W[1000]; int n, cnt, cnt2, cnt3[10000], cnt4, w[1000]; char a;
int main() {
	while (true) {
		for (int i = 0; i < 1000; i++) {
			W[i] = ""; w[i] = 0; T[i] = "";
			for (int j = 0; j < 1000; j++) {
				V[i][j] = "";
			}
		}
		U = "";
		cnt2 = 0; cnt4 = 0; memset(cnt3, 0, sizeof(cnt3));
		cin >> n; cnt = 0;
		if (!n) { break; }
		for (int i = 0; i < n; i++) {
			S = "";
			while (S == "")
			{
				getline(cin, S);
			}
			S += ' ';
			for (int i = 0; i < S.size(); i++) {
				if (S[i] == ' ') { T[cnt] = U; cnt++; U = ""; }
				else { U += S[i]; }
			}
		}
		cin >> a;
		for (int i = 0; i < cnt; i++) {
			if (T[i][0] == a) { 
				W[cnt2] = T[i]; cnt2++; 
			}
		}
		if (cnt2 == 0) { cout << "NA" << endl; goto F; }
		for (int i = 0; i < cnt2; i++) {
			for (int j = 0; j < i; j++) {
				if (W[i] == W[j]) {
					w[j]++; goto E;
				}
			}
			w[i]++;
		E:;
		}
		for (int i = 0; i < cnt2; i++) {
			if (w[i] >= 1) {
				V[w[i]][cnt3[w[i]]] = W[i];
				cnt3[w[i]]++;
			}
		}
		for (int i = 0; i < 1000; i++) {
			if (cnt3[i] >= 1) {
				sort(V[i], V[i] + cnt3[i]);
			}
		}
		for (int i = 999; i >= 0; i--) {
			for (int j = 0; j < cnt3[i]; j++) {
				if (cnt4) { cout << ' '; }
				cout << V[i][j];
				cnt4++;
			}
		}
		cout << endl;
	F:;
	}
}

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

int main(void){
  long long A=0;
  double B=0;

  cin >> A >> B;
  
  long long ib = 100*B+0.5;

  A*=ib;
  A/=100;
  
  cout << A << endl;
  return 0;
}



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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll x;
  cin >> x;
  ll ans = x / 11;
  x -= 11 * ans;
  ans *= 2;

  bool p = true;
  while (x > 0) {
    if (p) {
      x -= 6;
    } else {
      x -= 5;
    }

    p = !p;
    ans++;
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//↑templete
signed main(){

	int L, R;
	cin>>L>>R;
	int l=INF, r=0;
	for(int i=L;i<=L+2020 && i<=R;i++){
		int temp=i%2019;
		l=min(l, temp);
		r=max(r, temp);
	}

	int ans=INF;
	for(int i=l;i<=r;i++)
		for(int j=i+1;j<=r;j++)
			ans=min(ans, i*j%2019);

	cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  char s[100]={1};
  int i;
  scanf("%s", s);
  for(i = 0; i < 100; i ++){
    if(i%2 == 1){
      if(s[i] == 'R'){
        printf("No\n");
        return 0;
        //break;
      }
    }else if(i%2 == 0){
      if(s[i] == 'L'){
        printf("No\n");
        return 0;
        //break;
      }
    }
  }
  //if(i < 100){
    printf("Yes\n");
  //}

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int m,i,j,big,k;
		int count = 0;
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		int array[] = new int[n];

		for(m=0;m<n;m++)array[m] = Integer.parseInt(in.next());

	for (i=0; i<n-1; i++){               //???????????????????????????????????°i
		for (j=n-1; j>=i+1; j--){        //?????????????°?????????£??\????´???¨??????????????????????????°j
			if (array[j] < array[j-1]){
				big = array[j-1];        //??§???????????????????´????????????????????????????????????°big
				array[j-1] = array[j];   //??????????????§??\???????????????
				array[j] = big;
				count++;                 //???????????\??????????????°?????????????????????
			}
		}
	}
	for(k = 0;k<n-1;k++){
		System.out.print(array[k]+" ");
	}
    System.out.println(array[k]);       //????¨???????????????????????????¨??????k?????????n-1????????£?????????????????????????????§?????????????´??????§???
			System.out.println(count);  //??\??????????????°???????????????????????¨???????????\????????§???
	}
}

Measured memory_bytes: 26076
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
#define P(r)s.insert(a+b),s.insert(b+a),reverse(r.begin(),r.end())
using namespace std;int main(){string t,a,b;for(cin>>t;cin>>t;){set<string>s;for(int i=0;++i<t.size();P(a),P(b),P(a),P(b))a=t.substr(0,i),b=t.substr(i);cout<<s.size()<<endl;}}

Measured memory_bytes: 984
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int N;
	int n = 0, max = 0;
	int Cu[100] = { 0 }, Cd[100] = { 0 };
	int p = 0;

	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> Cu[i];
	}
	for (int i = 0;i < N;i++) {
		cin >> Cd[i];
	}
	for (int p = 0; p < N;p++) {
		n = 0;
		for (int i = 0;i <= p;i++) {
			n += Cu[i];
		}
		for (int i = p;i < N;i++) {
			n += Cd[i];
		}
		if (n > max)
			max = n;
	}


	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256