akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var perCount = 0;
            var total = 0;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == 'g')
                {
                    if (perCount > 0)
                    {
                        total++;
                        perCount--;
                    }
                    else
                        perCount++;
                }
                else
                {
                    if (perCount > 0)
                        perCount--;
                    else
                    {
                        total--;
                        perCount++;
                    }
                }

            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13148
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MAX_N 200005
#define INF 100000000000000000ll
#define P pair<long long,long long>
#define fst first
#define snd second
#define int long long

using namespace std;

int n,ans=INF;
int a[MAX_N];
int s[MAX_N];

inline int sec(int l,int r)
{
	if(l>r) return 0;
	return s[r]-s[l-1];
}

P cal(int L,int R)
{
	// cout<<" cal: L = "<<L<<" R = "<<R<<endl;
	int l=L,r=R;
	while(r-l>1)
	{
		int mid=(l+r)>>1;
		// cout<<"  l = "<<l<<" r = "<<r<<" ls = "<<sec(L,mid)<<" rs = "<<sec(mid+1,R)<<endl;
		if(sec(L,mid)<=sec(mid+1,R)) l=mid;
		else r=mid;
	}
	P pl(sec(L,l),sec(l+1,R));
	P pr(sec(L,r),sec(r+1,R));
	// cout<<" x = "<<x<<" y = "<<y<<endl;
	// return P(x,y);
	return abs(pl.fst-pl.snd)<abs(pr.fst-pr.snd) ? pl : pr;
}

int max(int a,int b,int c,int d)
{
	return max(a,max(b,max(c,d)));
}

int min(int a,int b,int c,int d)
{
	return min(a,min(b,min(c,d)));
}

int solve(int mid)
{
	// cout<<"solve: md = "<<mid<<endl;
	P l=cal(1,mid),r=cal(mid+1,n);
	return max(l.fst,l.snd,r.fst,r.snd)-min(l.fst,l.snd,r.fst,r.snd);
}

signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) s[i]=s[i-1]+a[i];
	for(int i=2;i<=n-2;i++) ans=min(ans,solve(i));
	printf("%lld\n",ans);
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 1000000007
vector<P>edge[100005];
int sub[100005];
ll sum = 0;
int n; bool ok = 0; int E = INF;
bool bad[100005]={};
void dfs(int v,int u){
	int only = -1;
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i].fi == u) continue;
		dfs(edge[v][i].fi,v);
		sub[v] += sub[edge[v][i].fi];
		sum += 2LL*edge[v][i].sc*min(n-sub[edge[v][i].fi],sub[edge[v][i].fi]);
		if(2*min(n-sub[edge[v][i].fi],sub[edge[v][i].fi])==n){
		    sum-=edge[v][i].sc; ok = 1;
		}
		if(sub[edge[v][i].fi]*2 >= n){
			only = i; bad[v] = 1;
			if(bad[edge[v][i].fi]) only = -2;
		}
	}
	sub[v]++; if(sub[v]*2 <= n) only = -2;
	if(only == -2) return;
	if(only >= 0){
		E = min(E,edge[v][only].sc);
	}
	else{
		for(int i=0;i<edge[v].size();i++){
			if(edge[v][i].fi == u) continue;
			E = min(E,edge[v][i].sc);
		}
	}
}
int main(){
	cin >> n;
	rep(i,n-1){
		int a,b,c; cin >> a >> b >> c;
		edge[a].pb(mp(b,c));
		edge[b].pb(mp(a,c));
	}
	dfs(1,-1);
	cout << (ok?sum:sum-E) << endl;
}

Measured memory_bytes: 14208
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BGreatOceanView solver = new BGreatOceanView();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGreatOceanView {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int H[] = new int[N];
            for (int i = 0; i < N; i++) {
                H[i] = in.nextInt();
            }
            int nb = 1;
            int start = H[0];
            for (int i = 1; i < N; i++) {
                if (H[i] >= start) {
                    start = H[i];
                    nb++;
                }
            }
            out.println(nb);
        }

    }
}



Measured memory_bytes: 23380
n = int(input())
l=[]
count=0
for h in range(n):
    for i in range(h+1):
        if (h+1)%(i+1)==0 and (h+1)%2!=0:
            l.append(h+1)
            if len(l)==8:
                count+=1
    if len(l)!=8:
        l.clear()
print(count)  

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
    	String[] nml= br.readLine().split(" ");
        int n = Integer.parseInt(nml[0]);
        int m = Integer.parseInt(nml[1]);
        int l = Integer.parseInt(nml[2]);
        int[][] nm = new int[n][m];
        int[][] ml = new int[m][l];
        
        for (int i = 0; i < n; i++)
        {
        	String[] nminput= br.readLine().split(" ");
        	for (int j = 0; j < m; j++)
        	{
        		nm[i][j] = Integer.parseInt(nminput[j]);
        	}
        }
        for (int i = 0; i < m; i++)
        {
        	String[] mlinput= br.readLine().split(" ");
        	for (int j = 0; j < l; j++)
        	{
        		ml[i][j] = Integer.parseInt(mlinput[j]);
        	}
        }
        
        
        for (int i = 0; i < n; i++)
        {
        	for (int j = 0; j < l; j++)
        	{
        		long sum = 0;
        		for (int k = 0; k < m; k++)
        		{
        			sum += nm[i][k] * ml[k][j];
        		}
        		System.out.print(sum);
        		if (j != l- 1)
        			System.out.print(" ");
        	}
        	System.out.println();
        }
	}

}

Measured memory_bytes: 36332
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines  

A, B, C = map(int, input().split())

x = A-B
print(0 if C-x < 0 else C-x)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

struct Task {
    char direction;
    ll cost;
};

int main() {
    ll w, h;
    cin >> w >> h;
    vector<ll> horizontal(w);
    vector<ll> vertical(h);
    rep(i, w) cin >> horizontal[i];
    rep(i, h) cin >> vertical[i];
    vector<Task> task;
    for (ll c : horizontal) task.push_back({'h', c});
    for (ll c : vertical) task.push_back({'v', c});

    sort(task.begin(), task.end(), [](Task t1, Task t2) {
        return t1.cost < t2.cost;
    });

    ll a = w + 1, b = h + 1;

    ll ans = 0;
    for (Task t : task) {
        if (t.direction == 'h') {
            ll now = b * t.cost;
            a--;
            ans += now;
        } else {
            ll now = a * t.cost;
            b--;
            ans += now;
        }
    }
    cout << ans << endl;

}


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

#define mn(s, t, u) min(s, min(t, u))

using namespace std;

int func(vector<bool> v1, vector<bool> v2, int n, string str)
{
  int top = 0, mid = 1, bot = 2, s, t, u;
  if(v2[0]){
    top = 3;
    mid = 2;
  } else if(v1[0]){
    top = 1;
  }

  for(int i = 1; i < v1.size()-1; i++){
    if(v1[i] && v2[i]){
      s = mn(top+4, mid+3, bot+3);
      t = mn(top+3, mid+3, bot+3);
      u = mn(top+3, mid+3, bot+4);
    } else if(v1[i]){
      s = mn(top+2, mid+2, bot+3);
      t = mn(top+2, mid+2, bot+3);
      u = mn(top+3, mid+3, bot+4);
    } else if(v2[i]){
      s = mn(top+4, mid+3, bot+3);
      t = mn(top+3, mid+2, bot+2);
      u = mn(top+3, mid+2, bot+2);
    } else {
      s = mn(top+1, mid+2, bot+3);
      t = mn(top+2, mid+1, bot+2);
      u = mn(top+3, mid+2, bot+1);
    }
    top = s;
    mid = t;
    bot = u;
  }

  if(v2[v2.size()-1]){
    return mn(top+4, mid+3, bot+3);
  } else if(v1[v1.size()-1]){
    return mn(top+2, mid+2, bot+3);
  }

  return mn(top+1, mid+2, bot+3);
}

int main()
{
  int n, m;
  string str;

  while(cin >> m && m){
    while(m--){
      cin >> n >> str;
      vector<bool> vec1, vec2;
      vec1.push_back((str[0] == 'Y'));
      vec2.push_back((str[2*n] == 'Y'));
      for(int i = 1; i < n; i++){
	vec1.push_back((str[2*i] == 'Y' || str[2*i-1] == 'Y'));
	vec2.push_back((str[2*i-1+2*n] == 'Y' || str[2*i+2*n] == 'Y'));
      }
      vec1.push_back((str[2*n-1] == 'Y'));
      vec2.push_back((str[4*n-1] == 'Y'));

      cout << func(vec1, vec2, n, str) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    long long ans = 0;
    vector<long long> num(10000001);
    vector<long long> cnt(10000001, 0);
    for(int i = 1; i <= N; i++){
        long long t = i;
        cnt[t]++;
        while(t + i <= N){
            t += i;
            cnt[t]++;
        }
    }
    for(long long i = 1; i <= N; i++){
        ans += i * cnt[i];
    }
    cout << ans << endl;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    ll r, d, x;
    cin >> r >> d >> x;
    
    rep(_, 0, 10) {
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int coin;

int main()
{
	int money = 1;
	int remoney;
	
	
	while (1){
	cin >> money;
	if (money == 0) break;
	remoney = 1000 - money;
	
	if ( remoney >= 500){
		coin++;
		remoney -= 500;
	}
	coin += remoney / 100;
	remoney %= 100;
	
	coin += remoney / 50;
	remoney %= 50;
	
	coin += remoney / 10;
	remoney %= 10;
	
	coin += remoney / 5;
	remoney %= 5;
	
	coin += remoney;
	
	cout << coin << endl;
	coin = 0;
	}
	return (0);
}

Measured memory_bytes: 2988
a[999],t,i,j,c,r;main(n){
	for(scanf("%d",&n);i<n;i++)scanf("%d",a+i);
	for(i=0;i<n;i++){
		for(c=i,j=i+1;j<n;j++)if(a[j]<a[c])c=j;
		if(c>i)t=a[i],a[i]=a[c],a[c]=t,r++;
	}
	for(i=0;i<n;i++)printf(i<n-1?"%d ":"%d\n",a[i]);
	printf("%d\n",r);
	exit(0);
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

#define int int64_t
int a[N+2];

int32_t  main(){
  IOS;
  int n,x;cin>>n>>x;
  int ans=0;
  fori(i,n){
    cin>>a[i];
    if(a[i]>x){
      ans+=a[i]-x;
      a[i]=x;
    }
  }
 // fori(i,n)cout<<a[i]<<" ";
  //cout<<endl;
  for(int i=2;i<n;++i){
    if(a[i]+a[i-1]>x){
      int diff=a[i]+a[i-1]-x;
      ans+=diff;
      a[i]-=diff;
    }
  }

  if(a[n]+a[n-1]>x){
    int diff=a[n]+a[n-1]-x;
    ans+=diff;
    a[n-1]-=diff;

  }

//  fori(i,n)cout<<a[i]<<" ";
  //cout<<endl;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int m = scn.nextInt();
        int l = scn.nextInt();
        int[][] a = new int[n][m], b = new int[m][l];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                a[i][j] = scn.nextInt();
            }
        }
        for(int i = 0; i < m; i++) {
            for(int j = 0; j < l; j++) {
                b[i][j] = scn.nextInt();
            }
        }
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < l; j++) {
                long v = 0;
                for(int k = 0; k < m; k++) {
                    v += a[i][k] * b[k][j];
                }
                if(j > 0) System.out.print(" " + v);
                else System.out.print("" + v);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 52552
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	x := readInt()
	a := readInt()
	b := readInt()

	if a >= b {
		println("delicious")
	} else if b-a <= x {
		println("safe")
	} else {
		println("dangerous")
	}
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
    int a,b,cost;
    cin>>a>>b;
    if (b%2==0){
        if (a>=13){
          cost=b;
          cout<<cost;}
      else if (13>a&&a>=6){
         cost=0.5*b;
            cout<<cost;}
      else if (a<6){
            cost=0*b;
            cout<<cost<<endl;}
    }
}


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

int h[100005], dp[100005];
int main(){
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i <= n; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
vector<long long> A,v1,v2;
long long absval(long long a)
{
	return a>0?a:-a;
}
int main()
{
	ios_base::sync_with_stdio(false);
	long long N,i,b=0,ans;
	cin>>N;
	A.resize(N);
	for(i=0;i<N;i++)
	{
		cin>>A[i];
		if(A[i]-i<=0)
			v1.push_back(A[i]-i-1);
		else
			v2.push_back(A[i]-i-1);
	}
	sort(v1.begin(),v1.end(),greater<long long>());
	sort(v2.begin(),v2.end());
	if(v2.size()>v1.size())
		b=v2[ceill((long double)(v2.size()-v1.size())/2)-1];
	else if(v1.size()>v2.size())
		b=v1[ceill((long double)(v1.size()-v2.size())/2)-1];
	ans=0;
	for(i=0;i<N;i++)
		ans+=absval(A[i]-b-i-1);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll a[N], dp[N];
int main()
{
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	memset(dp, 31, sizeof dp);
	dp[1] = 0;
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 1; j <= k; j ++)
			if(i - j >= 0)
			dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
	}
	cout << dp[n] << '\n';



	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 2816
def main():

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


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





if __name__== "__main__":
    main() 


Measured memory_bytes: 19004
T = int(input())

for i in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    S = input().rstrip()

    win = set()
    win.add(0)
    for j in range(len(S)-1, -1, -1):
        base = A[j]
        for v in win:
            base = min(base, base ^ v)

        if S[j] == '0':
            win.add(base)
        else:
            if base:
                print('1')
                break
    else:
        print('0')


Measured memory_bytes: 68384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

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

    cout << ((1000 - x % 1000) % 1000) << endl;


}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToArray();
            var t = Console.ReadLine().ToArray();
            var cnt = 0;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i]) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

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

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

  if (N % 500 > A) {
    cout << "No" << endl;
  }  
  if (N % 500 <= A) {
    cout << "Yes" << endl;
  } 
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int n;
  cin >> n;
  //初期値, 3変数の設定
  ll Li2 = 2;
  ll Li1 = 1;
  ll Li;
  
  for (int i = 2; i <= n; i++) {
    //Liの計算
    Li = Li1 + Li2;
    //次ステップの為に値を更新
    Li2 = Li1;
    Li1 = Li;
  }
  cout << Li1 << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
keiro = [1]
keiro_set = {1}
flag = True
now = 1
start = 0
loopN = 0
loop_list = []
not_loop = False
for i in range(N):
    now = A[now - 1]
    if now in keiro_set:
        start = keiro.index(now)
        loop_list = keiro[start:]
        loopN = len(loop_list)
        break
    else:
        keiro.append(now)
        keiro_set.add(now)
    if i + 2 > K:
        not_loop = True
        break
if not_loop:
    print(keiro[K])
elif K - start >= 0:
    print(loop_list[(K - start) % loopN])
else:
    print(keiro[K])


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

using namespace std;

int const maxn = 2e5 + 5;
int a[maxn], ans[maxn], best[maxn], len;
vector < int > g[maxn];

void dfs(int v, int p) {
    int lef = 0, righ = len + 1;
    while (righ - lef > 1) {
        int mid = (righ + lef) / 2;
        if (best[mid] < a[v]) lef = mid;
        else righ = mid;
    }
    int pos, lst;
    if (lef == len) {
        len++;
        pos = len, lst = best[len];
        best[len] = a[v];
    }
    else {
        pos = lef + 1, lst = best[lef + 1];
        best[lef + 1] = a[v];
    }
    ans[v] = len;
    for (auto u : g[v]) {
        if (u != p) dfs(u, v);
    }
    best[pos] = lst;
    if (lst == 0) len--;
}

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, u, v;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i < n; ++i) {
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, 0);
    for (int i = 1; i <= n; ++i) cout << ans[i] << '\n';
    return 0;
}


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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int cnt[n] = {};
  cnt[1] = 1;
  int key = 0;
  vector<int> v;
  v.push_back(1);

  for (int i = 0;;) {
    cnt[a[i]] += 1;
    v.push_back(a[i]);
    if (cnt[a[i]] == 2) {
      key = a[i];
      break;
    }
    i = a[i] - 1;
  }
  v.pop_back();
  int x = v.size();
  int memory = 0;
  for (int i = 0; i < x; i++) {
    if (v.at(i) == key) {
      memory = i;
      break;
    }
  }
  if (k < memory) {
    cout << v[k] << endl;
  } else {
    ll ans = (k - memory) % (x - memory);
    cout << v[ans + memory] << endl;
  }
  return 0;
}

Measured memory_bytes: 5772
main = do
    amount <- readLn
    if amount == 0 then return ()
                   else do
                       print $ searchMinimumPriceOf amount
                       main

searchMinimumPriceOf :: Int -> Int
searchMinimumPriceOf = minimum.map totalPrice.searchComb

searchComb :: Int -> [(Int,Int,Int)]
searchComb p = [(x,y,z) | x <- [0..25], y <- [0..17], z <- [0..10], 200*x+300*y+500*z == p]

totalPrice :: (Int,Int,Int) -> Int
totalPrice (x,y,z) = shopAprice x + shopBprice y + shopCprice z

shopAprice :: Int -> Int
shopAprice = shopPrice 'a'
shopBprice = shopPrice 'b'
shopCprice = shopPrice 'c'

shopPrice :: Char -> Int -> Int
shopPrice  s = priceCalc pa pp du dr
    where [pa,pp,du,dr] = case s of
                            'a' -> [200,380,5,20]
                            'b' -> [300,550,4,15]
                            'c' -> [500,850,3,12]

priceCalc packAmount packPrice discountUnit disCountRate amount =
    if amount `mod` discountUnit == 0 then amount `div` discountUnit * discountUnit * packPrice * (100 - disCountRate) `div` 100
                                      else amount `div` discountUnit * discountUnit * packPrice * (100 - disCountRate) `div` 100 + amount `mod` discountUnit * packPrice

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

int main(){
	int n, o;

	while(cin>>n, n!=0){
		int a[7]={0};
		while(n--){
			cin>>o;
			if(o<10)a[0]++;
			else if(o<20)a[1]++;
			else if(o<30)a[2]++;
			else if(o<40)a[3]++;
			else if(o<50)a[4]++;
			else if(o<60)a[5]++;
			else if(o>=60)a[6]++;
		}
		for(int i=0; i<7; i++){
			cout<<a[i]<<"\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
static const int INF = 10000000;
using ll = long long;

int main(){
	int N, M;
	cin >> N >> M;
	
	vector<int> a(M);
	vector<int> b(M);
	rep(i, M){
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		tmp1--;
		tmp2--;
		a[i] = tmp1;
		b[i] = tmp2;
	}
	
	int ans = 0;
	rep(si, M){
		vector<vector<int>> mp(N, vector<int>(N, INF));
		rep(i, N) mp[i][i] = 0;
		
		rep(i, M){
			if(i != si){
				mp[a[i]][b[i]] = 1;
				mp[b[i]][a[i]] = 1;
			}
		}
		
		rep(k, N) rep(i, N) rep(j, N){
			mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
		}
		
		bool find = false;
		rep(i, N){
			rep(j, N){
				if(mp[i][j] == INF){
					find = true;
					ans++;
					break;
				}
			}
			if(find) break;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def eratosthenes_sieve(n):
    table = [0] * (n+1)
    for i in range(1, n+1):
        for j in range(i, n+1, i):
            table[j] += 1
    return table

N = INT()

res = eratosthenes_sieve(N)
ans = 0
for i in range(1, N+1):
    ans += res[i] * i
print(ans)


Measured memory_bytes: 152032
#include<stdio.h>
#include<string.h>
int N=400000;
int main()
  
{
      char s[N],t[N];
  int count=0,i,l;
   // gets(s);
     //gets(t);
  scanf("%s",s);
  scanf("%s",t);
    l=strlen(s);
  for(i=0;i<l;i++)
  {
    if(s[i]!=t[i])
    {
      count++;
    }
  }
  printf("%d",count);
return 0;
}

Measured memory_bytes: 2080
"""
problem statment url: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C
"""


def lcs():
	s1 = raw_input()
	s2 = raw_input()
	la, lb = len(s1), len(s2)
	dp1 = [0 for _ in range(lb + 1)]

	for i in range(la):
		dp2 = dp1 + []
		for j in range(lb):
			if s1[i] == s2[j]:
				dp1[j + 1] = dp2[j] + 1
			elif dp1[j + 1] < dp1[j]:
				dp1[j + 1] = dp1[j]

	return dp1[-1]

if __name__ == '__main__':
	tc = int(raw_input())
	for _ in range(tc):
		print(lcs())

Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char a; cin >> a;
    cout << (a == 'a' || a == 'b' || a == 'c' || a == 'd' || a == 'e' || a == 'f' || a == 'g' || a == 'h' || a == 'i' || a == 'j' || a == 'k' || a == 'l' || a == 'm' || a == 'n' || a == 'o' || a == 'p' || a == 'q' || a == 'r' || a == 's' || a == 't' || a == 'u' || a == 'v' || a == 'w' || a == 'x' || a == 'y' || a == 'z' ? 'a' : 'A' )<< endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  vector<int> graph[n];
  for (int a, b; cin >> a >> b; ) {
    graph[a - 1].emplace_back(b - 1);
    graph[b - 1].emplace_back(a - 1);
  }
  int takahashi[n], aoki[n], parent[n], result = 0;
  auto bfs = [&](int start, int* distance) {
    queue<int> q;
    q.emplace(start);
    distance[start] = 0;
    vector<bool> visited(n);
    visited[start] = true;
    parent[start] = start;
    do {
      for (auto next : graph[q.front()]) {
        if (!visited[next]) {
          parent[next] = q.front();
          distance[next] = distance[q.front()] + 1;
          visited[next] = true;
          q.emplace(next);
        }
      }
      q.pop();
    } while (!q.empty());
  };
  bfs(u - 1, takahashi);
  bfs(v - 1, aoki);
  if (aoki[u - 1] != 1) {
    for (int i = 0; i < n; ++i) {
      if (takahashi[i] <= aoki[i]) {
        result = max(result, aoki[parent[parent[i]]] + 1);
      }
    }
  }
  cout << result;
  return 0;
}


Measured memory_bytes: 10020
#include<stdio.h>

int main(void)
{
    int a, b, x, y;
	
	scanf("%d %d", &a, &b);
	
	x = a*b;
	y = 2*a+2*b;
	
	printf("%d %d\n", x, y);
	
	return 0;
    
    
}


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

int main(){
  int n;
  string s;
  bool c=true,d=false;
  cin >> s;
  for(n=2;n<s.length();n++){
    if(isupper(s[n])&&d){
	  c=false;
    }else if(s[n]=='C'){
      d=true;
    }
  }
  if(s[0]=='A'&&islower(s[1])&&d&&c&&s[s.length()-1]!='C'){
    cout << "AC" << endl;
  }else {
    cout << "WA" << endl;
  }
}

Measured memory_bytes: 256
n,k=map(int,input().split())
h=[0]*n
for i in range(n):
  h[i]=int(input())
h=sorted(h,reverse=True)
#print(h)
ans=10**9
for i in range(n-k+1):
  ans=min(ans,h[i]-h[i+k-1])

print(ans)

Measured memory_bytes: 8240
def lcs():
    x = raw_input()
    y = raw_input()
    x1 = [0 for k in range(len(y)+1)]
    for i in xrange(len(x)):
        e = x[i]
        x2 = x1 + []
        for j in xrange(len(y)):
            if e == y[j]:
                x1[j+1] = x2[j] + 1
            elif x1[j+1] < x1[j]:
                x1[j+1] = x1[j]
    print max(x1)
 
n = input()
for i in xrange(n):
    lcs()

Measured memory_bytes: 6424
import bisect

q = int(input())
M = {}
sortedList = []

for i in range(q):
    query, *inp = input().split()
    key = inp[0]

    # insert
    if query == "0":
        x = int(inp[1])

        if key not in M:
            bisect.insort_left(sortedList, key)

        M[key] = x


    # get
    elif query == "1":
        if key in M:
            if M[key] != None:
                print(M[key])
            else:
                print(0)
        else:
            print(0)

    # delete
    elif query == "2":
        if key in M:
            M[key] = None

    # dump
    else:
        L = inp[0]
        R = inp[1]

        index_left = bisect.bisect_left(sortedList, L)
        index_right = bisect.bisect_right(sortedList, R)

        for i in range(index_left, index_right):
            key_ans = sortedList[i]
            if M[key_ans] != None:
                print(key_ans, M[key_ans])


Measured memory_bytes: 38800
#include<iostream>
using namespace std;
int main(){int x;char c,*d[]={"w","","k","s","t","n","h","m","y","r"};while(cin>>x>>c)(x==0&&c=='U')?cout<<"nn":cout<<d[x]<<((c=='T')?'a':(c=='L')?'i':(c=='U')?'u':(c=='R')?'e':'o');cout<<endl;}

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

struct Node {
  int key;
  Node *right, *left, *parent;
};
Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while( x->left != NIL) x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while (u != NIL && k != u->key) {
    if (k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}


Node * treeSuccessor(Node *x) {
  if (x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while( y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}
void treeDelete(Node *z) {
  Node *y;
  Node *x;

  if( z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  if (y->left !=NIL) {
    x = y->left;
  } else {
    x = y->right;
  }
  if( x!= NIL){
    x->parent = y->parent;
  }
  if (y->parent == NIL) {
    root = x;
  } else {
    if (y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }
  if (y != z) {
    z->key = y->key;
  }
  free(y);
}


void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ) {
    y = x;
    if( z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}
void inorder(Node *u){
  if ( u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if( u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
	int n, i, x;
  string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++ ) {
    cin >> com;
    if( com[0] == 'f') {
      scanf("%d", &x);
      Node *t = find(root, x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if (com == "insert") {
      scanf("%d", &x);
      insert(x);
    } else if (com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if( com == "delete") {
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 22044
long a,b,c,d,n;main(){scanf("%d%d%d%d%d",&a,&b,&c,&d,&n);a+a>b||(b=a+a);b+b>c||(c=b+b);c+c>d||(d=c+c);printf("%ld\n",n/2*d+n%2*c);}

Measured memory_bytes: 128
import numpy as np
n = int(input())
A = list(map(int,input().split()))
q = int(input())
ar = np.zeros(10**5+1)
for i in A:
    ar[i] += 1
ans = np.sum(A) 
for _ in range(q):
    b,c = map(int,input().split())
    ans = ans+ar[b]*(c-b)
    ar[c] += ar[b]
    ar[b] = 0
    print(int(ans))

Measured memory_bytes: 38804
n, ct = int(input()), 0
l = list(map(int, input().split()))
for i, j in enumerate(l):
    if j < 0:
        ct += 1
        l[i] *= -1
l.sort()
if ct % 2:
    print(sum(l)-l[0]*2)
else:
    print(sum(l))


Measured memory_bytes: 14224
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N;
ll a[3010];
ll dp[3010][3010];

int main() {
    cin >> N;
    rep(i, N) cin >> a[i];

    // 初期化
    rep(i, N) dp[i][i] = 0;

    // DP loop
    for (int len = 1; len <= N; len++) {
        for (int i = 0; i + len <= N; i++) {
            int j = i + len;
            if ((N - len) % 2 == 0) {
                dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);
            } else {
                dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1]);
            }
        }
    }

    cout << dp[0][N] << endl;
}


Measured memory_bytes: 70016
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> Pii;

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}

string rotation(string s){
    string t = s;
    t[0] = s[s.size() - 1];
    for(int i = 1; i < s.size(); i++){
        t[i] = s[i - 1];
    }

    return t;
}

int main(){

    string S, T;
    cin >> S;
    cin >> T;

    bool f = false;
    for(int i = 0; i <= S.size(); i++){
        if(S == T){
            f = true;
            break;
        }
        S = rotation(S);
    }
    if(f){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;    
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    N, P = [int(x) for x in input().strip().split()]
    A = [int(x) for x in input().strip().split()]
    odd = len([1 for a in A if a % 2])
    even = len([1 for a in A if a % 2 == 0])
    nCr_ = {}
    def nCr(n, r):
        r = min(n-r, r)
        if r == 0:
            return 1
        if (n, r) in nCr_:
            return nCr_[(n, r)]

        ret1 = 1
        ret2 = 1
        for r in range(1, r+1):
            ret1 *= n - r + 1
            ret2 *= r
        nCr_[(n, r)] = ret1 // ret2
        return nCr_[(n, r)]

    t = 0
    for i in range(even + 1):
        t += nCr(even, i)
    ans = 0
    for i in range(P, odd + 1, 2):
        ans += t * nCr(odd, i)

    print(ans)

if __name__ == '__main__':
    main()

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

int n,m;
vector<string> A,B;

bool isMatch(int a, int b){
  for(int i=0;i<m;i++)
	  for(int j=0;j<m;j++){
        if(A[i+a][j+b]==B[i][j]) continue;
        else return false;
      }
  return true;
}

int main(){
  cin >> n >> m;
  for(int i=0;i<n;i++) {string s; cin >> s; A.push_back(s);}
  for(int i=0;i<m;i++) {string s; cin >> s; B.push_back(s);}
  for(int i=0;i<n-m+1;i++) for(int j=0;j<n-m+1;j++){
  	if(isMatch(i,j)){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
using ll = long long;



int main() {
	ll r,d,x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
class Program
{
    static void Main(string[] args)
    {
        string[] input = ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        int C = int.Parse(input[2]);
        int a = A - B;
        if(C - a < 0)
        {
            WriteLine(0);
        }
        else
        {
            WriteLine(C - a);
        }
    }

}

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

long long n, k;
long long a[100000], b[100000];
long long ans = 0;
void f(vector<bool> &used, int digit, long long value) {
  if (digit == -1) {
    ans = max(value, ans);
    return;
  }
  int d_k = (k >> digit) & 1;
  if (d_k == 0) {
    set<int> unused;
    for (int i=0; i<n; i++) {
      int d_ai = (a[i] >> digit) & 1;
      if (used[i] && d_ai == 1) {
        unused.insert(i);
        used[i] = false;
        value -= b[i];
      }
    }
    f(used, digit-1, value);
    for (int i: unused) {
      used[i] = true;
    }
  } else {
    set<int> s1;
    for (int i=0; i<n; i++) {
      int d_ai = (a[i] >> digit) & 1;
      if (used[i] && d_ai == 1) {
        s1.insert(i);
      }
    }
    if (s1.size() == 0) {
      ans = max(value, ans);
      return;
    }
    f(used, digit-1, value);
    for (int i: s1) {
      value -= b[i];
    }
    ans = max(value, ans);
  }
}
int main() {
  cin>>n>>k;
  for (int i=0; i<n; i++) cin>>a[i]>>b[i];
  long long sum = 0;
  for (int i=0; i<n; i++) sum += b[i];
  vector<bool> used;
  for (int i=0; i<n; i++) used.push_back(true);
  f(used, 29, sum);
  cout<<ans<<endl;
}

Measured memory_bytes: 76800
N = int(input())
if N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9:
    print('hon')
if N%10==0 or N%10==1 or N%10==6 or N%10==8:
    print('pon')
if N%10==3:
    print('bon')

Measured memory_bytes: 9116
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define in(n) cin>>n>>
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    int x=0;
    
    string s;
    
    cin >> s;
    
    rep(i,3){
    
        if(s[i] == '1'){
        
            x++;
    
        }
    
    }
    
    cout << x << endl;
    
/////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()

a = [0]*n
for i in range(1,int(n**0.5)+1):
    for j in range(1,int(n**0.5)+1):
        for k in range(1,int(n**0.5)+1):
            if i**2+j**2+k**2+i*j+j*k+k*i <= n:
                a[i**2+j**2+k**2+i*j+j*k+k*i-1] += 1

for i in a:
    print(i)


Measured memory_bytes: 10424
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int a = int.Parse(ReadLine());
	ReadLine();
	ReadLine();
	ReadLine();
	int e = int.Parse(ReadLine());
	int k = int.Parse(ReadLine());

	if (e-a <= k)
	{
	    WriteLine("Yay!");
	}
	else
	{
	    WriteLine(":(");
	}
    }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) < (C + D)) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <cctype>
#include <climits> // INT_MAX ...
#include <cstring> // 

using namespace std;

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

	int n, k, s;
	cin >> n >> k >> s;
	int MAXA = 1e9;
	int nk = (s == MAXA ? 1 : s + 1);

	for (int i = 0; i < k; ++i) cout << s << " ";
	for (int i = 0; i < n - k; ++i) cout << nk << " ";
	cout << "\n";


	return 0;
}

Measured memory_bytes: 1280
k = int(input())

if k % 5 == 0 or k % 2 == 0:
  print(-1)
  exit()

n = 7 % k
m = 70 % k
ans = 1
while True:
  if n == 0:
    print(ans)
    break
  
  n += m
  n %= k
  m *= 10
  m %= k
  ans += 1

Measured memory_bytes: 63208
#include<bits/stdc++.h>
using namespace std;
#define M 1e9
#define C 998244353
#define pi 3.14159265359
#define loop(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define rloop(i,a,b) for(ll i = ll(a); i >= ll(b); --i)
#define sloop(i,a) for (std::set<ll>::iterator i = a.begin(); i != a.end(); ++i)
#define pb push_back
#define x n%10
typedef long long int ll;
typedef unsigned long long int ull;

void solve(){
    ll n,i,j,count=0;
    cin >> n;
    if(x==2 || x==4 || x==5 || x==7 || x==9){
        cout << "hon" << "\n";
    }
    else if(x==0 || x==1 || x==6 || x==8){
        cout << "pon" << "\n";
    }
    else{
        cout << "bon" << "\n";
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    loop(f,0,t){    
        solve();
    }   
}

Measured memory_bytes: 3612