akhauriyash/Code-Regression huggingface dataset:
/*input
8 6
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	cout<<n-k+1;
	return 0;
}


Measured memory_bytes: 256
//
// Created by kuroneko on 2019-07-06.
//

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

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

    for (int i = 0; i < N - 1; i++) {
        if (A[i] < 0 && A[i+1] < 0) {
            A[i] *= -1;
            A[i+1] *= -1;
        } else if (A[i] < 0) {
            if (abs(A[i]) > A[i+1]) {
                A[i] *= -1;
                A[i+1] *= -1;
            }
        }
    }
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        sum += A[i];
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
  // if the total score in one loop is positive, keep looping as many times as possible
  // if the total score in one loop is negative, take the max score in one loop
  int n, kk;
  cin >> n >> kk;
  vector<int> p(n), c(n);
  rep(i, n) { cin >> p[i]; p[i]--; }
  rep(i, n) cin >> c[i];

  ll ansMax = -10000000000000;
  for (int j = 0; j < n; j++) {
    ll score = c[p[j]], current = p[j], length = 1;
    while (current != j) {
      current = p[current];
      score += c[current];
      length++;
    }
    //cout << "info: " << score << " " << length << endl;

    ll ans = 0;
    if (score <= 0) {
      current = p[j]; score = c[current];
      ans = score;
      //cout << "ans: " << ans << endl;
      while (current != j) {
        current = p[current];
        score += c[current];
        if (ans < score) ans = score;
      }
    } else {
      int numberOfLoops = (kk - length + 1) / length;
      //cout << "numberOfLoops: " << numberOfLoops << endl;
      ans += numberOfLoops * score;
      //cout << "ans: " << ans << endl;
      int k = kk - numberOfLoops * length;
      //cout << "remaining " << k << endl;
      int i = 1;
      current = p[j]; score = c[current];
      ll maxScore = score;
      while (i < k) {
        current = p[current];
        score += c[current];
        if (maxScore < score) maxScore = score;
        i++;
      }
      ans += maxScore;
    }

    //cout << "start from " << j << ": " << ans << endl;
    if (ansMax < ans) ansMax = ans;
  }

  cout << ansMax << endl;
  return 0;
}
/*
*/


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    int x, y;
    
    cin >> x;
    cin >> y;
    
    if ( x > 0  &&  x < 10  &&  y > 0  &&  y < 10 ){
        cout << (x*y);
    }
    else{
        cout << ("-1");
    }

    return 0;
}


Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner
var out *bufio.Writer

const INF = 1 << 60

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	N, M, P := nextInt3()
	G := make([]edge, M)
	for i := 0; i < M; i++ {
		a, b, c := nextInt3()
		G[i] = edge{a, b, -(c - P)}
	}
	d, neg := solve(G, 1, N)
	if !neg[N] {
		fmt.Fprintln(out, max(0, -d[N]))
	} else {
		fmt.Fprintln(out, -1)
	}
}

type edge struct{ from, to, cost int }

func solve(G []edge, s, n int) ([]int, []bool) {

	d := make([]int, n+1)
	for i := 0; i < len(d); i++ {
		d[i] = INF
	}
	d[s] = 0

	neg := make([]bool, n+1)

	for i := 0; i < n-1; i++ {
		for u := 0; u < len(G); u++ {
			e := G[u]
			if d[e.from] != INF && d[e.to] > d[e.from]+e.cost {
				d[e.to] = d[e.from] + e.cost
			}

		}
	}
	//nd := append([]int{}, d...)
	for i := 0; i < n; i++ {
		for u := 0; u < len(G); u++ {
			e := G[u]
			if d[e.from] != INF && d[e.to] > d[e.from]+e.cost {
				d[e.to] = d[e.from] + e.cost
				neg[e.to] = true
			}
			if neg[e.from] {
				neg[e.to] = true
			}
		}
	}
	return d, neg
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInt2() (int, int)      { return nextInt(), nextInt() }
func nextInt3() (int, int, int) { return nextInt(), nextInt(), nextInt() }
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func cond(condition bool, t, f int) int {
	if condition {
		return t
	}
	return f
}
func abs(a int) int { return cond(a < 0, -a, a) }
func min(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		chmin(&ret, a[i])
	}
	return ret
}
func max(a ...int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		chmax(&ret, a[i])
	}
	return ret
}
func chmin(a *int, b int) { *a = cond(*a < b, *a, b) }
func chmax(a *int, b int) { *a = cond(*a > b, *a, b) }


Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
const u32 P=1e9+7;
inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}
const int N=1e6+1;
int n;
u32 fac[N], ifac[N], inv[N];
u64 com(int n, int r) {return n<0||r<0||r>n?0:(u64)fac[n]*ifac[n-r]%P*ifac[r]%P;}
int main() {
	n=rd();
	fac[0]=1;
	for(int i=1; i<=n; ++i) fac[i]=(u64)fac[i-1]*i%P;
	ifac[n]=power(fac[n], P-2);
	for(int i=n; i--; ) ifac[i]=(i+1llu)*ifac[i+1]%P;
	for(int i=1; i<=n; ++i) inv[i]=(u64)ifac[i]*fac[i-1]%P;
	u32 a=0, b=1, ans=0;
	for(int i=1; i<=n; ++i) {
		a=dif(b, a), inc(b, b);
		ans=(ans+com(n, i)*a%P*inv[n]%P*inv[i])%P;
	}
	ans=ans*power((P+1)/3, n)%P;
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n;
  string s,t ;
  cin >> n >> s >> t;
  int l = 2 * n;
  rep(i,n) {
    string tt = t.substr(0,i+1);
    string ss = s.substr(n-i-1,i+1);
    if (ss == tt) l = min(l, 2 * n - i -1);
    //if (s.substr(n-i-i,i+1) == t.substr(0,i+1)) l = min(l, 2*n-i-1); 
  }
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }
const lint mod = 1e9 + 7;

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  V<lint> dp1(n + 1), dp2(n + 1), dp3(n + 1);
  lint fr = 1;
  for (int i = 0; i < n; i++) {
    dp1[i + 1] = dp1[i], dp2[i + 1] = dp2[i], dp3[i + 1] = dp3[i];
    if (s[i] == 'A') {
      dp1[i + 1] = (dp1[i] + fr) % mod;
    }
    if (s[i] == 'B') {
      dp2[i + 1] = (dp2[i] + dp1[i]) % mod;
    }
    if (s[i] == 'C') {
      dp3[i + 1] = (dp3[i] + dp2[i]) % mod;
    }
    if (s[i] == '?') {
      dp1[i + 1] = (3 * dp1[i] + fr) % mod;
      dp2[i + 1] = (3 * dp2[i] + dp1[i]) % mod;
      dp3[i + 1] = (3 * dp3[i] + dp2[i]) % mod;
      fr = fr * 3 % mod;
    }
  }
  cout << dp3[n] << '\n';
}

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

int main()
{
	
	string s;
	
	cin>>s;
	
	string str,str2;
	
	if(s.size()%2==0)
	{
		for(int i=0; i<s.size()/2; i++)
			str+=s[i];
		for(int i=s.size()/2; i<s.size(); i++)
			str+=s[i];
	}
	else
	{
		for(int i=0; i<s.size()/2; i++)
			str+=s[i];
		for(int i=s.size()/2+1; i<s.size(); i++)
			str2+=s[i];
	}
	
	if(str==str2)
		cout<<"Yes"<< endl;
	else
		cout<<"No"<< endl;
		return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll k,n,suma,v[10010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    for(int i=1;i<=k;i++)
        suma+=v[i];
    cout<<suma;
    return 0;
}


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

int main() {
  float N;
  cin >> N;
  vector<float> X(N);
  for (int i = 0; i < N; ++i) {
    cin >> X.at(i);
  }
  float sum = accumulate(X.begin(), X.end(), 0);
  float mean = round(sum / N);
  float result = 0;
  for (int i = 0; i < N; ++i) {
    float xi = X.at(i);
    result += pow(xi - mean, 2);
  }
  cout << result << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

template<size_t N>
struct MatrixGraph { // {{{
    i64 G[N][N];
    constexpr explicit MatrixGraph() {
        for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) G[i][j] = LINF;
        for (int i = 0; i < N; ++i) G[i][i] = 0;
    }
    i64* operator[] (size_t i) { return G[i]; }
    const i64* operator[] (size_t i) const { return G[i]; }
};
// }}}

template<size_t N>
int floyd(MatrixGraph<N> &G, int V) // {{{
{
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            if (G[i][k] >= LINF) continue;
            for (int j = 0; j < V; ++j) {
                if (G[k][j] >= LINF) continue;
                chmin(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }

    for (int i = 0; i < V; ++i) if (G[i][i] < 0) return -1;
    return 0;
}
// }}}

signed main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);

    MatrixGraph<10> cost;

    int H, W;

    cin >> H >> W;

    for (int i = 0; i <= 9; ++i) {
        for (int j = 0; j <= 9; ++j) {
            cin >> cost[i][j];
        }
    }

    floyd(cost, 10);

    i64 ans = 0;

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            int a; cin >> a;
            if (a == -1 || a == 1) continue;
            ans += cost[a][1];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  int64_t x, y;
  cin >> x >> y;
  int64_t idx = 0LL;
  while (true) {
    idx++;
    x *= 2LL;
    if(x > y) {
      cout << idx << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

N,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
#print(N,K)
#print("A:",A)
#print(F)

A.sort()
F.sort(reverse=True)
#print("A:",A)
#print("F:",F)

left=-1
right=10**18
#right=10**3

while left+1<right:
  mid=(left+right)//2
  tmp=0
  for i in range(N):
    tmp+=max(A[i]-mid//F[i],0)
    
  if tmp<=K:
    right=mid
  else:
    left=mid
  #print("mid:",mid,",tmp:",tmp)
#print("left:",left,",mid:",mid,",right:",right)
print(right)

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

int main() {
  long long int N,K,last=0;
  vector<pair<int,int>> abs(0);
  cin>>N>>K;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    pair<int,int> ab(a,b);
    abs.push_back(ab);
  }
  sort(abs.begin(),abs.end());
  for(int i=0;i<N;i++){
    last+=abs.at(i).second;
    if(K<=last){
      cout<<abs.at(i).first<<endl;
      break;
    }
  }
}

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string s;
    cin >> s;
    if(s[s.length()-1]=='s') s += "es";
    else s += "s";
    print(s);
    return 0;
}

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

signed main() {
    int n, k, x, y, z;
    cin >> n;
    cin >> k;
    cin >> x;
    cin >> y;
    
    z = ((k-n)<0 ? k:n) * x + ((n-k)>0 ? (n-k):0) * y;

    cout << z << "\n" << endl;
    return 0;
}



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

using ll = long long;
#define MOD_BIG (ll)(1e9+7)

ll n, m;
vector<ll> a;
vector<bool> anaflag;
vector<ll> dp_memo;

ll dp(ll t)
{
    if(t==0){
        return 1;
    }
    if(t==1){
        if(anaflag[t]){
            return 0;
        }else{
            return 1;
        }
    }

    if(dp_memo[t] + 1){
        return dp_memo[t];
    }
    if(anaflag[t] || (anaflag[t-2]&&anaflag[t-1])){
        return dp_memo[t] = 0;
    }
    return dp_memo[t] = (dp(t-2) + dp(t-1)) % MOD_BIG;
    
}

int main(void)
{
    cin >> n >> m;
    a.resize(m);
    anaflag.assign(n+1, false);
    dp_memo.assign(n+1, -1);

    for (ll i = 0; i < m; i++)
    {
        cin >> a[i];
        anaflag[a[i]] = true;
    }

    // for(ll i=0;i<=n;i++){
    //     cout << i << dp(i) << endl;
    // }
    cout << dp(n) << endl;

}

Measured memory_bytes: 3072
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k,a[MAXN];
char str[MAXN];
int cntw[MAXN],cntb[MAXN];
int main()
{
    scanf("%d",&n);
    scanf("%s",str+1);
    int ans=INF;
    for(int i=1;i<=n;i++) 
    {
        cntw[i]=cntw[i-1]+(str[i]=='.');
        cntb[i]=cntb[i-1]+(str[i]=='#');
    }
    for(int i=0;i<=n;i++)
    {
        ans=min(ans,cntb[i]+(cntw[n]-cntw[i]));
    }
    printf("%d\n",ans);
    return 0;
}



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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int a,b,c;
    cin  >> a >> b >> c;
    if(a+b+c>=22){
        cout << "bust";
        return 0;
    }else{
        cout << "win";
        return 0;
    }


}

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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
  int n;
  bool flag[110][110];
  while(cin >> n, n) {
    rep(i, n+1) rep(j, n+1) flag[i][j] = false;

    rep(i, n) {
      int m; cin >> m;
      rep(j, m) {
        int x; cin >> x;
        flag[i][x] = true;
      }
    }

    int k; cin >> k;
    vi tmp(k);
    rep(i, k) cin >> tmp[i];

    vi ans;
    rep(i, n) {
      rep(j, k) {
        if(!flag[i][tmp[j]]) break;
        if(j == k-1) ans.push_back(i+1);
      }
    }
    if(ans.size() == 1) cout << ans[0] << endl;
    else cout << -1 << endl;
  }
}

Measured memory_bytes: 1232
using System;
using System.Linq;
using System.Collections.Generic;
    
class Program
{
    static void Main(string[] args)
    {
        string[] ABCK = Console.ReadLine().Split(' ');
        int A = int.Parse(ABCK[0]);
        int B = int.Parse(ABCK[1]);
        int C = int.Parse(ABCK[2]);
        int K = int.Parse(ABCK[3]);

        if(K <= A) {
            Console.WriteLine(K);
        } else if(A < K && K <= A+B) {
            Console.WriteLine(A);
        } else if(A+B < K) {
            Console.WriteLine(A*2 - K + B);
        }
    }
}

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

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

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<int> v(n);
	rep (i, 0, n)
		cin >> v[i];

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

	float tmp = v[0];
	rep (i, 1, n) {
		tmp = (tmp + v[i]) / 2;
	}

	cout << tmp << endl;

	return 0;
}


Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
 
//const long long INF = 1LL << 55;
 
#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false)

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
   ioboost;
   ll w,h;cin >> w >> h;
   vector<pair<ll,ll>> r;
   rep(i,w){
      ll p;cin >> p;
      r.pb(mp(p,0));
   }
   rep(i,h){
      ll q;cin >> q;
      r.pb(mp(q,1));
   }
   sort(all(r));
   ll ans = 0;
   
   ll a = w + 1;
   ll b = h + 1;
   
   for(auto i : r){
      if(i.second){
         ans += i.first * a;
         b--;
      }else{
         ans += i.first * b;
         a--;
      }
   }
   
   cout << ans << endl;
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
const int inf=2000000000;
struct node
	
{
	int l,r;
}t[100001];
bool cmp(node a,node b)
{
	if(a.r==b.r)
		return a.l>b.l;
	return a.r<b.r;
}
bool cmp2(node a,node b)
{
	if(a.l==b.l)
		return a.r<b.r;
	return a.l<b.l;
}
priority_queue<int,vector<int>,less<int> >q1;
priority_queue<int,vector<int>,greater<int> >q2;
int fl[100001],fr[100001];
int bl[100001],br[100001];
signed main() 
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&t[i].l,&t[i].r);
	sort(t+1,t+n+1,cmp);
	sort(t+2,t+n+1,cmp2);
	int mxl=0,mnr=inf,mx=0,at=0;
	for(int i=1;i<=n;i++)
	{
		mxl=max(mxl,t[i].l);
		mnr=min(mnr,t[i].r);
		fl[i]=mxl;
		fr[i]=mnr;
		if(mx<t[i].r-t[i].l+1)
			mx=t[i].r-t[i].l+1,at=i;
	}

	mxl=0,mnr=inf;
	for(int i=n;i>=1;i--)
	{
		mxl=max(mxl,t[i].l);
		mnr=min(mnr,t[i].r);
		bl[i]=mxl;
		br[i]=mnr;
		q1.push(t[i].l);
		q2.push(t[i].r);
	}
	
	int ans=0;
	for(int i=n;i>=1;i--)
	{
		int tmp1=0,tmp2=0;
		if(q1.top()==t[i].l)
		{
			q1.pop();
			tmp1=t[i].l;
		}
		if(q2.top()==t[i].r)
		{
			q2.pop();
			tmp2=t[i].r;
		}
		ans=max(ans,max(q2.top()-q1.top()+1,0)+t[i].r-t[i].l+1);
		if(tmp1)
			q1.push(tmp1);
		if(tmp2)
			q2.push(tmp2);
	}
	for(int i=1;i<n;i++)
	{
		ans=max(ans,max(fr[i]-fl[i]+1,0)+max(br[i+1]-bl[i+1]+1,0));
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    print((n + k - 3)/(k - 1));
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if((j < a && i >= b) || (j >= a && i < b)) {
        cout << 1;
      } else {
        cout << 0;
      }
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    if((a%2) != (b%2)){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    ll ans = abs(a-b)/2 + min(a,b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

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

//逆元を求める関数
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;
}

void solve() {
		int64 n; cin >> n;
		vector<pair<int64, int64>> wk(n);
		rep (i, n) {
			cin >> wk[i].second >> wk[i].first;
		}
		//締め切りの早い順にソートする
		sort(all(wk));
		int64 nt = 0;
		rep (i, n) {
			nt += wk[i].second;
			//作業時間の合計が各仕事の締め切りを超えた時点で全ての仕事をこなすことはできない
			if (nt > wk[i].first) {
				cout << "No" << endl;
				return;
			}
		}
		//全ての作業時間の合計が各作業の締め切りを超えなければOK
		cout << "Yes" << endl;
    return;
}

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



Measured memory_bytes: 3328
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m;
	cin >> n >> m;
	vector<int> a(n);
	int sum = 0;
	REP(i,n){ 
		cin >> a[i];
		sum += a[i];
	}
	sort(ALL(a), greater<int>());
	REP(i,m){
		if(a[i]*4*m < sum){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <limits>

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)

constexpr int MAXN = 51;
constexpr int MAXINT = std::numeric_limits<int>::max();
int h, w;

int G[MAXN][MAXN];
int C[MAXN][MAXN];
int D[MAXN][MAXN];
struct Pos{int x, y;};
std::queue<Pos> Q;

bool CheckPos(Pos p) {
    if ((p.x < 0) || (p.x > w-1) || (p.y < 0) || (p.y > h-1)) {
        return false;
    }
    if (!G[p.y][p.x]) {
        return false;
    }
    if (C[p.y][p.x]) {
        return false;
    }
    return true;
}

int wfs(Pos p) {
    Q.push(p);
    while (Q.size()) {
        p = Q.front();
        if((p.x == (w-1)) && (p.y == (h-1))) {
            return D[p.y][p.x] + 1;
        }
        if(CheckPos(Pos{p.x-1, p.y})){
            Q.push(Pos{p.x-1, p.y});
            D[p.y][p.x-1] = D[p.y][p.x] + 1;
            C[p.y][p.x-1] = 1;
        }
        if(CheckPos(Pos{p.x+1, p.y})){
            Q.push(Pos{p.x+1, p.y});
            D[p.y][p.x+1] = D[p.y][p.x] + 1;
            C[p.y][p.x+1] = 1;
        }
        if(CheckPos(Pos{p.x, p.y-1})){
            Q.push(Pos{p.x, p.y-1});
            D[p.y-1][p.x] = D[p.y][p.x] + 1;
            C[p.y-1][p.x] = 1;
        }
        if(CheckPos(Pos{p.x, p.y+1})){
            Q.push(Pos{p.x, p.y+1});
            D[p.y+1][p.x] = D[p.y][p.x] + 1;
            C[p.y+1][p.x] = 1;
        }
        Q.pop();
    }
    return -1;
}

int main() {
    std::cin >> h >> w;
    int cnt = 0;
    FOR(i,0,h) {
        std::string s;
        std::cin >> s;
        FOR(j, 0, w) {
            if (s[j] == '.') {
                G[i][j] = 1;
                ++cnt;
            }
        }
    }

    D[0][0] = 0;
    int c = wfs(Pos{0,0});
    if (c < 0) {
        std::cout << -1 << std::endl;
    }else {
        std::cout << cnt - wfs(Pos{0, 0}) << std::endl;
    }
}


Measured memory_bytes: 256
n = int(input())
S = input()

ans = 0
for i in range(1000):
    a = '{0:03d}'.format(i)
    if a[0] in S:
        idx1 = S.index(a[0])
        S1 = S[idx1+1:]
        if a[1] in S1:
            idx2 = S1.index(a[1])
            S2 = S1[idx2+1:]
            if a[2] in S2:
                ans += 1

print(ans)


Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;
const int MAXN = 100010;
const ll MOD = 1000000007;
ll ans, sy, sx;
int x[MAXN], y[MAXN], n, m;

int main() {
	int i;
	scanf("%d%d", &n, &m);
	for(i = 1; i <= n; i++) scanf("%d", &x[i]);
	for(i = 1; i <= m; i++) scanf("%d", &y[i]);
	for(i = 1; i <= m; i++) {
		sy = (sy+(ll)y[i]*(i-1)%MOD)%MOD;
		sy = (sy-(ll)y[i]*(m-i)%MOD+MOD)%MOD;
	}
	for(i = 1; i <= n; i++) {
		sx = (sx+(ll)x[i]*(i-1)%MOD)%MOD;
		sx = (sx-(ll)x[i]*(n-i)%MOD+MOD)%MOD;
	}
	printf("%lld", sx*sy%MOD);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ull sum;
ll pre;

int main(){
	string s;
	cin >> s;
	rep(i,(1<<s.length()-1)){

//cout << i << ":" ;

		pre=0;
		rep(j,s.length()-1){
			if(i&(1<<j)){

//cout << s.substr(pre,j-pre+1) << "+";

				sum+=atol(s.substr(pre,j-pre+1).c_str());
				pre=j+1;
			}
		}

//cout << s.substr(pre,s.length()-pre+1) << endl;

		sum+=atol(s.substr(pre,s.length()-pre+1).c_str());
	}
	cout << sum << endl;
}

Measured memory_bytes: 3636
let readCharArray () = stdin.ReadLine().ToCharArray()
let choice ok ng bool = if bool then ok else ng

let rec solve count target query =
    if Array.zip target query
       |> Array.filter (fun (a, b) -> a <> b)
       |> Array.length
       |> ((=) 0) then
        true
    else if target |> Array.length |> (=) count then
        false
    else
        solve
            (count + 1)
            target
            (Array.concat [ (query |> Array.tail)
                            [| query |> Array.head |] ])


()
|> readCharArray
|> solve 0
<| (readCharArray ())
|> choice "Yes" "No"
|> printfn "%s"


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> d(n);
	rep (i, n) cin >> d[i];
	sort(d.begin(), d.end());
	cout << d[n / 2] - d[n / 2 - 1] << endl;
    
    return 0;
}



Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		sc.close();
		int result = 0;
		int bigCount = 0;
		for (; i > 1; i--) {
			int count = 0;
			int tempI = i;
			while (tempI % 2 == 0) {
				count++;
				tempI = tempI / 2;
			}
			if (count > bigCount) {
				bigCount = count;
				result = i;
			}
		}
		if (result == 0) {
			result = i;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

#define N 1000000

int main(){
    bool p[N];
    for (int i = 0; i < N; i++) p[i] = 1;
    p[0] = p[1] = 0;
    p[2] = p[3] = 1;
    for (int i = 1; i < N; i++) {
        if (!p[i]) continue;
        for (int j = i*2; j < N; j += i) { p[j] = 0; }
    }

    int a, d, n;
    int res;
    while (cin >> a >> d >> n && a && d && n) {
        int cnt = 0;
        while (cnt < n) {
            if (p[a]) cnt++;
            res = a;
            a += d;
        }
        cout << res << endl;
    }


    return 0;
}

Measured memory_bytes: 2136
#include<stdio.h>
int main(void)
{
	int i,n;
	int a[1000+1],b[1000+1],c[1000+1],d[1000+1],cal[1000+1],cnt[1000+1];
	int con,w,x,y,z;
	scanf("%d",&n);
	while(n!=0) {
		con=0;
		for(i=1;i<=n;i++) {
			scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);   /*お菓子の情報   a=番号、b=たんぱく質、c=脂質、d=炭水化物*/
			cal[i]=b[i]*4+c[i]*9+d[i]*4;
		}
		scanf("%d %d %d %d",&w,&x,&y,&z);   /*栄養素及びカロリーの制限値　　　w=たんぱく質、x=脂質、y=炭水化物、z=最大カロリー*/
		for(i=1;i<=n;i++) {
			cnt[i]=0;
		}
		for(i=1;i<=n;i++) {
			if((b[i]<=w)&&(c[i]<=x)&&(d[i]<=y)&&(cal[i]<=z)) {
				cnt[i]=cnt[i]+1;
				con+=1;
			}
		}
		if(con==0) {
			printf("NA\n");
		}
		else {
			for(i=1;i<=n;i++) {
				if(cnt[i]==1) {
					printf("%d\n",a[i]);
				}
			}
		}
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 636
#include<stdio.h>

#define N 100

int min(int x, int y)
{
    if (x < y)
        return (x);
    else
        return (y);
}

int main(){
  int i,j,k,l,n,p[N+1],m[N+1][N+1];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&p[i-1]);
    scanf("%d",&p[i]);
  }

  for(i=1;i<=n;i++) m[i][i]=0;

  for(i=2;i<=n;i++){
    for(j=1;j<=n-i+1;j++){
      k=i+j-1;
      m[j][k]=(1<<21);
      for(l=j;l<=k-1;l++){
	m[j][k]=min(m[j][k],m[j][l]+m[l+1][k]+p[j-1]*p[l]*p[k]);
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}

Measured memory_bytes: 636
/**
 *    author:  zjsdut
 *    created: 2020/01/20 06:32:34
**/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template<typename A, typename B>
bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template<typename A, typename B>
bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec) stream >> x;
  return stream;
}

void scan() {}

template<class T, class ...Args>
void scan(T &a, Args &...rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template<typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n) for(int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x: cont)
#define For(x, cont) for (auto &x: cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template<typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template<typename T>
void print(const vector<T> &t) { cout << t << '\n'; }

template<typename T>
void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template<typename T>
void print(const T &t) { cout << t << ' '; }

template<typename T, typename ...Args>
void print(const T &t, const Args &...rest) {
  print(t);
  print(rest...);
}

template<typename T>
void println(const T &t) { cout << t << '\n'; }

template<typename T, typename ...Args>
void println(const T &t, const Args &...rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  int n;
  scan(n);
  int a[10][10];
  memset(a, 0, sizeof a);
  up (i, 1, n) {
    int j = i;
    while (j >= 10) {
      j /= 10;
    }
    a[j][i % 10]++;
  }
  ll ans = 0;
  rng (i, 1, 10) {
    rng (j, 0, 10) {
      ans += 1ll * a[i][j] * a[j][i];
    }
  }
  println(ans);
  return 0;
}

Measured memory_bytes: 256
"""
n1 = int(input())*100
n2 = n1+99
x = n1//108+1
y = n2//108
print(x,y)
if x >=y:
	print(n2//108)
else:
	print(":(")

"""
x = int(input())
y = x//100
z = x%100
if y*5 >= z:
	print("1")
else:
	print("0")



Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int sum;
	int digit;
	
	while (scanf("%d %d", &a, &b) != EOF){
		sum = a + b;
		
		digit = 0;
		while (sum > 0){
			sum /= 10;
				digit++;
		}
		printf("%d\n", digit);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int n,k,sum,m;
int a[12][6]={
    {4,2,0,9,7},
    {1,10,8,6,4},
    {9,7,5,3,1},
    {6,4,2,0,9},
    {3,1,10,8,6},
    {0,9,7,5,3},
    {8,6,4,2,0},
    {5,3,1,10,8},
    {2,0,9,7,5},
    {10,8,6,4,2},
    {7,5,3,1,10}
};
int main(){
    scanf("%d%d",&n,&k);
	n-=2;
    m=n%11;
	n/=11;
    sum=n*5;
    for(register int i=0;i<m;i++)
    	for(register int j=0;j<5;j++)
    		if(a[i][j]==k)
				sum++;
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <limits>
#include <vector>


using usize = std::size_t;
using i64 = std::int_fast64_t;

constexpr i64 Minf = std::numeric_limits<i64>::min() / 5;

struct segtree {
  std::vector<i64> c;

  segtree() = default;
  segtree(usize n) : c(n * 2, Minf) {}

  void set(usize i, i64 v) {
    i += c.size() / 2;
    c[i] = std::max(c[i], v);
    while (i != 1) {
      i /= 2;
      c[i] = std::max(c[i * 2], c[i * 2 + 1]);
    }
  }

  i64 get(usize l, usize r) const {
    i64 ret = Minf;
    l += c.size() / 2;
    r += c.size() / 2;
    while (l < r) {
      if (l % 2 == 1) {
        ret = std::max(ret, c[l]);
        l += 1;
      }
      l /= 2;
      if (r % 2 == 1) {
        r -= 1;
        ret = std::max(ret, c[r]);
      }
      r /= 2;
    }
    return ret;
  }

  void dump() const {
    for (usize i = 0; i < c.size() / 2; ++i) {
      std::cout << c[i + c.size() / 2] << ' ';
    }
    std::cout << std::endl;
  }
};

int main() {
  usize n, m;
  std::cin >> n >> m;
  i64 x, y;
  std::cin >> x >> y;

  struct inter_t {
    usize c;
    usize r;
  };
  std::vector<std::vector<inter_t>> is;
  std::vector<i64> zip;

  struct interval_t {
    usize c;
    i64 l, r;
  };
  std::vector<interval_t> intervals(m);
  for (auto& e : intervals) {
    std::cin >> e.c >> e.l >> e.r;
    --e.c;
    --e.l;
    zip.push_back(e.l);
    zip.push_back(e.r);
  }
  std::sort(zip.begin(), zip.end());
  zip.erase(std::unique(zip.begin(), zip.end()), zip.end());
  n = zip.size();
  const auto rzip = [&](const i64 x) -> usize {
    return std::lower_bound(zip.cbegin(), zip.cend(), x) - zip.cbegin();
  };
  is.resize(n);
  for (const auto& e : intervals) {
    is[rzip(e.l)].push_back({ e.c, rzip(e.r) });
  }

  std::array<segtree, 3> dp, dps;
  i64 curmax = Minf;
  for (usize i = 0; i < 3; ++i) {
    dp[i] = segtree(n);
    dps[i] = segtree(n);
    dp[i].set(0, -(x + x + y) * zip[0]);
    dps[i].set(0, -x * zip[0]);
  }
  for (usize i = 0; i < n; ++i) {
    for (usize d = 0; d < 3; ++d) {
      curmax = std::max(curmax, dps[d].get(i, i + 1) + x * zip[i]);
    }
    for (const auto& e : is[i]) {
      {
        const i64 t = curmax + x * (zip[e.r] - zip[i]);
        dp[e.c].set(e.r, t - (x + x + y) * zip[e.r]);
        dps[e.c].set(e.r, t - x * zip[e.r]);
      }
      for (usize d = 0; d < 3; ++d) {
        if (e.c == d) {
          const i64 t =
            dps[d].get(i, e.r + 1) + x * zip[i] + x * (zip[e.r] - zip[i]);
          dp[e.c].set(e.r, t - (x + x + y) * zip[e.r]);
          dps[e.c].set(e.r, t - x * zip[e.r]);
        }
        else {
          const i64 t = dp[d].get(i, e.r + 1) + (x + x + y) * zip[i] +
            x * (zip[e.r] - zip[i]);
          dp[e.c].set(e.r, t - (x + x + y) * zip[e.r]);
          dps[e.c].set(e.r, t - x * zip[e.r]);
        }
      }
    }
  }
  std::cout << curmax << std::endl;
  return 0;
}


Measured memory_bytes: 63716
#include <iostream>
#include <string>
#include <queue>

using namespace std;

struct cha{
	string name;
	queue<int> q;
	int toku;
};

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int d[30];
		for (int i = 0; i < 30; i++) {
			d[i] = n+1;
		}
		cha c[20];
		int a, b;
		for (int i = 0; i < n; i++) {
			cin >> c[i].name;
			cin >> a;
			for (int j = 0; j < a; j++) {
				cin >> b;
				d[b]--;
				(c[i].q).push(b);
			}
		}
		cha max;
		for (int i = 0; i < n; i++) {
			c[i].toku = 0;
			int v;
			while (!(c[i].q).empty()) {
				v = (c[i].q).front();
				(c[i].q).pop();
				c[i].toku += d[v];
			}
			if (i == 0) {
				max.name = c[i].name;
				max.toku = c[i].toku;
			} else if (max.toku > c[i].toku) {
				max.name = c[i].name;
				max.toku = c[i].toku;
			} else if (max.toku == c[i].toku) {
				if (max.name > c[i].name) {
					max.name = c[i].name;
				}
			}
		}
		cout << max.toku << " " << max.name << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
# 2019-11-18 17:34:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 

odd_position = 'RUD'
even_position = 'LUD'

def main():
    s = 'S' + sys.stdin.readline().rstrip() # S: no meaning
    for i in range(1, len(s)-1+1):
        if i % 2 != 0:
            if s[i] in odd_position:
                continue
            else:
                ans = 'No'
                break
        else:
            if s[i] in even_position:
                continue
            else:
                ans = 'No'
                break
    else:
        ans = 'Yes'
    
    print(ans)
     


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import string

A = [chr(i) for i in range(ord('a'), ord('z')+1)]
B = {}
for i in range(26):
    B[A[i]] = i

s = input()
n = len(s)


def a():
    C = [0] * 26
    for i in range(n):
        C[B[s[i]]] = 1

    if n < 26:
        i = 0
        while C[i] == 1:
            i += 1
        return s + A[i]
    else:
        for i in range(25, -1, -1):
            t = s[i]
            for j in range(B[s[i]]+1, 26):
                if C[j] == 0:
                    return s[:i] + A[j]
            C[B[t]] = 0
            # print(i)
            # print(C)
        return -1

print(a())
                




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

int a,b,c,x,y;

int main()
{
    int impart;
    unsigned long long sol=0;
    cin>>a>>b>>c>>x>>y;
    if(a+b>2*c)
    {
        impart=min(x,y)*2;
        sol+= impart*c;
        if(2*c<a)
            sol+=2*c*(x-min(x,y));
        else
            sol+= (x-min(x,y))*a;

        if(2*c<b)
            sol+=2*c*(y-min(x,y));
        else
            sol+= (y-min(x,y))*b;
    }
    else
    {
        sol+=x*a;
        sol+=y*b;
    }
    cout<<sol<<'\n';
    return 0;
}


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

int get(int m,int s){
	return m * 60 + s;
}
int main(){
	int n;
	while(cin >> n , n){
		vector< pair<int,int> > data;
		rep(i,n){
			int m,s,c,sum = 0;
			cin >> c;
			rep(j,4)cin >> m >> s , sum += get(m,s);
			data.push_back(make_pair(sum,c));
		}
		sort(data.begin(),data.end());
		cout << data[0].second << endl;
		cout << data[1].second << endl;
		cout << data[data.size()-2].second << endl;
	}
}

Measured memory_bytes: 968
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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 ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  ll A, B, K; cin >> A >> B >> K;

  ll ans_takahashi = A, ans_aoki = B;
  if (A >= K){
    ans_takahashi -= K;
  }else if (A + B >= K){
    ans_takahashi = 0;
    ans_aoki -= (K - A);
  }else {
    ans_takahashi = 0;
    ans_aoki = 0;
  }
  cout << ans_takahashi << " " << ans_aoki << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);

int main(){ 
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> a(r);
  rep(i,r) cin >> a[i], --a[i];
  vector<vector<ll>> dist(n, vector<ll>(n, INF));

  rep(i,m) {
    int u, v, c;
    cin >> u >> v >> c;
    u--; v--;
    dist[u][v] = c;
    dist[v][u] = c;
  }
  rep(i,n) dist[i][i] = 0;

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
  }

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

  ll res = INF;

  do {

    ll tmp = 0;

    for (int i = 0; i < r - 1; i++) {
      tmp += dist[a[i]][a[i + 1]];
    }
    res = min(res, tmp);
  } while (next_permutation(a.begin(), a.end()));
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 512
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
_a = LI()
#AB = [LI() for _ in range(N)]
#A,B = zip(*AB)
a = np.array(_a)
#C = np.zeros(N + 1)

if not np.amin(a)==1:
    print(-1)
    exit()

maxNumber = 1

for i in range(N):
  if a[i] == maxNumber:
      maxNumber += 1

print(N - (maxNumber-1))

# current = 0
# for i in range(1,200001):
#     position=[]
#     position = np.where(a[current:] == i)
#     if position ==[] or position[0] == []:
#         break
#     else:
#         current = position[0][0]
# print(current)
    


# if ans:
#     print('Yes')
# else:
#     print('No')

Measured memory_bytes: 51396