akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)	{
	
	int n, r, p, c, res;
	int yama[50];
	int temphigh[50];
	int templow[50];
	
	while (true)	{
		
		scanf("%d %d", &n, &r);
		
		if (n == 0)	{
			break;
		}
		
		// 山札の初期化
		for (int i = 0; i <= 49; i++)	{
			yama[i] = 50 - i;
			//printf("yama[%d] = %d\n", i, yama[i]);
		}
		
		for (int i = 1; i <= r; i++)	{

			scanf("%d %d", &p, &c);
			
			// p枚の札をtemphighにうつしとる
			for (int j = 0; j <= p-2; j++)	{
				temphigh[j] = yama[j];
			}
			
			// c枚の札をtemplowにうつしとる
			for (int j = 0; j <= c-1; j++)	{
				templow[j] = yama[j + (p-1)];
			}
			
			// c枚分山札を下にずらす
			for (int j = 0; j <= p-2; j++)	{
				yama[j + c] = temphigh[j];
			}
			
			////////////////////////////////////
			//printf("ずらす---------------\n");
			//for (int k = 0; k <= n-1; k++)	{
			//	printf("yama[%d] = %d\n", k, yama[k]);
			//}
			
			// templowを山札の上部にうつしとる
			for (int j = 0; j <= c-1; j++)	{
				yama[j] = templow[j];
			}
			
			//
			//printf("上部に戻す-------------\n");
			//for (int k = 0; k <= n-1; k++)	{
			//	printf("yama[%d] = %d\n", k, yama[k]);
			//}
			
		}
		
		res = yama[0] - (50 - n);
		
		printf("%d\n", res);
	}
	
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int t[26];
int main(void){
    // Your code here!
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0,p;
    for(int i=0;i<n-1;i++){
        p=0;
        for(int ii=0;ii<26;ii++){
            t[ii]=0;
        }
        for(int j=0;j<=i;j++){
            t[s[j]-'a']=1;
        }
        for(int k=i+1;k<n;k++){
            t[s[k]-'a']*=2;
        }
        for(int j=0;j<26;j++){
            //cout<<t[j]<<endl;
            if(t[j]>=2)p++;
        }
        ans=max(ans,p);
    }
    cout<<ans<<endl;
}


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

void solve()
{
    string S; cin >> S;
    int N = S.size();
    long long ans=0;
    for(int i = 0; i < (1 << N-1); ++i){
        string tmp = S;
        bitset<9> bit = i;
        int flags =0;
        vector<int> idx ={0};
        for(int j =0; j < N-1; j++){
            if(bit[j] == 1) {
                flags++;
                idx.push_back(j+1);
            }
        }
    
        for(int j = 0; j < flags; ++j){
            long long ll = stoll(tmp.substr(0, idx[j+1] - idx[j]));
            ans += ll;
            tmp.erase(0, idx[j+1]-idx[j]);
            // cout<< "j: "<<j << " " << idx[j+1] - idx[j] << endl;
        }
        long long a = stoll(tmp);
        ans += a;
        // cout << ans << endl;
    }   
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll ans = 1;
  ll n,k;cin>>n>>k;
  vector<ll> v[n];

  REP(i,n-1){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    v[a].pb(b);
    v[b].pb(a);
    //cout<<a<<"   "<<b<<" JIJI"<<endl;
  }

  queue<ll> q;
  q.push(0);
  ll lin[n];
  bool tan[n];
  REP(i,n){
    lin[i] = 1;
    tan[i] = false;
  }

  while(!q.empty()){
    ll l = q.front();
        //cout<<"ばば"<<l<<endl;
    q.pop();
    tan[l] = true;
    ll liveCount = 0;
    REP(i,v[l].size()){
      //cout<<"  "<<v[l][i]<<endl;
      if(tan[v[l][i]]){
        liveCount += lin[v[l][i]];
        //cout<<lin[v[l][i]]<<endl;;
        lin[v[l][i]]++;
        lin[l]++;
      }else{
        q.push(v[l][i]);
      }
    }
    ans *= k-liveCount;
    ans %= MOD;
  }

  cout<<ans<<endl;

 

  return 0;
}

Measured memory_bytes: 8180
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont,from,to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
int N;
string S;
vector<int> sumB;
int main() {
    cin  >> N >> S;
    sumB.resize(N+1,0);
    for(int i=0;i<N;++i) {
        sumB[i+1]=sumB[i]+(S[i]=='#');
    }
    int ans=N+100;
    for(int i=0;i<=N;++i) {
        ans=min(ans, N-i-(sumB[N]-sumB[i]) + sumB[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1412
/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC target("avx2")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'


using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

const double PI = acos((double)-1);
const double eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

void solve() {
	string s, t; cin >> s >> t;
	int n = s.size();
	if (t.substr(0, n) == s) cout << "Yes\n";
	else cout << "No\n";
	return;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>   
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a; return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE   
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main(){
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)<<endl;
    //printclock;
    return 0;
}

Measured memory_bytes: 3676
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF 1<<30
#define LINF 1LL60

struct edge {
	int to; // ?????????
	int cap; // ??????
	int rev; // ??????
	edge() {}
	edge(int to, int cap, int rev) :to(to), cap(cap), rev(rev) {}
};

vector<vector<edge>> G; // ??°???????????£??\???????????¨???
vector<int> used; // DFS??§?????§???????????????????????°

vector<vector<int>> one_path;

// from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from, int to, int cap) {
	if (cap == 1) {
		one_path[from].push_back(G[from].size());
		one_path[to].push_back(G[to].size());
	}
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, cap, G[from].size() - 1));
}

// ?¢?????????????DFS??§??¢???
int dfs(int v, int t, int f) {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

// s??????t???????????§???????±???????
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		fill(used.begin(), used.end(), 0);
		int f = dfs(s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}

/* ???1?????????(u,v)??? u->v??????????????§??????????????\????????????????????????????¢???? ex.( u->s->t->v) */
bool check(int u, int v, int rev) {
	if (u == v)return true;
	used[u] = true;
	for (int i = 0; i < G[u].size();i++) {
		if (used[G[u][i].to] == true) continue;
		if (G[u][i].cap <= 0) continue;
		if (G[u][i].to == rev)continue;
		if (check(G[u][i].to, v, u))return true;
	}
	return false;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	int F = 10000;
	G.resize(V); used.resize(V); one_path.resize(V);
	for (int i = 0; i < E;i++) {
		int s, t, c; cin >> s >> t >> c;
		add_edge(s, t, c);
	}

	int f = max_flow(0, V - 1);
	for (int i = 0; i < V;i++) {
		bool break_flag = false;
		for (int j = 0; j < one_path[i].size();j++) {
			if (G[i][one_path[i][j]].cap == 0) {
				fill(used.begin(), used.end(), 0);
				if (!check(i, G[i][one_path[i][j]].to, -1)) {
					f--; break_flag = true; break;
				}
			}
		}
		if (break_flag)break;
	}
	cout << ((f > F) ? -1 : f) << endl;
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int res = 0;
  for (int i = A; i <= B; i++) {
    if (i/10000 == i%10  && i/1000%10 == i%100/10) {
      res += 1;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3544
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ta, tb, tc;
	int ans = 0;
	while ((a!=b&&b!=c)
		&&(a % 2 == 0 && b % 2 == 0 && c % 2 == 0)) {
		ta = a;
		tb = b;
		tc = c;
		a = (ta + tb) / 2;
		b = (tb + tc) / 2;
		c = (ta + tc) / 2;
		ans++;
	}
	if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
		cout << ans << endl;
	}
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3612
from sys import stdin

def combination_table(N):
	C = []
	for i in range(N+1):
		C.append([0] * (N+1))
	for i in range(N+1):
		for j in range(i+1):
			if (j==0 or j==i):
				C[i][j] = 1
			else:
				C[i][j] = C[i-1][j-1]+C[i-1][j]
	return C

if __name__ == "__main__":
	N, A, B = stdin.readline().split(" ")
	N = int(N)
	A = int(A)
	B = int(B)
	V = []
	line = stdin.readline().split(" ")
	unique_elements = dict()
	for e in line:
		V.append(int(e)) 
		if not int(e) in unique_elements:
			unique_elements[int(e)] = 1
		else:
			unique_elements[int(e)] += 1
	V.sort(reverse=True)

	C = combination_table(N)

	# find optimal selections between A and B
	a_th_val_pos = 0
	a_th_val_num = 0
	highest_avg = float(sum(V[:A])) / float(A)
	for i in range(N):
		if V[i] == V[A-1]:
			a_th_val_num += 1
			if i < A:
				a_th_val_pos += 1


	cnt = 0
	if a_th_val_pos == A:
		for i in range(A, B+1):
			cnt += C[a_th_val_num][i]
	else:
		cnt += C[a_th_val_num][a_th_val_pos]

	print ("{:6f}".format(highest_avg))
	print (cnt)


Measured memory_bytes: 3064
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    let s = s.trim();
    let x: u32 = s.parse().unwrap();
    let fx = s.chars().map(|c| format!("{}", c).parse::<u32>().unwrap()).fold(0, |n, s| n + s);

    println!("{}", if x % fx == 0 { "Yes" } else { "No" });
}

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

#define lint long long

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

    int h[N + 1];

    for(int i = 1; i < N + 1; ++i){
        cin >> h[i];
    }
    
    int dp[N + 1];

    for(int i = 0; i < N + 1; ++i){
        dp[i] = 1000000000;
    }

    dp[N] = 0;

    for(int i = N - 1; i > 0; --i){
        for(int j = 1; j <= K && i + j <= N; ++j){
            dp[i] = min(dp[i], dp[i + j] + abs(h[i] - h[i + j]));
        }
    }
    
    cout << dp[1] << endl;
}

Measured memory_bytes: 1024
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            sum = 500 * i + 100 * j + 50 * k
            if sum == X:
                count += 1

print(count)


Measured memory_bytes: 3068
import sys
from collections import Counter

def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact

N, A, B = map(int,input().split())
V = list(map(int,input().split()))

c1 = Counter(V)

V.sort(reverse = True)

if all([V[0] == i for i in V[:A]]):
    print(V[0])
    ans = 0
    for i in range(A-1, B):
        if V[i] != V[0]:
            break
        ans += factorial(c1[V[0]])//(factorial(c1[V[0]]-(i+1))*factorial(i+1))
    print(ans)
    sys.exit()

print(sum(V[:A]) / A)

c2 = Counter(V[:A])

print(factorial(c1[V[A-1]])//(factorial(c1[V[A-1]]-c2[V[A-1]])*factorial(c2[V[A-1]])))

Measured memory_bytes: 3316
n = int(input())
list_score = list(map(int, input().split()))
ans = []
score = 0
if len(list_score) == 1:
    print(0)
else:
    for i in range(n-1):
        if list_score[i] >= list_score[i+1]:
            score += 1
        else:
            ans.append(score)
            score = 0
        if i == n-2:
            ans.append(score)

        #print(score, ans)

    print(max(ans))

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
using ll = long long;

const int nax = 1e5 + 5;
vector<int> edges[nax];

const int mod = 1e9 + 7;
int mul(int a, int b) {
	return (ll) a * b % mod;
}

pair<int,int> dfs(int current, int pre) {
	int presently_white = 1, presently_black = 1;
	for (auto each : edges[current]) {
		if (each != pre) {
			auto other_tree = dfs(each, current);

			presently_white = mul(presently_white, (other_tree.first + other_tree.second) % mod);

			presently_black = mul(presently_black, other_tree.first);
		}
	}

	return make_pair(presently_white, presently_black);
}

int main() {
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n - 1; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	pair<int,int> p = dfs(1, -1); //from 1 to endless
	int answer = (p.first + p.second) % mod;
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 16020
import sys


def main():
    n_and_k_s = sys.stdin.readline().strip().split(' ')
    n, k = [int(s) for s in n_and_k_s]
    h = [int(s) for s in sys.stdin.readline().strip().split(' ')]

    h.sort(reverse=True)

    total = 0
    special = 0
    for i in range(len(h)):
        if special < k:
            special += 1
            continue
        total += h[i]
    print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26764
import math
import sys


def insertionSort(data, N, g, cnt):
    
    for i in range(g, N):
        v = data[i]
        j = i - g
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j = j - g
            cnt += 1
        data[j+g] = v
        
    return data, cnt


def shellSort(data, N, G, cnt):
    
    h = 1
    while (True):
        if h > N:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    

    for i in range(m):
        data, cnt = insertionSort(data, N, G[i], cnt)
        
    return m, G, cnt


def main():
    N = int(input())
    data = [int(input()) for _ in range(N)]
    
    cnt = 0
    G = []
    m = 0
    
    m, G, cnt = shellSort(data, N, G, cnt)
    
    print(m)
    print(' '.join(map(str, G)))
    print(cnt)
    for i in range(N):
        print(data[i])
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 45604
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
	int n,m; cin >>n>>m;
	vector<int> l(m),r(m);
	cinf(m,l,r);
	int cnt[100005];
	int ans=0;
  for(int i=0;i<n+1;i++) cnt[i]=0;
	for(int i=0;i<m;i++){
		cnt[l[i]-1]++;
		cnt[r[i]]--;
	}
	for(int i=0;i<n;i++){
		cnt[i+1]+=cnt[i];
	}
	for(int i=0;i<n;i++){
		if(cnt[i]==m) ans++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
        pn(ni()*ni());
    }


    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();

        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();

        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;

    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

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

main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
     long long i,j,m,a,b,k,n,w,p,l;
    string s,t;
    while(cin>>s>>t){
        a=s.size();
        b=t.size();
        n=b;
        for(i=0;i<=a-b;i++){
            k=0;
            for(j=0;j<b;j++){
                if(s[i+j]!=t[j])k++;
            }
            n=min(k,n);
        }
        cout<<n<<endl;
    }
    return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e8
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V 100005

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rank;
    vector<int> size; // size[i]: iが親なら連結成分の数
 
    UnionFind(int N) : par(N), rank(N), size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {par[i] = i; rank[i] = 0; size[i] = 1;}
    }
 
    int find(int x) { // データxが属する木の根を再帰で得る：find(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }
 
    void unite(int x, int y) { // xとyの木を併合
        int rx = find(x); //xの根をrx
        int ry = find(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
 
        // rank[rx] >= rank[ry] となるように rx と ry を swap
        if(rank[rx] < rank[ry]) swap(rx, ry);
 
        // 同じ高さだったならばまとめたことによって高さ +1
        if(rank[rx] == rank[ry]) ++rank[rx];
 
        par[ry] = rx; // root rx に ry の木をつなぐ
        size[rx] += size[ry];
        size[ry] = 0;
 
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }
 
    int get_size(int x){
        int rx = find(x);
        return size[rx];
    }
};


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    UnionFind uf(n);

    REP(i, m) {
        int x, y;
        cin >> x >> y;
        uf.unite(x-1, y-1);
    } 

    int ans = 0;

    REP(i, n) {
        if(uf.same(i, a[i]-1)) ans++;
    }
 
    cout << ans << endl;
 
}
 

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  string s;
  cin >> s;

  bool flag = true;
  for (int i = 0; i + 1 < s.size(); i++) {
    if (s[i] != s[i + 1]) {
      flag = false;
      break;
    }
  }

  if (flag) {
    cout << 0 << endl;
    return 0;
  }

  set<char> st;
  for (int i = 0; i < s.size(); i++) st.insert(s[i]);

  int min = INF;
  for (char c = 'a'; c != 'z' + 1; c++) {

    string tmp = s;
    int num = s.size(), cont = 1;
    if (EXIST(st, c)) {
      while (true) {
        for (int i = 0; i + 1 < num; i++) {
          if (tmp[i + 1] == c) tmp[i] = c;
        }

        bool flag = true;
        for (int i = 0; i + 1 < num; i++) {
          if (tmp[i] != c) {
            flag = false;
            break;
          }
        }

        if (flag) break;

        num--;
        cont++;
      }
      chmin(min, cont);
    }
  }

  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;
  cin>>n;
  if(n==3){
    cout<<"2 5 63"<<endl;
    return 0;
    }
  int cnt=0;
  int sum=0;
  rep(i,30000){
    if(cnt==n-2)break;
    if((i+1)%2==0||(i+1)%3==0){
      cout<<i+1<<" ";
      cnt++;
      sum=(sum+i+1)%6;
      }
    }
  if(sum==0)cout<<"29996 29998"<<endl;
  if(sum==1)cout<<"29996 29997"<<endl;
  if(sum==2)  cout<<"29998 30000"<<endl;
  if(sum==3)  cout<<"29997 30000"<<endl;
  if(sum==4)  cout<<"29996 30000"<<endl;
  if(sum==5)  cout<<"29997 29998"<<endl;     
    
  return 0;
  }

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			long n = long.Parse(Console.ReadLine());
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
			var a = new List<long>();

			long total = 0;
			for (var i = 0; i < n; ++i) {
				total += array[i];
			}

			long min = int.MaxValue;

			long sunuke = 0;
			long arai = 0;
			
			for (var i = 0; i < n - 1; ++i) {
				sunuke += array[i];
				arai = total - sunuke;
				long ans = Math.Abs(sunuke - arai);
				if (ans < min) {
					min = ans;
				}
			}

			Console.WriteLine($"{min}");
			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 34040
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#include <map>
#define pb push_back
#define ll long long
using namespace std;
string lcs(string X,string Y,int m, int n)
{
    int dp[m+1][n+1];
    int i,j;
    for(i=0;i<=m;i++)
    {
        dp[i][0]=0;
    }
    for(i=1;i<=n;i++)
    {
        dp[0][i]=0;
    }
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(X[i-1]==Y[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int p=m,q=n;
    string ans;
    while(p>=1 && q>=1)
    {
        if(X[p-1]==Y[q-1])
           {
               ans+=X[p-1];
               p--;
               q--;
           }
           else if(dp[p-1][q]<dp[p][q-1])
           {
               q--;
           }
           else
           {
               p--;
           }
    }
    reverse(ans.begin(),ans.end());
    return ans;
}
int main()
{
    string s,t;
    cin>>s;
    cin>>t;
    int n,m;
    m=s.length();
    n=t.length();
    cout<<lcs(s,t,m,n);
    return 0;
}


Measured memory_bytes: 35456
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arrT = new int[n];
    int[] arrA = new int[n];
    for (int i = 0; i < n; i++) {
      arrT[i] = sc.nextInt();
      arrA[i] = sc.nextInt();
    }
    sc.close();

    BigDecimal t = BigDecimal.valueOf(arrT[0]);
    BigDecimal a = BigDecimal.valueOf(arrA[0]);
    for (int i = 1; i < n; i++) {
      BigDecimal ratT = BigDecimal.valueOf(arrT[i]);
      BigDecimal ratA = BigDecimal.valueOf(arrA[i]);
      BigDecimal mltT = t.divide(ratT, 0, RoundingMode.CEILING);
      BigDecimal mltA = a.divide(ratA, 0, RoundingMode.CEILING);
      BigDecimal mlt = mltT.compareTo(mltA) >= 0 ? mltT : mltA;
      t = ratT.multiply(mlt);
      a = ratA.multiply(mlt);
    }
    System.out.println(t.add(a).longValue());
  }
}


Measured memory_bytes: 26348
#include <stdio.h>


int main(void){

    int a[5];
    scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);

    for (int i = 0; i < 5; i ++) {
        if(a[i] == 0) {
            printf("%d", i + 1);
        }

    }


    return 0;
}

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

void merge_sort(long long x[], int n)
{
	static long long y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N;
	long long A[100001];
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%lld", &(A[i]));
	
	merge_sort(A, N);
	long long sum[100001] = {A[0]};
	for (i = 1; i < N; i++) sum[i] = sum[i-1] + A[i];
	for (i = N - 2; i >= 0; i--) if (sum[i] * 2 < A[i+1]) break;
	
	printf("%d\n", N - i - 1);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,m,n) for(int i=m;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int n;
	cin>>n;
	int x[n];
	REP(i,n)cin>>x[i];
	int ans=INT_MAX;

	REP(i,101){
		int pos = i;
		int temp = 0;
		REP(j,n){
			temp+=(x[j]-pos)*(x[j]-pos);
		}
		ans=min(ans,temp);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        solve2(sc, N);
    }

    private static void solve2(Scanner sc, int N) {
        System.out.println(0);
        String leftString = sc.next();
        if (leftString.equals("Vacant")) {
            return;
        }

        int left = 0;
        int right = N;
        while (true) {
            int mid = (left+right)/2;
            int numLeft = mid - left + 1;
            System.out.println(mid);
            String ans = sc.next();
            if (ans.equals("Vacant")) return;

            if ((numLeft)%2 == 0 && leftString.equals(ans)
                    || (numLeft)%2 != 0 && !leftString.equals(ans)) {
                // 偶数個なら左右が同一だと交互に配置できないのでこの領域に空席がある
                // 奇数個なら左右が異なると交互に配置できないのでこの領域に空席がある
                // この場合探索領域を左半分に絞ってよい
                right = mid;
            } else {
                // それ以外なら探索領域を右半分に絞ってよい
                leftString = ans;
                left = mid;
            }
        }
    }
}

Measured memory_bytes: 23720
N=int(input())
s=str(input())
S=[]
for i in s:
    S.append(i)

i=0
count=0
while i<N-1:
    if (S[i]=='O' and S[i+1]=='X') or (S[i]=='X' and S[i+1]=='O'):
        count+=1
        i+=2
    else:
        i+=1
print(count)



Measured memory_bytes: 6500
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int q = in();
	set<int>s;
	REP(i, q)
	{
		int n = in();
		int x = in();
		switch (n)
		{
		case 0:
			s.insert(x);
			cout << s.size() << endl;
			break;
		case 1:
			cout << (s.find(x) == s.end() ? 0 : 1) << endl;
			break;
		case 2:
			s.erase(x);
			break;
		}
	}
}


Measured memory_bytes: 12320
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
#define pb push_back
#define fi first
#define se second
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1LL<<60;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
int main(){
    string st;
    cin>>st;
    ll ans=0;
    ll cnt=0;
    REPR(i,st.size()-1){
        if(st[i]=='W'){
            cnt++;
        }else{
            ans+=cnt;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x=0,a=0;
    cin>>x>>a;
    if(x<a)
        cout<<"0";
    else
        cout<<"10";
    cout<<endl;
}


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

int main()
{
    int n,k,x,y;
    cin >> n;
    cin >> k;
    cin >> x;
    cin >> y;
    if(n > k) cout << k*x + (n-k)*y << endl;
    else cout << n*x << endl;
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    if (S == "Y"){
      cout << "Four" << endl;
      break;
    }
    if (i == N - 1){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;

signed main(){
    int n;
    cin >> n;
    int m;
    cin >> m;
    
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;




typedef long long LL;


int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, K; cin >> N >> K;
  long double part = 0;
  for (int i = 1; i <= N; ++i) {
    int cur = i;
    double w = 1;
    while (cur < K) w /= 2, cur *= 2;
    part += w;
  }
  cout << fixed << setprecision(10);
  cout << part / N << '\n';
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc084/tasks/abc084_d
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    vector<ll> isprime(100011, 0);
    size_t N = isprime.size();
    for (size_t n = 2; n < N; ++n)
    {
        if (isprime[n] == -1)
            continue;
        
        isprime[n] = 1;
        for (size_t k = n + n; k < N; k += n)
        {
            isprime[k] = -1;
        }
    }

    ll Q;
    cin >> Q;
    vector<ll> l(Q), r(Q);
    REP(i, Q) cin >> l[i] >> r[i];
    vector<ll> cnt(N, 0);
    for (size_t n = 3; n < N; n += 2)
    {
        if (isprime[n] == 1 && isprime[(n + 1) / 2] == 1)
        {
            cnt[n] = cnt[n - 2] + 1;
            cnt[n - 1] = cnt[n - 2];
        }
        else
        {
            cnt[n] = cnt[n - 2];
            cnt[n - 1] = cnt[n - 2];
        }
        
    }

    ll res = 0;
    REP(i, Q)
    {
        res = cnt[r[i]] - cnt[l[i] - 1];
        printf("%lld\n", res);
    }

    return 0;
}


Measured memory_bytes: 6368
import std.stdio;
import std.string;
import std.conv;

void main() {
    
    // input
    int n = to!int(readln.chomp);
    int k = to!int(readln.chomp);
    
    int[] x, y;
    x.length = y.length = k;
    
    for(int i=0; i<k; ++i) {
        auto temp = readln.split;
        x[i] = to!int(temp[0]);
        y[i] = to!int(temp[1]);
    }
    
    // output
    for(int i=0; i<k; ++i) {
        if(x[i] > n / 2)    x[i] = n - x[i] + 1;
        if(y[i] > n / 2)    y[i] = n - y[i] + 1;
        
        int min = x[i] < y[i] ? x[i] : y[i];
        writeln((min + 2) % 3 + 1);
    }
    
}

Measured memory_bytes: 2536
#ifndef bhartiya
    // #pragma GCC optimize("Ofast")
    // #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

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

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cout << "\n\nTime elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
}
#else
#define endl '\n'
#define trace(...)
#define start_routine()
#define end_routine()
#endif

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7

ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }
ll n,k;
ll a[105];
ll grundy[100005];
bool vis[105];

void find(ll ind){
    rep(i,105) vis[i] = false;
    rep(i,n){
        ll g;
        if(ind - a[i] >= 0){
            g = grundy[ind - a[i]];
            vis[g] = true;
        }
    }
    rep(i,105){
        if(!vis[i]){
            grundy[ind] = i;
            return;
        }
    }
}

int main() 
{ 
    start_routine();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        cin>>n>>k;
        ll low = inf;
        rep(i,n){
            cin>>a[i];
            low = min(a[i], low);
        }
        fr(i,low,k){
            find(i);
        }
        if(grundy[k]){
            cout<<"First\n";
        }
        else{
            cout<<"Second\n";
        }
    }
    end_routine();
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>

using namespace std;

int main(){
	int n,k,l[50];
	cin >> n >> k;
	for(int i = 0;i < n;i++){
		cin >> l[i];
	}
	sort(l,l+n,greater<int>());
	int res = 0;
	for(int i = 0;i < k;i++) res += l[i];
	cout << res;
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll k;
    cin >> k;
    ll num = 7 % k;
    REP(i, k + 1000) {
        if(num == 0) {
            cout << i + 1 << en;
            return;
        }
        num *= 10;
        num += 7;
        num %= k;
        //cout << num << en;
    }

    cout << -1 << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


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

int n, m;
string s;
int main() {
	cin >> s;
	n = s.find("A");
	reverse(s.begin(), s.end());
	m = s.size() - s.find("Z");
	cout << m - n << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    long long N,M;
    long long answer=0;
    cin>>N>>M;
    if(N==1 && M==1){
        cout<<1<<endl;
    }else if(N==1 && M!=1){
        cout<<M-2<<endl;
    }else if(N!=1 && M==1){
        cout<<N-2<<endl;
    }else{
        cout<<N*M-2*N-2*M+4<<endl;
    }
    
	
    return 0;
}


Measured memory_bytes: 256
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
 //  cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        string s,t;
        cin>>s>>t;
        ll ans=0;
        for(int i=0;i<s.size();i++)
        {
          if(s[i]!=t[i])
            ans++;
        }
        cout<<ans;

     
    }
    return 0;
}

Measured memory_bytes: 3812
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,x) for(int i=head[x];i+1;i=nxt[i])
using namespace std;
int f[20][70005],g[70005];
int con[20][20];
inline int lowbit(int x){return x&(-x);}
int main()
{
	int n,m;scanf("%d%d",&n,&m);int tot=0;
	rep(i,1,m){int x,y,z;scanf("%d%d%d",&x,&y,&z);con[x][y]=con[y][x]=z;tot+=z;}
	memset(f,-1,sizeof(f));
	rep(i,1,(1<<n)-1)rep(j,1,n)if((1<<(j-1))&i)rep(k,j+1,n)if((1<<(k-1))&i)g[i]+=con[j][k];
	rep(i,1,(1<<n)-1)if(i&1)f[1][i]=g[i];
//	rep(i,1,(1<<n)-1)printf("%d ",g[i]);puts("");
	rep(j,0,(1<<n)-1)
	{
		rep(i,1,n)if(f[i][j]>=0)
		{
			int k=((1<<n)-1)^j;
			//printf("Case 0:%d %d\n",k,j);
			for(int p=k;p;p=(p-1)&k)
			{
				//printf("Case 0:%d %d\n",k,p);
				rep(nxt,1,n)if(((1<<(nxt-1))&p) && con[i][nxt])
				{
					f[nxt][j|p]=max(f[nxt][j|p],f[i][j]+con[i][nxt]+g[p]);
				}
			}
		}
	}
	int ans=0;
	rep(i,1,(1<<n)-1)ans=max(ans,f[n][i]);
	printf("%d\n",tot-ans);
	return 0;
}

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

using namespace std;

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

int main(){

	int n;
	cin>>n;
	int flag=0;
	if(n/100==7)flag=1;
	else if((n/10)%10==7)flag=1;
	else if(n%10==7)flag=1;

	if(flag==1)cout<<"Yes";
	else cout<<"No";
	cout<<endl;
}


Measured memory_bytes: 3640
def main():
    n, *target = map(int, input().split())
    l = [int(input()) for _ in range(n)]
    ans = float("inf")
    base = 4
    for i in range(pow(base, n)):
        now_l = [0] * base
        add = [0] * base
        now = i
        for j in range(n):
            now_l[now % base] += l[j]
            add[now % base] += 1
            now //= base
        if 0 in now_l[:base - 1]:
            continue
        now_ans = sum([abs(target[i] - now_l[i]) for i in range(3)]) + (sum(add[:3]) - 3) * 10
        ans = min(ans, now_ans)
    print(0 if all(t in l for t in target) else ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9148