akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;
#define ASCII 48

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

	cin >> a >> b >> c;

	int max = 0;
	if (max < a) max = a;
	if (max < b) max = b;
	if (max < c) max = c;

	if (max == a) {
		cout << b + c;
	}
	else if (max == b) {
		cout << a + c;
	}
	else {
		cout << a + b;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)


def read():
    N = int(input().strip())
    return N,


def solve(N):
    C = "abcdefghijklmnopqrstuvwxyz"
    name = []
    while N > 0:
        c = C[(N-1) % 26]
        name.append(c)
        N = (N-1) // 26
    return "".join(name)[::-1]


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9072
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N;cin>>N;
    VP V(N);
    int b=1;
    int c=1;
    VI A(N);
    REP(i,N)
    {
        cin>>A[i];
    }
    SORT(A);
    REP(i,N)
    {
        int a=A[i];
        if (i==0)
        {
            V[0]=paired(1,a);
            continue;
        }
        if(a==V[b-1].second) V[b-1].first++;
        else
        {
            V[b]=paired(1,a);
            b++;
        }
    }
    ll ans=0;
    REP(i,b)
    {
        if (V[i].first<V[i].second) ans+=V[i].first;
        else if (V[i].first>V[i].second) ans+=V[i].first-V[i].second;
    }
    cout<<ans<<endl;
    /*
    REP(i,b)
    {
        cout<<V[i].first<<" "<<V[i].second<<endl;
    }
    */

    return 0;
}



Measured memory_bytes: 1408
a,b,c,d=map(int,input().split())

if a<c:
    if b<=c:
        print(0)
    else:
        if b>d:
            print(d-c)
        else:
            print(b-c)
else:
    if a>d:
        print(0)
    else:
        if d>b:
            print(b-a)
        else:
            print(d-a)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
	int K, T;
	cin >> K >> T;
	vector<int> a(T);
	for (int i = 0; i < T; ++i) { cin >> a[i]; }

	sort(a.begin(), a.end(), greater<int>());
	int l = 0, r = 1;
	int res = 0;
	a[0] -= 1;
	int cnt = 0;
	while ((l < T) || (r < T) && (cnt++ < 1e6)) {
		if (r >= T) {
			res += a[l++];
			continue;
		}

		if (a[r] > 0) {
			a[r] -= 1;
		} else {
			++r;
			if ((r < T) && (a[r] > 0)) {
				a[r] -= 1;
			} else {
				continue;
			}
		}

		if (a[l] > 0) {
			a[l] -= 1;
		} else {
			l = r;
			r += 1;
			if ((l < T) && (a[l] > 0)) {
				a[l] -= 1;
			}
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
N, *L = map(int, open(0).read().split())
dic = [[] for i in range(N)]
ans = [-1]*N
cnt = [0]*N
hq = []
for a,b in zip(*[iter(L[:2*(N-1)])]*2):
  a -= 1
  b -= 1
  dic[a] += [b]
  dic[b] += [a]
  cnt[a] += 1
  cnt[b] += 1
C = L[2*(N-1):]
C.sort()
for i in range(N):
  heappush(hq,(cnt[i],i))
arg = 0
m = sum(C)-C[-1]
while True:
  c, i = heappop(hq)
  if ans[i]!=-1:
    continue
  ans[i] = C[arg]
  arg += 1
  if arg==N:
    break
  for v in dic[i]:
    cnt[v] -= 1
    heappush(hq,(cnt[v],v))
print(m)
print(*ans)

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

int main() {
  int n;
  cin >> n;
  int s = 0;
  vector<int> v(n);
  for (int i = i; i < n; i++) {
    cin >> v.at(i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n && j != i; j++) {
      s += v.at(i) * v.at(j);
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define _ ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

int n;
vector<int> a;
map<pair<int, int>, int> dp;

int go(int ind, int left)
{
    if (left == 0)
        return 0;

    if (ind >= n || n - ind < left * 2 - 1)
        return -1e16;

    if (dp.find({ind, left}) != dp.end())
    {
        return dp[{ind, left}];
    }
    return dp[{ind, left}] = max(a[ind] + go(ind + 2, left - 1), go(ind + 1, left));
}

int32_t main()
{
    _
            cin >>
        n;
    a.resize(n + 1);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    cout << go(0, n / 2);
    return 0;
}

Measured memory_bytes: 32972
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    bool jun=true;
    int q;
    cin >>s;
    cin >>q;
    for(int i=0;i<q;i++){
      int t,f;
      char c;
      cin >>t;
      if(t==1){
        if(jun) jun=false;
        else jun=true;
      }
      else{
        cin >>f>>c;
        if(f==1){
          if(jun) s.insert(s.begin(),c);
          else s.push_back(c);
        }
        else{
          if(jun) s.push_back(c);
          else s.insert(s.begin(),c);
        }
      }
    }
    if(jun) cout <<s;
    else for(int i=s.size()-1;i>=0;i--) cout <<s[i];
    cout <<'\n';
    return (0);
}


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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//lambda: [](int x, int y){return x<y;}

signed main(void){

    int n,k;cin>>n>>k;
    int ans=0;
    while(n>0){
        n/=k;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*  
    Talkin' to myself and feelin' old
    Sometimes I'd like to quit, nothin' ever seems to fit
    Hangin' around, nothin' to do but frown
    Rainy days and Mondays always get me down
    _________________________
    _________________________
    912 Hours of Solitude
    Quarantine_Day : 38
*/

#include<bits/stdc++.h>

using namespace std;

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

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005


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

	string s; cin>>s;
	cout<<s[0]<<s.size() - 2<<s[s.size() - 1]<<"\n";
	
	return 0;
}


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

signed main(void)
{
	ll N;
	cin >> N;
	for(int h = 1; h <= 3500; h++)
	{
		for(int n = 1; n <= 3500; n++)
		{
			if (4 * h * n - N * n - N * h > 0)
			{
				ll w = (ll)(N * h * n) / (4 * h * n - N * n - N * h);
				if ((N * h * n) % (4 * h * n - N * n - N * h) == 0 && w > 0)
				{
					cout << h << " " << n << " " << w << endl;
					return 0;
				}	
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
a = x2-x1
b = y2-y1
x3 = x2-b
y3 = y2+a
x4 = x3-a
y4 = y3-b

print(str(x3)+' '+str(y3)+' '+str(x4)+' '+str(y4))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <set>
#include <string>
using namespace std;

void Main() {
    // input
    u_int64_t N;
    cin >> N;

    set<string> S;

    for (u_int64_t i = 0; i < N; i++) {
        string str;
        cin >> str;
        S.insert(str);
    }

    // translate


    // output
    cout << S.size() << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 19208
/* 
 * Project: AtCoder Beginners Contest 157 B - Bingo
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/03/01
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {

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

    int n;
    cin >> n;

    bool a_bingo[3][3];

    for (int i=0;i<3;i++) {
        for (int j=0;j<3;j++) {
            a_bingo[i][j] = false;
        }
    }

    int b;
    for (int i=0;i<n;i++) {
        cin >> b;
        for (int j=0;j<3;j++) {
            for (int k=0;k<3;k++) {
                if (a[j][k] == b) {
                    a_bingo[j][k] = true;
                }
            }
        }
    }

    if (a_bingo[0][0] & a_bingo[0][1] & a_bingo[0][2])
        cout << "Yes" << endl;
    else if (a_bingo[1][0] & a_bingo[1][1] & a_bingo[1][2])
        cout << "Yes" << endl;
    else if (a_bingo[2][0] & a_bingo[2][1] & a_bingo[2][2])
        cout << "Yes" << endl;
    else if (a_bingo[0][0] & a_bingo[1][0] & a_bingo[2][0])
        cout << "Yes" << endl;
    else if (a_bingo[0][1] & a_bingo[1][1] & a_bingo[2][1])
        cout << "Yes" << endl;
    else if (a_bingo[0][2] & a_bingo[1][2] & a_bingo[2][2])
        cout << "Yes" << endl;
    else if (a_bingo[0][0] & a_bingo[1][1] & a_bingo[2][2])
        cout << "Yes" << endl;
    else if (a_bingo[0][2] & a_bingo[1][1] & a_bingo[2][0])
        cout << "Yes" << endl;
    else
        cout << "No"  << endl;

}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int[][] A = new int[N][2];

		for(int i=0;i<N;i++) {
			A[i][0] = nextInt();
			A[i][1] = i+1; // index
		}
		Arrays.sort(A,(a1,a2)->Integer.compare(a1[0],a2[0]));

		StringBuilder buf = new StringBuilder();

		for(int i=0;i<N;i++) {
			if(i != 0)buf.append(" ");
			buf.append(A[i][1]);
		}
		out.println(buf);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 49192
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int sumi[35][35];
int H, W, S;

int sum(int i, int j, int k, int l) {
  return sumi[k][l] - (i ? sumi[i-1][l] : 0) - (j ? sumi[k][j-1] : 0) + (i && j ? sumi[i-1][j-1] : 0);
}

typedef pair<int, int> pii; // pattern, yobi

pii dp[35][35][35][35];

int yobi(int i, int j, int k, int l) {
  return S - sum(0, 0, H-1, W-1) + sum(i, j, k, l);
}

pii dfs(int i, int j, int k, int l) {
  auto& ret = dp[i][j][k][l];
  if(ret.first != -1) { return ret; }

  ret = {1, yobi(i, j, k, l)};

  REP(a, i, k) {
    if(yobi(i, j, a, l) < 0) continue;
    if(yobi(a+1, j, k, l) < 0) continue;
    auto x = dfs(i, j, a, l);
    auto y = dfs(a+1, j, k, l);
    ret = max(ret, {x.first + y.first, min(x.second, y.second)}); // テ、ツサツサテヲツ?湘」ツ?ョ -> テ、ツコツ暗・ツつ凖・ツ環崚」ツ?ョテヲツ慊?・ツーツ湘・ツ?、テ」ツつ津ヲツ慊?・ツ、ツァテ・ツ個?
  }

  REP(b, j, l) {
    if(yobi(i, j, k, b) < 0) continue;
    if(yobi(i, b+1, k, l) < 0) continue;
    auto x = dfs(i, j, k, b);
    auto y = dfs(i, b+1, k, l);
    ret = max(ret, {x.first + y.first, min(x.second, y.second)});
  }

  return ret;
}

int main() {

  for(; cin >> H >> W >> S && (H|W|S);) {
    vector<vector<int>> U(H, vector<int>(W));
    rep(i, H) rep(j, W) {
      cin >> U[i][j];
    }

    zero(sumi);

    rep(i, H) rep(j, W) {
      sumi[i][j] = U[i][j];
      if(i) sumi[i][j] += sumi[i-1][j];
      if(j) sumi[i][j] += sumi[i][j-1];
      if(i && j) sumi[i][j] -= sumi[i-1][j-1];
    }

    rep(i, 35) rep(j, 35) rep(k, 35) rep(l, 35) dp[i][j][k][l] = {-1,-1};

    auto k = dfs(0, 0, H-1, W-1);
    cout << k.first << " " << k.second << endl;
  }
  
  return 0;
}

Measured memory_bytes: 14812
// you**can**do**anything :)  
#include <bits/stdc++.h>
#include<iostream> 
#include<algorithm> 
#include<vector> 
#define ll long long
const int maxn=5e5+10;
char s[maxn];
using namespace std;
int main() {
ll c;
cin>>c;
if(c%500==0)
cout<<c*2;
else{
	ll to=c-(c%500) ,v=(c%500)%5;
	cout<<(2*to)+((c%500)-v);
}


//cout<<1024%500;  //youssef ahmed ali amer**
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int , int);

int main()
{
  int x,y,z;
  
  scanf("%d%d",&x,&y);

  z = gcd(x,y);

  printf("%d\n",z);

  return 0;
}
    
int gcd(int x,int y)
{
  int z,r;
  if(x < y){
    z = x;
    x = y;
    y = z;
  }
  while(y>0){
    r = x%y;
    x = y;
    y = r;
  }
  return x;
}

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

using namespace std;

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

#define MAX_N 100
#define MAX_W 100000
int N, W;
int weight[MAX_N];
int val[MAX_N];
long long dp[MAX_N+1][MAX_W+1];

int main() {
	cin >> N >> W;
	FOR(i,0,N) cin >> weight[i] >> val[i];
	FOR(i,1,N+1){
		FOR(j,1,W+1){
			if (weight[i-1] > j) dp[i][j] = dp[i-1][j];
			else {
				dp[i][j] = max(dp[i-1][j-weight[i-1]]+val[i-1], dp[i-1][j]);
			}
		}
	}
    cout << dp[N][W] <<"\n";
    return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define mkp make_pair
typedef long long ll;
using namespace std;

ll L,A,B,M;

ll d[20];

ll MOD=1000000007;

typedef vector<ll> vec;//ll?
typedef vector<vec> mat;

mat mul(mat &A,mat &B){
  mat C(A.size(),vec(B[0].size()));
  for(int i=0;i<A.size();i++){
    for(int k=0;k<B.size();k++){
      for(int j=0;j<B[0].size();j++){
        C[i][j]=(C[i][j]+A[i][k]*B[k][j]%MOD)%MOD;
      }
    }
  }
  return C;
}

mat pow(mat A,ll n){
  mat B(A.size(),vec(A.size()));
  for(int i=0;i<A.size();i++){
    B[i][i]=1;
  }
  while(n>0){
    if(n&1) B=mul(B,A);
    A=mul(A,A);
    n=(n>>1);
  }
  return B;
}



int digit(ll val){
    if(val==0) return 0;
    else return (1+digit(val/10));
}

int main(){
  cin>>L>>A>>B>>M;
  MOD=M;

  ll ans=0;
  ll s=A;
  ll ten[20]={};
  ten[0]=1;
  for(int i=1;i<=18;i++) ten[i]=ten[i-1]*10%MOD;

  ll start=0;
  while(start<L){
    ll ng=L;
    ll ok=start;
    ll nowdigit=digit(A+B*start);

    while(ng-ok>1){
      ll mid=(ng+ok)/2;
      if(digit(A+B*mid)==nowdigit) ok=mid;
      else ng=mid; 
    }
    mat C(3,vec(3));
    C[0][0]=ten[nowdigit];
    C[0][1]=1;
    C[0][2]=0;
    C[1][0]=0;
    C[1][1]=1;
    C[1][2]=B%MOD;
    C[2][0]=0;
    C[2][1]=0;
    C[2][2]=1;
    C=pow(C,(ok-start+1));

    mat D(3,vec(1));
    D[0][0]=ans;
    D[1][0]=(A+B*start)%MOD;
    D[2][0]=1;
    D=mul(C,D);

    ans=D[0][0];
    ans=(ans+MOD)%MOD;
    start=ok+1;
  }

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


// -----------------------------------------------------------------------

// -----------------------------------------------------------------------

void solve(){
	int n,m;
	cin>>n>>m;
	int arr[10][10];
	for(int i=0;i<10;++i)
	for(int j=0;j<10;++j)
	cin>>arr[i][j];
	int cost[10][10];
	for(int i=0;i<10;++i)
	for(int j=0;j<10;++j)
	cost[i][j]=arr[i][j];
	for(int k=0;k<10;++k)
	for(int i=0;i<10;++i)
	for(int j=0;j<10;++j)
	if(cost[i][j]>cost[i][k]+cost[k][j])
	cost[i][j]=cost[i][k]+cost[k][j];
	int ans=0;
	for(int i=0;i<n;++i)
	for(int j=0;j<m;++j){
		int xp;
		cin>>xp;
		if(xp!=-1)
		ans+=cost[xp][1];
	}
	cout<<ans;
}


// -----------------------------------------------------------------------


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

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

  if (a > x) {
    cout << x % MOD << endl;
    return 0;
  }
  int m = (x - a) / (a - b) + 1;
  cout << (int)((x + (b % MOD) * (m % MOD)) % MOD) << endl;
  return 0;
}



Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 1; i < 10; ++i) if (n % i == 0 && n / i < 10) {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
    return 0;
}


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


int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<vector<int>>pre(n+1, vector<int>(3));
	for(int i = 1; i <= n ; i ++)
	{
		if(s[i-1] =='R')
		{
			pre[i][0] = pre[i-1][0] + 1; 
			pre[i][1] = pre[i-1][1]; 
			pre[i][2] = pre[i-1][2]; 
		}
		else if(s[i-1] =='G')
		{
			pre[i][0] = pre[i-1][0]; 
			pre[i][1] = pre[i-1][1] + 1; 
			pre[i][2] = pre[i-1][2]; 
		}
		else
		{
			pre[i][0] = pre[i-1][0]; 
			pre[i][1] = pre[i-1][1]; 
			pre[i][2] = pre[i-1][2] + 1; 
		}
	}
	long ans = 0;
	for(int i =0; i < n-2 ; i++)
	{
		for(int j = i + 1; j < n-1; j ++)
		{
			if(s[i] == s[j])
				continue;
			if((s[i] == 'R' && s[j] =='G') || (s[i] == 'G' && s[j] =='R'))
			{
				ans += pre[n][2] - pre[j][2];
				int k = j - i;
				if(j + k < n && s[j+k] =='B')
					ans--;
			}
			else if((s[i] == 'R' && s[j] =='B') || (s[i] == 'B' && s[j] =='R'))
			{
				ans += pre[n][1] - pre[j][1];
				int k = j - i;
				if(j + k < n && s[j+k] =='G')
					ans--;
			}
			else if((s[i] == 'G' && s[j] =='B') || (s[i] == 'B' && s[j] =='G'))
			{
				ans += pre[n][0] - pre[j][0];
				int k = j - i;
				if(j + k < n && s[j+k] =='R')
					ans--;
			}
		}
	}
	cout<<ans<<endl;
}

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

int main(void) {
  int N;
  cin>>N;
  vector<int> V(N);
  
  for (int i=0;i<N;i++) {
    cin>>V[i];
  }
  
  int A=N/2;
  
  sort(V.begin(),V.end());
  
  cout<<V[A]-V[A-1]<<endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   int C = sc.nextInt();

   int[] aa = {A,B,C};
   Arrays.sort(aa);
   System.out.println(aa[0]+aa[1]+aa[2]*10);
 }
}

Measured memory_bytes: 22608
#pragma region Include/Defines
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <limits.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <memory.h>
#include <string.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>
#include <cassert>
#include <map>
#include <set>
#include <iostream>
#include <queue>
#include <time.h>

using namespace std;
typedef long long lli;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<pii> vpii;
typedef vector <pll> vpll;
typedef long double ld;
#define all(a) std::begin(a), std::end(a)

const int INF = 0x3f3f3f3f;
const lli LINF = 0x3f3f3f3f3f3f3f3f;

template<typename T, typename T2> inline void _max(T &a, T2 b) { a = max((T)a, (T)b); }
template<typename T, typename T2> inline void _min(T &a, T2 b) { a = min((T)a, (T)b); }

#ifdef _DEBUG
#define epr(...) fprintf(stderr,__VA_ARGS__)
#else
#define epr(...) 
#endif
#pragma endregion

int L;

struct Edge {
	int f, t, l;
};

void clear() {
}

void read() {
}

void solve() {
	int n = 20;
	vector<Edge> es;	

	int v = 1;
	while (L > 1) {
		if (L & 1) {
			es.push_back({ v, n, L - 1 });
			L--;
		}
		L /= 2;
		es.push_back({ v, v + 1, L });
		v++;
	}
	for (int i = 1; i <= n - 1; i++) es.push_back({ i, i + 1, 0 });

	printf("%d %d\n", n, es.size());
	for(auto &e : es)
		printf("%d %d %d\n", e.f, e.t, e.l);
}

int main() {
#ifdef _LOCAL_VAN
	freopen("in.txt", "r", stdin);
#endif
	while (scanf("%d", &L) == 1) {
		clear();
		read();
		solve();
#ifndef _LOCAL_VAN
		return 0;
#endif
	}
	return 0;
}

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

int main(){
	int n;
	std::cin >> n;
	while (n){
		std::vector<int> ball(10);
		for (int i = 0; i < 10; ++i)std::cin >> ball[i];
		int b = 0, c = 0;
		for (int i = 0; i < 10; ++i){
			if (b < c){
				std::swap(b, c);
			}
			else if (b < ball[i]){
				b = ball[i];
			}
			else if (c < ball[i]){
				c = ball[i];
			}
			else {
				std::cout << "NO" << std::endl;
				break;
			}
			if(i==9){
				std::cout << "YES" << std::endl;
				break;
			}
		}
		n--;
	}
	return 0;
}

Measured memory_bytes: 1184
using System;

namespace _0528
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string a = "?" + Console.ReadLine();
                if (a == "?") break;
                string b = "!" + Console.ReadLine();
                int[,] dp = new int[b.Length,2];
                int ret = 0;
                for (int i = 0; i < a.Length; i++)
                {
                    for (int j = 0; j < b.Length; j++)
                    {
                        dp[j,1] = (a[i] == b[j] ? dp[j - 1,0] + 1 : 0);
                        ret = Math.Max(ret,dp[j,1]);
                    }
                    for (int j = 0; j < b.Length; j++) dp[j,0] = dp[j,1];
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 9340
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;


static class P
{
    static void Main()
    {
        var v = Enumerable.Range((int)'a', 26).Except(Console.ReadLine().Select(x => (int)x)).FirstOrDefault();
        Console.WriteLine(v == 0 ? "None" : ((char)v).ToString());
    }
}


Measured memory_bytes: 13280
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Integer>[] g = new ArrayList[n];
		for(int i = 0; i < n; i++) g[i] = new ArrayList<>();
		for(int i = 0; i < m; i++){
			int u = sc.nextInt()-1;
			int v = sc.nextInt()-1;
			g[u].add(v);
		}
		int s = sc.nextInt()-1, t = sc.nextInt()-1;
		int[][] dist = new int[3][n];
		for(int i = 0; i < 3; i++) Arrays.fill(dist[i], -1);
		dist[0][s] = 0;
		LinkedList<Integer> q = new LinkedList<>();
		q.add(s);
		while(!q.isEmpty()){
			int u = q.removeFirst();
			for(int v: g[u]){
				boolean yes = false;
				for(int d = 0; d < 3; d++){
					if(dist[d][u] >= 0 && dist[(d+1)%3][v] < 0){
						dist[(d+1)%3][v] = dist[d][u] + 1;
						yes = true;
					}
				}
				if(yes) q.add(v);
			}
		}
		System.out.println(dist[0][t] >= 0 ? dist[0][t] / 3 : dist[0][t]);
	}
}


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

int main() {
	
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	rep(i, m) cin >> b[i];
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, n) rep(j, m) cin >> a[i][j];
	
	int ans = 0;
	rep(i, n){
		int sum = 0; 
		rep(j, m){
			sum += b[j] * a[i][j];
		}
		sum += c;
		if(sum > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
c = [list(map(int, input().split())) for _ in range(3)]

import numpy as np

A = np.array([
    [1, 0, 0, 1, 0, 0],
    [1, 0, 0, 0, 1, 0],
    [1, 0, 0, 0, 0, 1],
    [0, 1, 0, 1, 0, 0],
    [0, 1, 0, 0, 1, 0],
    [0, 1, 0, 0, 0, 1],
    [0, 0, 1, 1, 0, 0],
    [0, 0, 1, 0, 1, 0],
    [0, 0, 1, 0, 0, 1]])

B=np.array([
    [1, 0, 0, 1, 0, 0, c[0][0]],
    [1, 0, 0, 0, 1, 0, c[0][1]],
    [1, 0, 0, 0, 0, 1, c[0][2]],
    [0, 1, 0, 1, 0, 0, c[1][0]],
    [0, 1, 0, 0, 1, 0, c[1][1]],
    [0, 1, 0, 0, 0, 1, c[1][2]],
    [0, 0, 1, 1, 0, 0, c[2][0]],
    [0, 0, 1, 0, 1, 0, c[2][1]],
    [0, 0, 1, 0, 0, 1, c[2][2]]])

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

if rankA == rankB:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27996
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 1;
    Rep (i, N-1) {
        if (S[i] != S[i+1]) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d",&x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for(int i = 0 ; i < n ;i ++)
#define repc(i, n) for(int i = 0 ; i < n ; i ++)
#define FOR(i, x, y) for(int i = x ; i < y ; i ++)
#define DEC(i, x, y) for(int i = x ; i >= y ; i --)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b,c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a+n
using namespace std;
#define ll long long
 

int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    if(((c-a-b)*(c-a-b))>(4*a*b) and (c-a-b)>0)
    cout<<"Yes";
    else
    cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;
const int mod = 1e9 + 7;



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

    int n;
    string s, t;

    cin >> n;
    cin >>s  >> t;
    for (int i = 0; i < n; ++i)
    {
        cout << s[i] << t[i];
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Collections;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Map;

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

        Map<String, Long> m = new HashMap<>();

        for (int i=0; i<n; i++){
            String st = sc.next();
            char[] c = st.toCharArray();
            Arrays.sort(c);
            st = new String(c);
//            System.out.println(st);
            if (m.containsKey(st)){
                m.put(st, m.get(st)+1);
            }else{
                m.put(st, 1L);
            }
        }
//        System.out.println(m);

        long ans = 0;

        for (Long v: m.values()){
            ans += v*(v-1)/2;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 55812
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,D,F,G=0,H=0,I=0;
    cin >> A >> B;
    vector<int> like(B);
    for(int i=0;i<A;i++){
        cin >> C;
        for(int j=0;j<C;j++){
            cin >> D;
            like[D-1]++;
        }
    }
    for(int i=0;i<B;i++){
        if(like[i]==A)H++;
    }
    cout << H << endl;
}

Measured memory_bytes: 256
use input::*;
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

mod input {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn str() -> String {
        read()
    }
    pub fn s() -> Vec<char> {
        str().chars().collect()
    }
    pub fn i() -> i64 {
        read()
    }
    pub fn u() -> usize {
        read()
    }
    pub fn f() -> f64 {
        read()
    }
    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }
    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }
    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }
    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}

fn main() {
    let (n, m) = (u(), u());
    let mut x = Vec::new();
    let mut y = Vec::new();
    for _ in 0..m {
        let temp = uv(2);
        x.push(temp[0]);
        y.push(temp[1]);
    }
    let mut r = vec![false; n + 1];
    r[1] = true;
    let mut c = vec![1; n + 1];
    for i in 0..m {
        if r[x[i]] {
            if c[x[i]] == 1 {
                r[x[i]] = false;
            }
            r[y[i]] = true;
        }
        c[x[i]] -= 1;
        c[y[i]] += 1;
    }

    let mut ans = 0;
    for i in 1..(n + 1) {
        if r[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<stdio.h>
int main () {

	int S, h, m, s;
	scanf("%d",&S);
	h = S / 3600;  
	m = S % 3600 / 60;
	s = S % 3600 % 60;
	printf("%d:%d:%d\n",h, m, s);

	return 0;
}

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




int main(void){
   int A,B;
   cin>>A>>B;
   for(int i=0;i<=1000;i++){
     int a=i*8/100;
     int b=i*10/100;
     if(A==a&&B==b){
       cout<<i<<endl;
       return 0;
     }
   }
   cout<<-1<<endl;

   return 0;
   
}




Measured memory_bytes: 3644
/*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.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 100000000
const int maxn= 100010;
lli a[maxn];
lli pre[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0;lli leafnahi=1ll,res=0ll;
    cin>>n;
    for(int i=0;i<=n;++i)
    {
    	cin>>a[i];
    	pre[i]=a[i];
    }
    for(int i=n;i>0;--i)
    	pre[i-1]+=pre[i];
    for(int i=0;i<=n;++i)
    {
    	pre[i]=min(pre[i],leafnahi);
    	leafnahi-=a[i];
    	if(leafnahi<0ll)
    	{
    		cout<<"-1";
    		return 0;
    	}
    	leafnahi*=2ll;
    	if(leafnahi>(lli)(1e18))
    		leafnahi=(lli)(1e18);
    }
    for(int i=0;i<=n;++i)
    	res+=pre[i];
    cout<<res<<endl;
}

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

int main()
{
    string str;
    while (true)
    {
        cin >> str;
        if (str[0] == '0')    break;

        int sum=0;
        for (int i=0; i<str.size(); ++i)
        {
            sum += (str[i] - '0');
        }
        cout << sum << endl;
    }
    
    return 0;
}

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

using namespace std;

bool is_unique(string str){
  int n = str.size();
  sort(str.begin(),str.end());
  str.erase(unique(str.begin(),str.end()),str.end());
  return n == str.size();
}

int main(){
  string str;
  cin >> str;
  cout << (is_unique(str)?"yes":"no") << endl;
}


Measured memory_bytes: 3616
NM = input().split();
N,M = int(NM[0]),int(NM[1]);
A = list(map(int, input().split()));
A.sort(reverse=True);

#先に総得票数を調べる
Sum = 0;
for i in range(N):
    Sum = Sum + A[i];
    
#人気商品とは呼べないボーダー
fil = Sum / (4 * M);

#全探索
count=0;
for j in range(M):
    if(A[j] >= fil):
        count+=1;

if(count >= M):
    print("Yes");
else:
    print("No");

Measured memory_bytes: 3064
// AOJ q0039
// YAMADA Terushige
// 2013.5.6

#include<iostream>
#include<string>
#include<map>
#include<vector>
 
using namespace std;
 
int main(){
  string s;
  map<char,int> m;
  m['I']=1;
  m['V']=5;
  m['X']=10;
  m['L']=50;
  m['C']=100;
  m['D']=500;
  m['M']=1000;

  while(cin >> s){
    vector<int> n;
    for (int i = 0;i < s.size() ;i++)
      n.push_back( m[s[i]] );
    for (int i = 1;i < s.size() ;i++)
      if(n[i] > n[i-1]) n[i-1] *= -1;
    int ans = 0;
    for (int i = 0;i < s.size() ;i++)
      ans += n[i];
    cout << ans << endl;
  }
}


Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
    unsigned long long int N,K;
    unsigned long long int sum=0,val;
    vector<unsigned long long int> monsters;

    cin>>N>>K;
    for(int i=0;i<N;i++)
    {
        cin>>val;
        monsters.push_back(val);
    }
    if(K>=N)
    {
        cout<<0;
    }
    else
    {

        sort(monsters.begin(),monsters.end());
        for(int i=0;i<N-K;i++)
        {
            sum+=monsters[i];
        }
        cout<<sum;
    }
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int k;
    string s;
    cin >> k;
    cin >> s;
    if(s.size() <= k){
        cout << s <<endl;
        return 0;
    }else{
        REP(i,k)
            cout << s[i];
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
  int X;
  cin >> X;
  int i=X;
  while(IsPrime(i)==false) i++;
  cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pp push_back
#define fr first
#define sc second
#define mp make_pair
using namespace std;


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


    for(int i = 0;i < 5;i++){
        int x; cin >> x;
        if(x == 0)
        {
            return cout << i + 1 << '\n' , 0;

        }
    }

    return 0;
}


Measured memory_bytes: 3648
#from collections import defaultdict
n = int(input())
di = [list(map(int, input().split(' '))) for _ in range(n)]
result = {0:0}
#md = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            p = di[i][0] - di[j][0]
            q = di[i][1] - di[j][1]
            result[(p,q)] = result.get((p,q), 0)+1
            #md[(p,q)] += 1
#print(result)
print(n - max(result.values()))
#print(md)
#print(n - max(md.values()))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
    ll k,l;
    cin>>k;
    ll i=0;
    if(k%7==0)l=9*k/7;
    else l=9*k;
    ll n=l;
    if(l%2==0 || l%5==0) {cout<< "-1"<<endl; return 0;}
    while(n>0){
        n=n/10;
        i++;
    }
    ll r = rep_jijo(10, i);
     r=r%l;
    while(r!=1){
        r=10*r%l;
        i++;
    }
    cout<<i<<endl;
}


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

/*
提出前に確認!
- setとmultisetを間違えない
*/

/*
26進数で考えればいい
*/

void	solve(long long num)
{
	if (num == 0) return ;
	solve((num - (num % 26 + 26) % 27) / 26);
	cout << (char)((num % 26 - 1 + 26) % 26 + 'a');
}

int		main(void)
{
	long long n;
	cin >> n;
	solve(n);
	cout << endl;
	return (0);
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
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();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#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 INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
//    // input from txt
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    int N;
    cin >> N;
    VI a(N);
    REP(i,N)cin>>a[i];
    int count=0,flag=0;
    while(1){
        REP(i,N){
            if(a[i]%2!=0){
                flag=1;
            }
            a[i]/=2;
        }
        if(flag==1)break;
        count++;
    }
    cout << count << endl;
    
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef char chr;
typedef double  dbl;
typedef long long int lld;
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
double getComb (double n, double x){
    if (x > n){
        return 0;
    }
    else{
        double r = 1.0;
        for(double i = 1.0; i<=x;i+=1){
            double a = n-i+1;
            double b = a / i;
            r*=b;
        }
        return r;
    }
}
int main () {
    FastIO
    lld n, r;
    cin >> n;
    lld f =0;
    while (n!=0){
        r = n%10;
        if (r==7)
            f= 1;
        n = n/10;
    }
    if (f == 1)
        cout << "Yes\n";
    else
        cout <<  "No\n";
    return 0;
}

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

int main() {

    int n;
    cin >> n;

    long sum_2=0;
    long sum_1=0;
    int tmp;
    vector<int> x(n);
    for (int i=0;i<n;i++){
        cin >> tmp;
        x[i]=tmp;
        sum_2 += tmp*tmp;
        sum_1 += tmp;
    }   

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

    long ans = 10000000000000;
    long l_tmp;
    for(int i=x[0];i<=x[n-1];i++){
        l_tmp = sum_2 - 2*sum_1*i+i*i*n;
        if(l_tmp < ans){
            ans =l_tmp;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> value_index; // (value, index)
    for(int i = 0; i < n; i++){
        pair<int, int> vi;
        cin >> vi.first;
        vi.second = i;
        value_index.push_back(vi);
    }

    /*for(int i = 0; i < value_index.size(); i++){
        cout << "(" << value_index[i].first << ", " << value_index[i].second << ")" << endl;
    }*/

    //cout << endl;
    sort(value_index.begin(), value_index.end());

    /*for(int i = 0; i < value_index.size(); i++){
        cout << "(" << value_index[i].first << ", " << value_index[i].second << ")" << endl;
    }*/

    vector<int> medians_vec(n, 0);
    for(int i = 0; i < n; i++){
        int medIndex = value_index[i].second;
        int viIndex = (i < n / 2)? n / 2 : n / 2 - 1;
        medians_vec[medIndex] = value_index[viIndex].first;
    }

    for(int i = 0; i < n; i++){
        cout << medians_vec[i] << endl;
    }

//    int ans = min(charge1, charge2);
//    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    ll x = n, m = 0;
    while (x > 0)
    {
        m += (x % 10);
        x /= 10;
    }
    if (n % m == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include   <stdio.h>

struct AOJ_0138{
	int num;
	double time;
};
typedef struct AOJ_0138 aoj;

void sort_down00(aoj data[], int n);
int min_idx00(aoj data[], int from, int to);
void display(aoj data[], int n){
	int i;
	for(i=0; i<n; i++){
		printf("\n%d %f\n", data[i].num, data[i].time);
	}
}

int main()
{
	aoj data[8];
	aoj sub[18];
	int i,k;
	int m = 0;
	for(i=0; i<3; i++){
		for(k=0; k<8; k++){
			scanf("%d %lf", &data[k].num, &data[k].time);
		}
		//display(data, k);
		sort_down00(data, k);
		printf("%d %.2f\n", data[0].num, data[0].time);
		printf("%d %.2f\n", data[1].num, data[1].time);
		for(k=2; k<8; k++, m++){
			sub[m] = data[k];
		}
	}
	sort_down00(sub, m);
	printf("%d %.2f\n", sub[0].num, sub[0].time);
	printf("%d %.2f\n", sub[1].num, sub[1].time);
	return   0;
}


void sort_down00(aoj data[], int n){
	aoj work;
	int idx;
	int i;
	for(i=0; i<n/2; i++){
		idx = min_idx00(data, i, n);
		work = data[i];
		data[i] = data[idx];
		data[idx] = work;
	}
	return;
}


int min_idx00(aoj data[], int from, int to){
	int i;
	int result = from;
	for(i=from; i<to; i++){
		if(data[result].time > data[i].time){
			result = i;
		}
	}
	return result;
}

Measured memory_bytes: 652
S = input()
T = input()
value = 10000
score = 0

for x in range(len(S)):
  S_cut = S[x:x+len(T)]
  if len(S_cut) < len(T):
    break
  else:
    score = 0
    for y in range(len(T)):     
      if S_cut[y] != T[y]:
        score += 1
      else:
        continue
  if score < value:
        value = score
print(value)

Measured memory_bytes: 9040