akhauriyash/Code-Regression huggingface dataset:
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_H = 20;
const int MAX_W = 20;
const int MAX_N = 15;
const int MAX_T = 200;

const int INF = 1 << 30;

const int dxs[] = {0, 1, 0, -1, 0}, dys[] = {0, 0, -1, 0, 1};
const int dds[] = {0, 1, 1, 1, 1};

/* typedef */

struct Stat {
  int d, t, i, x, y;
  Stat() {}
  Stat(int _d, int _t, int _i, int _x, int _y):
    d(_d), t(_t), i(_i), x(_x), y(_y) {}
  bool operator<(const Stat &s) const { return d > s.d; }
};

/* global variables */

string flds[MAX_N + 1][MAX_H];
int tis[MAX_N + 1];
int dists0[MAX_T][MAX_H][MAX_W], dists1[MAX_H][MAX_W];

/* subroutines */

/* main */

int main() {
  int h, w;
  cin >> h >> w;

  int sx, sy, gx, gy;
  
  for (int y = 0; y < h; y++) {
    cin >> flds[0][y];
    for (int x = 0; x < w; x++)
      switch (flds[0][y][x]) {
      case 'S': flds[0][y][x] = '.'; sx = x; sy = y; break;
      case 'G': flds[0][y][x] = '.'; gx = x; gy = y; break;
      }
  }

  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> tis[i - 1];
    for (int y = 0; y < h; y++) cin >> flds[i][y];
  }
  tis[n] = INF;

  for (int t = 0; t < tis[n - 1]; t++)
    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++) dists0[t][y][x] = INF;
  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++) dists1[y][x] = INF;
  dists0[0][sy][sx] = 0;
  
  priority_queue<Stat> q;
  q.push(Stat(0, 0, 0, sx, sy));
  int gd = -1;

  while (! q.empty()) {
    Stat u = q.top(); q.pop();

    if (u.x == gx && u.y == gy) {
      gd = u.d;
      break;
    }

    int vt = u.t + 1;
    int vi = (vt >= tis[u.i]) ? u.i + 1 : u.i;
    
    for (int di = 0; di < 5; di++) {
      int vx = u.x + dxs[di], vy = u.y + dys[di];
      int vd = u.d + dds[di];
      if (vx >= 0 && vx < w && vy >= 0 && vy < h && flds[vi][vy][vx] == '.') {
	if (vi < n) {
	  if (dists0[vt][vy][vx] > vd) {
	    dists0[vt][vy][vx] = vd;
	    q.push(Stat(vd, vt, vi, vx, vy));
	  }
	}
	else {
	  if (dists1[vy][vx] > vd) {
	    dists1[vy][vx] = vd;
	    q.push(Stat(vd, vt, vi, vx, vy));
	  }
	}
      }
    }
  }

  printf("%d\n", gd);
  return 0;
}


Measured memory_bytes: 1600
using System;

class Plogram
{
    static void Main()
    {
        var array = Console.ReadLine().Split();
        int r = int.Parse(array[0]);
        int D = int.Parse(array[1]);
        int x = int.Parse(array[2]);

        for (int i = 0; i < 10; i++)
        {
            x = r * x - D;
            Console.WriteLine(x);
        }
    }
}

Measured memory_bytes: 11092
n = int(input())

u = [input() for _ in range(n)]

m = int(input())

t = [input() for _ in range(m)]

state = 'Closed'

for k in t:
    if k in u:
        if state == 'Closed':
            print('Opened by', k)
            state = 'Opened'
        else:
            print('Closed by', k)
            state = 'Closed'
    else:
        print('Unknown', k)

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

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);
	for (ll i = 0; i < n; ++i)cin >> a[i];
	for (ll i = 0; i < m; ++i)cin >> b[i];
	for (ll i = 1; i < n; ++i)a[i] += a[i - 1];
	for (ll i = 1; i < m; ++i)b[i] += b[i - 1];
	ll ans = distance(b.begin(), upper_bound(b.begin(), b.end(), k));
	for (ll i = 0; i < n; ++i) {
		if (k - a[i] < 0)continue;
		ll bi = distance(b.begin(), upper_bound(b.begin(), b.end(), k - a[i]));
		ans = max(ans, i + bi + 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 6376
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int a,b,c,d,k,x;
	cin >> a >> b >> c;
	cin >> k;
	if(a<=b && c<=b){
		d=b;
		x=a+c;
	}
	else if(b<=a, c<=a){
		d=a;
		x=b+c;
	}
	else{
		d=c;
		x=a+b;
	}

	int i;
	for(i=0;i<k;i++)
		d=d*2;

	d=d+x;

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

    return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print((N - 2) * (M - 2))


#A = [[0] * W for i in range(H)]
#C = ["o" * W for i in range(H)] 
#C = ["#"*(W+2)] + ["#"+C[i]+"#" for i in range(H)] + ["#"*(W+2)]
#dx = [1, 1, 0, -1, -1, -1, 0, 1]
#dy = [0, 1, 1, 1, 0, -1, -1, -1]
#
#for h in range(H):
#    for w in range(W):
#        for i in range(8):
#            if C[h+1+dx[i]][w+1+dy[i]] == "o":
#                A[h][w] += 1
#ans = 0
#for h in range(H):
#    for w in range(W):
#        if A[h][w] % 2 == 0:
#            ans += 1
#
#print(ans)


Measured memory_bytes: 5144
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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


  string s;
  cin >> s;

  int p = 0, g = 0;
  REP(i, s.size()) {
    if (s[i] == 'p') {
      p++;
    } else {
      g++;
    }
  }
  cout << (g - p) / 2 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    long long int n, ans=0;
    cin >> n;
    ans = 0;
    for (int i=1; i<=n; i++){
        long long int num = n/i;
        ans += (num+1)*i*num/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  D(s[0][0] << s[1][0] << s[2][0]);
  return 0;
}



Measured memory_bytes: 256
s=list(input())
n=len(s)

ans=0
for i in range(2**(n-1)):
    f=[]
    s_=0
    for j in range(n-1):
        if (i>>j) & 1:
            t=s[s_:j+1]
            if len(t)!=0:
                f.append("".join(t))

            s_=j+1

    t=s[s_:]
    if len(t)!=0:
        f.append("".join(t))

    ans+=eval("+".join(f))

print(ans)


Measured memory_bytes: 39280
// abc160_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll K, N;
    cin >> K >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<ll> B(N);

    B[0] = A[0] + K - A[N-1];
    REPN(i, 1, N){
        B[i] = A[i] - A[i-1];
    }

    ll mx = *max_element(ALL(B));

    ll ans = K - mx;
    print(ans);


    return 0;
}


Measured memory_bytes: 3456
from collections import Counter

n = int(input())
list = list(map(int,input().split()))

list_o = list[::2]
list_e = list[1::2]

cnt_o = Counter(list_o).most_common(2)
cnt_e = Counter(list_e).most_common(2)

#最頻値が同じ
if cnt_o[0][0] == cnt_e[0][0]:
    #値が1つ
    if len(cnt_o) == 1 and len(cnt_e) ==1:
        print(int(len(list) / 2))
    elif len(cnt_o) == 1 and len(cnt_e) != 1:
        print(len(list) - cnt_o[0][1] - cnt_e[1][1])
    elif len(cnt_o) != 1 and len(cnt_e) == 1:
        print(len(list) - cnt_o[0][1] - cnt_e[1][1])
    else:
        print(min(len(list) - cnt_o[1][1] - cnt_e[0][1], len(list) - cnt_o[0][1] - cnt_e[1][1]))
#最頻値が異なる
elif cnt_o[0][0] != cnt_e[0][0]:
    if len(cnt_o) == 1 and len(cnt_e) ==1:
        print(0)
    else:
        print(len(list) - cnt_o[0][1] - cnt_e[0][1])


Measured memory_bytes: 15972
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy


def odd(n): return n & 1


def even(n): return not odd(n)


def comb(n, m):
    r = 1
    m = min({n - m, m})
    for i in range(1, n+1):
        r *= i
    for i in range(1, m+1):
        r //= i
    for i in range(1, n-m+1):
        r //= i
    return r


N, P = map(int, input().split())
A = [int(n) % 2 for n in input().split()]
cnt0 = len([a for a in A if a == 0])
cnt1 = len([a for a in A if a == 1])
ans = 0
if odd(P):
    for i in range(cnt1 + 1):
        if odd(i):
            ans += comb(cnt1, i)
else:
    for i in range(cnt1 + 1):
        if even(i):
            ans += comb(cnt1, i)
ans *= pow(2, cnt0)
print(ans)


Measured memory_bytes: 81612
def main():
    x,y  = map(int,input().split())
    if y-2*x<0:
        print('No')
    else:
        if (y-2*x)%2==1:
            print('No')
        else:
            b = (y-2*x)//2
            if x-b>=0:
                print('Yes')
            else:
                print('No')
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

struct edge{
  int a, b, color;
  edge(){}
  edge(int p, int q){
    a = p; b = q; color = -1;
  }
  edge(int p, int q, int r){
    a = p; b = q; color = r;
  }
};

int main(){
  int N;
  cin >> N;
  vector<edge> E(N-1);
  vvi G(N, vi(0));
  for(int i = 0; i < N-1; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    E.at(i) = edge(a, b);
    G.at(a).push_back(i);
    G.at(b).push_back(i);
  }
  int center = 0;
  for(int i = 0; i < N; i++){
    if(G.at(i).size() > G.at(center).size()) center = i;
  }
  int cnum = G.at(center).size();
  vector<bool> flag(N);
  queue<int> que;
  flag.at(center) = true;
  for(int i = 0; i < cnum; i++){
    E.at(G.at(center).at(i)).color = i+1;
    if(!flag.at(E.at(G.at(center).at(i)).a)) que.push(E.at(G.at(center).at(i)).a);
    if(!flag.at(E.at(G.at(center).at(i)).b)) que.push(E.at(G.at(center).at(i)).b);
  }
  
  while(!que.empty()){
    int next = que.front(); que.pop();
    flag.at(next) = true;
    set<int> used;
    for(int j = 0; j < G.at(next).size(); j++){
      if(E.at(G.at(next).at(j)).color != -1) used.insert(E.at(G.at(next).at(j)).color);
    }
    int c = 1;
    for(int j = 0; j < G.at(next).size(); j++){
      if(E.at(G.at(next).at(j)).color == -1){
        while(used.count(c)) c++;
        E.at(G.at(next).at(j)).color = c;
        used.insert(c);
        if(!flag.at(E.at(G.at(next).at(j)).a)) que.push(E.at(G.at(next).at(j)).a);
        if(!flag.at(E.at(G.at(next).at(j)).b)) que.push(E.at(G.at(next).at(j)).b);
      }
    }
  }
  cout << cnum << endl;
  for(int i = 0; i < N-1; i++){
    cout << E.at(i).color << endl;
  }
}


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

using namespace std;
using ll = long long;

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

	if (a >= 13) { cout << b << endl; }
	else if (a <= 5) { cout << 0 << endl; }
	else { cout << b / 2 << endl; }

	return 0;
}


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

int main(){
  int x,y,z;cin>>x>>y>>z;
  x -= z;
  cout << x/(y+z) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int arr1[10005];
int arr2[505];
int n,q,ans;

bool Linear_Serch(int x)
{
    for(int j=0;j<n;j++)
        {
            if(x==arr1[j])
                return true;
        }
    return false;
}
bool Binary_Serch(int x)
{
    int l=0,r=n-1,mid;

    while(l<r)
    {
        mid=l+r>>1;
        if(arr1[mid]<=x)r=mid;
        else l=mid+1;
    }
    /*
    while(l<r)
    {
        mid=1+r+1>>1;
        if(arr1[mid]>=x)l=mid;
        else r=mid-1;
    }
    */
    return x==arr1[l];
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>arr1[i];
    cin>>q;
    for(int i=0;i<q;i++)cin>>arr2[i];
    for(int i=0;i<q;i++)
    {
        if(Linear_Serch(arr2[i]))
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3156
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		int N = sc.nextInt();
		char[] input = sc.next().toCharArray();
		ArrayList<Integer> ws = new ArrayList<Integer>();
		ArrayList<Integer> rs = new ArrayList<Integer>();

		for(int i=0;i<N;i++) {
			if(input[i]=='W') {
				ws.add(i);
			}else {
				rs.add(i);
			}
		}
		int wInd = 0, rInd = rs.size() - 1;
		int count = 0;
		while(wInd<ws.size()&&rInd>=0&& ws.get(wInd)<rs.get(rInd)) {
			count++;
			wInd++;
			rInd--;
		}
		
		System.out.println(count);
		

	}

}

Measured memory_bytes: 47516
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N,K;
int P[5005];
int C[5005];
signed main(){
    scanf("%lld %lld",&N,&K);
    rep(i,N){
        scanf("%lld",&P[i]);P[i]--;
    }
    rep(i,N){
        scanf("%lld",&C[i]);
    }
    int ans=-INF;
    rep(start,N){
        int now=start;
        int cycle_point=0;
        int cycle_len=0;
        while(true){//一周を求める
            now=P[now];
            cycle_point+=C[now];
            cycle_len+=1;
            if(now==start)break;
        }
        int score=0;
        now=start;
        rep(move,cycle_len){//move回動いたあと周回するとどうなるか
            if(move>=K)break;
            now=P[now];
            score+=C[now];
            int sans=score;
            if(cycle_point>0){//周回する
                int laps=(int)(K-move-1)/cycle_len;
                sans+=laps*cycle_point;
            }
            ans=max(sans,ans);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int c[1000006];
vector<int> V;
set<int> S;
multiset<int> T;

int N, A[200005];

int dp[200005];

int num[1000006];

int main(void) {
	cin >> N;
	int Am = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		V.push_back(A[i]);
		S.insert(A[i]);
		T.insert(A[i]);
		Am = max(Am, A[i]);
		num[A[i]]++;
	}

	//sort(V.begin(), V.end());

	

	for(auto y: V){
		if (c[y] >= 1) { c[y] = 2; }
		else if (c[y] >= 0) { c[y]++;
		for (long long int j = y*2; j <= Am; j+=y) {
			c[(int) j] = -1;
		}
		}
	}

	for (int i = 1; i <= N;i++) {
		if (T.count(A[i]) >= 2) { continue; }
		else { int x = 1; }
	}

	int ans = 0;

	for (int i = 1; i <= N; i++) {
		//if (T.count(A[i]) >= 2) { continue; }
		if (c[A[i]] == 1) { ans++; }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 30380
import collections
N=int(input())
L=[input() for _ in range(N)]
K=collections.Counter(L).most_common()
bv, bk=K[0]
#print(bk)
ANS=[]
for v,k in K:
  if bk == k:
    ANS.append(v)
  else:
    break
S=sorted(ANS)
[print(s) for s in S] 

Measured memory_bytes: 45040
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		int[] abya=new int[4];
		int[] ope= {1,-1};
		String[] kig= {"+","-"};
		int sum=0;
		String ala="";

		for(int i=0; i<4; i++) {
			abya[i]=Integer.parseInt(a.charAt(i)+"");
		}
		for(int i=0; i<8; i++) {
			ala="";
			sum=0;
			sum+=abya[0];
			ala=ala+abya[0]+"";
			for(int j=1; j<4; j++) {
				sum+=ope[(i>>(j-1))%2]*abya[j];
				ala=ala+kig[(i>>(j-1))%2]+""+abya[j];
			}
			if(sum==7) {
				System.out.println(ala+"=7");
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 21844
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  string s,t;
  cin>>s>>t;
  
  int n,m;
  n=s.size(),m=t.size();
  int mi=1e9;
  for(int i=0;i+m<=n;i++){
    int cnt=0;
    for(int j=0;j<m;j++){
      if(t[j]!=s[j+i]) cnt++;
    }
    mi=min(mi,cnt);
  }
  cout<<mi<<endl;
  
  return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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; }

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

int main(int argc, char**argv){
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for (int i = 0; i < n; i++){
        cin >> h[i];
    }

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

    ll ans = 99999999999;
    for (int i = 0; i + k - 1 < n; i++){
        chmin(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;

    return 0;
}


















Measured memory_bytes: 1024
package main

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

func main() {
	N := nextInt()
	D := nextInt()
	xs := make([][]int, N)
	for i := 0; i < N; i++ {
		xs[i] = nextInts(D)
	}
	count := 0
	for i := 0; i < N-1; i++ {
		for j := i + 1; j < N; j++ {
			d := float64(0)
			for k := 0; k < D; k++ {
				d += math.Pow(float64(xs[i][k]-xs[j][k]), 2)
			}
			if math.Sqrt(d) == float64(int(math.Sqrt(d))) {
				count += 1
			}
		}
	}
	fmt.Printf("%d", count)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main()
{
	cin >> n >> m;
	vi v(n);
	REP(i, n) cin >> v[i];
	sort(RALL(v));
	REP(i, m)
	{
		sum += v[i];
	}
	cout << sum << endl;
}

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

int main(){
	int a,b,m,ma=1e9,mb=1e9;
	cin>>a>>b>>m;
	vector<int>aa(a),bb(b);
	for(int i=0;i<a;++i){
		cin>>aa.at(i);
		ma=min(aa.at(i),ma);
	}
	for(int i=0;i<b;++i){
		cin>>bb.at(i);
		mb=min(bb.at(i),mb);
	}
	int ans=ma+mb;
	for(int i=0,pa,pb,minus;i<m;++i){
		cin>>pa>>pb>>minus;
		ans=min(ans,aa.at(pa-1)+bb.at(pb-1)-minus);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 1024
s = input()
t = input()
ss = []

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i+j] not in ('?', t[j]):
            break
    else:
        S = s[:i] + t + s[i+len(t):]
        ss.append(S.replace('?', 'a'))

if ss:
    print(min(ss))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		sc.close();

		boolean bool = false;

		for (int i = 0; i <= N / 4; i++) {
			for (int j = 0; j <= N / 7; j++) {

				if (N == (4 * i + 7 * j)) {
					bool = true;
				}
			}
		}

		System.out.print(bool == true ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
N = int(input())
A = list(map(int, input().split()))

B = []
for i in range(N):
    if A[i] % 2 == 0:
        B.append(A[i])

count = 0
for i in range(len(B)):
    if B[i] % 3 == 0 or B[i] % 5 == 0:
        count += 1

if count == len(B):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

ll n, a, b;

ll modpow(ll base, ll exp) {
  base %= MOD;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % MOD;
    base = (base * base) % MOD;
    exp >>= 1;
  }
  return result;
}

int nChoose(int N, int K)
{
	ll res = 1;
	for(int i=0;i<K;++i){
		(res = res * (N-i))%=MOD;
	}
	for(int i=1;i<=K;++i){
		(res *= modpow(i, MOD-2))%=MOD;
	}
	return res;
}

void solve()
{
	ll res = modpow(2,n)-1 - nChoose(n,a) - nChoose(n,b);
	while(res < 0) res += MOD;
	cout << res << '\n';
}

int main()
{
	//ios::sync_with_stdio(false);
	cin >> n >> a >> b;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,a[10001],sum;
int main(void){
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n,greater<int>());
    for(int i=1;i<=k;i++) sum+=a[i];
    cout<<sum<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i,n,x,min=1000000,max=-1000000;
    long long ss=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x);
        if(min > x)min = x;
        if(max < x)max = x;
        ss += x;
    }
    printf("%d %d %lld\n",min,max,ss);
    return 0;
}


Measured memory_bytes: 2120
n = int(input())
c = []
s = []
f = []
for i in range(n-1):
    tmp = [int(v) for v in input().split()]
    c.append(tmp[0])
    s.append(tmp[1])
    f.append(tmp[2])

ans = []
for i in range(n-1):
    t = s[i] + c[i]
    j = i + 1
    while j <= n - 2:
        if t <= s[j]:
            t = s[j] + c[j]
        else:
            if t % f[j] == 0:
                t += c[j]
            else:
                t += f[j] - (t % f[j]) + c[j]
        j += 1
    ans.append(t)

ans.append(0)
for line in ans:
    print(line)

Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


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

		List<Integer> list =new ArrayList<Integer>();
		String[] strings;

		while(sc.hasNext()){
			strings = sc.nextLine().split(",");

			if(Double.parseDouble(strings[1]) / Math.pow(Double.parseDouble(strings[2]), 2) >= 25){
				list.add(Integer.parseInt(strings[0]));
			}
		}

		for (int value : list) {
			System.out.println(value);
		}
	}
}

Measured memory_bytes: 12000
n,y = map(int, input().split())

a = -1
b = -1
c = -1
for i in range(min(n, y//10000)+1):
  for j in range(min(n-i, (y-10000*i)//5000)+1):
    if ((n-i-j)*1000 == y-10000*i-5000*j):
      a = i
      b = j
      c = n-i-j

print(a, b, c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct Dice{
    int lab[6];
    int sumple[6];
    void in(){
        for(int i=0;i<6;i++){
            cin >> lab[i];
        }
    }
    void sumplein(){
        for(int i=0;i<6;i++){
            cin >> sumple[i];
        }
    }
    void roll(char a){
        if(a=='S'){
            int stock;
            stock=lab[0];
            lab[0]=lab[4];
            lab[4]=lab[5];
            lab[5]=lab[1];
            lab[1]=stock;
        }
        if(a=='N'){
            int stock;
            stock=lab[0];
            lab[0]=lab[1];
            lab[1]=lab[5];
            lab[5]=lab[4];
            lab[4]=stock;
        }
        if(a=='W'){
            int stock;
            stock=lab[0];
            lab[0]=lab[2];
            lab[2]=lab[5];
            lab[5]=lab[3];
            lab[3]=stock;
        }
        if(a=='E'){
            int stock;
            stock=lab[0];
            lab[0]=lab[3];
            lab[3]=lab[5];
            lab[5]=lab[2];
            lab[2]=stock;
        }
        if(a=='R'){
            roll('N');roll('E');roll('S');
        }
        if(a=='L'){
            roll('N');roll('W');roll('S');
        }
    }
    
    int top(){
        return lab[0];
    }
    void right(int a,int b){
        int i;
        for(i=0;i<6;i++){
            if(lab[i]==a){
                break;
            }
        }
            
        if(i==1){
            roll('N');
        }
        if(i==2){
            roll('W');
        }
        if(i==3){
            roll('E');
        }
        if(i==4){
            roll('S');
        }
        if(i==5){
            roll('N');roll('N');
        }
            
        for(int j=1;j<5;j++){
            roll('L');
            
            if(lab[1]==b){
                break;
            }
        }
        return;
    }
    bool judge(){
        for(int i=0;i<2;i++){
            for(int j=0;j<4;j++){
                for(int k=0;k<4;k++){
                    if(lab[0]==sumple[0]&&lab[1]==sumple[1]&&lab[2]==sumple[2]&&lab[3]==sumple[3]&&lab[4]==sumple[4]&&lab[5]==sumple[5]){
                        return true;
                    }
                    roll('W');
                }
                roll('N');
            }
            roll('L');
        }
        return false;
    }
};

int main() {
    Dice d;
    d.in();
    d.sumplein();
    if(d.judge()){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  int last_r = 0;
  int next_l = 0;
  vector<int> ret(s.size());
  fill(ret.begin(), ret.end(), 0);
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'L') {
      if ((i - last_r) % 2 == 0)
        ++ret[last_r];
      else
        ++ret[last_r + 1];
    } else {
      if (i >= next_l && next_l < s.size() - 1) {
        next_l = i;
        do {
          ++next_l;
        } while (s[next_l] != 'L');
      }
      if ((next_l - i) % 2 == 0)
        ++ret[next_l];
      else
        ++ret[next_l - 1];
      last_r = i;
    }
  }

  for (int i = 0; i < ret.size(); ++i) {
    if (i != 0)
      cout << " ";
    cout << ret[i];
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 1024
fn getline() -> String{
	let mut __ret=String::new();
	std::io::stdin().read_line(&mut __ret).ok();
	return __ret;
}

fn main(){
	let s=getline();
	let ary:Vec<_>=s.trim().split(' ').collect();
	let N:i64=ary[0].parse().unwrap();
	let K:i32=ary[1].parse().unwrap();
	
	let mut ans = K;

	for i in 1..N{
		ans = ans * (K-1);
	}

	println!("{}",ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> N >> M >> K;
	for (i = 0; i <= N; i++) {
		for (j = 0; j <= M; j++) {
			if (N*j+M*i-j*2*i == K) {
				cout << "Yes";
				exit(0);
			}
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define SP <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> Graph;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換
int main(){

    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(k <= a)  ans = k;
    else{
        if(k <= a+b) ans = a;
        else ans = a-(k-a-b);
    }
    cout << ans << endl;

}


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

int N, H[5];

int main(){
	long long res = 0;
	cin >> N;
	for(int i = 0; i < N; i++){
		string s;
		cin >> s;
		if(s[0] == 'M') H[0]++;
		else if(s[0] == 'A') H[1]++;
		else if(s[0] == 'R') H[2]++;
		else if(s[0] == 'C') H[3]++;
		else if(s[0] == 'H') H[4]++;
	}
	for(int i = 0; i < 3; i++)
		for(int j = i + 1; j < 4; j++)
			for(int k = j + 1; k < 5; k++)
				res += (long long)H[i] * H[j] * H[k];
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  int N, M;
  int A[101];
  int ans = 0;
  long long int total = 0;
  scanf("%d %d", &N, &M);
  for(int i = 0; i < N; i++){
    scanf("%d", &A[i]);
    total += A[i];
  }
  double th = (double)total / (double)(4 * M);
  for(int i = 0; i < N; i++){
    if(A[i] >= th){
      ans += 1;
    }
  }

  if(ans >= M) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize, _l: usize,
        mut s: [chars; n]
    }

    s.sort();
    let mut ret = vec![];
    for v in s {
        ret.extend(v);
    }
    println!("{}", ret .iter().cloned().collect::<String>());
}

Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CGCDOnBlackboard {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long pre[] = new long[n + 2];
            long post[] = new long[n + 2];
            long a[] = new long[n + 2];
            for (int i = 1; i <= n; i++) a[i] = in.nextInt();
            for (int i = 1; i <= n; i++) pre[i] = Maths.gcd(a[i], pre[i - 1]);
            for (int i = n; i >= 1; i--) post[i] = Maths.gcd(a[i], post[i + 1]);
            long ans = 0;
            for (int i = 1; i <= n; i++) {
                ans = Math.max(ans, Maths.gcd(post[i + 1], pre[i - 1]));
            }
            out.println(ans);
        }

    }

    static class Maths {
        static long gcd(long a, long b) {
            if (a == 0) {
                return b;
            }
            if (b == 0) {
                return a;
            }

            long r, i;
            while (b != 0) {
                r = a % b;
                a = b;
                b = r;
            }
            return a;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST_CASE int tc;cin>>tc;while(tc--)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define JD



int main(int argv, char* argc[])
{
    FASTIO

    #ifndef JD
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif


    int n;
    cin>>n;
    vii v(n);
    int xr=0;
    rep(i,n) {cin>>v[i];xr^=v[i];}
    rep(i,n)
    {
        int g = xr^v[i];
        cout<<g<<" ";
    }


    return 0;
}


Measured memory_bytes: 3972
A = tuple([tuple(map(int,input().split())) for i in range(3)])
N = int(input())
B = tuple([int(input()) for i in range(N)])
BINGO = [[False]*3 for i in range(3)]
for b in B:
    for y, line in enumerate(A):
        for x, a in enumerate(line):
            if a == b:
                BINGO[y][x] = True
def solve():
    for line in BINGO:
        if line == [True, True, True]:
            return "Yes"
    if BINGO[0][0] == True and BINGO[1][0] == True and BINGO[2][0] == True:
        return "Yes"
    if BINGO[0][1] == True and BINGO[1][1] == True and BINGO[2][1] == True:
        return "Yes"
    if BINGO[0][2] == True and BINGO[1][2] == True and BINGO[2][2] == True:
        return "Yes"
    if BINGO[0][0] == True and BINGO[1][1] == True and BINGO[2][2] == True:
        return "Yes"
    if BINGO[0][2] == True and BINGO[1][1] == True and BINGO[2][0] == True:
        return "Yes"
    return 'No'        
print(solve())


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n-1){
    ans+=a[i]/2;
    a[i]%=2;
    if(a[i]==1&&a[i+1]>0){
      ans++;
      a[i+1]--;
    }
  }
  ans+=a[n-1]/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
from itertools import permutations

N,M = map(int,input().split())
Alist = [list(map(int,input().split())) for i in range(M)]

graph = [[False]*(N+1) for i in range(N+1)]

for i ,j in Alist:
  graph[i][j] = True
  graph[j][i] = True

route = permutations(range(1,N+1))

count = 0
for i in route:
  flag = True
  if i[0] !=1:
    continue
  for j in range(N-1):
    if graph[i[j]][i[j+1]] == False:
      flag = False
      break
  
  if flag == True:
    count += 1

print(count)

Measured memory_bytes: 9216
//a
const solve = (inputs) => {
  const input = inputs.split("\n");
  const nums = input[0].split(' ').map((e)=>parseInt(e));
  console.log('%d', Math.min(nums[2],Math.floor(nums[1]/nums[0])));
}

solve(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include<iostream>
#include<algorithm>

using namespace std;
int main(){
  int A[5],B[5],minB=9;
  for(int i=0 ; i<5;i++){
  cin >> A[i] ;
  B[i]=A[i]%10;//10で割った余り
  if(B[i]<=minB && B[i]>0)
  minB=B[i];
  //A[i]+=10-(A[i]%10);
  }
  int mark;
for(int i=0 ; i<5;i++){
if(B[i]==minB)
mark=i;
}
int sumtime=0;
for(int l=0;l<5;l++){
    if(l==mark);
    else if(B[l]!=0)
    {
        A[l]+=10-B[l];
    }
    sumtime+=A[l];
    

}
 
  
  cout << sumtime<<endl;

  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,D,A;
P X[200001];
queue<P> range;
ll ans;
ll m;
ll K;



int main(){
    cin >> N>>D>>A;
    for(int i=0;i<N;i++){
        int a,b;
        cin >> a >> b;
        X[i] = P(a,b);
    }
    sort(X,X+N);
    
    for(int i=0;i<N;i++){
        while(range.size()!=0&& range.front().first<X[i].first){
            m -= range.front().second;
            range.pop();
        }
        if( X[i].second<m){
            X[i].second = 0;
        } else {
            X[i].second -= m;
        }
        K = (X[i].second+A-1)/A;
        range.push(P(X[i].first+2*D,K*A));
        m += K*A;
        ans += K;
    }
    cout << ans << endl;
    
}




Measured memory_bytes: 6656
# coding: utf-8
N, A, B = map(int, input().split(" "))

sum = 0
for i in range(N + 1):
    cnt = 0
    for num in str(i):
        cnt = cnt + int(num)
    #print(str(i) + ": " + str(cnt))
    if cnt >= A and cnt <= B:
        #print("Add " + str(i))
        sum = sum + int(i)
        
print(sum)




Measured memory_bytes: 3060