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

int main() {
    string S;
    cin >> S;
    int size = S.size();
    string ans = "Yes";

    for(int i = 0; i < size; i++) {
        if(i % 2 == 0) {
            if(S[i] == 'L') {
                ans = "No";
                break;
            }
        }
        if(i % 2 == 1) {
            if(S[i] == 'R') {
                ans = "No";
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int k;
    vector<int> abc(5);
    bool flag = true;
    cin >> abc[0] >> abc[1] >> abc[2] >> abc[3] >> abc[4] >> k;

    for(int i = 0;i < 5 - 1;i++){
        for(int j = i + 1;j < 5;j++){
            if(abc[j] - abc[i] > k){
                flag = false;
            }
        }
    }

    if(flag){
        cout << "Yay!";
    }
    else{
        cout << ":(";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int a[26];
char s[11];

int main() {
    int n, k, ans = 0, i;
    vector <int> v;
    
    scanf("%d %d", &n, &k);
    
    for (i = 0; i < n; i++) {
        scanf("%s", s);
        
        a[s[0] - 'A']++;
    }
    
    for (i = 0; i < 26; i++) {
        if (a[i] > 0) v.push_back(a[i]);
    }
    
    while (v.size() >= k) {
        vector <int> w;
        
        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
        
        for (i = 0; i < k; i++) v[i]--;
        
        ans++;
        
        for (i = 0; i < v.size(); i++) {
            if (v[i] > 0) w.push_back(v[i]);
        }
        
        v = w;
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	for (int i = 1; i <= N - K; i++) {
		if (A.at(i-1) < A.at(i + K-1)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 4840
#include <cstdio>
#define INF (50000.0)
using namespace std;

int main()
{
	float xa, ya, xb, yb, xc, yc, xd, yd;
	
	while (scanf("%f%f%f%f%f%f%f%f",
	&xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF){
		float m_ab;
		if (xb - xa == 0.0){
			m_ab = INF;
		}
		else {
			m_ab = (yb - ya) / (xb - xa);
		}
		
		float m_cd;
		if (xd - xc == 0.0){
			m_cd = INF;
		}
		else {
			m_cd = (yd - yc) / (xd - xc);
		}
		
//		printf("%f %f\n", m_ab, m_cd);
		
		if (m_ab == 0.0 && m_cd == 0.0){
			puts("NO");
		}
		else if (m_ab == INF){
			if (m_cd == 0.0){
				puts("YES");
			}
			else {
				puts("NO");
			}
		}
		else if (m_cd == INF){
			if (m_ab == 0.0){
				puts("YES");
			}
			else {
				puts("NO");
			}
		}
		else if (m_ab * m_cd == -1.0){
			puts("YES");
		}
		else {
			puts("NO");
		}
	}
	
	return 0;
}

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

template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

const int INF = 1145141919;
const long long INFL = 1LL<<60;

int main()
{
	int n;
	cin >> n;
	int a[110000], b[110000], c[110000];
	int dp[110000][3] = {};
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for (int i = 1; i < n; ++i)
	{
		dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
		dp[i][1] = max(dp[i-1][2] + b[i], dp[i-1][0] + b[i]);
		dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353


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

    // solution comes here

    ll N, W;
    vl w(110), v(110);
    cin >> N >> W;
    rep(i, N) cin >> w[i+1] >> v[i+1];//1-indexed

    matrix dp(110, vl(100100, INF));//dp[i][value] = weight
    dp[0][0] = 0;
    rep(i, N) {
        rep(j, 100010) {
            if(v[i+1] > j) dp[i+1][j] = dp[i][j];
            else {
                dp[i+1][j] = min(w[i+1] + dp[i][j-v[i+1]],  dp[i][j]);
            }
        }
    }

    for(ll i=100010; ; i--) {
        if(dp[N][i] <= W) {
            cout << i << nl;
            return 0;
        }
    }
}


Measured memory_bytes: 87296
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n, m,k,l; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	cin >> n >> m;
	vector<string> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	vector<string> b(m);
	rep(i, m) {
		cin >> b[i];
	}
	for (int i = 0; i < n - m + 1; i++) {
		if (a[i].substr(i, m) == b[0]) {
			bool flg = true;
			for (int j = i; j < m; j++) {
				if (a[j].substr(i, m) != b[j]) {
					flg = false;
				}
			}
			if (flg) { cout << "Yes" << endl; return 0; }
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define MIN(a,b) (((a)>(b))?(b):(a))
#define MIN3(a,b,c) (((a)>(MIN(b,c))?(MIN(b,c)):(a)))
#include <string>
using namespace std;

int main(void){
	int dp[1001][1001];
	string s1,s2;
	int len1,len2;
	cin>>s1>>s2;
	len1=s1.length();
	len2=s2.length();
	for(int i=0;i<=len1;i++)dp[i][0]=i;
	for(int j=0;j<=len2;j++)dp[0][j]=j;
	for(int i=1;i<=len1;i++){
		for(int j=1;j<=len2;j++){
			dp[i][j]=MIN3(dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+((s1[i-1]==s2[j-1])?(0):(1)));
		}
	}
	cout<<dp[len1][len2]<<endl;
	return 0;
}

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

typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//これを使うときにはCOMinit();を忘れずに

int main(void){
    int N, K; cin >> N >> K;
    K = min(N-1, K);
    COMinit();
    //0..K部屋の空きができる
    //n部屋にr人を分ける（1人もいなくても構わない）
    //(n-1+r)Cr
    ll ans = 0;
    for(int i = 0; i <= K; i++){
        ll keisuu = COM(N, i);
        ll people = i;
        ans = (ans + keisuu*COM((N-i)-1+people, people)) % MOD;
    }
    cout << ans << endl;
}

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

using namespace std;

int n;
vector<vector<int>> g;
vector<int> a, dp, ans;

void dfs(int x, int p = -1){
	auto it = lower_bound(dp.begin() + 1, dp.end(), a[x]) - dp.begin();
	int old = dp[it];
	dp[it] = a[x];
	ans[x] = it;
	if(p != -1)
		ans[x] = max(ans[x], ans[p]);
	for(int y : g[x]){
		if(y != p)
			dfs(y, x);
	}
	dp[it] = old;
}

int main(void){
	cin >> n;
	a.resize(n + 1);
	dp.resize(n + 1);
	ans.resize(n + 1);
	g.resize(n + 1);
	for(int i = 1 ; i <= n ; i++) cin >> a[i];
	for(int i = 1 ; i < n ; i++){
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(int i = 1 ; i <= n ; i++){
		dp[i] = INT_MAX;
	}
	dfs(1);
	for(int i = 1 ; i <= n ; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 27948
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#define MAX_N 200000
#define INF 2147483647
using namespace std;
int n, m;
int dis[MAX_N+5];
vector <int> G[MAX_N+5];
void SPFA() {
	queue <int> que;
	bool inque[MAX_N+5];
	for (int i = 1; i <= n; i++)	inque[i] = false, dis[i] = INF;
	dis[1] = 0, que.push(1), inque[1] = true;
	while (!que.empty()) {
		int u = que.front();
		for (int i = 0; i < G[u].size(); i++) {
			int v = G[u][i];
			if (dis[u]+1 < dis[v]) {
				dis[v] = dis[u]+1;
				if (!inque[v])	que.push(v), inque[v] = true;
			}
		}
		que.pop(), inque[u] = false;
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	SPFA();
	if (dis[n] <= 2)	printf("POSSIBLE");
	else	printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 13424
import copy
N,M = input().split()
N,M = int(N),int(M)
graph = []

node = [[] for N in range(N+1)]

for m in range(M):
    tmp0 = list(map(int,input().split()))
    tmp1 = copy.deepcopy(tmp0)
    tmp1.reverse()
    node[tmp0[0]].append(tmp0)
    node[tmp1[0]].append(tmp1)

counter = 0
flag = True

while flag:
    for n in range(len(node)):
        if len(node[n]) == 1:
            tmp = copy.deepcopy(node[n][0])
            tmp.reverse()
            node[n].pop()
            counter += 1
            for k in range(len(node[tmp[0]])):
                if node[tmp[0]][k] == tmp:
                    node[tmp[0]].remove(tmp)
                    break

    flag = False
    for _ in node:
        if len(_) == 1:
            flag = True
            break
        
print(counter)




Measured memory_bytes: 3572
#include <stdio.h>

#define RANGE_MAX 2147483647
#define MAX 100001

int A[MAX];

int main(void) {
	int i, j, n, q, m;
	int com, x, y, min;
	int *p;

	scanf("%d %d\n", &n, &q);
	for(i=0;i<n;i++) A[i] = RANGE_MAX;
	
	for(i=0;i<q;i++) {
		scanf("%d %d %d\n", &com, &x, &y);
		if(com == 0) {
			A[x] = y;
		} else { 
			m = RANGE_MAX;
			p = &A[x];
			for(j=x;j<=y;j++,p++) {
				if(m > *p)
					m = *p;
				if(m==0) break;
			}
			printf("%d\n", m);
		}
	}
	
	return 0;
}

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

using namespace std;

int N;
vector<int> DataInfo;

void solve() {
	int aF, aR, num;
	stringstream ss;
	multiset<int> result;
	multiset<int>::iterator pos;

	for (int i = 0; i < 2; ++i) {
		aF = DataInfo[i];
		for (int j = i + 1; j < N; ++j) {
			aR = DataInfo[j];
			ss.clear();
			ss << aF << aR;
			ss >> num;
			//cout << "1:" << num << endl;
			result.insert(num);
			ss.clear();
			ss << aR << aF;
			ss >> num;
			//cout << "2:" << num << endl;
			result.insert(num);
		}
	}

	pos = result.begin();
	advance(pos, 2);
	cout << *pos << endl;
}

int main() {
	int num;

	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> num;
		DataInfo.push_back(num);
	}
	sort(DataInfo.begin(), DataInfo.end());
	solve();
	
	return 0;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int s,w;

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

    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
        return 0;
    }
    cout<<"safe"<<endl;
    return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException{
		
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(input.readLine());
		String xline = input.readLine();
		String yline = input.readLine();
		String[] xstr = xline.split(" ");
		String[] ystr = yline.split(" ");
		double[] x = new double[n];
		double[] y = new double[n];
		double p1 = 0 , p2 = 0 , p3 = 0 , p = 0;
			for(int i = 0 ; i < n ; i++){
				x[i] = Double.parseDouble(xstr[i]);
				y[i] = Double.parseDouble(ystr[i]);
				p1 += Math.abs(x[i] - y[i]);
				p2 += Math.pow(x[i] - y[i] , 2);
				p3 += Math.pow(Math.abs(x[i] - y[i]) , 3);
				if( p < Math.abs(x[i] - y[i])) p = Math.abs(x[i] - y[i]);
			}
			p2 = Math.sqrt(p2);
			p3 = Math.cbrt(p3);
			
			
		System.out.println(p1 + "\n" + p2 + "\n" + p3 + "\n" + p);
	}

}

Measured memory_bytes: 16992
# B - Simplified mahjong
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
for i in range(N):
    ans += A[i]//2
    A[i] %= 2
    if i<N-1 and A[i]>0 and A[i+1]>0:
        ans += 1
        A[i+1] -= 1
print(ans)

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

#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define vll vector<ll>
#define pll pair<ll , ll>
#define vpll vector<pair<ll, ll> >
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define N 100001
#define HOLE 1000000007

ll fn(ll x,ll rn[])
{
    if(rn[x]==x) return x;
    else return rn[x]=fn(rn[x],rn);
}

void un(ll x,ll y,ll rn[],ll sz[])
{
    x=fn(x,rn);
    y=fn(y,rn);
    if(x==y) return;
    if(sz[x]<sz[y]) swap(x,y);
    sz[x]+=sz[y];
    rn[y]=x;
    return;
}

ll power(ll x,ll y)
{
    ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x)%HOLE;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%HOLE; // Change x to x^2
    }
    return res;
}

vector <ll> adjl[N];
ll marked[N]={0};
vector <ll> order;

void dfs (ll x){

    if(marked[x])
        return;
    marked[x]=1;

    REP(i,0,adjl[x].size()){

    }

    return;
}

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

    ll q=1;
    //cin>>q;
    while(q--){

        ll n,m;
        cin>>n>>m;



        int flag=0;

        cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;

    }

return 0;
}


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

char maze[8][8];


int h, w;


int main(){
    cin >> h >> w;

    int count = 0;
    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            cin >> maze[y][x];
            if(maze[y][x] == '#'){
                count++;
            }
        }
    }



    if(count != h+w-1){
        printf("Impossible\n");
    }
    else{
        printf("Possible\n");
    }

    return 0;

}

Measured memory_bytes: 256
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){/*if(a<b)swap(a,b);*/ if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modPow(ll x,ll n,ll mod){if(n==0)return 1; if(n%2==0)return modPow(x*x,n/2,mod)%mod; return x%mod*modPow(x,n-1,mod)%mod;}


/*------------------------------------------------*/

//main関数
int main() {
    ll n; cin >> n;

    vl a(n), count(1e6 + 1);
    ll GCD = 0;
    rep(i,n){
        cin >> a[i];
        count[a[i]]++;
        GCD = gcd(GCD, a[i]);
    }

    if(GCD != 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    REP(i,2,1e6){
        ll div_count = count[i];
        ll now = 2 * i;
        while(now <= 1e6){
            div_count += count[now];
            now += i;
        }
        if(div_count >= 2) {
            cout << "setwise coprime" << endl;
            return 0;
        }
    }

    cout << "pairwise coprime" << endl;
}



Measured memory_bytes: 18816
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	vi a(5);
	rep(i,0,5) cin>>a[i];
	rep(i,0,5) if(a[i]==0) cout<<i+1;
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3612
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(0, n)]

ab.sort()

ans = 0
c = 0
for a, b in ab:
  if c + b >= m:
    ans += (m - c) * a
    break
  else:
    ans += a * b
    c += b
print(ans)

Measured memory_bytes: 27880
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC123D
{
    class MainClass
    {

        static int[] xyzk;
        static long[] a;
        static long[] b;
        static long[] c;

        public static void Main(string[] args)
        {

            xyzk = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            a = Array.ConvertAll(Console.ReadLine().Split().ToArray(), long.Parse);
            b = Array.ConvertAll(Console.ReadLine().Split().ToArray(), long.Parse);
            c = Array.ConvertAll(Console.ReadLine().Split().ToArray(), long.Parse);


            var alst = a.ToList();
            var blst = b.ToList();
            var clst = c.ToList();

            alst.Sort((x, y) => y.CompareTo(x));
            blst.Sort((x, y) => y.CompareTo(x));
            //clst.Sort((x, y) => x.CompareTo(y));
            var ablst = new List<long>();
            for(int i = 0; i < xyzk[0]; i++)
            {
                for(int j = 0; j < xyzk[1]; j++)
                {
                    /*
                    if ((i + 1) * (j + 1) > xyzk[3])
                    {
                        break;
                    }
                    */
                    ablst.Add(alst[i] + blst[j]);
                }
            }

            ablst.Sort((x, y) => y.CompareTo(x));
            int ablen = Math.Min(ablst.Count, xyzk[3]);
            var abclst = new List<long>();
            for(int i = 0; i < ablen; i++)
            {
                for(int j = 0; j < xyzk[2]; j++)
                {
                    abclst.Add(ablst[i] + clst[j]);
                }
            }

            abclst.Sort((x, y) => y.CompareTo(x));
            for (int i = 0; i < xyzk[3]; i++)
            {
                Console.WriteLine(abclst[i]);
            }


        }
    }
}


Measured memory_bytes: 65560
#include<stdio.h>
int main(void){
    int a, b, c, d=0;
    int i;
    scanf("%d %d %d", &a, &b, &c);
    for(i=a; i<=b; i++){
        if(c%i==0){
            d++;
        }
    }
    printf("%d\n", d);
    return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

int main()
{
  int n, t;
  std::cin>>n>>t;
  
  int bestc, bestt;
  
  std::cin>>bestc;
  std::cin>>bestt;
  
  int judgec, judget;
  
  for(int i=0;i<n-1;i++)
  {
    std::cin>>judgec>>judget;
    
    if(t>=judget && bestc>judgec)
    {
      bestc=judgec;
      bestt=judget;
    }
    
  }
  
  if(bestt>t)
  {
    std::cout<<"TLE"<<"\n";
  }
  else
  {
	std::cout<<bestc<<"\n";
  }
  
  return 0;
}
      
	

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

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

	pair<int,int> shop[n];
	int a,b;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		shop[i]=make_pair(a,b);
	}

	sort(shop,shop+n);

	long long int ans=0;

	for(int i=0;i<n;i++){
		while(shop[i].second>0){
			--shop[i].second;
			--m;
			ans+=shop[i].first;
			if(m==0)break;
		}
		if(m==0)break;
	}


	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 1024
cookie = list(map(int, input().split()))

cookie.sort()

count = 0
if cookie[0] == cookie[2] and cookie[0] % 2 == 0:
    print(-1)
    exit()
    
while cookie[2] - cookie[0] > 0:
    if cookie[0] % 2 == 1 or cookie[1] % 2 == 1 or cookie[2] % 2 == 1:
        print(count)
        exit()
    if cookie[0] == cookie[2]:
        print(-1)
        exit()
    count += 1
    a = (cookie[1] + cookie[2]) // 2
    b = (cookie[2] + cookie[0]) // 2
    c = (cookie[0] + cookie[1]) // 2
    cookie[0] = a
    cookie[1] = b
    cookie[2] = c
    cookie.sort()

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    rep(i, n) {
        cout << s[i] << t[i];
    }
    cout << endl;
}

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


Measured memory_bytes: 3612
n=int(input())
hlist=list(map(int,input().split()))

tmpcount=0
maxcount=0
mae=0

for h in hlist:
    if mae >= h:
        tmpcount +=1
    else:
        if tmpcount > maxcount:
            maxcount = tmpcount
        tmpcount = 0
    mae = h
print(max(maxcount,tmpcount))

Measured memory_bytes: 14252
X, N = map(int, input().split())
P = list(sorted(map(int, input().split())))

mindiff = 1000
minval = None
for i in range(0, 101+1):
    diff = abs(X- i)
    if i not in P and diff < mindiff:
        mindiff = diff
        minval = i
print(minval)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int a[5];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	FOR(i, 3) cin >> a[i];
	sort(a, a+3);
	if (a[0] == a[1]) cout << a[2] << endl;
	else cout << a[0] << endl;
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  string S, T;
  cin >> S >> T;
  i64 a, b;
  cin >> a >> b;
  string U;
  cin >> U;
  if (S == U) {
    a--;
  } else {
    b--;
  }
  cout << a << " " << b << endl;

  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
if m % 2 == 1:

    cnt = 0

    for i in range(m // 2):
        num1 = 1 + i
        num2 = m - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
    for i in range(m // 2 + 1):
        num1 = m + 1 + i
        num2 = 2 * m + 1 - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
else:
    cnt = 0

    for i in range(m // 2):
        num1 = 1 + i
        num2 = m + 1 - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
    for i in range(m // 2):
        num1 = m + 2 + i
        num2 = 2 * m + 1 - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()


Measured memory_bytes: 9112
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int K=sc.nextInt();
		int X=sc.nextInt();
		
		for(int i=K-1;i>0;i--) {
			p(X-i);
		}
		for(int i=0;i<K;i++) {
			p(X+i);
		}
		
		
	}
	
		
	
	
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	map<string, int> days = {{"SUN", 7}, {"MON", 6}, {"TUE", 5}, {"WED", 4}, {"THU", 3}, {"FRI", 2}, {"SAT", 1}};
	string s;
	cin >> s;
	cout << days[s] << endl;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<pair<int, int>> vp;

int main()
{
    int n, a;
    cin>>n;
    REP(i,n) {
        cin>>a;
        vp.push_back({a, i+1});
    }
    SORT(vp);
    REP(i,n) {
        cout<<vp[i].scd;
        if (i < n - 1)
            cout<<" ";
    }
    nextline;

    return 0;
}


Measured memory_bytes: 1780
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, x[100001], y[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(x[i]), &(y[i]));

	list *adj[200001] = {}, e[200003];
	for (i = 1; i <= N; i++) {
		e[i*2].v = y[i] + 100000;
		e[i*2+1].v = x[i];
		e[i*2].next = adj[x[i]];
		e[i*2+1].next = adj[y[i]+100000];
		adj[x[i]] = &(e[i*2]);
		adj[y[i]+100000] = &(e[i*2+1]);
	}

	int count, flag[200001] = {}, q[200001], head, tail;
	long long ans = 0;
	list *p;
	for (i = 1; i <= 200000; i++) {
		if (flag[i] != 0 || adj[i] == NULL) continue;
		q[0] = i;
		flag[i] = 1;
		count = 1;
		for (head = 0, tail = 1; head < tail; head++) {
			for (p = adj[q[head]]; p != NULL; p = p->next) {
				if (flag[p->v] == 0) {
					flag[p->v] = -flag[q[head]];
					if (flag[p->v] == 1) count++;
					q[tail++] = p->v;
				}
			}
		}
		ans += (long long)count * (tail - count);
	}
	
	printf("%lld\n", ans - N);
	fflush(stdout);
	return 0;
}

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

long long int pow_2(int n) {
	long long int x;
	if (n == 1) {
		return 2;
	}
	if (n == 0) {
		return 1;
	}
	x = pow_2(n / 2);
	x *= x;
	x %= 1000000007;
	if (n % 2 == 0) {
		return x;
	}
	else {
		x *= 2;
		x %= 1000000007;
		return x;
	}
}

int main() {
	int n;
	cin >> n;
	long long int x;
	if (n % 2 == 0) {
		x = 1;
	}
	else {
		x = 0;
	}
	int y;
	vector<int> a(n, 0);
	int ans = 0;
	for (int i = 0;i < n;i++) {
		cin >> y;
		if (ans == 1) {
			continue;
		}
		if (y % 2 != x) {
			ans = 1;
			continue;
		}
		a[(y + 1) / 2]++;
		if (a[(y + 1) / 2] > 2) {
			ans = 1;
		}
		if (x == 0 && a[0] > 1) {
			ans = 1;
		}
	}
	if (ans == 1) {
		cout << "0" << endl;
	}
	else {
		x = pow_2(n / 2);
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define ull unsigned long long
#define EPS 1e-8
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
using namespace std;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const double pi = acos(-1.0);
inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return f*x;
}
inline void write(ll a){
    if (a<0) putchar('-'),a=-a;
    if (a>=10) write(a/10); putchar(a%10+'0');
}
const int MAX_N=2e5+10;
int a[MAX_N],b[MAX_N],n; 
int main()
{
 	#ifdef TEST
	 	freopen("input.txt","r",stdin);
	#endif
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		b[i]=a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		if(b[i]<a[n>>1])
		{
			printf("%d\n",a[n>>1]);
		}
		else
		{
			printf("%d\n",a[(n-1)>>1]);
		}
	}
	return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define INT long long int
#define MOD 1000000007
#define oo 978654321
#define OO 9999999987654321ll
#define PI (3.141592653589793238462643383279502884197)
using namespace std;
INT x, y, a, ans;
int main()
{
    ios::sync_with_stdio(false);
    cin>>x>>y;
    a = x;
    while( a <= y and a >= 0 )
    {
        ans++;
        a*=2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
ll a[N];

int main(){
    ll n,x,sum=0;cin>>n;
    for(ll i=0;i<n;i++)
        cin>>x,a[x]++;
    for(ll i=1;i<=N;i++)
        sum+=i*a[i];
    ll q;cin>>q;
    while(q--){
        ll b,c;cin>>b>>c;
        a[c]+=a[b];
        sum=sum+a[b]*(c-b);
        a[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 4408
#include<iostream>

void bubblesort(int *M){

  int u = 0,temp;

  while(u!=9){
    for(int i=9;i>u;i--){
      if(M[i]>M[i-1]){
        temp = M[i];
        M[i] = M[i-1];
        M[i-1] = temp;
      }
    }
    ++u;
  }
}
int main(){

  int M[10];
  for(int i=0;i<10;i++){
    std::cin >> M[i];
  }

  bubblesort(M);

  std::cout << M[0] << std::endl << M[1] << std::endl << M[2] << std::endl;

  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
const int MAX = 100001;
const int MOD = pow(10, 9) + 7;
// dp[i] : 13で割ったあまりが i である数値の個数
int dp[13], new_dp[13];
char s[MAX];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    // for (int i = 0; i < MAX; i++) s[i] = '?';

    dp[0] = 1;
    int mul = 1;
    for (int i = strlen(s) - 1; i >= 0; i--) {
        if (s[i] == '?') {
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 13; k++) {
                    new_dp[(mul * j + k) % 13] += dp[k];
                    new_dp[(mul * j + k) % 13] %= MOD;
                }
            }
        } else {
            int j = s[i] - '0';
            for (int k = 0; k < 13; k++) {
                new_dp[(mul * j + k) % 13] += dp[k];
                new_dp[(mul * j + k) % 13] %= MOD;
            }
        }

        for (int l = 0; l < 13; l++) {
            dp[l] = new_dp[l];
            new_dp[l] = 0;
        }
        mul *= 10;
        mul %= 13;
    }

    cout << dp[5] << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<cctype>
#include<stack>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn =  10;
int main()
{
	ios::sync_with_stdio(false);
	int t,n, k, flag, d[maxn];
	while (cin >> n >> k)
	{
		memset(d, 0, sizeof(d));
		for (int i = 0; i < k; i++)
		{
			cin >> t;
			d[t]++;
		}
		for (int i = n;; i++)
		{
			flag = 0;
			int a = i;
			while (a)
			{
				int x = a % 10;
				if (d[x])
				{
					flag = 1;
					break;
				}
				a = a / 10;
			}
			if (flag == 0)
			{
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

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

int main(){
  int n,sum=0;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];
  
  
  for(int i=0;i<n;i++)sum+=a[i];
  cout<<sum - n<<endl;
 }


Measured memory_bytes: 256
use std::io::{Read, Write};
use std::f64::consts::PI;

fn main() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut iter = input.split_whitespace();

    let r: f64 = iter.next().unwrap().parse().unwrap();
    out.write_fmt(format_args!("{:.5} {:.5}\n", PI*r*r, 2.0*PI*r)).unwrap();

}



Measured memory_bytes: 5056
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}
void solve()
{   int n;
    cin>>n;
    int a[n];
    fi(i,0,n)
        cin>>a[i];
    int cost[n];
    mz(cost);
    cost[0] = 0;
    cost[1] = abs(a[1] - a[0]);
    fi(i,2,n)
        cost[i] = min(abs(a[i] - a[i-1]) + cost[i-1],abs(a[i] - a[i-2]) + cost[i-2]);
    cout<<cost[n-1]<<"\n";
}
int main() {
        solve();

    return 0;
}


Measured memory_bytes: 1024
/*input
20
*/

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n; cin >> n;
  cout << 360 / __gcd(n, 360);

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

// Finds smallest s s.t. n/s < t
ll bins(ll n, ll t) {
	ll low = 1;
	ll high = n+1;
	while(low != high) {
		ll s = (low + high) / 2;
		if (n/s < t) high = s;
		else low = s + 1;
	}
	return low;
}

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

	ll n, k;
	cin >> n >> k;
	
	vector<ll> cou, val;
	ll s = 1;
	for (; s <= n;) {
		ll v = n/s;
		ll nxt_s = bins(n, v);
		cou.push_back(nxt_s - s);
		val.push_back(v);
		s = nxt_s;
	}
	int m = cou.size();

	vector<ll> cur = cou;
	vector<ll> nxt(m);
	for (int i = 1; i < k; ++i) {
		for (int j = 0; j < m; ++j) {
			int t = m-1-j;
			nxt[t] = cur[j] % MOD;
		}
		for (int j = m-1; j >= 0; --j) {
			nxt[j] = (nxt[j] + (j+1 < m ? nxt[j+1] : 0)) % MOD;
			cur[j] = (nxt[j] * cou[j]) % MOD;
		}
	}

	ll res = 0;
	for (auto v : cur) res = (res + v) % MOD;
	cout << res << '\n';
}

Measured memory_bytes: 2420
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    int ans = 0;
    if( a == b){
        ans += 2*a;
    }else if ( a > b){
        ans += a+(a-1);
    }else{
        ans += b+(b-1);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
MOD = 10**6+3
q = int(input())

fact = [1]*MOD
for i in range(1, MOD):
    fact[i] = fact[i-1]*i%MOD
finv = [1]*(MOD-1) + [pow(fact[-1], MOD-2, MOD)]
for i in range(MOD-1, 0, -1):
    finv[i-1] = finv[i]*i%MOD

for _ in range(q):
    x, d, n = map(int, input().split())
    if d == 0:
        ans = pow(x, n, MOD)
    else:
        x_div = x*pow(d, MOD-2, MOD)%MOD
        if x_div+n-1 > MOD:
            ans = 0
        else:
            if x_div+n-1 >= MOD:
                ans = 0
            else:
                f = fact[x_div+n-1]
                fi = pow(fact[x_div-1], MOD-2, MOD)
                ans = f*fi%MOD*pow(d, n, MOD)%MOD
    print(ans)


Measured memory_bytes: 84716
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 1e5 + 7;
int n, k, ans;
int Len[N];
vector<int>G[N];
void dfs(int u) {
	for(auto v:G[u]) {
		dfs(v);
		if(u != 1 && Len[v] == k - 1) { ++ans; continue;}
		Max(Len[u], Len[v] + 1);
	}
//	printf("%d %d\n", u, Len[u]);
}
int main() {
#ifdef fwat
#endif
	n = gi(), k = gi();
	int x = gi();
	if(x ^ 1) ++ans;
	rep(i, 2, n) G[gi()].pb(i);
	dfs(1);
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    int N;
    int joshi;
    cin >> N;
    vector<int> buka(N, 0);

    for(int i=1; i<N; i++) {
        cin >> joshi;
        buka[joshi]++;
    }
    for(int i=1; i<N; i++) cout << buka[i] << endl;
    cout << 0 << endl;
    return 0;
}


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

  int A, B;
  cin >> A >> B;
  
  
  if (25*A+25<=20*B || 20*B+20<=25*A){
    cout << -1 << endl;
  } else {
    cout << max((25*A+1)/2,10*B) << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin >> k;
    cout << a[k-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define __TRUE "yes"
#define __FALSE "no"

int main() {
  string s;
  cin >> s;
  bool flag=true;
  for(int i=0;i<s.size()-1;i++) {
    for(int j=i+1;j<s.size();j++) {
      if(s[i] == s[j]) {
        flag=false;
        break;
      }
    }
  }
  if(flag) cout << __TRUE << endl;
  else cout << __FALSE << endl;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair


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

    ll n;
    cin>>n;
    ll a[n],b[n],c[n-1];
    ll i;
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n;i++)cin>>b[i];
    for(i=0;i<n-1;i++)cin>>c[i];

    ll ans=0;
    for(i=0;i<n;i++){
        ans+=b[a[i]-1];
        if(i>0){

            if(a[i]-a[i-1]==1)
            {    ans+=c[a[i-1]-1]; 
                // cout<<a[i]<<" "<<a[i-1]<<" "<<c[a[i]-1]<<"\n";
            }
        }
    }
    cout<<ans;

    return 0;  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<cmath>

using namespace std;

struct S{
	long double L, a, b;
};

int N, M;
S color[30];
stack<int> calcs;



double search(int n,int num){
	if (n == 0){
		double sum = 0;
		int arr[100];
		for (int i = 0; i < M; i++){
			//cout << calcs.top()<<"="<<n << endl;
			arr[i] = calcs.top();
			calcs.pop();
		}
		for (int i = 0; i < M; i++){
			//cout << arr[i] << ",";
			for (int j = i + 1; j < M; j++){
				sum += pow(color[arr[i]].L - color[arr[j]].L, 2) + pow(color[arr[i]].a - color[arr[j]].a, 2) + pow(color[arr[i]].b - color[arr[j]].b, 2);
			}
		}
		//cout << endl;
		for (int i = M - 1; i >= 0; i--) calcs.push(arr[i]);
		//cout << sum << "," << calcs.size() << endl;
		return sum;
	}
	double mx = 0;
	for (int i = num; i < N; i++){
		calcs.push(i);
		mx = max(mx,search(n - 1, i+1));
		calcs.pop();
	}
	return mx;
}

int main(){

	cin >> N >> M;

	for (int i = 0; i < N; i++){
		cin >> color[i].L >> color[i].a >> color[i].b;
	}

	printf("%.6f\n", search(M, 0));
	return 0;
}

Measured memory_bytes: 1260
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    S=input()
    if(S=="SUN"):
        print(7)
    elif(S=="MON"):
        print(6)
    elif(S=="TUE"):
        print(5)
    elif(S=="WED"):
        print(4)
    elif(S=="THU"):
        print(3)
    elif(S=="FRI"):
        print(2)
    else:
        print(1)
resolve()

Measured memory_bytes: 38384