akhauriyash/Code-Regression huggingface dataset:
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
    IOS;
    int64 T=1;
    //cin>>T;
    while(T--)
    {
      int64 n,m,i,j,k;
      cin>>n>>m;
      char mat[n][m];

      for(i=0;i<n;i++)
      {
        for(j=0;j<m;j++)
        {
          cin>>mat[i][j];
        }
      }
      int64 inf=100000;
      int64 tot=n*m;
      int64 dis[tot][tot];
      for(i=0;i<tot;i++)
      {
        for(j=0;j<tot;j++)
          dis[i][j]=inf;
        dis[i][i]=0;
      }
    
      for(i=0;i<n;i++)
      {
        for(j=0;j<m;j++)
        {
          int64 nd=i*m+j;
          if(mat[i][j]=='.')
          {
            if(j+1<m&&mat[i][j+1]=='.')
            {
              int64 nd2=i*m+j+1;
              dis[nd][nd2]=dis[nd2][nd]=1;
            }
            if(i+1<n&&mat[i+1][j]=='.')
            {
              int64 nd2=(i+1)*m+j;
              dis[nd][nd2]=dis[nd2][nd]=1;
            }
          }
        }
      }

      for(k=0;k<tot;k++)
      {
        for(i=0;i<tot;i++)
        {
          for(j=0;j<tot;j++)
            dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
        }
      }
      int64 ans=0;
      for(i=0;i<tot;i++)
      {
        for(j=0;j<tot;j++)
        {
          if(dis[i][j]<inf)
          {
            ans=max(ans,dis[i][j]);
          }
        }
      }

      cout<<ans<<endl;


    }

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

struct Sieve {
	int n;
	vector<int> f, primes;
	Sieve(int n=1):n(n), f(n+1) {
		f[0] = f[1] = -1;
		for (ll i = 2; i <= n; ++i) {
			if (f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for (ll j = i*i; j <= n; j += i) {
				if (!f[j]) f[j] = i;
			}
		}
	}
	bool isPrime(int x) { return f[x] == x;}
	vector<int> factorList(int x) {
		vector<int> res;
		while (x != 1) {
			res.push_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	vector<P> factor(int x) {
		vector<int> fl = factorList(x);
		if (fl.size() == 0) return {};
		vector<P> res;
		int pre= -1;
		for (int p : fl) {
			if (pre == p) {
				res.back().second++;
			} else {
				res.emplace_back(p, 1);
			}
			pre=p;
		}
		return res;
	}
};


int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i, n) cin>>a[i];

	bool pc=true, sc=true;
	vector<bool> deta(1000005);
	vector<int> inter, ninter, li;
	bool first=true;
	Sieve si(1000005);

	rep(i, n){
		auto vp=si.factor(a[i]);
		for(auto p : vp){
			int pr=p.first;
			if(deta[pr]) pc=false;
			deta[pr]=true;

			if(first) ninter.push_back(pr);
			else{
				auto it=lower_bound(inter.begin(), inter.end(), pr);
				if(it!=inter.end() && (*it) == pr) ninter.push_back(pr);
			}
		}
		inter.clear();
		for(int v : ninter) inter.push_back(v);
		ninter.clear();
		if(first) first=false;
	}

	sc=inter.empty();
	if(pc) cout<<"pairwise coprime"<<endl;
	else if(sc) cout<<"setwise coprime"<<endl;
	else cout<<"not coprime"<<endl;

	return 0;
}


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

using namespace std;


int pow100 ( int x ){
    int p = 1;

    while ( x-- ){
        p *= 100;
    }

    return p ;
}

int main(){
    int n ,d ;

    scanf("%d%d",&d,&n);

    int val = pow100( d ) * n ;

    if ( n == 100 ){
        val += pow100( d );

    }

    printf("%d",val );



    return 0;
}


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

int main() {
  int H, A;
  cin >> H >> A;
  
  if (H % A == 0) {
    cout << H / A << endl;
  } else {
    cout << H / A + 1 << endl;
  }
  
  return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    int M = 0;
    cin >> M;
    vector<int> s(M,0);
    vector<int> c(M,0);
    if(M == 0) {
        cout << (int)pow(10, N - 1)*(N != 1) << endl;
        return 0;
    }
    for(int i = 0; i < M; i++) {
        cin >> s.at(i);
        cin >> c.at(i);
    }
    for(int i = pow(10, N - 1)*(N != 1); i < pow(10, N); i++) {
        int check = 1;
        for(int j = 0; j < M; j++) {
            if((i/(int)pow(10, N - s.at(j)))%10 == c.at(j)) {
                continue;
            }
            check = 0;
        }
        if(check) {
            cout << i << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;


    return 0;
}

Measured memory_bytes: 3960
N,KK = list(map(int,input().split()))
A = list(map(int,input().split()))
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)

    # divisors.sort()
  return divisors
for i in sorted(make_divisors(sum(A)),key=lambda x:-x ):
  
  J = []
  j_prev=0
  for j in  sorted([a%i for a in A if a%i !=0]):
    J.append(j_prev+j)
    j_prev = J[-1]
  
  K = []
  k_prev=0
  for k in  sorted([a%i-i for a in A if a%i !=0],key=lambda x:-x ):
    K.append(k_prev+k)
    k_prev = K[-1]
  for jdx,j in enumerate(J):
    
    if jdx<len(K)-1 and j + K[-jdx-2] ==0:
      if j<= KK:
        print(i)
        quit()
else:
  print(1)

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
const int N = 2e5 + 100;

inline ll rd() {
  ll s = 0, w = 1; char c = getchar();
  while (c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); }
  while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
  return s * w;
}

ll n, k, a[N], fst[N], tot, pos;
pair <ll, ll> p[N];
vector <ll> r[N], ans;

inline void calc() {
  rep(i, 1, N - 100) {
    if (!r[i].size()) continue ; int len = r[i].size();
    rep(j, 0, len - 1) {
      if (j != len - 1)
        p[r[i][j]].fi = (r[i][j + 1] + 1) % n,
        p[r[i][j]].se = r[i][j + 1] + 1 - r[i][j];
      else
        p[r[i][j]].fi = (r[i][0] + 1) % n,
        p[r[i][j]].se = n - r[i][j] + r[i][0] + 1;
    }
  }
}

int main() {
  n = rd(), k = rd(); memset(fst, -1, sizeof(fst));
  rep(i, 0, n - 1) r[a[i] = rd()].pb(i);
  calc(); tot = pos = 0; ll s = n * k - 1;
  while (tot + p[pos].se <= s) {
    if (fst[pos] != -1) {
      ll K = tot - fst[pos], h = (n * k - fst[pos]) % K;
      if (h == 1ll) { puts(""); return 0; }
      h = (!h ? K - 1 : h - 1);
      s =  fst[pos] + h, tot = fst[pos];
      break ;
    }
    else fst[pos] = tot;
    tot += p[pos].se, pos = p[pos].fi;
  }
  if (s == tot + p[pos].se - 1) { puts(""); return 0; }
  while (tot <= s) {
    while (tot + p[pos].se <= s) tot += p[pos].se, pos = p[pos].fi;
    if (tot + p[pos].se - 1 == s) break ;
    ans.pb(a[pos]), (++pos) %= n, tot++;
  }
  int len = ans.size(); if (!len) puts("");
  else {
    rep(i, 0, len - 1) printf("%lld ", ans[i]);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 20340
#include <bits/stdc++.h>
#define fp(i, l, r) for(register int i = (l); i <= (r); ++i)
#define fd(i, l, r) for(register int i = (l); i >= (r); --i)
#define il inline
#define MAXN 105
using namespace std;

il int init() {
	char s[MAXN], t[MAXN];
	scanf("%s%s", s, t);
	int len = strlen(t);
	fp(i, 1, strlen(s)) {
		if(strcmp(s, t) == 0) {
			printf("Yes\n");
			return 0;
		}
		char asd = t[0];
		fp(j, 0, len-2) {
			t[j] = t[j+1];
		}
		t[strlen(s)-1] = asd;
	}
	printf("No\n");
}

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

Measured memory_bytes: 256
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def dfs(L, v, p, D):
    for w in L[v]:
        if w == p:
            continue
        dfs(L, w, v, D)
    D.append(v)


def main():
    N = int(input())
    L = [set() for _ in range(N)]
    for _ in range(N - 1):
        a, b = read_index()
        L[a].add(b)
        L[b].add(a)
    
    C = read_list()
    C.sort()

    D = []
    dfs(L, 0, -1, D)
    E = [""] * N
    for i, d in enumerate(D):
        E[d] = str(C[i])
    
    print(sum(C[: N - 1]))
    print(" ".join(E))


if __name__ == "__main__":
    main()

Measured memory_bytes: 21668
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
li = [[] for _ in range(n)]
for _ in range(m):
    a, b = rm()
    a -= 1
    b -= 1
    li[a].append(b)
    li[b].append(a)
for lis in li:
    print(len(lis))















Measured memory_bytes: 27160
#include <stdio.h> 

int main(void)
{
	int x, y, i, tmp;

	for(i=0; i<3000; i++)
	{
		
		scanf("%d %d", &x, &y);

		if(x==0 && y==0)
		{
			break;
		}

		if(x > y)
		{
			tmp = x;
			x = y;
			y = tmp;
		}

		printf("%d %d\n",x, y);

	}


	return 0;
}

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

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 998244353
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_A = 100005;
int A, B;
int Q;

int S[MAX_A], T[MAX_A];

signed main()
{
  cin >> A >> B >> Q;
  S[0] = T[0] = -INF_LL;
  FOR(n,1,A+1) {
    cin >> S[n];
  }
  FOR(n,1,B+1) {
    cin >> T[n];
  }
  S[A+1] = T[B+1] = INF_LL;
  A += 2; B += 2;

  REP(q,Q) {
    int x; cin >> x;
    int si = upper_bound(S,S+A,x) - S;
    int ti = upper_bound(T,T+B,x) - T;
    int sx1 = S[si-1], sx2 = S[si];
    int tx1 = T[ti-1], tx2 = T[ti];
    int ret = min(max(abs(x-sx1), abs(x-tx1)), max(abs(x-sx2), abs(x-tx2)));
    ret = min(ret, abs(sx1-x) + abs(tx2-x) + min(abs(sx1-x), abs(tx2-x)));
    ret = min(ret, abs(sx2-x) + abs(tx1-x) + min(abs(sx2-x), abs(tx1-x)));
    cout << ret << endl;
  }

  return 0;
}

Measured memory_bytes: 2816
N = int(input())

m = [0] * (N+1)
for i in range(1, N+1):
  temp = i
  for k in range(temp, N+1, i):
    m[k] += 1

ans = 0
for n in range(1, N+1):
  ans += n*m[n]
print(ans)


Measured memory_bytes: 151688
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

struct Data {
    int C,S,F;
};

void solve() {
    int N;
    cin >> N;
    vector<Data> vd(N-1);
    REP(i,N-1) {
        int C,S,F; cin >> C >> S >> F;
        vd[i] = Data{C,S,F};
    }

    vector<int> ans(N,0);
    REP(i,N-1) {
        FOR(j,0,i+1) {
            // まだ運行されていないならSiまで待ってそれに乗る
            auto p1 = vd[i].S + vd[i].C;
            auto p2 = ((ans[j]+vd[i].F-1)/vd[i].F)*vd[i].F + vd[i].C;
            if (ans[j] < vd[i].S) ans[j] = p1;
            else ans[j] = p2;
        }
    }
    REP(i,N) cout << ans[i] << endl;
}

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

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(c-a)<=d) cout << "Yes" << endl;
  else if(abs(b-a)<=d && abs(c-b)<=d) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())

x=[]
for i in range(a,min(b+1,a+k)):
  x.append(i)
for i in range(max(a,b-k+1),b+1):
  x.append(i)

ans=list(set(x))
ans.sort()
for i in ans:
  print(i)

Measured memory_bytes: 3060
package main

import (
  "bufio"
  "container/list"
  "fmt"
  "math"
  "os"
  "sort"
  "strconv"
  "strings"
)

var O,X Point

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  r,c,n := input.Next3Ints()
  O = Point{0.5*float64(r),0.5*float64(c),0}
  X = Point{0.5*float64(r)+1,0.5*float64(c),0}
  p := Points{}
  for i:=0;i<n;i++ {
    x,y,z,w := input.Next4Ints()
    if (x == 0 || x == r || y == 0 || y == c) &&
    (z == 0 || z == r || w == 0 || w == c) {
      p = append(p,Point{float64(x),float64(y),len(p)/2})
      p = append(p,Point{float64(z),float64(w),len(p)/2})
    }
  }
  n = len(p)
  sort.Sort(p)
  used := make(map[int]struct{})
  stack := list.New()
  for i:=0;i<n;i++ {
    if _,ok := used[p[i].n];!ok {
      used[p[i].n] = struct{}{}
      stack.PushFront(p[i].n)
      continue
    }
    m,_ := stack.Remove(stack.Front()).(int)
    if m != p[i].n { fmt.Println("NO");return }
  }
  fmt.Println("YES")
}

type Point struct { x,y float64;n int }
func(p Point) Equals(t Point) bool { return p.x == t.x && p.y == t.y }
func(p Point) Angle(sta Point,end Point) float64 {
  ax,bx := sta.x-p.x,end.x-p.x
  ay,by := sta.y-p.y,end.y-p.y
  return math.Atan2(ax*by-ay*bx,ax*bx+ay*by)
}
type Points []Point
func(ps Points) Len() int { return len(ps) }
func(ps Points) Swap(i,j int) { ps[i],ps[j] = ps[j],ps[i] }
func(ps Points) Less(i,j int) bool {
  return O.Angle(X,ps[i]) < O.Angle(X,ps[j])
}


type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) Next3Ints() (int,int,int) {
  s := strings.Split(i.NextLine()," ")
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  z,_ := strconv.Atoi(s[2])
  return x,y,z
}
func(i *Input) Next4Ints() (int,int,int,int) {
  s := strings.Split(i.NextLine()," ")
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  z,_ := strconv.Atoi(s[2])
  w,_ := strconv.Atoi(s[3])
  return x,y,z,w
}

Measured memory_bytes: 22784
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

struct Player
{
	Player( int score, int id ) : first( score ), second( id ){}
	int first;
	int second;
	bool operator<( const Player& p ) const
	{
		if( this->first > p.first ) return true;
		if( this->first < p.first ) return false;
		if( this->second < p.second ) return true;
		return false;
	}
};

int main()
{
	int n;

	while( cin >>n && n ){
		vector< Player > playerList;

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

			cin >> id;

			vector< pair< int, int > > throwResult;
			vector< pair< int, int > > scoreBoard;
			int frame = 0;
			int prevPin = 0;
			int throwCount = 0;
			while( frame < 10 - 1 ){
				int pin;
				cin >> pin;
				throwResult.push_back( make_pair( frame, pin ) );

				if( throwCount == 0 ){
					if( pin == 10 ){
						scoreBoard.push_back( make_pair( 10, 2 ) );
						++frame;
					}else{
						prevPin = pin;
						++throwCount;
					}
				}else{
					pin += prevPin;
					prevPin = 0;
					throwCount = 0;
					int state = pin == 10 ? 1 : 0;
					scoreBoard.push_back( make_pair( pin, state ) );
					++frame;
				}
			}
			throwCount = 0;
			prevPin = 0;
			while( throwCount < 3 ){
				int pin;
				cin >> pin;
				throwResult.push_back( make_pair( frame, pin ) );

				prevPin += pin;
				if( throwCount == 1 && prevPin < 10 ){
					break;
				}
				++throwCount;
			}
			scoreBoard.push_back( make_pair( prevPin, 0 ) );

			int score = 0;
			vector< pair< int, int > >::iterator itr = throwResult.begin();
			for( int j = 0; j < 10; ++j ){
				int sc = scoreBoard[ j ].first;
				int st = scoreBoard[ j ].second;
				if( st > 0 ){
					while( itr != throwResult.end() && itr->first <= j ){
						++itr;
					}
					vector< pair< int, int > >::iterator itr2 = itr;
					for( int k = 0; k < st; ++k, ++itr2 ){
						sc += itr2->second;
					}
				}
				score += sc;
			}
			playerList.push_back( Player( score, id ) );
		}
		sort( playerList.begin(), playerList.end() );

		for( int i = 0; i < n; ++i ){
			cout << playerList[ i ].second << " " << playerList[ i ].first << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
constexpr int MOD = 1000000007;
constexpr ll INF = 50000000000000000;
typedef std::pair<int, int> P;
constexpr ll SIZE = 100010;

ll N, A[2 * SIZE];
ll ans = 0;
bool F[2 * SIZE] = {};
int main() {
	std::ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> A[i];
		if ((i>0 && A[i] - A[i - 1]>1) || A[0] != 0) {
			cout << -1;
			return 0;
		}
	}
	REP(i, N) {
		if ( i == 0)continue;
		if (A[i] >= A[i + 1] )ans += A[i];

		DEB(ans)
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		if(b % a == 0){
			System.out.println(a + b);
		}else{
			System.out.println(b - a);
		}
	}
}

Measured memory_bytes: 21972
#include <cstdio>
#include <cctype>
#include <utility>
#include <bitset>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

using D = bitset<7>;

int main() {
	const D s[10] = {63, 6, 91, 79, 102, 109, 125, 39, 127, 111};
	for (int n; n = in(), ~n;) {
		D a {};
		while (n--)  {
			D c {s[in()]};
			outl((a ^ c).to_string());
			a = c;
		}
	}
}


Measured memory_bytes: 2556
// AISing.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<string>

using namespace std;

using ll = long long;

int main()
{
    int n;
    cin >> n;
    int cnt = 0;

    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        if (i % 2 == 1 && a % 2 == 1)cnt++;
    }

    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main() {
  int N; cin >> N;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int p; cin >> p;
    ans++;
    for (int j = 2; j*j <= p; j++) {
      if (p % j == 0) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3096
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<time.h>
#include<cstdlib>
#include<cmath>
#include<list>
using namespace std;
#define MAXN 100100
#define eps 1e-7
#define For(i,a,b) for(int i=a;i<=b;i++) 
#define Fore(i,a,b) for(int i=a;i>=b;i--) 
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define cr clear()
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false)
#define fre freopen
#define pi acos(-1.0)
#define inf 1e9+9
#define Vector Point
const int Mod=1e9+7;
typedef unsigned long long ull;
typedef long long ll;
int dcmp(double x){
	if(fabs(x)<=eps) return 0;
	return x<0?-1:1;
}
struct Point{
	double x,y;
	Point(double x=0,double y=0):x(x),y(y) {}
	bool operator < (const Point &a)const{
		if(x==a.x) return y<a.y;
		return x<a.x;
	}
	Point operator - (const Point &a)const{
		return Point(x-a.x,y-a.y);
	}
	Point operator + (const Point &a)const{
		return Point(x+a.x,y+a.y);
	}
	Point operator * (const double &a)const{
		return Point(x*a,y*a);
	}
	Point operator / (const double &a)const{
		return Point(x/a,y/a);
	}
	void read(){
		scanf("%lf%lf",&x,&y);
	}
	void out(){
		cout<<"debug: "<<x<<" "<<y<<endl;
	}
	bool operator == (const Point &a)const{
		return dcmp(x-a.x)==0 && dcmp(y-a.y)==0;
	}
};
double Dot(Vector a,Vector b) {
	return a.x*b.x+a.y*b.y;
}
double dis(Vector a) {
	return Dot(a,a);
}
double Cross(Point a,Point b){
	return a.x*b.y-a.y*b.x;
}
int ConvexHull(Point *p,int n,Point *ch){
	int m=0;
	for(int i=0;i<n;i++){
		while(m>1 && Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0) m--;
		ch[m++]=p[i];
	}
	int k=m;
	for(int i=n-1;i>=0;i--){
		while(m>k && Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0) m--;
		ch[m++]=p[i];
	}
	if(n>1) m--;
	return m;
}
int n,a[100005];
void solve(){
	iossy;
	cin>>n;
	For(i,1,n) cin>>a[i];
	int ans=0;
	For(i,2,n) {
		if(a[i]==a[i-1] && a[i-1]!=-1) ans++,a[i]=-1;
	}
	cout<<ans<<endl;
}
int main(){
//	fre("in.txt","r",stdin);
	int t=0;
	solve();
	return 0;
}


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

int main()
{
	int n, t;
	scanf("%d%d",&n,&t);
	long long ans = 0;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		int x;
		scanf("%d",&x);
		ans += (x + t) - max(last, x);
		last = x + t;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void erase(int island[52][52],int x,int y){
	island[x][y]=0;
	for(int m=-1;m<=1;m++){
		if(island[x+m][y]==1){
			erase(island,x+m,y);
		}
		if(island[x][y+m]==1){
			erase(island,x,y+m);
		}
		if(island[x+m][y+m]==1){
			erase(island,x+m,y+m);
		}
		if(island[x-m][y+m]==1){
			erase(island,x-m,y+m);
		}
	}
}
int main(){
	int w,h;
	while(cin>>w>>h){
		if(w==0 && h==0) break;
		int island[52][52]={0};
		int num,count=0;		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>num;
				island[i+1][j+1]=num;
			}
		}
		for(int i=1;i<h+1;i++){
			for(int j=1;j<w+1;j++){
				if(island[i][j]==1){
					erase(island,i,j);
					count++;
				}
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 1432
#include<iostream>
#include<string>
#include<algorithm>
#define lp(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int dice[7];
	lp(i,6){
		cin>>dice[i];
	}
	string com;
	cin>>com;
	swap(dice[3],dice[4]);
	lp(i,com.size()){
		int a=dice[0],b=dice[1],c=dice[2],d=dice[3],e=dice[4],f=dice[5];
		//cout<<com[i]<<endl;
		if(com[i]=='S'){
			dice[0]=d;
			dice[1]=a;
			dice[2]=c;
			dice[3]=f;
			dice[4]=e;
			dice[5]=b;
		}
		
		else if(com[i]=='N'){
			dice[0]=b;
			dice[1]=f;
			dice[2]=c;
			dice[3]=a;
			dice[4]=e;
			dice[5]=d;
		}
		
		else if(com[i]=='E'){
			dice[0]=e;
			dice[1]=b;
			dice[2]=a;
			dice[3]=d;
			dice[4]=f;
			dice[5]=c;
		}
		
		else{
			dice[0]=c;
			dice[1]=b;
			dice[2]=f;
			dice[3]=d;
			dice[4]=a;
			dice[5]=e;
		}
	}
		cout<<dice[0]<<endl;
	return 0;
}


Measured memory_bytes: 3224
use proconio::*;

fn run() {
    input! {
        n: usize,
        a: [u64; n],
    }
    const MOD: u64 = 1_000_000_007;
    let sum = a.iter().sum::<u64>() % MOD;
    let sq = a.iter().map(|a| *a * *a % MOD).sum::<u64>() % MOD;
    let ans = (sum * sum % MOD - sq + MOD) * (MOD + 1) / 2 % MOD;
    println!("{}", ans);
}

fn main() {
    run();
}

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

int main() {
  int a,b,c;cin>>a>>b>>c;
  int ans = min(a+b,min(b+c,c+a));
  cout << ans << endl;
}


Measured memory_bytes: 256
def gcd(x, y): 
	while(y): 
   		x, y = y, x % y 
	return x 
a,b,c,d=map(int,input().split())
m=((c*d)//(gcd(c,d)))
di=b-a+1
c1=(b//c-(a-1)//c)
c2=(b//d-(a-1)//d)
c3=(b//m-(a-1)//m)
print(di-(c1+c2-c3))  

Measured memory_bytes: 3188
#include <bits/stdc++.h>
const int N=100005,M=20;
using namespace std;
int n,L,q,ar[N],nx[M][N];
int calc(int i){
    int l=i,r=n,ans=-1;
    while(l<=r){
        int m=(l+r)/2;
        if(ar[m]-ar[i]<=L){
            ans=m;
            l=m+1;
        }else{
            r=m-1;
        }
    }
    return ans;
}
int kth(int cur,int k){
    for(int i=M-1;i>=0;i--){
        if(k>=(1<<i)){
            k-=(1<<i);
            cur=nx[i][cur];
        }
    }
    return cur;
}
int main()
{ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>ar[i];
    cin>>L>>q;
    for(int i=1;i<=n;i++)nx[0][i]=calc(i);
    for(int i=1;i<M;i++){
        for(int j=1;j<=n;j++){
            nx[i][j]=nx[i-1][nx[i-1][j]];
        }
    }
    while(q--){
        int a,b;cin>>a>>b;
        if(a>=b)swap(a,b);
        int l=1,r=n,ans=-1;
        while(l<=r){
            int m=(l+r)/2;
            //cout<<a<<' '<<m<<' '<<kth(a,m)<<'\n';
            if(kth(a,m)>=b){
                ans=m;
                 r=m-1;
            }else{

                l=m+1;
            }
        }
        cout<<ans<<'\n';
    }
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;


int n;
ll a[maxn];
ll b[maxn];

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

    
    cin>>n;
    bool same = true;
			 
    for (int i=0; i<n; i++) {
	cin>>a[i]>>b[i];
	if (a[i]!=b[i]) same = false;	
    }

    if (same) out(0);

    // Player 1 can always stall out by keeping at least 1 a[i]>b[i], and decreasing everything else
    // Meanwhile, player 2 just needs to always be making moves such that b[i]>a[i] to stay productive.
    // Player 1 will pick the a[i]>b[i] such that b[i] is smallest to stall out for as long as possible.

    ll res = 0;
    for (int i=0; i<n; i++) {
	res += a[i];
    }

    ll bmin = 1e9;
    for (int i=0; i<n; i++) {
	if (a[i] > b[i]) {
	    bmin = min(bmin, b[i]);
	}
    }

    res -= bmin;

    cout<<res<<endl;    
    return 0;
}


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

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

fn main() {
    let n: usize = read();
    let m: usize = read();
    let l: usize = read();
    let mut a: Vec<Vec<u64>> = vec![vec![0; m]; n];
    let mut b: Vec<Vec<u64>> = vec![vec![0; l]; m];
    let mut c: Vec<Vec<u64>> = vec![vec![0; l]; n];
    for n_index in 0..n {
        for m_index in 0..m {
            a[n_index][m_index] = read();
        }
    }
    for m_index in 0..m {
        for l_index in 0..l {
            b[m_index][l_index] = read();
        }
    }
    for n_index in 0..n {
        for l_index in 0..l {
            for m_index in 0..m {
                c[n_index][l_index] += a[n_index][m_index] * b[m_index][l_index]
            }
            if l_index != (l - 1) {
                print!("{} ", c[n_index][l_index])
            } else {
                println!("{}", c[n_index][l_index])
            }
        }
    }
}



Measured memory_bytes: 5052
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

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

    bool flag = true;
    vector<ll> num(n+1);
    int maxDepth = 0;
    for(int i=0; i<n; i++){
        int d;
        cin >> d;
        if((i==0 && d!=0)||(i>0 && d==0)){
            flag = false;
            break;
        }
        num[d]++;
        maxDepth = max(maxDepth, d);
    }

    for(int i=1; i<=maxDepth; i++){
        if(num[i]==0){
            flag = false;
            break;
        }
    }

    if(flag){
        ll ans=1;
        for(int i=1; i<n+1; i++){
            for(int j=0;j<num[i];j++){
                ans = ans * num[i-1] % 998244353;
            }

        }
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

long long mod = 1000000007;
long long A[1009];

void init() {
	A[0] = 1;
	for (int i = 1; i <= 1000; i++) {
		A[i] = 1LL * (2LL * i - 1LL) * A[i - 1] % mod;
	}
}

long long N, K;
long long X[309], Y[309];
long long dp[609][609], dpg[609][609];
bool used[609][609], forced[609];

void solve(int cl, int cr) {
	// DP の最初の値
	int el = cl, er = cr;
	int cnt = 0;
	for (int i = el; i <= er; i++) {
		if (forced[i % (2 * N)] == false) cnt++;
	}
	dp[cl][cr] = A[cnt / 2];

	// DPG の計算
	for (int i = el + 1; i <= er - 1; i += 2) {
		long long c1 = dpg[cl][i % (2 * N)];
		long long c2 = dp[(i + 1) % (2 * N)][cr];
		dpg[cl][cr] += c1 * c2;
		dpg[cl][cr] %= mod;
	}
	dp[cl][cr] = (dp[cl][cr] - dpg[cl][cr] + mod) % mod;
	dpg[cl][cr] += dp[cl][cr];
	dpg[cl][cr] %= mod;
}

int main() {
	cin >> N >> K; init();
	for (int i = 1; i <= K; i++) {
		cin >> X[i] >> Y[i];
		X[i]--; forced[X[i]] = true;
		Y[i]--; forced[Y[i]] = true;
	}

	for (int i = 0; i < 2 * N; i++) {
		for (int j = i; j < 2 * N; j++) {
			if ((j - i + 1 + 2 * N) % 2 == 1) continue;

			for (int k = 1; k <= K; k++) {
				int a1 = X[k] * 2, a2 = Y[k] * 2;
				int b1 = (i * 2 + 4 * N - 1) % (4 * N), b2 = (j * 2 + 1) % (4 * N);
				pair<int, int> V[4];
				V[0] = make_pair(a1, 0);
				V[1] = make_pair(a2, 0);
				V[2] = make_pair(b1, 1);
				V[3] = make_pair(b2, 1);
				sort(V, V + 4);
				bool flag = true;
				for (int l = 0; l < 3; l++) {
					if (V[l].second == V[l + 1].second) flag = false;
				}
				if (flag == true) used[i][j] = true;
			}
		}
	}

	for (int len = 2; len <= 2 * N; len += 2) {
		for (int i = 0; i < 2 * N; i++) {
			if (i + len - 1 >= 2 * N) continue;
			int a = i, b = i + len - 1;
			if (used[a][b] == false) solve(a, b);
		}
	}

	long long FinalAns = 0;
	for (int i = 0; i < 2 * N; i++) {
		int cnt = 2 * (N - K);
		for (int j = i; j < 2 * N; j++) {
			if (forced[j % (2 * N)] == false) cnt--;
			if (dp[i][j % (2 * N)] == 0) continue;
			FinalAns += dp[i][j % (2 * N)] * A[cnt / 2];
			FinalAns %= mod;
		}
	}

	cout << FinalAns << endl;
	return 0;
}

Measured memory_bytes: 6400
#include <iostream>

using namespace std;

int main()
{
    unsigned long long N;
    cin >> N;
    
    unsigned long long tmp;
    unsigned long long minimum_transition = 1000000000000001;
    for(int ii = 0; ii < 5; ++ii){
        cin >> tmp;
        if( minimum_transition > tmp ){
            minimum_transition = tmp;
        }
    }
    
    unsigned long long min = 4;
    
    min += (N-1) / minimum_transition + 1;
    
    cout << min << endl;
    
    return 0;
}


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

int main(){
  string S;
  cin>>S;
  int N=S.size();
  set<char> s;
  for(int i=0;i<N;i++){
    char c=S.at(i);
    s.insert(c);
  }
  bool flag=true;
  for(int i=0;i<26;i++){
    char c=(char)(i+'a');
    if(s.count(c)!=1){
      cout<<S<<c<<endl;
      flag=false;
      break;
    }
  }

  if(flag){
    int i=N-2;
    vector<char> s;
    s.push_back(S.at(N-1));
    while(S.at(i)>S.at(i+1)){
      s.push_back(S.at(i));
      i--;
      if(i<0){
        break;
      }
    }
    if(i<0){
      cout<<-1<<endl;
    }else{
      sort(s.begin(),s.end());
      int k=upper_bound(s.begin(),s.end(),S.at(i))-s.begin();
      S.at(i)=s.at(k);
      for(int j=0;j<=i;j++){
        cout<<S.at(j);
      }
      cout<<endl;
    }
  }
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        for(int i = 1; i <= x; i++){
            int max = i * (i + 1) / 2;
            if(x <= max){
                System.out.println(i);
                return;
            }
        }
        System.out.println(1);
    }
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lwb lower_bound
#define N 100010
#define M 200010
#define endl "\n"

ll gcd(ll a_,ll b_){if(b_>a_)swap(b_,a_);return (b_==0?a_:gcd(b_,a_%b_));}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, arr[110];
	
	cin >> n;
	REP(i, n) cin >> arr[i];
	
	int sum = 0, mn = INT_MAX, mx = INT_MIN;
	REP(i, n){
	    sum += arr[i];
	
		mn = min(mn, arr[i]);
		mx = max(mx, arr[i]);
	}
	ll c = ceil((double) sum / n);
	
	ll ans = LLONG_MAX;
	for(int i = mn; i <= mx; i++){
		ll s = 0;
		
		REP(j, n){
			s += (arr[j] - i) * (arr[j] - i);
		}
		
		ans = min(ans, s);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}



	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long a[] = new long[n];
		for(int i=0; i<n; i++) {
			a[i]=sc.nextLong();
		}
		long ans = a[0];
		for(int i=1; i<n; i++) {
			ans = lcm(ans, a[i]);
		}
		System.out.println(ans);
		sc.close();
	}

	private long gcd(long a, long b) {
		if(b==0) {
			return a;
		}
		long ans = gcd(b, a%b);
		return ans;
	}

	private long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

}


Measured memory_bytes: 23508
import java.util.*;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve(N, a) ? YES : NO);
    }

    private static boolean solve(int N, int[] a) {
        if (allZero(a)) return true;
        if (N%3 != 0) return false;

        Arrays.sort(a);
        List<Pair> set = new ArrayList<>();
        int last = a[0];
        int count = 1;
        for (int i=1; i<N; i++) {
            if (a[i] == last) {
                count++;
            } else {
                set.add(new Pair(last, count));
                last = a[i];
                count = 1;
            }
        }
        set.add(new Pair(last, count));

        if (set.size() == 3) {
            if ((set.get(0).x ^ set.get(1).x ^ set.get(2).x) == 0) {
                if (set.get(0).y == N/3 && set.get(1).y == N/3 && set.get(2).y == N/3) {
                    return true;
                }
            }
        } else if (set.size() == 2) {
            if (set.get(0).x == 0 && set.get(0).y == N/3) {
                return true;
            }
        }

        return false;
    }

    private static boolean allZero(int[] a) {
        for (int i=0; i<a.length; i++) {
            if (a[i] != 0) return false;
        }

        return true;
    }

    public static class Pair {
        public int x;
        public int y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}


Measured memory_bytes: 49736
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=4e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int n,m,x;
    cin>>n>>m>>x;
    int cnt0=0,cntn=0;
    loop(m,i,0){
        int y;
        cin>>y;
        if(y>x)
            cntn++;
        else
            cnt0++;
    }
    cout<<min(cnt0,cntn)<<Endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int A= stdIn.nextInt();
		int B= stdIn.nextInt();
		int C= stdIn.nextInt();
		int K= stdIn.nextInt();
		int counter = 0;

		if(A>=K) {
			counter += K;
		}else if(K>A) {
			counter += A;
			K -= A;
			if(K>B) {
				K -= B;
				if(K>0) {
					counter -= K;
				}
			}
		}
		System.out.println(counter);

		stdIn.close();
	}

}


Measured memory_bytes: 35560
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if((a + b == c)|| (a + c == b) || (b + c == a)) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
n = int(input())
i = 1
a = ''
while i <= n:
    x = i
    if x % 3 == 0:
        a += ' ' + str(i)
    elif x % 10 == 3:
        a += ' ' + str(i)
    else:
        x /= 10
        x = int(x)
        while x:
            if x % 10 == 3:
                a += ' ' + str(i)
                break
            x /= 10
            x = int(x)
    i += 1
print(a)


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b,c;
  	ci(a>>b>>c);
  ll ans=a+b+c;
  co(ans-max({a,b,c}))
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char **argv) {
  unsigned long long S = 0;
  unsigned long long ans = 0;
  cin >> S;
  unsigned long long tmp = S;
  int tmp2 = 1;
  while(tmp/=10){
    tmp2 <<= 1;
  }
  for (int i = 0; i < tmp2; i++) {
    int j = i;
    unsigned long long S2 = S;
    int divider = 10;
    while(j){
      if(j%2){
        ans += S2%divider;
        S2 /= divider;
        divider = 10;
      }else{
        divider *= 10;
      }
      j/=2;
    }
    ans += S2;
  }
  cout << ans;
  return 0;
}

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

int main(void){
  while(1){
    int all;
    cin >> all;
    if(all == -1) break;
    else{
      if(all < 10){
        all =0;
      }
      if(all >=10 && all < 20){
        all -= 10;
        all *= 125;
      }else if(all >= 20 && all < 30){
        all -= 20;
        all *= 140;
        all +=1250; 
      }else if(all >=30 && all <= 100){
        all -=30;
        all *= 160;
        all += 1250 + 1400;
      }
      all += 1150;
      cout << 4280 - all << endl;
    }
  }
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

using ll    = long long;
using vll   = vector<ll>;
using pll   = pair<ll,ll>;
using ld    = long double;

const ll mod = (ll)1e9 + 7;
const ll mxN = (ll)1e6 + 3;



void solve() {
	string s,t;cin>>s>>t;
	ll ans=0;
	for(int i=0;i<s.length();i++)
		ans+=(s[i]!=t[i]);
	cout<<ans<<"\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	pre();
//	ll t;cin>>t;while (t--)
		solve();
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int X;
    cin>>X;
    int n=360;
    while(true){
        if(n%X==0){
            cout << n/X << endl;
            return 0;
        }
        n+=360;
    }

    



}


Measured memory_bytes: 3648
from collections import deque

N = int(input())
hhh = list(map(int, input().split()))

# Initial settings
stack = deque()
stack.append(hhh)
n_operation = 0


def operation():
    global stack, n_operation

    flower_heights = stack.pop()
    args_zero_height = [i for i, v in enumerate(flower_heights) if v == 0]
    
    if args_zero_height == []:  # If there is no zero elem.
        flower_heights_minus1 = list(map(lambda x: x-1, flower_heights))
        n_operation += 1
        stack.append(flower_heights_minus1)
    else:  # If there are zero elems
        last_arg_zero = -1
        for i, arg in enumerate(args_zero_height):
            if i == 0:
                # Rightside
                non_zero_heights = flower_heights[:arg]
            else:
                # Middle
                non_zero_heights = flower_heights[last_arg_zero+1:arg]

            if non_zero_heights != []:
                non_zero_heights_minus1 = \
                    list(map(lambda x: x-1, non_zero_heights))
                n_operation += 1
                stack.append(non_zero_heights_minus1)
            last_arg_zero = arg
        # Add leftside
        if last_arg_zero < len(flower_heights)-1:
            non_zero_heights = flower_heights[last_arg_zero+1:]
            # The fucking code (DRY)
            non_zero_heights_minus1 = \
                list(map(lambda x: x-1, non_zero_heights))
            n_operation += 1
            stack.append(non_zero_heights_minus1)


# Do operations while stack is not empty
while stack:
    operation()

print(n_operation)


Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int count=0;
  if(s.at(0) == '1') count++;
  if(s.at(1) == '1') count++;
  if(s.at(2) == '1') count++;
  cout << count << endl;
}

Measured memory_bytes: 256