akhauriyash/Code-Regression huggingface dataset:
def main():
    S = input()
    N = len(S)
    ans = 0
    for bit in range(1<<(N-1)):
        cur = []
        for i in range(N-1):
            if bit&(1<<i):
                cur.append(i)
        else:
            cur.append(N-1)
        pre = 0
        for c in cur:
            num = int(S[pre:c+1])
            ans += num
            pre = c+1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 39664
using System;
class Test{
  static void Main(){
    var buf=Console.ReadLine().Split();
    int H=Int32.Parse(buf[0]),
    	W=Int32.Parse(buf[1]),
        A=Int32.Parse(buf[2]),
    	B=Int32.Parse(buf[3]);
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if((i<B&&j<A)||(i>=B&&j>=A))
        	Console.Write("0");
        else
          	Console.Write("1");
      }
      Console.Write("\n");
    }
  }
}

Measured memory_bytes: 14164
def recur(i, buf, current, S):
  global result
  if i == len(S) - 1:
    result += current + buf * 10 + S[i]
    return
  # +を入れる
  recur(i + 1, 0, current + buf * 10 + S[i], S)

  # +を入れない
  recur(i + 1, buf * 10 + S[i], current, S)

S = list(map(int, list(input())))
result = 0
recur(0, 0, 0, S)
print(result)


Measured memory_bytes: 3060
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

#define V 310

int main() {
    ll n,m1,L;
    cin>>n>>m1>>L;
    ll m[V][V];

for(ll i = 0; i < V; i++){
  for(ll r = 0; r < V; r++){
    if(i == r){
      m[i][i] = 0;
    }
    else{
      m[i][r] = 1000000000000000000LL; // 十分に大きな数値
    }
  }
}

for(ll i = 0; i < m1; i++){
  ll a,b,c;
  cin>>a>>b>>c;
  a--;b--;
  m[a][b] = c;
  m[b][a] = c;
}

for(ll k = 0; k < V; k++){
  for(ll i = 0; i < V; i++){
    for(ll j = 0; j < V; j++){
      if(m[i][j] > m[i][k] + m[k][j]){
        m[i][j] = m[i][k] + m[k][j];
      }
    }
  }
}

ll mm[V][V];

for(ll i = 0; i < V; i++){
  for(ll r = 0; r < V; r++){
    if(i == r){
      mm[i][i] = 0;
    }
    else{
      mm[i][r] = 1000000000000000000LL; // 十分に大きな数値
    }
  }
}

rep(i,0,n){
  rep(j,0,n){
    if(i==j)continue;
    if(m[i][j]<=L){
        mm[i][j] = 1;
    }
  }
}

for(ll k = 0; k < V; k++){
  for(ll i = 0; i < V; i++){
    for(ll j = 0; j < V; j++){
      if(mm[i][j] > mm[i][k] + mm[k][j]){
        mm[i][j] = mm[i][k] + mm[k][j];
      }
    }
  }
}
ll q;
cin>>q;
rep(i,0,q){
  ll a,b;
  cin>>a>>b;
  a--;b--;
  if(mm[a][b]==1000000000000000000){
    cout <<   -1 << endl;
  }
  else{
  cout <<   mm[a][b]-1 << endl;
}
}
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s1, s2, s3, out = "";
	cin >> s1 >> s2 >> s3;
	out += toupper(s1[0]);
	out += toupper(s2[0]);
	out += toupper(s3[0]);
	cout << out << endl;
}

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

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

    string S;
    cin >> S;

    if (S.size() > K) {
        cout << S.substr(0, K) << "..." << endl;
    } else {
        cout << S << endl;
    }
}


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

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

	vector<tuple<long long, int>> p;

	for (int i = 0; i < n; i++) {

		long long tmp_l;
		int tmp_i;

		cin >> tmp_l >> tmp_i;

		p.emplace_back(tmp_l, tmp_i);

	}
	
	sort(p.begin(), p.end());

	long long ans = 0;
	int tmpCnt = 0;
	int accumCnt = 1;

	for (int i = 0; i < m; i++) {

		if (get<1>(p[tmpCnt]) < accumCnt){
			tmpCnt++;
			accumCnt = 1;
		}
		ans += get<0>(p[tmpCnt]);
		accumCnt++;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2420
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[m];
        int[] d = new int[m];
        int[] ans = new int[n];
        for(int i = 0;i < n;i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        for(int i = 0;i < m;i++){
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        for(int i = 0;i < n;i++){
            int point = Integer.MAX_VALUE;
            for(int j = 0;j < m;j++){
                int tmp = Math.abs(a[i]-c[j]) + Math.abs(b[i]-d[j]);
                if(tmp < point){
                    point = tmp;
                    ans[i] = j+1;
                }
            }
        }
        for(int ret:ans)
            System.out.println(ret);
    }
}

Measured memory_bytes: 21844
use std::io::*;
use std::str::FromStr;

fn main() {
	let x: u32 = read();
	let y: u32 = read();
	for i in 0..x+1 {
		if 2*i+4*(x-i) == y {
			println!("Yes");
			return ();
		}
	}
	println!("No");
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}


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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  for(int i=0;i<4;i++){
    if( s.at(i) == '+' ){
      ans++;
    }else{
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#16D8101023J 久保田凌弥 kubotarouxxx python3
import math as mh
a=int(input())
A=[0]*a
x=0
for i in range(a):
 A[i]=int(input())
 for j in range(1,A[i]):
  if A[i]==2:
    x+=1
    continue
  if j==1:
   continue
  elif (A[i]%j)==0:
   break
  elif j>=mh.sqrt(A[i]):
   x+=1
   break
print(x)



Measured memory_bytes: 5996
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	int a,b;
	cin>>a>>b;
	rep(i,0,101){
		if((a-1)*i+1>=b){
			cout<<i<<endl;
			return;
		}
	}
}

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int A,B,C,K;
  cin >> A >>B >> C >> K;
  int ans = 0;
  if(K<=A){
  ans += K*1;
  K = 0;
}else{
  ans += A*1;
  K -= A;
}
if(K<=B){
  ans  += K*0;
  K = 0;
}else{
  ans  += B*0;
  K -= B;
}
if(K<=C){
  ans  += K*(-1);
  K = 0;
}else{
  ans  += C*(-1);
  K -= C;
}
cout << ans << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
using namespace std;
int n;
long long ans,a,b;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&a,&b);
        ans+=b-a;
    }
    printf("%lld\n",ans+n);
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 2e18;

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    string s;
    vector <string> p1;
    vector <string> p2;
    for(int i = 0; i < n; i++){
        cin >> s;
        p1.pb(s);
    }
    for(int i = 0; i < m; i++){
        cin >> s;
        p2.pb(s);
    }
    bool pos;
    for(int i = 0; i <= n-m; i++){
        for(int j = 0; j <= n-m; j++){
            pos = 1;
            for(int k = 0; k < m; k++){
                if(p1[i+k].substr(j, m) != p2[k]){
                    pos = 0;
                }
            }
            if(pos){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
#include<cstdio>

using int64=long long;

int cnt[20];

inline int pcnt(int n){
	int ccnt=0;
	for(int i=19;i;--i)
		for(;n>=cnt[i];n-=cnt[i])
			++ccnt;
	return ccnt;
}
int main(){
	int L;scanf("%d",&L);

	cnt[1]=1;
	for(int i=2;i<=19;++i)
		cnt[i]=cnt[i-1]<<1;
	printf("20 %d\n",36+pcnt(L));

	for(int i=1;i<=18;++i)
		printf("%d %d %d\n",i,i+1,0),
		printf("%d %d %d\n",i,i+1,cnt[i]);
	
	for(int i=19;i;--i)
		for(;L>=cnt[i];)
			L-=cnt[i],
			printf("%d %d %d\n",i,20,L);

	return 0;
}


Measured memory_bytes: 128
import re
import doctest


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        # return raw_input()
        return input()

    @staticmethod
    def read_from_input():
        return IO_for_Contest.read_n_int(2)

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(
                    int,
                    re.split('\s+', IO_for_Contest.my_input().strip())))[: n]


def solve():
    buf = IO_for_Contest.read_from_input()
    n = buf[0]
    k = buf[1]
    print(k * ((k - 1) ** (n - 1)))


if __name__ == '__main__':
    # doctest.testmod()
    solve()

Measured memory_bytes: 8172
using System;
using System.Linq;


namespace _009_PrimeNumber
{
	class Program
	{
		static void Main ( string[] args )
		{
			bool[] primeTable = new bool[1000000];

			primeTable[0] = false;
			primeTable[1] = false;
			primeTable[2] = true;

			for (int lp = 3; lp < primeTable.Length; lp++)
			{
				bool isOdd = lp % 2 == 1;

				if (isOdd)
				{
					int number = 3;
					bool isPrimeNumber = true;

					while (number <= Math.Sqrt (lp))
					{
						if (lp % number == 0 || primeTable.Length / 2 < number)
						{
							isPrimeNumber = false;
							break;
						}

						number += 2;
					}

					if (isPrimeNumber)
					{
						primeTable[lp] = true;
					}
				}
			}

			string inputStr;
			while ((inputStr = Console.ReadLine ()) != null)
			{
				int num = int.Parse (inputStr);

				int count = primeTable.Take (num + 1).Count (item => item == true);

				Console.WriteLine (count);
			}
		}
	}
}

Measured memory_bytes: 10416
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f, mod=1000000007;
int fa[200200],fb[200200],a[200200];
int maxa1=0, maxa2=0, taga1=0, taga2=0;
int maxb1=0, maxb2=0, tagb1=0, tagb2=0;

void read(int &x)
{
    char ch; bool ok;
    for(ok=0,ch=getchar(); !isdigit(ch); ch=getchar()) if(ch=='-') ok=1;
    for(x=0; isdigit(ch); x=x*10+ch-'0',ch=getchar()); if(ok) x=-x;
}

int main()
{
    int n;read(n);
    for (int i=1; i<=n; i++) read(a[i]);
    memset(fa,0,sizeof(fa));
    memset(fb,0,sizeof(fb));
    for (int i=1; i<=n; i+=2) fa[a[i]]++;
    for (int i=2; i<=n; i+=2) fb[a[i]]++;
    for (int i=1; i<=100000; i++)
    {
        if (fa[i]>maxa1)
        {maxa1=fa[i]; taga1=i; }
        if (fb[i]>maxb1)
         {maxb1=fb[i]; tagb1=i;}
    }
    if (taga1!=tagb1) {printf("%d\n",n-maxa1-maxb1); return 0;}
    fa[taga1]=0; fb[tagb1]=0;
    for (int i=1; i<=100000; i++)
    {
        if (fa[i]>maxa2)
        {maxa2=fa[i]; taga2=i; }
        if (fb[i]>maxb2)
         {maxb2=fb[i]; tagb2=i;}
    }
    int tmp=max(maxa2+maxb1, maxa1+maxb2);
    printf("%d\n",n-tmp);
    
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;

typedef long long int ll;
const ll inf = 1000000000;
const ll mod = 1000000007;
const ll nil = -1;
ll i, n, m, k, ans,a;
vector<pair<ll, ll>> iminusa;
ll iplusa[200000];

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


int main() {
    scanf(" %lld", &n);
    rep(0,n) {
        scanf(" %lld", &a);
        iminusa.push_back(make_pair(i, i - a));
        iplusa[i] = i + a;
    }
    sort(iminusa.begin(), iminusa.end(), compare_by_b);
    ans = 0;
    rep(0, n) {
        const ll sum = iplusa[i];
        auto lb = lower_bound(iminusa.begin(), iminusa.end(), make_pair(nil, sum), compare_by_b);
        auto ub = upper_bound(iminusa.begin(), iminusa.end(), make_pair(inf, sum), compare_by_b);
        ans += ub - lb;
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 8544
# coding: utf-8

while True:
	a, b = map(int, raw_input().split())
	if a == 0:
		break
	else:
		method = []
		for i in range(a):
			row = []
			for j in range(b):
				row.append(0)
			method.append(row)
	n = int(raw_input())
	for i in range(n):
		x, y = map(int, raw_input().split())
		method[x-1][y-1] = -1
	for j in range(b):
		if method[0][j] == -1:
			break
		else:
			method[0][j] = 1
	for i in range(a):
		if method[i][0] == -1:
			break
		else:
			method[i][0] = 1
	for i in range(1,a):
		for j in range(1,b):
			if method[i][j] != -1:
				if method[i-1][j] == -1 and method[i][j-1] == -1:
					method[i][j] = 0
				elif method[i-1][j] == -1 and method[i][j-1] != -1:
					method[i][j] = method[i][j-1]
				elif method[i-1][j] != -1 and method[i][j-1] == -1:
					method[i][j] = method[i-1][j]
				else:
					method[i][j] = method[i-1][j] + method[i][j-1]
	#print(method)
	print(method[a-1][b-1])

Measured memory_bytes: 4704
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;    
typedef long long ll;
//#define int long long
//#define int unsigned long long
const int mod = 1000000007;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    int a;
    cin >> a;
    string s;
    cin >> s;
    
    cout << (a < 3200 ? "red" : s) << endl;
    
    
    return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
  int A[3];
  for(int i=0; i < 3; ++i){
    cin >> A[i];
  }
  sort(A, A+3);
  int sum = 0;
  for(int i=0; i < 2; ++i){
    sum += A[i+1] - A[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second

using namespace std;

int t,temp1,temp2,tempc;
char a[1000],b[1000];
char temp[1000];
int c[1000];

int addition(int n1,int n2)
{
	//printf("%d,%d ",n1,n2);
	if(n1>=n2)
	{
		if(n2!=-1)
		{
			temp1=(int)a[n1]-48;
			temp2=(int)b[n2]-48;
			tempc=temp1+temp2;
			//printf("%d,%d,%d",temp1,temp2,tempc);
			if(tempc+c[n1+1]>=10)
			{
				tempc-=10;
				c[n1]+=1;
			}
			c[n1+1]+=tempc;
			//printf("%d,%d",c[n1+1],tempc);
			addition(n1-1,n2-1);
		}
		else if(n1!=-1)
		{
			tempc=(int)a[n1]-48;
			if(tempc+c[n1+1]>=10)
			{
				c[n1+1]-=10;
				c[n1]+=1;
			}
			c[n1+1]+=tempc;
			addition(n1-1,n2);
		}
	}
	else
	{
		for(int x=0;x<max(strlen(a),strlen(b))+5;x++)
		{
			temp[x]=a[x];
			a[x]=b[x];
			b[x]=temp[x];
		}
		addition(n2,n1);
	}
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%s",a);
		scanf("%s",b);
		for(int x=0;x<max(strlen(a),strlen(b))+5;x++)
		{
			c[x]=0;
		}
		if(strlen(a)>80||strlen(b)>80)
		{
			printf("overflow\n");
			continue;
		}
		else
		{
			addition(strlen(a)-1,strlen(b)-1);
			//printf("%d",(int)a[1]);
			//printf("%d,%d\n",strlen(a),strlen(b));
		}
		if(c[0]>0&&max(strlen(a),strlen(b))>=80)
		{
			printf("overflow\n");
		}
		else
		{
			for(int z=0;z<max(strlen(a),strlen(b))+1;z++)
			{
				if(c[z]==0&&z==0)
				continue;
				printf("%d",c[z]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1204
S=input()
SS=[str(a) for a in S]
SSS=tuple(SS)
kaisuu=len(S)-1
answers=[]
for i in range(2**kaisuu):
    T=list(SSS)
    for j in range(kaisuu):
        if ((i>>j)&1):
            T.insert(j*2+1,'+')
        else:
            T.insert(j*2+1,'')
    answers.append(T)
answer=[]
for a in answers:
    kotae=''
    for b in a:
        kotae+=b
    answer.append(kotae)
kotaes=[]
for a in answer:
    b=a.split('+')
    kotaes.append(b)
B=[]
for a in kotaes:
    C=[]
    for b in a:
        b=int(b)
        C.append(b)
    B.append(C)
A=0
for a in B:
    A+=sum(a)
print(A)


Measured memory_bytes: 3444
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

string N;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  string T(N);
  reverse(all(T));
  if (N == T) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#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 REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll a, b, ma, ho, now = 0;
string ss, s;
int main() {
	cin >> a >> b;
	if (a <= b) {
		cout << "Impossible" << endl;
		return 0;
	}
	ll n = a + b;
	vector<ll> ans(n);
	REP(i, n) {
		cout << "? " << i << " " << (i + 1) % n << endl;
		char res;
		cin >> res;
		ss.push_back(res);
	}
	s = ss + ss + ss;
	REP(i, s.size()) {
		if (s[i] == 'Y')now++;
		else {
			if (ma < now){
				ma = now;
				ho = i % n;
			}
			now = 0;
			
		}
	}
	REP(i, n) {
		cout << "? " << ho << " " << i << endl;
		char res;
		cin >> res;
		if (res == 'Y')ans[i] = 1;
	}
	cout << "! ";
	REP(i, n) cout << ans[i];
	cout << endl;
}

Measured memory_bytes: 852
from collections import deque
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    edge = [[] for _ in range(N)]
    for _ in range(M):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        edge[u].append(v)

    S, T = map(int, input().split())
    S -= 1
    T -= 1
    dist = [[float('inf')] * 3 for _ in range(N)]
    dist[S][0] = 0
    q = deque([])
    q.append((S,0))
    while q:
        v, l = q.popleft()
        nl = (l + 1) % 3
        for nv in edge[v]:
            if dist[nv][nl] != float('inf'):
                continue
            dist[nv][nl] = dist[v][l] + 1
            q.append((nv,nl))
        
    
    if dist[T][0] == float('inf'):
        print(-1)
    else:
        print(dist[T][0] // 3)




if __name__ == "__main__":
    main()

Measured memory_bytes: 79924
s = input()
t = input()
count = len(s)-len(t)+1
ans = len(t)
for i in range(count):
    res = 0
    for j in range(len(t)):
        if t[j] == s[i+j]:
            res += 1
    ans = min(ans, len(t)-res)
print(ans)

Measured memory_bytes: 9060
n, m = map(int, input().split())
denkyu = [list(map(int, input().split())) for _ in range(m)]
p =list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
    count = [0 for i in range(m)]
    for j in range(n):
        if ((i >> j) & 1):
            for k in range(m):
                if j + 1 in denkyu[k][1:]:
                    count[k] += 1
    for j in range(m):
        count[j] %= 2
    if count == p:
        ans += 1
print(ans)

Measured memory_bytes: 3064
ABCD = input()
for i in range(2 ** (len(ABCD)-1)):
    bit = format(i, "b").zfill(len(ABCD))[::-1]
    t = ""
    for j, s in enumerate(ABCD):
        t += s
        if bit[j] == "0":
            t += "+"
        if bit[j] == "1":
            t += "-"
    if len(t) == 8:
        t = t[:-1]
    if eval(t) == 7:
        print(t + "=7")
        break

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

void print_vec(vector<string> &vec, int n) {
  for (int i = 0; i < n; i++) {
    cout << vec[i];
    if (i < n - 1) cout << " ";
  }
  cout << endl;
}

int main() {
  int n; //number of entries;
  cin >> n;

  vector<string> sort_vec1;

  for (int i = 0; i < n; i++) {
    string entry;
    cin >> entry;
    sort_vec1.push_back(entry);
  }

  vector<string> sort_vec2 = sort_vec1; //make copy

  //bubble sort
  for (int i = 0; i < n; i++) {
    for (int j = n-1; j > i; j--) {
      if (stoi(sort_vec1[j].substr(1)) < stoi(sort_vec1[j-1].substr(1))) {
	swap(sort_vec1[j], sort_vec1[j-1]);
      }
    }
  }

  print_vec(sort_vec1, n);
  
  cout << "Stable" << endl; // bubble sort always stable

  //selection sort
  bool unstable = false;
  for (int i = 0; i < n; i++) {
    int min_index = i; // assume min is first element
    int min_value = stoi(sort_vec2[i].substr(1)); // value at minimum
    int repeated_index = n; // track min index of repeated value
    for (int j = i+1; j < n; j++) {
      // test for minimum
      if (stoi(sort_vec2[j].substr(1)) == min_value) {
	if (repeated_index == n) repeated_index = j; //set min index
      }					      
      if (stoi(sort_vec2[j].substr(1)) < stoi(sort_vec2[min_index].substr(1))) min_index = j;
    }
    if (i != min_index) {
      if (min_index > repeated_index) unstable = true;
      swap(sort_vec2[i], sort_vec2[min_index]); //swap 
    }
  }

  print_vec(sort_vec2, n);
  
  if (unstable) {
    cout << "Not stable" << endl;
  } else {
    cout << "Stable" << endl;
  }
  
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 2e5 + 5;
const int MAXD = 1e4 + 5;
const int MOD = 1e9 + 7;
const long double EPS = 1e-4;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll a, ll b) {ll c = rng(); return a+((ll)abs(c))%(b-a+1);}

ll a[MAXN];
int main(){

        ios::sync_with_stdio(0);
        cin.tie(0);
        int n;
        cin >> n;
        ll sum = 0;
        for(int i = 0 ; i < n ; i++)
              {
                cin >> a[i];
                sum^=a[i];
              }

        for(int i = 0 ; i < n ; i++)
        {
            sum^=a[i];
            cout << sum << ' ';
            sum^=a[i];
        }






        
       
}

Measured memory_bytes: 5132
#include "bits/stdc++.h"
using namespace std;

int main() {
    int A,B,C,D;
    string S;
    cin >> S;
    A=S[0]-'0';
    B=S[1]-'0';
    C=S[2]-'0';
    D=S[3]-'0';
    vector<char> op={'+','-'};
    vector<int> num={A,B,C,D};
    int sum;
    for(int i=0;i<(1<<3);i++){
        sum=A;
        for(int j=0;j<3;j++){
           if(i>>j & 1) sum-=num[j+1];
           else sum+=num[j+1]; 
        }
        if(sum==7){
            cout << A ;
            for(int k=1;k<4;k++){
                cout << op[i>>(k-1) & 1] << num[k];
                if(k==3){
                    cout << '=' << sum << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#define ENABLE_LL
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

void init();
void solve();
int main(){
try { 

#ifndef CUSTOM_MAIN
#ifdef MULTIPLE_TEST_CASES_WITH_T

int T; scanf("%d",&T); while(T--) {init(); solve();}

#else
#ifdef MULTIPLE_TEST_CASES_WITHOUT_T

while(1) {try{init(); } catch(bool t){return 0;} solve(); }

#else

init(); solve();

#endif
#endif
#endif

} catch (const char* s) { return 0; }
    return 0;
}

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr; typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; } char nextChar(){ char r; ist>>r; return r;} }; Scanner sc(cin);
void ALERT(bool judgememt, const char* phrase) { if (judgememt) { puts(phrase); throw "ALERT"; } }
bool alert(bool judgememt, const char* phrase) { if (judgememt) puts(phrase); return judgememt; }

const int N = 300005;
int n, m, s;
int dir[N], pos[N];
int rad[N], ans[N];

void init() {
    scanf(III,&n,&m,&s);
    rep (i,n) {
        char s[5];
        scanf("%lld%s",&pos[i],s);
        dir[i] = (s[0] == '2') ? -1 : 1;
    }
}

void solve() {
    rep (i,n) rad[i] = i;
    sort(rad, rad+n, [](int a, int b) {
        return pos[a] < pos[b];
    });
    int Fir=0;
    rep (i,n) {
        int add= (dir[i]==1) ? (pos[i]+s) /m %n
                          : (pos[i]-s-m+1) /m %n;
        Fir = (Fir+add+n+n) % n;
        pos[i] = (pos[i] +s%m*dir[i] +m +m) %m;
    }
    sort(pos, pos+n);
    rep (i,n) ans[ rad[(i-Fir +n)%n] ] = pos[i];
    rep (i,n) printf("%lld\n",ans[i]);
}


Measured memory_bytes: 6884
import java.util.*;

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

        boolean[][] grid = new boolean[H][W];
        for (int i = 0; i < H; i++) {
            String row = sc.next();
            int j = 0;
            for (char ch : row.toCharArray()) {
                grid[i][j] = ch == '.';
                j++;
            }
        }

        grid[0][0] = true;
        grid[H-1][W-1] = true;

        long[][] dp = new long[H][W];
        dp[0][0] = 1;

        for (int i = 1; i < W; i++) {
            if (grid[0][i]) {
                dp[0][i] = 1;
            } else {
                break;
            }
        }
        for (int i = 1; i < H; i++) {
            if (grid[i][0]) {
                dp[i][0] = 1;
            } else {
                break;
            }
        }

//        print(dp);

        for (int i = 1; i < H; i++) {
            for (int j = 1; j < W; j++) {
                if (grid[i][j]) {
//                    dp[i][j] = dp[i - 1][j] % 1000_000_007 + dp[i][j - 1] % 1000_000_007;
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1])% 1000_000_007;
                } else {
                    dp[i][j] = 0;
                }
            }
        }

//        print(dp);

        long res = dp[H-1][W-1];
//        System.out.println(res % 1000_000_007);
        System.out.println(res);

    
  }
}


Measured memory_bytes: 51008
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            bool flug = true;
            int ans = 0;
            for (int i = 1; i <= n; i++)
            {
                if (s[i-1] == i && flug)
                {
                    flug = !flug;
                    ans++;
                }
                else
                {
                    flug = true;
                }
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 19936
#include <stdio.h>

int main(void)
{
	char c[20];
	int a[10];
	int ans;
	while(scanf("%s", c) != EOF){
		for(int i = 0; i < 10; i++){
			a[i] = c[i] - '0';
		}
		ans = (a[0] + a[9] + (a[1] + a[8]) * 9 +(a[2] + a[7]) * 36 + (a[3] + a[6]) * 84 + (a[4] + a[5]) * 126) % 10;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 964
#include <stdio.h>

int main(void){
  int N;
  int d[50];
  int sum=0;
  int heal;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&d[i]);
  }
  for (int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i<j){
        heal=d[i]*d[j];
        sum+=heal;
      }
    }
  }
  printf("%d",sum);
  return 0;
}



Measured memory_bytes: 128
import java.util.*;


import java.io.*;
 
 
 
public class Main 
{   
	
	static long MOD=(long) (1e9+7);
	public static void main(String[] args) throws IOException 
	{ 
	
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer s=new StringTokenizer(br.readLine());
		
		int n=Integer.parseInt(s.nextToken());
		 s=new StringTokenizer(br.readLine());
		int arr[]=new int[n];
		
		for(int i=0;i<n;i++) {
			arr[i]=Integer.parseInt(s.nextToken());
		}
		long[][] dp = new long[n][n];
       

		for(int L = n-1; L >= 0; --L) {
			for(int R = L; R < n; ++R) {
				if(R==L) dp[L][R] = arr[L];
				else dp[L][R] = Math.max(arr[L] - dp[L+1][R], arr[R] - dp[L][R-1]);
			}
		}
		
		

        pw.println(dp[0][n-1]);
		
		pw.close();
		
	}
	
	
	
	
	
}

Measured memory_bytes: 129488
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))


def cmd(n,r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result

n = inp()
d = defaultdict(int)
for i in range(1,n+1):
    if i%10==0:
        continue
    if i<10:
        d[i*10+i] += 1
        continue
    tmp = str(i)
    d[int(tmp[0]+tmp[-1])] += 1
# print(d)
res = 0
fin = set()
for key in list(d):
    # print(key)
    if key%11==0:
        res += d[key]**2
    else:
        tmp = int(str(key)[-1] + str(key)[0])
        if tmp in fin:
            continue
        fin.add(key); fin.add(tmp)
        res += d[key] * d[tmp] * 2
print(res)

Measured memory_bytes: 66408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    string s;cin>>s;
    int sum=0;
    int ind=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0') sum++;
    }
    int t = s.size() - sum;
    cout << min(sum,t) * 2 << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
typedef vector<vector<int> > Mat;

const Mat B = {
  {1, 1, 2},
  {1, 2, 2},
  {0, 1, 1},
};
const Mat C = {
  {1, 1, 2},
  {0, 1, 0},
  {0, 1, 1},
};
const Mat A = { {1, 1, 2} };

Mat mul(Mat a, Mat b) {
  assert(a[0].size() == b.size());
  int w = b[0].size(), h = a.size();
  Mat ret(h, vector<int>(w, 0));
  rep(x, w) rep(y, h) {
    rep(k, a[0].size()) ret[y][x] = (ret[y][x]+1LL*a[y][k]*b[k][x])%MOD;
  }
  return ret;
}
Mat pow(Mat x, int k) {
  assert(x.size() == x[0].size());
  int n = x.size();
  Mat a(n, vector<int>(n, 0));
  rep(i, n) a[i][i] = 1;

  while (k>0) {
    if (k&1) a = mul(a, x);
    x = mul(x, x);
    k>>=1;
  }
  return a;
}

int N, M;
int X[100001];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  // A*(B^k)
  cin >> N >> M;
  X[0] = 0;
  rep(i, M) cin >> X[i+1];
  Mat cur(A);
  rep(i, M) {
    cur = mul(cur, pow(B, X[i+1]-X[i]-1));
    cur = mul(cur, C);
  }
  cur = mul(cur, pow(B, N-1-X[M]));
  cout << cur[0][1] << "\n";
  return 0;
}


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



int main() {
	int n, m, t = 0, a;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a;
		while (a%2 == 0) {
			a /= 2;
			t++;
		}
	}

	cout << t << endl;
	//cin >> n;

	return 0;
}

Measured memory_bytes: 256
n = input()
tmp_n = n.split(" ")

N = tmp_n[0]
T = tmp_n[1]

num = input()
tmp_num = num.split(" ")

yu_interval = int(T)
yu_fin = int(T)
loss_time = 0

for i in range(int(N)):
    if int(tmp_num[i]) <= yu_fin:
        yu_fin = int(tmp_num[i]) + yu_interval
    elif int(tmp_num[i]) > yu_fin:
        loss_time += int(tmp_num[i])-yu_fin
        yu_fin = int(tmp_num[i]) + yu_interval

print(yu_fin-loss_time)


Measured memory_bytes: 19220
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;

	string str;
	set<char> naka;
	while(N--){
		cin >> str;
		naka.insert(str[0]);
	}
	if( naka.size() == 3 ){
		cout << "Three" << endl;
	}else{
		cout << "Four" << endl;
	}
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    sum += B - A + 1;
  }
  cout << sum << endl;
    
  
}

Measured memory_bytes: 256
private class D {
    fun solve() {
        val n = nextInt()
        val numMap = mutableMapOf<Long, Int>()
        var sum = 0L
        for (i in 0 until n) {
            val a = nextLong()
            numMap[a] = (numMap[a] ?: 0) + 1
            sum += a
        }
        val q = nextInt()
        for (i in 0 until q) {
            val b = nextLong()
            val c = nextLong()
            val bCount = numMap[b] ?: 0
            if (bCount !=0) {
                sum -= b * bCount
                numMap.remove(b)
                sum += c * bCount
                numMap[c] = (numMap[c] ?: 0) + bCount
            }
            println(sum)
        }
    }

    var tokenBuffer = listOf<String>()
    var bufferPosition = 0

    private fun checkBuffer() {
        if (bufferPosition == tokenBuffer.size) {
            tokenBuffer = nextLine().split(" ")
            bufferPosition = 0
        }
    }

    fun nextLine() = readLine()!!
    fun nextInt(): Int {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toInt()
    }

    fun nextLong(): Long {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toLong()
    }

    fun nextDouble(): Double {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toDouble()
    }

    fun nextToken(): String {
        checkBuffer()
        return tokenBuffer[bufferPosition++]
    }
}

fun main() {
    val reader = D().solve()

}


Measured memory_bytes: 71772
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll k,a[55];

int main(){
	cin >> k;
	REP(i,0,50) a[i]=i;
	REP(i,0,50) a[i]+=k/50;
	REP(i,0,k%50){
		int pos=0;
		REP(j,0,50) a[j]--;
		a[i]+=51;
	}
	
	cout << 50 << endl;
	REP(i,0,50) cout << a[i] << " "; cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
char s[MAXN];

int main() {
    scanf("%s", s);
    int n = strlen(s);
    int cnt0 = 0, cnt1 = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '0') cnt0++;
        else cnt1++;
    }
    printf("%d\n", min(cnt0, cnt1) * 2);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
priority_queue<P,vector<P>,greater<P>> que;
ll board[2000][2000];
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>h>>w>>a>>b;
    if(b==0){
        rep(i,a)s+="0";
        rep(i,w-a)s+="1";
        rep(i,h)Cout(s);
        return 0;
    }
    else if(a==0){
        rep(i,b)s+="0";
        rep(i,h-b)s+="1";
        rep(i,h){
            rep(j,w){
                cout<<s[i];
            }
            cout<<"\n";
        }
        return 0;
    }
    rep(i,h){
        rep(j,w){
            if((i<b&&j<a)||(i>=b&&j>=a)){
                cout<<1;
            }
            else{
                cout<<0;
            }
        }
        cout<<"\n";
    }
    return 0;
}


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

int main()
{
	ll N, K, Q;
	cin >> N >> K >> Q;
	vector<ll> A(Q);
	rep(i, Q)cin >> A[i];

	vector<ll> cnt(N, 0);
	for (ll num : A) {
		num--;
		cnt[num]++;
	}
	rep(i, N) {
		cout << (K - Q + cnt[i] > 0 ? "Yes" : "No") << endl;
	}

	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

struct mint {
	typedef long long ll;
	ll x, m;
	mint(ll x=0, ll m=998244353): x((m+x%m)%m), m(m) {}
	mint operator-() const { return mint(m-x, m); }
	mint& operator+=(const mint o) { x=(x+o.x)%m; return *this; }
	mint& operator+=(const ll o) { return (*this)+=mint(o, m); }
	mint& operator-=(const mint o) { return (*this)+=(-o); }
	mint& operator-=(const ll o) { return (*this)-=mint(o, m); }
	mint& operator*=(const mint o) { x = x*o.x%m; return *this; }
	mint& operator*=(const ll o) { return (*this)*=mint(o, m); }
	mint& operator/=(const mint o) { return (*this)*=o.inv(); }
	mint& operator/=(const ll o) { return (*this)/=mint(o, m); }
	friend mint operator+(mint l, const mint r) { l+=r; return l; }
	friend mint operator+(mint l, const ll r) { l+=r; return l; }
	friend mint operator+(const ll l, mint r) { r+=l; return r; }
	friend mint operator-(mint l, const mint r) { l-=r; return l; }
	friend mint operator-(mint l, const ll r) { l-=r; return l; }
	friend mint operator-(const ll l, mint r) { r-=l; return r; }
	friend mint operator*(mint l, const mint r) { l*=r; return l; }
	friend mint operator*(mint l, const ll r) { l*=r; return l; }
	friend mint operator*(const ll l, mint r) { r*=l; return r; }
	friend mint operator/(mint l, const mint r) { l/=r; return l; }
	friend mint operator/(mint l, const ll r) { l/=r; return l; }
	friend mint operator/(const ll l, const mint r) { return mint(l, r.m)/r; }
	bool operator==(const mint o) const { return x==o.x; }
	bool operator!=(const mint o) const { return x!=o.x; }
	friend bool operator==(const ll l, const mint r) { return mint(l, r.m) == r; }
	friend bool operator!=(const ll l, const mint r) { return mint(l, r.m) != r; }

	mint pow(ll k) const {
		if(k==0) return mint(1, m);
		if(k%2) return pow(k-1)*x;
		mint z = pow(k/2);
		return z*z;
	}

	mint inv() const { return pow(m-2); }
};

int _main(){
	for(auto x: std::vector<int>{3, 5, 7, 11, 13, 17, 19}){
		assert((mint(4, x)/mint(4, x))==1);
	}
	return 0;
}

mint dp[3005][3005];
mint dp2[3005][3005];
int main(){
	int N, S;
	cin >> N >> S;
	vector<int> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	dp[0][0] = mint(1);
	dp2[0][0] = mint(1);

	for(int i=0; i<N; i++){
		dp[i+1][0] = dp[i][0]+1;
		dp2[i+1][0] = dp2[i][0]+1;
		for(int j=1; j<=S; j++){
			dp[i+1][j] = dp[i][j] + dp2[i][j];
			if(j-A[i]>=0) {
				dp[i+1][j] += dp2[i][j-A[i]];
			}
			dp2[i+1][j] = dp2[i][j];
			if(j-A[i]>=0){
				dp2[i+1][j] += dp2[i][j-A[i]];
			}
			debug(i, j, dp[i+1][j].x, dp2[i+1][j].x);
		}
	}

	cout << dp[N][S].x << endl;
	return 0;
}


Measured memory_bytes: 282496
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
  double a,b,x;
  cin >> a >> b >> x;
  double ans;
  if(x>=a*a*b/2){
    ans=atan2(2*(a*a*b-x)/(a*a),a);
    ans*=180/M_PI;
  }
  else{
    ans=atan2(b,2*x/(a*b));
    ans*=180/M_PI;
  }
  printf("%.14f\n",ans);
}


Measured memory_bytes: 256
N = int(input())
a = 0

if N < 10:
    a = N
elif 10 <= N <100:
    a = 9
elif 100 <= N < 1000:
    a = N - 90
elif 1000 <= N < 10000:
    a = 909
elif 10000 <= N < 100000:
    a = N - 9090
else :
    a = 90909

print(a)

Measured memory_bytes: 2940
# ABC167C

import numpy as np
import itertools

n, m, x = map(int, input().split())

c = [0] * n
a = [0] * n
for i in range(n):
    temp = list(map(int, input().split()))
    c[i] = int(temp[0])
    a[i] = temp[1:]
a = np.array(a)
skill = a.sum(axis=0)
if np.all(skill >= x):
    bincombinations = list(itertools.product([0, 1], repeat = n))
    min_price = sum(c)
    for i, selection in enumerate(bincombinations):
        total_price = 0
        skill2 = np.zeros(m)
        for j in range(n):
            if selection[j] == 1:
                total_price += c[j]
                skill2 +=  a[j, :]
        if all(skill2 >= x):
            if total_price < min_price:
                min_price = total_price
    print(min_price)
else:
    print(-1)


Measured memory_bytes: 27652