akhauriyash/Code-Regression huggingface dataset:
def solve(H, W, C):
	cnt = 0
	d = [[1,0],[-1,0],[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1]]

	while True:
		start = [-1,-1]
		for i in range(H):
			for j in range(W):
				if C[i][j] == 1:
					start = [i,j]
					break

		if start == [-1,-1]:
			return cnt
		else:
			cnt += 1
			q = [start]


		while q:
			cx,cy = q.pop()
			C[cx][cy] = 0
			for dx,dy in d:
				nx,ny = cx+dx, cy+dy
				if 0 <= nx < H and 0 <= ny < W:
					if C[nx][ny] == 1:
						q.append([nx,ny])


ans = []
while True:
	W,H = map(int, input().split())
	if H == 0 and W == 0:
		break
	C = [list(map(int, input().split())) for _ in range(H)]
	#print(H,W,C)
	ans.append(solve(H,W,C))




for a in ans:
	print(a)


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

int main(void){
    int N, K, Q;
    cin >> N >> K >> Q;
    
    int A[Q], person[N];

    for(int i = 0; i < N; ++i)person[i] = K - Q;

    for(int i = 0; i < Q; ++i){
        cin >> A[i];
        person[A[i] - 1]++;
    }

    for(int i = 0; i < N; ++i){
        if(person[i] > 0){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
}

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

public class Main {

  static final long MOD = 1000000007L;
  static final int MAX = 200001;

  static long[] fac = new long[MAX];
  static long[] finv = new long[MAX];

  static long powerMOD(long a, long b){
    long result = 1L;
    while(b > 0){
      if(b % 2 == 1) result = (result * a) % MOD;
      a = (a * a) % MOD;
      b = (b>>1);
    }
    return result;
  }

  static void combIni(){
    fac[0] = 1; fac[1] = 1;
    finv[0] = 1; finv[1] = 1;
    for(int i = 2; i < MAX; i++){
      fac[i] = fac[i-1] * i % MOD;
      finv[i] = finv[i-1] * powerMOD(i, MOD - 2) % MOD;
    }
  }

  static long combMOD(int n, int r){
    if(n < r) return 0;
    if(n < 0 || r < 0) return 0;
    if(r == 0) return 1;
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
  }
  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] in1 = br.readLine().split(" ");
    int N = Integer.parseInt(in1[0]);
    int K = Integer.parseInt(in1[1]);
    
    in1 = br.readLine().split(" ");
    int[] A = Stream.of(in1).mapToInt(Integer::parseInt).toArray();
    br.close();

    combIni();

    Arrays.sort(A);

    long ans = 0, ma = 0, mi = 0;


    for(int i = 0; i <= N-K; i++){
      mi += (A[i] * combMOD(N - i - 1, K - 1)) % MOD;
      mi %= MOD;
    }

    for(int i = K-1; i < N; i++){
      ma += (A[i] * combMOD(i, K - 1)) % MOD;
      ma %= MOD;
    }

    ans = ma - mi;
    while(ans < 0) ans += MOD;
    ans %= MOD;

    System.out.println(ans);
  }
}

Measured memory_bytes: 50064
n = int(input())
a = list(map(int,input().split()))
ans = 0
keisu = [0]*n
t = 0

for i in range(n):
    
    keisu[i] += t
    t += a[i]


for i in range(n):
    ans += a[i] * keisu[i]

        
        

print(ans%(1000000000+7))


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

const int N = 200010;
using pii = std::pair <int, int>;

int fa[N], sz[N];
std::vector <pii> e[N];
pii p[N];
bool vis[N];
int d[N];
int ans[N], color[N];
bool vis1[N];

int find(int u){
    return fa[u] == u ? u : (fa[u] = find(fa[u]));
}

void unite(int u, int v){
    u = find(u), v = find(v);
    if (u == v){
        return;
    }
    if (sz[u] < sz[v]){
        std::swap(u, v);
    }
    sz[u] += sz[v];
    fa[v] = u;
}

void dfs(int u){
    vis1[u] = true;
    for (auto p : e[u]){
        int v = p.first;
        if (d[v] != d[u]){
            continue;
        }
        if (!vis1[v]){
            color[v] = color[u] ^ 1;
            dfs(v);
        }
    }
}

int main(){
    for (int i = 0; i < N; ++ i){
        fa[i] = i;
        sz[i] = 1;
    }
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++ i){
        scanf("%d", &d[i]);
        p[i] = {d[i], i};
    }
    for (int i = 0, u, v; i < m; ++ i){
        scanf("%d%d", &u, &v);
        e[u].push_back({v, i});
        e[v].push_back({u, i});
    }
    std::sort(p + 1, p + 1 + n);
    for (int i = 1, j = 1; i <= n; i = j){
        while (j <= n && p[j].first == p[i].first){
            ++ j;
        }
        int value = p[i].first;
        for (int k = i; k < j; ++ k){
            for (auto p : e[::p[k].second]){
                int v = p.first;
                if (d[v] <= value){
                    unite(::p[k].second, v);
                    ans[p.second] = value;
                }
            }
        }
        for (int k = i; k < j; ++ k){
            if (sz[find(p[k].second)] == 1){
                puts("-1");
                return 0;
            }
        }
        for (int k = i; k < j; ++ k){
            int vertex = p[k].second;
            if (!vis1[vertex]){
                for (auto p : e[vertex]){
                    int v = p.first;
                    if (d[v] < value){
                        color[vertex] = color[v] ^ 1;
                        dfs(vertex);
                        break;
                    }
                }
            }
        }
        for (int k = i; k < j; ++ k){
            if (!vis1[p[k].second]){
                dfs(p[k].second);
            }
        }
    }
    for (int i = 1; i <= n; ++ i){
        putchar(color[i] ? 'B' : 'W');
    }
    puts("");
    for (int i = 0; i < m; ++ i){
        printf("%d\n", ans[i] == 0 ? int(1e9) : ans[i]);
    }
    return 0;

}


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

int main(void)
{ 
  char tur[]="CODEFESTIVAL2016";
  char s[16];
  int count=0;
  for(int i=0;i<16;i++){
    cin>>s[i];
    if(tur[i]!=s[i])
      count++;
  }
  cout<<count<<endl; 
}

Measured memory_bytes: 256
a = int(input())
n = [int(x) for x in input().split()]
b = [i for i in n if i % 2 == 0 ]
f = 0
for i in range(len(b)):
  if b[i] % 3 == 0:
    f += 1
    continue
  if b[i] % 5 == 0:
    f += 1
    continue
if len(b) == f:
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 3060
N = gets.to_i
words = []
check = 'Yes'
N.times do |i|
  word = gets.chomp
  if words.include?(word)
    check = 'No'
  end
  if i >= 1 && words[-1][-1] != word [0]
    check = 'No'
  end
  words.push(word)
end

puts check

Measured memory_bytes: 1788
n=int(input())
m=int(input())
l=[]
for i in range(m):
  l1=list(map(int,input().split(",")))
  l.append(l1)
s,g,v,p=map(int,input().split(","))
listl=[[100000 for i in range(n+1)] for i in range(n+1)]
for i in l:
  listl[i[0]][i[1]]=i[2]
  listl[i[1]][i[0]]=i[3]
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      if listl[j][k]>listl[j][i]+listl[i][k]:
        listl[j][k]=listl[j][i]+listl[i][k]
print(v-p-(listl[s][g]+listl[g][s]))


Measured memory_bytes: 5608
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=105;
int n;
int a[maxn];
int ans=INF;

int main(){
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	for(int t=-100;t<=100;t++){
		int cur=0;
		rep(i,n)cur+=(abs)(a[i]-t)*(abs)(a[i]-t);
		ans=min(ans,cur);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n; cin>>n;
    vector<int> a(n,0);
    vector<int> matome(n+5,0);
    rep(i,1,n){
        cin>>a[i];
        matome[a[i]]++;
    }
    rep(i,1,n+1) cout<<matome[i]<<endl;

}

Measured memory_bytes: 4844
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                         long long int
#define mp make_pair
ll ok[1000000];
using namespace std;

int main(){

     ll i,n,m,s=0,sum=0,x=0,k,j;
     cin>>n;
     ll a[100]={0};

     for(i=1;i<=100;i++){
        for(j=1;j<=100;j++){
            for(k=1;k<=100;k++){
                s=i*i+j*j+k*k+i*j+j*k+k*i;


                    ok[s]+=1;



            }
        }
     }



     for(i=1;i<=n;i++){


        cout<<ok[i]<<endl;



     }


}




Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  char c[10][10];
  int ans=0;
  rep(i,h) rep(j,w){
    cin>>c[i][j];
  }
  rep(bits1,1<<h){
    rep(bits2,1<<w){
      int cnt=0;
      rep(i,h){
	rep(j,w){
	  if(((bits1>>i)&1) || ((bits2>>j)&1)) continue;
	  if(c[i][j]=='#') {
	    cnt++;
	  }
	}
      }
      if(cnt==k) {
	ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3608
n = int(input())
tn = [0]+[int(i) for i in input().split()]+[0]
an = [0]+[int(i) for i in input().split()]+[0]
ans = 1
mod = 10**9+7

for i in range(1,n+1):
  if tn[i-1] < tn[i] and an[i] > an[i+1]:
    ans *= int(tn[i] == an[i])
  elif tn[i-1] < tn[i] and an[i] == an[i+1]:
    ans *= int(tn[i] <= an[i])
  elif tn[i-1] == tn[i] and an[i] > an[i+1]:
    ans *= int(tn[i] >= an[i])
  else:
    ans *= min(an[i],tn[i])
    ans %= mod
print(ans)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int h, w; cin >> h >> w;
    if(h == 0 && w == 0) break;
    vvi a(h);
    REP(i, h) {
      a[i].resize(w);
      REP(j, w) {
        cin >> a[i][j];
      }
    }
    int ma = 0;
    FOR(i, 3, h+1) {
      FOR(j, 3, w+1) {
        REP(k, h-i+1) {
          REP(l, w-j+1) {
            int mi = INF;
            FOR(m, k, k+i) {
              FOR(n, l, l+j) {
                if(m == k || m == k+i-1 || n == l || n == l+j-1) {
                  mi = min(mi, a[m][n]);
                }
              }
            }
            int sz = 0;
            bool ok = true;
            FOR(m, k+1, k+i-1) {
              FOR(n, l+1, l+j-1) {
                if(a[m][n] >= mi) {
                  ok = false;
                  break;
                } else {
                  sz += mi - a[m][n];
                }
              }
              if(!ok) {
                sz = 0;
                break;
              }
            }
            ma = max(ma, sz);
          }
        }
      }
    }
    cout << ma << endl;
  }
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10, MOD = 1e9 + 7;
ll pos[maxn],fac[maxn],facm[maxn];
ll quick_pow(ll a,ll n,ll p)
{
    ll x = a;
    ll res = 1;
    while(n)
    {
        if(n & 1)
        {
            res = ((ll)res * (ll)x) % p;
        }
        n >>= 1;
        x = ((ll)x*(ll)x) % p;
    }
    return res;
}
ll C(ll n,ll k){
    if(k > n) return 0ll;
    ll ans = fac[k]*fac[n-k]%MOD;
    ans = (fac[n]*quick_pow(ans,MOD-2ll,MOD))%MOD;
    return ans;
}
int main()
{
    fac[0] = 1;
    for(int i = 1;i < maxn;i++)
        fac[i] = (fac[i-1]*i)%MOD;
    ll n;
    scanf("%lld", &n);
    n++;
    ll m, x;
    for(int i = 1;i <= n;i++)
    {
        scanf("%lld", &x);
        if (pos[x])
        {
            m = n - (i - pos[x] + 1);
            break;
        }
        pos[x] = i;
    }
    for(int i = 1;i <= n;i++)
        printf("%lld\n", (C(n, i) - C(m, i-1)+MOD) % MOD);
    return 0;
}


Measured memory_bytes: 2816
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
 	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long[][] comb = new long[2001][2001];
		for (int i = 0; i <= 2000; i++) {
		    for (int j = 0; j <= i; j++) {
		        if (j == 0 || j == i) {
		            comb[i][j] = 1;
		        } else {
		            comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % MOD;
		        }
		    }
		}
		int n = sc.nextInt();
		int blue = sc.nextInt();
		int red = n - blue;
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= blue; i++) {
		    long blueCount = comb[blue - 1][i - 1];
		    long redCount = comb[red + 1][i];
		    sb.append((blueCount * redCount) % MOD).append("\n");
		}
		System.out.print(sb);
   }
}




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

int main()
{
	int n;
	cin>>n;
	int a[n+5];
	for( int i = 0; i<n; i++)
		cin>>a[i];
	int ans[110000] = {0};
	for( int i =0; i<n; i++)
	{
		ans[(a[i])]++;
		ans[(a[i] + 1)]++;
		if( a[i] != 0 )
			ans[(a[i] - 1)]++;
	}
	int big = -1;
	int an = -1;
	for(int i = 0; i< 110000; i++)
	{
		if( ans[i] > big )
		{
			big = ans[i];
			an = i;
		}
	}
	cout<<big<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)
#define f first
#define se second
#define M 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<long long, long long>
#define vi vector<int>
#define ll long long

ll n,m,x;
ll grid[20][20];
ll cost[20];
ll find(int ind,ll cur[],int co){
	if(ind==n+1){
		int c=1;
		for(int i=1;i<=m;i++){
			if(cur[i]<x){
				c=0;
				break;
			}
		}
		if(c){
		return co;
		}
		return INT_MAX;
	}
	ll cur1[m+1];
	for(int i=1;i<=m;i++){
		cur1[i]=cur[i]+grid[ind][i];
	}
	return min(find(ind+1,cur,co),find(ind+1,cur1,co+cost[ind]));
	
}
int main(){
 
 cin>>n>>m>>x;
 for(int i=1;i<=n;i++){
	 cin>>cost[i];
	 for(int j=1;j<=m;j++){
		 cin>>grid[i][j];
	 }
 }
 ll cur[m+1]={0};
 ll ans=find(1,cur,0);
 if(ans==INT_MAX){
	 cout<<-1;
 }else {
	 cout<<ans;
 }
} 


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int n; cin >> n;
	vector<int> t(n);
	ll total = 0;
	rep(i, n) {
		cin >> t[i];
		total += t[i];
	}
	int m; cin >> m;
	rep(i, m) {
		int p, x;
		cin >> p >> x;
		cout << total - t[p-1] + x << endl;
	}
}


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

using namespace std;

void solve()
{
	int n, m;
	while(cin >> n >> m, n || m)
	{
		vector<int> Vec;
		Vec.assign(n, 1);
		int count = n;
		int pos = 0;
		int step;
		while(count != 1)
		{
			step = m - 1;
			while(step)
			{
				if(Vec[pos] == 0)
				{
					while(Vec[pos] == 0)
					{
						pos++;
						if(pos == n)
						{
							pos = 0;
						}
					}
				}
				step--;
				pos++;
				if(pos == n)
				{
					pos = 0;
				}
			}
			while(Vec[pos] == 0)
			{
				pos++;
				if(pos == n)
				{
					pos = 0;
				}
			}
			Vec[pos] = 0;
			count--;
		}
		for(int i = 0; i < n; ++i)
		{
			if(Vec[i] == 1)
			{
				cout << i + 1<< endl;
			}
		}
	}
}

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

Measured memory_bytes: 0
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Sun,  4th Aug 2019                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

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

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

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void mini(int &a, int b){
	a = min(a,b);
}

void solve() {

	int n, w;
	cin >> n >> w;

	int lim = 1e5+5;
	
	// dp[i] - minimum weight that is needed to obtain a value of `i`.
	vi dp(lim,2e9);
	dp[0] = 0;

	rep(i,1,n+1){

		int vi, wi;
		cin >> wi >> vi;

		for(int j=lim-1; j>=0; j--){
			if(j - vi >= 0) mini(dp[j], dp[j-vi] + wi); 
		}
	}

	int mx = dp[0];
	rep(i,1,lim){
		if(dp[i] <= w) mx = max(mx, i);
	}

	cout << mx << endl;
}


Measured memory_bytes: 1024
from sys import stdin
K = int(stdin.readline().rstrip())
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(L[K-1])

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  vector<ll> a(3);
  cin >> a[0] >> a[1] >> a[2];

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

  ll ans = 0;
  if(a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0){
    ans = 0;
  }else{
    ans = a[0] * a[1];
  }

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	i64 ans = 0;
	while(true) {
		int l = 0, mi = 1 << 30;
		for(int i = 0; i < n; i++) {
			if(!a[i] and mi != 1 << 30) {
				ans += mi;
				for(int j = l; j < i; j++) a[j] -= mi;
				l = i + 1;
				mi = 1 << 30;
			} else if(!a[i] and mi == 1 << 30) {
				l++;
			} else if(a[i]) {
				mi = std::min(mi, a[i]);
			}
		}
		if(mi != 1 << 30) {
			ans += mi;
			for(int j = l; j < n; j++) a[j] -= mi;
		}
		
		bool f = false;
		for(int i = 0; i < n; i++) f |= !!a[i];
		if(!f) break;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	sort(a, a+n);
	int o = 0;
	for (int i=0; i<k; i++) {
		o += a[i];
	}
	cout << o << endl;
}

Measured memory_bytes: 3608
import random
D = int(input())
c = [int(x) for x in input().split()]
s = [input().split() for l in range(D)]

manzoku = 0
kyounomanzoku = 0
kyounotype = 0
d = 1
last = [0]*26

for p in range(D):
    print(int(random.uniform(1, 26.999)))


"""
for p in range(D):
    #タイプはt[p]-1,0~25 満足度増加 s[p][t[p]] p+1日目 
    #typeを出力するときは＋１するのを忘れずに
    for t in range(26):
        if kyounomanzoku < int(s[p][t]):
            kyounomanzoku = int(s[p][t])
            kyounotype = t
    print(kyounotype+1)
    kyounomanzoku = 0
"""

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

int main(){
	int N;
	cin >> N;
	int xors = 0;
	
	int bit[32] = {};
	for(int i = 0 ; i < N ; i++){
		int z = 0;
		int n;
		cin >> n;
		xors ^= n;
		while( n % 2 == 0 ) z++, n /= 2;
		bit[z]++;
		//cout << z << endl;
	}
	int ans = 0;
	for(int i = 31 ; i >= 0 ; i--){
		if( xors >> i & 1 ){
			if( !bit[i] ){
				cout << -1 << endl;
				return 0;
			}
			ans++;
			xors ^= ((1ll<<i)-1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        
        dmg = min(B[i], A[i])
        ans += dmg
        A[i] -= dmg
        B[i] -= dmg

        dmg = min(B[i], A[i + 1])
        ans += dmg
        A[i + 1] -= dmg
        B[i] -= dmg
        
    print(ans)


resolve()

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

int main() {
	int d[2]={+1,-1};
	int n[4];
	for(int i=0;i<4;i++){
		scanf("%1d",&n[i]);
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				if(n[1]*d[i]+n[2]*d[j]+n[3]*d[k]==7-n[0]){
					cout<<n[0];
					if(n[1]*d[i]>=0)cout<<'+';
					else cout<<'-';
					cout<<n[1];
					if(n[2]*d[j]>=0)cout<<'+';
					else cout<<'-';
					cout<<n[2];
					if(n[3]*d[k]>=0)cout<<'+';
					else cout<<'-';
					cout<<n[3]<<"=7";
					return 0;
				}
			}
		}
	}
	// your code goes here
	return 0;
}

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

#define MAX 1024

int LCS[MAX][MAX];

void ini(){
}
int solve(string s1,string s2){
  if(s1.length() > s2.length())
	swap(s1,s2);
  for(int i=1;i<=s1.length();i++){
    for(int j=1;j<=s2.length();j++){
      if(s1[i-1]==s2[j-1])
	LCS[i][j]=LCS[i-1][j-1]+1;
      else
	LCS[i][j]=max(LCS[i][j-1],LCS[i-1][j]);
    }
  }
  return LCS[s1.length()][s2.length()];
}


int main(){
  string s1, s2;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    for(int i=0;i<MAX;i++){
      for(int j=0;j<MAX;j++){
        LCS[i][j] = 0;
      }
    }
    cin>>s1>>s2;
    cout<<solve(s1,s2)<<endl;
    /*
    for(int i=0;i<=s1.length();i++){
      for(int j=0;j<=s2.length();j++){
	cout << LCS[i][j] << "  " ;
      }
      cout << endl;
    }*/
  }

}

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

void solve(){
	//code
	int a,b;
	cin>>a>>b;
	if(a>9 || b>9) cout<<-1;
	else cout<<a*b;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int a[5][105];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
			a[i][j]+=max(a[i-1][j],a[i][j-1]);
	cout<<a[2][n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
ld n,a[8],b[8],ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]));
        }
    }
    //cout<<ans<<endl;
    
    cout<<setprecision(15)<<ans*2/n<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)

signed main() {
  int n; cin >> n;
  string c; cin >> c;
  int r=0;
  rep(i,n) if(c[i]=='R') r++;

  int ans = 0;
  rep(i,n) {
    if(c[i]=='W' && i < r) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3752
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <list>
#include <bitset>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
typedef long long ll;
const ll MOD=998244353;
const int maxn=400050;
ll sum[maxn],res[maxn];
int l[20],r[20];
int n,k;

void solve(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=k;i++)	scanf("%d %d",&l[i],&r[i]);
	res[1]=sum[1]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=k;j++){
			res[i]=(res[i]+(sum[max(i-l[j],0)]-sum[max(i-r[j]-1,0)]+MOD)%MOD)%MOD;
		}
		sum[i]=(sum[i-1]+res[i])%MOD;
	}
	printf("%lld\n",res[n]);
}
int main(){
	solve();
	return 0;
}

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


int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int a,b;
	cin>>a>>b;
	if (a==b){
		cout<<"Draw";
	}
	a=a==1?14:a;
	b=b==1?14:b;
	if (a>b){
		cout<<"Alice";
	}
	else if (a<b){
		cout<<"Bob";
	}
	return 0;
}

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

int main() {
  string s,t; cin >>s >>t;
  reverse(s.begin(),s.end());
  cout <<(s==t ? "YES":"NO") <<endl;
  return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int a , b , c , k ;
  cin >> a >> b >> c >> k ;
  
  int MAX = max(a,max(b,c));
  int ans = a + b + c - MAX;
  
  rep(i,k) MAX *= 2;
  
  cout << ans + MAX;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int>k(m);
    vector<vector<int>>s(m);
    rep(i,m){
        cin >> k[i];
        s[i].assign(k[i],0);
        rep(j,k[i]){
            cin >> s[i][j];
            s[i][j]--;
            }

    }
    vector<int>p(m);
    rep(i,m)cin >> p[i];
    int ans = 0;
    for(int i = 0;i < 1<<n;i++){
        bool ok = true;
        rep(j,m){
            int cnt = 0;
            rep(l,k[j]){
                if(i >> s[j][l] & 1)cnt++;
            }
            if(cnt % 2 != p[j])ok = false;
            //cout << i << " " << j << " " << cnt << endl;
        }
        if(ok)ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
  long long sum=100,x;
  int i=0;
  cin >> x;
  while(1){
    sum=sum*1.01;
    ++i;
    if(sum>=x){
      cout << i;
      return 0;
    }
  }
  return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int X = sc.nextInt();
        int ans = 0;
        for(int i = 0; i <= a; i++){
            for(int j = 0; j <= b; j++){
                for(int k = 0; k <= c; k++){
                    if(500 * i + 100 * j + 50 * k == X) ans++;
                }
            }
        }
        System.out.println(ans);
    }
}


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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

//return x^y mod p
ll power(ll x,ll y, ll p)
{
    ll res = 1;     
    x = x % p; 
 
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; // y = y/2
        x = (x*x) % p;  
    }
    return res;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n; cin>>n;
    vector<lll> arr(n);
    map<lll, int> cnt;
    FOR(i, 0, n) {
        cin>> arr[i].ff >> arr[i].ss;
        if(arr[i].ff || arr[i].ss) {
            ll g = __gcd(abs(arr[i].ff), abs(arr[i].ss));
            arr[i].ff /= g;
            arr[i].ss /= g;

            if(arr[i].ss < 0) {
                arr[i].ss *= -1;
                arr[i].ff *= -1;
            } else if(arr[i].ss == 0) arr[i].ff = 1; 
        }
        cnt[{arr[i].ff, arr[i].ss}]++;
    }

    // for(auto itr : cnt) {
    //     cout << itr.ff.ff << " " << itr.ff.ss << " " << itr.ss << endl;
    // }
    // cout << endl << endl << endl;

    ll res = 1;
    for(auto itr : cnt) {
        ll a, b; tie(a, b) = itr.ff;
        if(a == 0 && b == 0) continue;
        ll freq = itr.ss;
        ll reva = -b, revb = a;
        if(revb < 0) {
            revb *= -1;
            reva *= -1;
        } else if(revb == 0) reva = 1;

        if(!cnt.count({reva, revb})) {
            res *= power(2, freq, MOD);
            res %= MOD;
            continue;
        }
        if(a > reva) continue;
        ll freq2 = cnt[{reva, revb}];
        ll curr = (power(2LL, freq, MOD) + power(2LL, freq2, MOD) - 1 + MOD)%MOD;
        res *= curr; res %= MOD;
    }
    res = (res - 1 + MOD)%MOD; // choose at least one.
    res = (res + cnt[{0, 0}])%MOD;
    cout << res;
    return 0;
}

Measured memory_bytes: 18764
import numpy as np

N,K = [int(i) for i in input().split()]
n = np.array([int(i) for i in input().split()])
n=(n+1)
t=np.empty(N+1)
t[0] = 0
t[1:]=np.cumsum(n)
print(max(t[K:]-t[:-K])*0.5)

Measured memory_bytes: 33848
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    map<ll, ll> cnt;
    ll h, ans = 0;
    cin >> h;
    cnt[h] = 1;
    while (cnt.size() > 0) {
        auto it = cnt.rbegin();
        ll num = it->first;
        if (num == 0) break;
        ll freq = it->second;
        ans += freq;
        cnt.erase(num);
        cnt[num/2] += freq*2;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef pair<int,int> P;

const int MOD=1000000007;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int k;
	cin>>k;k--;
	cout<<a[k]<<"\n";	
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	vector<int> results;

	while (true) {
		int n, k;
		cin >> n >> k;
		if (n == 0 && k == 0) break;

		int* a = new int[n];
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}

		int max = 0;
		int prev = 0;
		for (int i = 0; (i + k - 1) < n; i++) {
			int s = 0;
			if (prev == 0) {
				for (int j = i; j <= (i + k - 1); j++) {
					s += a[j];
				}
			} else {
				s = prev;
				s -= a[i - 1];
				s += a[i + k - 1];
			}
			prev = s;

			if (max < s) {
				max = s;
			}
		}

		results.push_back(max);
	}

	for (int i = 0; i < results.size(); i++)
		cout << results[i] << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) cin >> X.at(i);
  int ans = 2e9;
  for (int i = 1; i <= 100; i++) {
    int tmp = 0;
    for (int j = 0; j < N; j++) {
      tmp += (X.at(j) - i) * (X.at(j) - i);
    }
    ans = min(ans, tmp);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

//??\?????????
void swap(int *a, int *b){
	int temp = *a;
	*a = *b;
	*b = temp;
}

int main(){

	int num,i,j;
	
	cin >> num;
	
	int a[num],b[num],c[num];
	
	for(i=0;i<num;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	
	int t[3];
	for(i=0;i<num;i++){
		t[0] = a[i];
		t[1] = b[i];
		t[2] = c[i];
		
		int max,str;
		str = 1;
		while(str<=3){
			max = t[str-1];
			for(j=str;j<3;j++){
				if(max<t[j]){
					max = t[j];
					swap(t[str-1],t[j]);
				}
			}
			str++;
		}
		if(t[0]*t[0]==t[1]*t[1]+t[2]*t[2])
			cout << "YES\n";
		else cout << "NO\n";
	}
	
	return 0;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
#define sz 100005

using namespace std;
const int mod = 1e9+7;

long long ara[sz],fib[sz];


int cnt_step(int n)
{
    if(fib[n] != -1) return fib[n];
    if(n==0) {
        return 1;
    }
    if(!ara[n]) return fib[n]=(cnt_step(n-1)%mod+cnt_step(n-2)%mod)%mod;
    return 0;

}

int main()
{
    memset(fib,-1,sizeof (fib));
    int n,input,m;
    cin>>n>>m;
    fib[0]=1;

    for(int i=0;i<m;i++){
        cin>>input;
        ara[input]=1;
    }

    cout << cnt_step(n)<<endl;

    return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, X;
	cin >> N >> X;
	vector<int>L(N);
	rep(i, N) {
		cin >> L[i];
	}
	vector<int>D(N + 1);
	D[0] = 0;
	for (int i = 1; i < N+1; i++) {
		D[i] = D[i - 1] + L[i - 1];
	}
	int cnt = 0;
	rep(i, N + 1) {
		if (D[i] <= X) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;


int main(int argc, char *argv[])
{
	int k, x;

	//input
	cin >> k >> x;



	//calc
	string ans;

	if (x <= k * 500){
		ans = "Yes";
	}
	else{
		ans = "No";
	}


	//ans
	cout << ans << endl;

	return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int vec[5] = {1,0,-1,0,1};
int field[20][20];
int butux[10],butuy[10];
int w,h,sx,sy,gx,gy,nowx,nowy,ans;
bool flag;

void dfs(int x,int y,int count){
  if(count<=10){
    for(int i=0;i<4;i++){
      nowx=x;
      nowy=y;
      while(1){
        nowx+=vec[i];
        nowy+=vec[i+1];
        if(0<=nowy&&nowy<h&&0<=nowx&&nowx<w){
          if(field[nowy][nowx]==1){
            flag=false;
            for(int j=0;j<count-1;j++){
              if(butuy[j]==nowy&&butux[j]==nowx){
                flag=true;
                break;
              }
            }
            if(!flag){
              butux[count-1]=nowx;
              butuy[count-1]=nowy;
              if(nowx-vec[i]!=x||nowy-vec[i+1]!=y){
                dfs(nowx-vec[i],nowy-vec[i+1],count+1);
              }
              break;
            }
          }else if(field[nowy][nowx]==3){
            ans=min(ans,count);
            break;
          }
        }else{
          break;
        }
      }
    }
  }
  return;
}

int main(){
  while(1){
    cin >> w >> h;
    if(w==0) return 0;
    ans=100;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> field[i][j];
        if(field[i][j]==2){
          sx=j;
          sy=i;
        }else if(field[i][j]==3){
          gx=j;
          gy=i;
        }
      }
    }
    dfs(sx,sy,1);
    if(ans==100){
      cout << -1 << endl;
    }else{
      cout << ans << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3056
s = input()
K = int(input())

def substring(S):
    N = len(S)
    ls = []
    for i in range(1,min(6,N+1)):
        for j in range(0,N-i+1):
            ls.append(S[j:j+i])
    setls = set(ls)
    ls = list(setls)
    ls.sort()
    return ls
print(substring(s)[K-1])

Measured memory_bytes: 11248
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = lr() + [0]
# ある回数から先は全ての電球にNを足す
for _ in range(min(K, 41)):
    next = [0] * (N+1)
    for i in range(N):
        x = A[i]
        next[max(0, i-x)] += 1
        next[min(N-1, i+x)+1] -= 1
    for i in range(N):
        next[i+1] += next[i]
    A = next.copy()

print(*A[:-1])

Measured memory_bytes: 168980
#pragma GCC optimize("O3")
//#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

struct point {
	ll x, y;
	int idx;
};
// 0 1 2 3
pair<point, point> closest_point(vector<point>& pl, int l, int r) {
	//auto dist_m = [](point& l, point& r) {return abs(l.x - r.x) + abs(l.y - r.y); };
	auto dist_m = [](point& l, point& r) {return (l.x - r.x) * (l.x - r.x) + (l.y - r.y) * (l.y - r.y); };
	if (r - l == 2)return { pl[l],pl[l + 1] };
	if (r - l == 3) {
		if (dist_m(pl[l], pl[l + 1]) <= dist_m(pl[l + 1], pl[l + 2]) && dist_m(pl[l], pl[l + 1]) <= dist_m(pl[l], pl[l + 2])) return { pl[l],pl[l + 1] };
		if (dist_m(pl[l + 1], pl[l + 2]) <= dist_m(pl[l], pl[l + 2]) && dist_m(pl[l + 1], pl[l + 2]) <= dist_m(pl[l], pl[l + 1])) return { pl[l + 1],pl[l + 2] };
		return { pl[l],pl[l + 2] };
	}
	int mid = (l + r) / 2;
	sort(pl.begin() + l, pl.begin() + r, [](const auto& l, const auto& r) { if (l.x == r.x)return l.y < r.y; return l.x < r.x; });
	auto p1 = closest_point(pl, l, mid), p2 = closest_point(pl, mid, r);
	auto pd = (dist_m(p1.first, p1.second) < dist_m(p2.first, p2.second) ? p1 : p2);
	auto d = dist_m(p1.first, p1.second);
	//cout << d << endl;
	auto x_med = (((r - l) % 2 == 0) ? (pl[mid].x + pl[mid - 1].x) / 2 : pl[mid].x);

	sort(pl.begin() + l, pl.begin() + r, [](const auto& l, const auto& r) { if (l.y == r.y)return l.x < r.x; return l.y < r.y; });
	for (int i = l; i < r; i++) {
		if (abs(pl[i].x - x_med) > d)continue;
		for (int j = i + 1; j < r; j++) {
			if (dist_m(pl[i], pl[j]) > d)break;
			if (d > dist_m(pl[i], pl[j])) {
				d = dist_m(pl[i], pl[j]);
				pd = { pl[i],pl[j] };
			}
		}
	}

	return pd;

}

int main() {
	io_init;
	ll N;
	cin >> N;
	vector<point> pl;
	for (int i = 0; i < N; i++) {
		ll a, b;
		cin >> a >> b;
		pl.push_back({ a,b,i });
	}
	auto tmp = closest_point(pl, 0, N);
	cout << ( (tmp.first.x - tmp.second.x) * (tmp.first.x - tmp.second.x) + (tmp.first.y - tmp.second.y) * (tmp.first.y - tmp.second.y) )<< endl;
}


Measured memory_bytes: 15224
#include <bits/stdc++.h>
using namespace std;
int main(){
 string S, T;
 int a, b;
 cin >> S >> T;
  cin >> a >> b;
  string U;
  cin >> U;
  if(S == U){
	a -= 1;
  }else if(T == U){
    b -= 1;
  }
  cout << a << ' '<< b << endl;
}

Measured memory_bytes: 256
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
int main(){
    int x; cin>>x;
    int a[x];
    int k; cin>>k;
    int l=0;
    for(int i=0;i<x;i++){
        cin>>a[i];
        if(a[i]>=k)l++;
    }cout<<l;



















return 0;}


Measured memory_bytes: 640
#include <cstdio>
#include <queue>
#include <vector>
#include <utility>
using namespace std;
int a[210][210];
struct E {
	int to, cap, co, rev;
};
vector<E> e[80010];
const int C = 40010;
void add_edge(int f, int t, int c, int ca) {
	e[f].push_back((E){t, ca, c, (int)e[t].size()});
	e[t].push_back((E){f, 0, -c, (int)e[f].size()-1});
}
long long h[80010],  d[80010];
long long prevv[80010], preve[80010];
const long long inf = 1ll << 50;
int go(int f, int t) {
	int res = 0;
	int fl = 2;
	while (fl) {
		for (int i = 0; i < t + C; i++) {
			d[i] = inf;
		}
		d[f] = 0;
		priority_queue<pair<int, int> > q;
		q.push(make_pair(0, f));
		while (q.size()) {
			int x = q.top().second, z = -q.top().first;
			q.pop();
			if (d[x] < z) continue;
			for (int i = 0; i < e[x].size(); i++) {
				E &ed = e[x][i];
				int y = ed.to;
				if (ed.cap > 0 && d[x] + ed.co + h[x] < d[y] + h[y]) {
					d[y] = d[x] + ed.co + h[x] - h[y];
					prevv[y] = x;
					preve[y] = i;
					q.push(make_pair(-d[y], y));
				}
			}
		}
		for (int i = 0; i < t + C; i++) {
			h[i] += d[i];
		}
		int v = t;
		while (v != f) {
			E &ed = e[prevv[v]][preve[v]];
			ed.cap -= 1;
			e[v][ed.rev].cap += 1;
			v = prevv[v];
		}
		res += h[t];
		--fl;
	}
	return res;
}
int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			scanf("%d", &a[i][j]);
			a[i][j] = 100000 - a[i][j];
			if (i < h - 1) {
				add_edge(i * w + j + C, i * w + w + j, 0, 1);
			}
			if (j < w - 1) {
				add_edge(i * w + j + C, i * w + j + 1, 0, 1);
			}
			add_edge(i * w + j, i * w + j + C, a[i][j], 1);
		}
	}
	long long ans = 200000 - a[0][0] - a[h-1][w-1] + 200000ll * (h + w - 3) - go(C, (h - 1) * w + w - 1);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 11184
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def main():
    n = int(input())
    ans = float("inf")
    for i in range(1,1000001):
        if n % i == 0:
            ans = min(i-1 + n//i-1,ans)
    print(ans)





    
            
    

    

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 74476
# 深さ優先探索
from sys import setrecursionlimit


def genid(a, b):
    if b < a:
        a, b = b, a
    return a * 100000 + b


N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]

edges = [[] for _ in range(N)]
for a, b in ab:
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

colors = {}
q = [(0, -1, -1)]
while q:
    currentNode, usedColor, parentNode = q.pop()
    color = 1
    for childNode in edges[currentNode]:
        if childNode == parentNode:
            continue
        if color == usedColor:
            color += 1
        colors[genid(currentNode, childNode)] = color
        q.append((childNode, color, currentNode))
        color += 1

print(max(len(e) for e in edges))
for a, b in ab:
    print(colors[genid(a - 1, b - 1)])


Measured memory_bytes: 53784
N, K = map(int, input().split())
A = list(map(int, input().split()))
Kb = format(K, 'b')
f = lambda x: sum(a ^ x for a in A)
table = [f(2 ** i) - f(0) for i in range(42)]
candy = {i: x for i, x in enumerate(table) if x > 0 and 2 ** i <= K}
mask = [K]
for i in range(len(Kb) - 1, -1, -1):
    if K & (1 << i):
        mask += [K ^ (1 << i) | ((1 << i) - 1)]
res = 0
for m in mask:
    tmp = 0
    for b in range(42):
        if m & (1 << b) and b in candy:
            tmp += candy[b]
    res = max(res, tmp)
print(res + f(0))

Measured memory_bytes: 14840
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
result = 0

for i in range(N):
    attack = B[i] - A[i]
    if attack > 0:
        result += A[i]
        if A[i+1] >= attack:
            result += attack
            A[i+1] -= attack
        else:
            result += A[i+1]
            A[i+1] = 0
    else:
        result += B[i]

print(result) 

Measured memory_bytes: 18476
cnt = 0
n = int(input())
l = list(map(int, input().split()))

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            tmp = [l[i], l[j], l[k]]
            tmp.sort()
            if tmp[0] == tmp[1] or tmp[1] == tmp[2]:
                continue
            if tmp[0] + tmp[1] <= tmp[2]:
                continue
            cnt += 1

print(cnt)

Measured memory_bytes: 68292
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,K;
    cin>>N>>K;
    int i;
    int A[N];
    for(i=0;i<N;i++)
    {
        cin>>A[i];
    }
    sort(A,A+N);
    int sum=0;
    for(i=0;i<K;i++)
    {
        sum=sum+A[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3628