akhauriyash/Code-Regression huggingface dataset:
import collections
from collections import deque

n=int(input())
a=deque(map(int, input().split()))  
dp=[[0]*(n+1) for i in range(n+1)]

x=0
y=0

for i in range(n-1,-1,-1):
    for j in range(i+1,n+1):
        if (n-(j-i))%2==0:
            dp[i][j]=max(dp[i][j-1]+a[j-1],dp[i+1][j]+a[i])
        else:
            dp[i][j]=min(dp[i][j-1]-a[j-1],dp[i+1][j]-a[i])


print(dp[0][n])


Measured memory_bytes: 112348
# bcd acd abd abc
# a^a = 0
# bcd ^ acd ^ abd ^ abc = a^b^c^d = total
# bcd ^ total = a^(b^b)^(c^c)^(d^d) = a

N = int(input())
xor_num = [int(x) for x in input().split()]
total = 0

for n in xor_num:
  total = total ^ n
for i in range(N):
  print(xor_num[i] ^ total, end=' ')

Measured memory_bytes: 31496
using System;
using System.Collections.Generic;

namespace ABC086
{
    public class Problem_C
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var routes = new List<int[]>();
            routes.Add(new int[] { 0, 0, 0 });
            for (var i = 0; i < n; i++)
            {
                routes.Add(Array.ConvertAll(Console.ReadLine().Split(), int.Parse));
            }

            for (var i = 0; i < routes.Count - 1; i++)
            {
                var tDiff = routes[i + 1][0] - routes[i][0];
                var dDiff = Math.Abs(routes[i][1] - routes[i + 1][1])
                                + Math.Abs(routes[i][2] - routes[i + 1][2]);
                if (dDiff > tDiff || !(tDiff % 2 == 0 && dDiff % 2 == 0)
                    && !(tDiff % 2 == 1 && dDiff % 2 == 1))
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 21576
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  vector<set<char>> vec(2);
  vec[0].insert('L');
  vec[0].insert('U');
  vec[0].insert('D');
  vec[1].insert('R');
  vec[1].insert('U');
  vec[1].insert('D');
  string s;
  cin >> s;
  for(int i = 0;i < s.size();i++) {
    if(!vec[(i + 1) % 2].count(s[i])){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

int n,m,k,s,p[11],ans=0;
vector<set<int>> bulb;
vector<bool> states;
map<vector<bool>,int> visited;
void switches(vector<bool> sts, int ptr, int cnt){
	if(ptr<=n){
		int c=0;
		if(visited[sts]<=0){
			// for(int i=0;i<sts.size();i++){
			// 	cout<<sts[i]<<' ';
			// }
			// cout<<": ";
			for(int i=0;i<m;i++){
				c=0;
				for(auto it=bulb[i].begin();it!=bulb[i].end();++it){
					if(sts[*it])
						c++;
				}
				if(p[i]%2==0){
					if(c%2==0)
						cnt++;
				}
				else{
					if(c%2!=0)
						cnt++;
				}
			}
			// cout<<cnt<<endl;
			if(cnt==m)
				ans++;
			visited[sts]++;
		}
		// for(int i=ptr;i<n;i++){
			sts[ptr]=!sts[ptr];
			switches(sts,ptr+1,0);
			sts[ptr]=!sts[ptr];
			switches(sts,ptr+1,0);
		// }
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>k;
		set<int> tem;
		for(int j=0;j<k;j++){
			cin>>s;
			tem.insert(s-1);
		}
		bulb.push_back(tem);
	}
	for(int i=0;i<m;i++){
		cin>>p[i];
	}
	for(int i=0;i<n;i++){
		states.push_back(true);
	}
	switches(states, 0, 0);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
# import sys

# sys.setrecursionlimit(2000)

tmp=input().split(" ")
n = int(tmp[0])
m = int(tmp[1])

node_groups = [ i for i in range(n)]
group_sizes = [ 1 for _ in range(n)]
group_ranks = [ 0 for _ in range(n)]

edges = []
for i in range(m):
    tmp=input().split(" ")
    edges.append([int(tmp[0])-1, int(tmp[1])-1])

hubensa_list = [0] * (m + 1)
hubensa_list[m] = n*(n-1)//2

def root(i):
    if node_groups[i] == i:
        #print(i, "is root.")
        return i
    else:
        #_1 = node_groups[i]
        node_groups[i] = root(node_groups[i])
        #_2 = node_groups[i]
        #print ("root: ", _1, _2)
        return node_groups[i]

def same(a, b):
    return root(a) == root(b)

def size(i):
    return group_sizes[root(i)]

def unite(a, b):
    a = root(a)
    b = root(b)

    if a == b:
        return

    if group_ranks[a] < group_ranks[b]:
        group_sizes[b] += size(a)
        node_groups[a] = b
    else:
        group_sizes[a] += size(b)
        node_groups[b] = a
        if group_ranks[a] == group_ranks[b]:
            group_ranks[a] += 1


for i in range(m-1, -1, -1):
    edge = edges[i]
    # print("edge: ",edge)
    #print("node_groups: ", node_groups)
    node_1 = edge[0]
    node_2 = edge[1]

    root_1 = root(node_1)
    root_2 = root(node_2)
    if root_1 == root_2:
        hubensa_list[i] = hubensa_list[i+1]
        continue

    # 不便さをだす
    hubensa_list[i] = hubensa_list[i+1] - (size(root_1) * size(root_2))

    unite(root_1, root_2)

#print("node_groups: ", node_groups)


for i in range(1, m+1):
    print(hubensa_list[i])

Measured memory_bytes: 27204
#include <iostream>

typedef long long ll;
using namespace std;

ll dp[1001][1001];

ll solve(ll n, ll k, ll m) {
  dp[0][0] = 1;
  for(int i=1;i<=n;++i) {
    for(int j=1;j<=i;++j) {
      dp[i][j] = (dp[i-1][j-1] + dp[i-1][j]) % m;
    }
  }
  return dp[n][k];
}

int main() {
  ll n,k,mod=1e9+7;
  cin>>n>>k;
  cout<<solve(n,k,mod)<<endl;
  return 0;
}


Measured memory_bytes: 9972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> arr;
typedef vector<arr> matrix;
typedef vector<ll> longarr;
typedef vector<longarr> longmat;
typedef map<int, arr> graph;
typedef vector<char> chararr;
typedef vector<chararr> charmat;
typedef pair<int, int> fraction;
double dp[301][301][301];
double solve(int x, int y, int z, int n) {
	if (x < 0 || y < 0 || z < 0)
		return 0;
	if (x == 0 && y == 0 && z == 0)
		return 0;
	if (dp[x][y][z] > -0.9)
		return dp[x][y][z];
	double exp = n + x * solve(x - 1, y, z, n) + y * solve(x + 1, y - 1, z, n) + z * solve(x, y + 1, z - 1, n);
	return dp[x][y][z] = exp / (x + y + z);
}

int main() {

	int n;
	cin >> n;
	int one = 0;
	int two = 0;
	int three = 0;
	int x;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		if (x == 1) ++one;
		else if (x == 2) ++two;
		else ++three;
	}
	memset(dp, -1, sizeof(dp));
	cout << fixed << setprecision(10) << solve(one, two, three, n);
}

Measured memory_bytes: 216872
#include <iostream>

using namespace std;

int n, k, i, j, a[110];
bool dp[100010];

int main() {
    cin >> n >> k;
    for (i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (i = 1; i <= k; ++i) {
        for (j = 1; j <= n; ++j) {
            if (i - a[j] >= 0) {
                dp[i] |= !dp[i - a[j]];
            }
        }
    }
    if (dp[k]) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }
    return 0;
}


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

#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  int N,K;cin >> N >> K;
  vector<int> vec(N);
  rep(i,N) cin >> vec[i];
  ll ans = 0;
  for(int i=0;i<N;i++){
    int dis = min(abs(vec[i])*2,abs(vec[i]-K)*2);
    ans += dis;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    regex re("A[a-z]+C[a-z]+");

    string s;
    cin >> s;
    if(regex_match(s, re))
        cout << "AC" << endl;
    else
        cout << "WA" << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

ll N, M, Q, A, B, C, D, E, X, Y, Z, arr[100005];

string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> A >> B;
	if (A >= 13){
		cout << B << '\n';
	}
	else if (6 <= A && A <= 12){
		cout << B/2 << '\n';
	}
	else cout << 0 << '\n';
}

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

using namespace std;

#define int long long

signed main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N;
	cin >> N;
	int a[N];
	for (int i = 0; i < N; ++i) cin >> a[i];

    int start = N, cnt = 0;
    for (int i = N-1; i >= 0; --i) {
        int val = i - start;
        if (val == a[i]) continue;
        else if (val > a[i]) {
			cout << -1 << endl;
			return 0;
        } else {
            cnt += a[i];
            start = i - a[i];
            if (start < 0) {
				cout << -1 << endl;
				return 0;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int max=0;
  int a1[N],a2[N];
  int b[N]; 
  int c=0;
  int i;
  for (i=0;i<N;i++){
    cin >>a1[i];
    b[i]=0;
  }
  for (i=0;i<N;i++){
    cin >>a2[i];
    c+=a2[i];
  }
  b[0]=c+a1[0];
  max=b[0];
  for (i=1;i<N;i++){
    b[i]=b[i-1]+a1[i]-a2[i-1];
    if(b[i]>max){
      max=b[i];
    }
  }
  cout << max;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    string S;
    cin>>S;
    int N=S.size();
    bool ok=true;
    if(N%2){
        ok=false;
    }else{
        for(int i=0;i<N;i++){
            if(i%2){
                if(S[i]!='i'){ok=false;break;}
            }else{
                if(S[i]!='h'){ok=false;break;}
            }
        }
    }
    cout<<(ok?"Yes":"No")<<endl;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  int out=0;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  if(v[N-1]<K)out++;
  int lll=0;
  for(int i=2;i*i<=v[N-1]&&out==0;i++){
    lll=0;
    for(int k=2;k*k<=i&&lll==0;k++)if(i%k==0)lll++;
    if(lll==0){
      int pre=0;
      for(int j=0;j<N&&out==0;j++)pre+=v[j]%i;
      if(pre==0&&K%i!=0)out++;
    }
  }
  int i=v[0];
  int pre=0;
  for(int j=0;j<N;j++)pre+=v[j]%i;
  if(pre==0&&K%i!=0)out++;
  if(out)cout<<"IMPOSSIBLE"<<endl;
  else cout<<"POSSIBLE"<<endl;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
import itertools

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


h, w = MI()
Ch, Cw = MI()
Dh, Dw = MI()

S = [["#"] * (w + 4), ["#"] * (w + 4)]
for _ in range(h):
    S.append(["#", "#"] + list(ST()) + ["#", "#"])
S.append(["#"] * (w + 4))
S.append(["#"] * (w + 4))

dxy = ((0, 1), (0, -1), (1, 0), (-1, 0), (0, 0))
wxy = tuple(
    (x, y)
    for x, y in itertools.product([-2, -1, 0, 1, 2], repeat=2)
    if (x, y) not in dxy
)
dxy = ((0, 1), (0, -1), (1, 0), (-1, 0))

wq = {(Ch + 1, Cw + 1)}
cost = 0
while wq:
    q = wq
    passed = set()
    while q:
        qq = set()
        for y, x in q:
            if y == Dh + 1 and x == Dw + 1:
                print(cost)
                exit()
            passed.add((y, x))
            S[y][x] = "#"
            for dy, dx in dxy:
                ny, nx = y + dy, x + dx
                if S[ny][nx] == "#":
                    continue
                # if ny == Dh + 1 and nx == Dw + 1:
                #     print(cost)
                #     exit()
                qq.add((ny, nx))
                # S[ny][nx] = "#"
        q = qq

    # print(cost, set(passed))
    wq = set()
    for y, x in passed:
        for dy, dx in wxy:
            ny, nx = y + dy, x + dx
            if S[ny][nx] == "#":
                continue
            wq.add((ny, nx))

    cost += 1

print(-1)


Measured memory_bytes: 122232
#include<stdio.h>
#include<string.h>
int main(void)
{
	long long int n,m,flg,i,j,a[1001],b[1001],c[1001];
	long long int e[1001],p[1001],q[1001];
	while(1){
		scanf("%lld",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
			a[i]=0; b[i]=0; c[i]=0;
		}	
		for(i=0;i<n;i++){
			scanf("%lld %lld %lld",&e[i],&p[i],&q[i]);
			if(p[i]*q[i]>=1000000) a[i]=1;
			if(a[i]==0) b[i]=p[i]*q[i];
		}	
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(e[i]==e[j]){
					if(a[i]==0){
						b[i]+=b[j];
						b[j]=0;
					}
					if(b[i]>=1000000&&a[i]==0) a[i]=1;
				}
			}
		}
		flg=0;
		for(i=0;i<n;i++){
			if(a[i]!=0){
				printf("%lld\n",e[i]);
				flg=1;
			}
		}	
		if(flg==0) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 2716
#!/usr/bin/env python

def main():
    N, M, X = map(int, input().split())
    mat = [list(map(int, input().split())) for _ in range(N)]

    flag = False
    ans = 10 ** 18

    for i in range(1<<N):
        tmp = [0] * (M+1)
        mflag = True
        for j in range(N):
            if (i>>j)&1:
                tmp = [x+y for x, y in zip(tmp, mat[j])]
        for k in range(M):
            if tmp[1+k] < X:
                mflag = False
                break
        if mflag and tmp[0] < ans:
            ans = tmp[0]
            flag = True
    print(ans) if flag else print('-1')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
#define l long

int main(){
     ios::sync_with_stdio(0);
     cin.tie(0);
     
     string a,b,c;
     int x,y;
     
     cin >> a >> b;
     cin >> x >> y;
     cin >> c;
     
     
     if(c == a){x-=1;}
     if(c == b){y-=1;}
     
     cout << x <<" "<< y;
     
     
     
     
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
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;
using std::min;
using std::max;
//#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
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;


    ll N,K,L;
    ll ans;
    P A[200010];
    std::map<P,int> S;
struct UnionFind {
    vector< int > data;
    UnionFind(int sz){
        data.assign(sz, -1);
    }

    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return(false);
        if(data[x] > data[y]) std::swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }

    int find(int k){
        if(data[k] < 0) return(k);
        return(data[k] = find(data[k]));
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int k){
        return(-data[find(k)]);
    }
};
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N>>K>>L;
    UnionFind X(N+10),Y(N+10);
    REP(i,K){
        int a,b;
        cin>>a>>b;
        X.unite(a-1,b-1);
    }
    REP(i,L){
        int a,b;
        cin>>a>>b;
        Y.unite(a-1,b-1);
    }
    REP(i,N){
        A[i]={X.find(i),Y.find(i)};
        if(S.find(A[i])!=S.end())S[A[i]]++;
        else S.insert({A[i],1});
    }
    REP(i,N){
        cout<<S[A[i]];
      	if(i!=N-1)cout<<" ";
    }
    return 0;
}


Measured memory_bytes: 15104
#include <iostream>
using namespace std;
int main () {
	int n;
	string s,ans="Yes";
	cin>>n>>s;
	for (int i=0;i<n/2;i++) {
		if (s[i]!=s[i+n/2]) {
			ans="No";
			break;
		}
	}
	if (n%2!=0) ans="No";
	cout<<ans;
}

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

vector<int> res;
Graph G;
void dfs(int u,int prev,int color){
    res[u] = color;
    for(auto v : G[u]){
        if(v.first == prev)continue;
        if(v.second&1)dfs(v.first,u,1-color);
        else dfs(v.first,u,color); 
    }
}

int main(){
    int N;
    cin >> N;
    G.resize(N);
    res.resize(N,0);
    rep(i,N-1){
        int u,v,cost;
        cin >> u >> v >> cost;
        u--;v--;
        G[u].push_back(make_pair(v,cost));
        G[v].push_back(make_pair(u,cost));
    }
    dfs(0,-1,1);
    for(auto e : res){
        cout << e << endl;
    }
    return 0;
}

Measured memory_bytes: 8960
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,M = II()
A = III()

a = [0]*(N+1)
for i in range(1,N+1):
    a[i] = a[i-1]
    a[i] += A[i-1]
    a[i] %= M

d = defaultdict(list)
for i in range(N+1):
    d[a[i]].append(i)

ans = 0
for k in d.keys():
    if len(d[k]) >= 2:
        ans += len(d[k])*(len(d[k])-1)//2

print(ans)

Measured memory_bytes: 24464
import sys
input = sys.stdin.readline

n = int(input())
a = [int(a) for a in input().split()]
s = [None] * n; s[0] = a[0]
for i in range(n-1): s[i+1] = s[i] + a[i+1]

mixi = abs(s[0] - (s[n-1] - s[0]))
for i in range(1, n-1):    # 全部取るのはダメ
    x, y = s[i], s[n-1] - s[i]
    mixi = min(mixi, abs(x - y))

print(mixi)

Measured memory_bytes: 24680
s = input()
ans = (-1, -1)
if s[0] == s[1]:
    ans = (1, 2)
for i in range(len(s) - 2):
    if s[i] == s[i + 1] or s[i] == s[i + 2] or s[i + 1] == s[i + 2]:
        ans = (i + 1, i + 3)
print(ans[0], ans[1])

Measured memory_bytes: 39664
INF = 10**11
from bisect import bisect
import sys
readline = sys.stdin.readline

A, B, Q = map(int, readline().split())
s_array = [int(readline()) if i != 0 else -INF for i in range(A + 1)]
s_array.append(INF)
t_array = [int(readline()) if i != 0 else -INF for i in range(B + 1)]
t_array.append(INF)
q_array = [int(readline()) for i in range(Q)]

# print(s_array, t_array, q_array)

ans_array = []
for q in q_array:
    s_index = bisect(s_array, q) - 1
    t_index = bisect(t_array, q) - 1
    # print(s_index,t_index)
    method_a = q - min(s_array[s_index], t_array[t_index])
    method_b = max(s_array[s_index + 1], t_array[t_index + 1]) - q
    method_c = (q - s_array[s_index]) + (t_array[t_index + 1] - q) + min(
        (q - s_array[s_index]), (t_array[t_index + 1] - q))
    method_d = (q - t_array[t_index]) + (s_array[s_index + 1] - q) + min(
        (q - t_array[t_index]), (s_array[s_index + 1] - q))
    ans_array.append(str(min(method_a, method_b, method_c, method_d)) + "\n")

sys.stdout.writelines(ans_array)

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

int main(void){
  int n;
  int a,b;
  long s;
  while(cin>>a>>b>>n){
    s=0;
    a=a%b;
    for(int i=0;i<n;i++){
      a*=10;
      s+=a/b;
      a=a%b;
    }
    cout<<s<<endl;
  }
  return 0;
}



Measured memory_bytes: 3044
#include <cstdio>
#include <algorithm>

using namespace std;

char g[1111][1111];
char f[11][11];
bool ok[1111][1111];

bool ch(int i,int j) {
  return g[i][j] == f[0][0] && g[i][j+1] == f[0][1] &&
    g[i+1][j] == f[1][0] && g[i+1][j+1] == f[1][1];
}

int main(void)
{
  int h,w;
  scanf("%d%d",&h,&w);
  for( int i = 0; i < h; i++ ) {
    for( int j = 0; j < w; j++ ) {
      scanf(" %c",g[i]+j);
    }
  }
  for( int i = 0; i < 2; i++ ) {
    for( int j = 0; j < 2; j++ ) scanf(" %c",f[i]+j);
  }
  int res = 0,cnt = 0;
  for( int i = 0; i < h-1; i++ ) {
    for( int j = 0; j < w-1; j++ ) {
      if( ch(i,j) ) {
        ok[i][j] = true;
        ++cnt;
      }
    }
  }
  res = cnt;
  for( int i = 0; i < h; i++ ) {
    for( int j = 0; j < w; j++ ) {
      static const char* joi = "JOI";
      char t = g[i][j];
      for( int k = 0; k < 3; k++ ) {
        int c = cnt;
        g[i][j] = joi[k];
        for( int ii = max(0,i-1); ii <= min(i,h-1); ii++ ) {
          for( int jj = max(0,j-1); jj <= min(j,w-1); jj++ ) {
            if( ok[ii][jj] ) --c;
            if( ch(ii,jj) ) ++c;
          }
        }
        res = max(res,c);
      }
      g[i][j] = t;
    }
  }
  printf("%d\n",res);
  return 0;
}

Measured memory_bytes: 3196
fn solve() {
    let (h, w, m): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    let mut row_bomb = HashMap::<usize, usize>::new();
    let mut col_bomb = HashMap::<usize, usize>::new();
    for i in 0..h {
        row_bomb.insert(i, 0);
    }
    for j in 0..w {
        col_bomb.insert(j, 0);
    }
    let mut ms = HashSet::new();
    for _ in 0..m {
        let (h0, w0): (usize, usize) = (read::<usize>() - 1, read::<usize>() - 1);
        ms.insert((h0, w0));
        match row_bomb.get_mut(&h0) {
            Some(v) => *v += 1,
            None => (),
        }
        match col_bomb.get_mut(&w0) {
            Some(v) => *v += 1,
            None => (),
        }
    }
    // let mut arow = 0;
    let arv = row_bomb.iter().fold(0, |acc, e| max(acc, *e.1));
    let mut rows = HashSet::new();
    for (&k, &v) in &row_bomb {
        if v == arv {
            rows.insert(k);
        }
    }

    let acv = col_bomb.iter().fold(0, |acc, e| max(acc, *e.1));
    let mut cols = HashSet::new();
    for (&k, &v) in &col_bomb {
        if v == acv {
            cols.insert(k);
        }
    }

    for r in rows {
        for &c in &cols {
            if !ms.contains(&(r, c)) {
                println!("{}", acv + arv);
                return;
            }
        }
    }
    println!("{}", acv + arv - 1);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

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

// =========


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec c(n,0);
    rep(i,n){
        ll tmp;
        cin>>tmp;
        tmp--;
        c[tmp]++;
    }
    sort(ALL(c));
    Vec cnt;
    rep(i,n){
        if(c[i]>0){
            cnt.pb(c[i]);
        }
    }
    Vec sm(n+1,0);
    sm[0]=cnt[0];
    rep(i,cnt.size()){
        if(i==0)continue;
        sm[i]=cnt[i]+sm[i-1];
    }
    REP(k,1,n+1){
        if(cnt.size()<k){
            cout<<0<<endl;
            continue;
        }
        ll l = -1,r = 300300;
        while(l+1<r){
            ll c = (l+r)/2;
            bool ok = [&]{
                ll x = lower_bound(ALL(cnt),c) - cnt.begin();
                return sm[x-1]+c*(cnt.size()-x) >= k*c;
            }();
            if(ok){
                l = c;
            }else{
                r = c;
            }
        }
        cout<<l<<endl;
    }
    return  0;
}


Measured memory_bytes: 8816
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) int __VA_ARGS__; in(__VA_ARGS__)
//オーバーフロー対策
#define INL(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#pragma endregion RegionDefs

void solve()
{
    INL(x, y, z, k);
    ll *a = new ll[x];
    ll *b = new ll[y];
    ll *c = new ll[z];
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(a, a+x);
    sort(b, b+y);
    sort(c, c+z);
    set<ll> seen;
    PQ<tuple<ll, ll, ll, ll>> q;
    q.emplace(a[x-1]+b[y-1]+c[z-1], x-1, y-1, z-1);
    rep(i, k)
    {
        auto t = q.top();
        cout << get<0>(t) << endl;
        ll mx = get<1>(t);
        ll my = get<2>(t);
        ll mz = get<3>(t);
        q.pop();
        if (mx >= 1 && seen.find(mx*1000*1000+my*1000+mz-1000*1000) == seen.end())
        {
            q.emplace(a[mx-1]+b[my]+c[mz], mx-1, my, mz);
            seen.insert(mx*1000*1000+my*1000+mz-1000*1000);
        }
        if (my >= 1 && seen.find(mx*1000*1000+my*1000+mz-1000) == seen.end())
        {
            q.emplace(a[mx]+b[my-1]+c[mz], mx, my-1, mz);
            seen.insert(mx*1000*1000+my*1000+mz-1000);
        }
        if (mz >= 1 && seen.find(mx*1000*1000+my*1000+mz-1) == seen.end())
        {
            q.emplace(a[mx]+b[my]+c[mz-1], mx, my, mz-1);
            seen.insert(mx*1000*1000+my*1000+mz-1);
        }
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

/*bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) { // 素数ではない
			return false;
		}
	}
	// 素数である
	return true;
}*/
/*ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/
/*ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}*/
/*ll modpow(ll x, ll y, ll mod) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}*/
/*ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}*/
//printf("%.10f\n", n);

ll test[223456], rui[223456];
signed main() {
	string s, t;
	ll n, m, k, a, b, c, cnt = 0, ans = 0;
	cin >> n;
	rep(i, n) {
		cin >> test[i];
	}
	for (int h = n - 1; h >= 0; h--) {
		rui[h] = (rui[h + 1] + test[h]) % mod;
	}
	rep(i, n) {
		ans += (rui[i + 1] * test[i]) % mod; ans %= mod;
		
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    set<int>s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,t;
    while(cin>>n){
        int x=0;
        for(int i=0;i<n;i++){
            cin>>t;
            if(t%2)x++;
        }
        if(x%2==0)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    ll x; cin >> x;
    for (ll i = -5300; i <= 5300; i++) {
        for (ll j = i; j <= 5300; j++) {
            if (j * j * j * j * j - i * i * i * i * i == x) {
                cout << j << ' ' << i << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

int main(int argc, char *argv[]){
  int N;
  long long K;
  cin>>N>>K;
  vector<long long> hist(100001,0);
  for(int i=1; i<N+1; i++){
    int a,b;
    cin>>a>>b;
    hist[a]+=b;
  }
  long long sum=0;
  for(int i=1; i<100001; i++){
    if(hist[i]==0) continue;
    sum+=hist[i];
    if(sum<K) continue;
    else if(sum>=K){
      cout<<i<<endl;
      return 0;

    }
  }


}
      
  


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


int main()
{
  	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
	return 0;
}

Measured memory_bytes: 256
while 1:
    n = int(input())
    if n == 0:
        break
    i = 0
    a=1000-n
    if a>=500:
        a = a-500
        i =i+1
    if a>=100:
        b = a//100
        i = i+b
        a = a-(100*b)
    if a>=50:
        i = i+1
        a = a-50
    if a>=10:
        b = a//10
        i = i+b
        a = a-(10*b)
    if a>=5:
        i = i+1
        a = a-5
    i = i+a
    print(i)


Measured memory_bytes: 5588
#include <bits/stdc++.h>
#define N 100002
using namespace std;
int A,B,C,D,E,F,f[N],g[N],u,v;
int main() {cin>>A>>B>>C>>D>>E>>F;
	for (int i=0;i*100<=F;i+=A)
		for (int j=0;i*100+j*100<=F;j+=B) f[i*100+j*100]=1;
	for (int i=0;i<=F;i+=C)
		for (int j=0;i+j<=F;j+=D) g[i+j]=1;
	for (int a=1;a<=F;a++)
		for (int b=0;b+a<=F;b++) {
			if (f[a] && g[b])
				if (b*100<=E*(a) && (!u||b*(u+v)>v*(a+b))) u=a,v=b;
		}
	cout<<u+v<<' '<<v<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]and A[i][2]>A[i+1][2]:return'Not s'
 return'S'
n=int(input())
A=[(e[0],int(e[2:]),i)for i,e in enumerate(sys.stdin)]
k(A,0,n-1)
for e in[[s(A)+'table']]+A:print(*e[:2])


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

int calculate(int n) {
  int count = 0;
  for (int i = 0; i < 5; i++) {
    count += n % 10;
    n /= 10;
  }
  count += n;
  return count;
}

int main() {
  //数の代入
  int N;
  cin >> N;
  
  //最小値を入れる変数の設定
  int min = 50;
  
  //Nまでの整数に対して，数の組み合わせにつき桁の和を計算して比較
  for (int i = 1; i < N; i++) {
    if (min > calculate(i) + calculate(N-i)) {
      min = calculate(i) + calculate(N-i);
    }
  }
  
  cout << min << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(A,B) << ' ' << max(0,A+B-N) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)

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

int main(){
  int n,m;
  cin>>n>>m;
  priority_queue<ll,vector<ll>,less<ll>> a;
  rep(i,n){
    ll an;cin>>an;
    a.push(an);
  }
  vector<pair<ll,ll>> card;
  rep(i,m){
    ll b,c;cin>>b>>c;
    card.push_back(make_pair(c,b));
  }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  ll sum=0;
  ll bcnt=card[0].second,cn=0;
  rep(i,n){
    ll an = a.top();
    a.pop();
    if(an>=card[cn].first){
      sum += an;
    }
    else{
      sum += card[cn].first;
      bcnt--;
      a.push(an);
      if(bcnt==0){
        cn++;
        bcnt = card[cn].second;
      }
    }
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 4212
#include <iostream>
#include <set>

using namespace std;

int table[201];

int main() {
    int N;
    cin >> N;
    for (int i = 1; i <= 200; ++i) {
        for (int j = i; j <= 200; j += i) {
            table[j] += 1;
        }
    }
    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        if (table[i] == 8) {
            ans += 1;
        }
    }
    cout << ans << endl;
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

struct Edge{
	int to, a, b;
	Edge(int to, int a, int b):to(to),a(a),b(b){}
};

struct Data{
	int v, s;
	ll x;
	Data(int v, int s, ll x):v(v), s(s), x(x){}
	bool operator<(const Data& a) const {
		return x > a.x;
	}
};

#define S_MAX 2500

int main(){
	int n, m, s;
	cin>>n>>m>>s;
	vector<Edge> e[50];
	rep(i, m){
		int u, v, a, b;
		cin>>u>>v>>a>>b; u--; v--;
		e[u].push_back(Edge(v, a, b));
		e[v].push_back(Edge(u, a, b));
	}
	int c[50], d[50];
	rep(i, n) cin>>c[i]>>d[i];

	priority_queue<Data> q;

	ll mm[50][S_MAX];
	rep(i, 50) rep(j, S_MAX) mm[i][j]=LLONG_MAX;
	s=min(s, S_MAX-1);
	mm[0][s]=0;
	q.push(Data(0, s, 0));

	while(!q.empty()){
		Data da=q.top(); q.pop();
		if(da.x>mm[da.v][da.s]) continue;

		repit(it, e[da.v]){
			int ns=da.s-(it->a);
			ll nx=da.x+(it->b);
			if(ns>=0 && nx<mm[it->to][ns]){
				mm[it->to][ns]=nx;
				q.push(Data(it->to, ns, nx));
			}
		}
		for(ll ns=da.s, nx=da.x; ; ){
			ns+=c[da.v];
			nx+=d[da.v];
			if(ns>=S_MAX) break;
			if(nx < mm[da.v][ns]){
				mm[da.v][ns]=nx;
				q.push(Data(da.v, ns, nx));
			}
			
		}
	}

	for(int i=1; i<n; i++){
		ll mn=LLONG_MAX;
		rep(j, S_MAX) mn=min(mn, mm[i][j]);
		cout<<mn<<endl;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int x;
  cin>>x;
  int ans=8;
  for(int i=400; i<2000; i+=200){
    if(i<=x && x<i+200){
      cout<<ans<<'\n';
      return 0;
    }
    --ans;
  }
  return 0;
}


Measured memory_bytes: 3632
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())

cnt = 0
while cnt < M:
    P, X = map(int, input().split())

    ans = 0
    P -= 1
    for i in range(len(T)):
        if i == P: 
            ans += X
        else:
            ans += T[i]
    print(ans)
    cnt += 1

Measured memory_bytes: 3064
"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function

# import itertools as it
# import collections
import sys


def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


K, X = map(int, input().split())
res = range(max(-1000000, X-K+1), min(100001, X + K))
print(*res)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#define in(a) scanf("%d",&a)
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn]; int b[maxn];

int main()
{
	int n; in(n);
	for (int i = 1; i <= n; i++)
	{
		int x; in(x);
		if (i & 1 == 1)a[x] += 1;
		else b[x] += 1;
	}
	
	int pmax = 0; int sec = 0; int pos = 0;
	for (int i = 1; i < maxn; i++)
	{
		if (a[i] > pmax)
		{
			sec = pmax; pmax = a[i]; pos = i;
		}
		else
		{
			sec = max(sec, a[i]);
		}
	}
	int ans = 1e9;
	for (int i = 1; i < maxn; i++)
	{
		if (pos != i)ans = min(ans, n - pmax - b[i]);
		else ans = min(ans, n - sec - b[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
/*
▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define zhfs main
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define re return
#define forn(i, n) for (int i = 1; i <= n; i++)
const int MAXN = 500 * 1000 + 7;
int d[MAXN], pos[MAXN];
bool win[MAXN];
int mx[MAXN];
int zhfs()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	scanf("%d %d", &n, &pos[0]);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &d[i]);
		pos[i] = min(pos[i - 1], abs(pos[i - 1] - d[i]));
	}
	mx[n] = 1;
	for (int i = n - 1; i >= 1; i--)
	{
		if (mx[i + 1] > d[i + 1] / 2)
		{
			mx[i] = mx[i + 1] + d[i + 1];
		}
		else
		{
			mx[i] = mx[i + 1];
		}
	}
	int q;
	scanf("%d", &q);
	for (int qq = 1; qq <= q; qq++)
	{
		int x;
		scanf("%d", &x);
		if (pos[x - 1] >= mx[x])
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
}



Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int N;   
    cin >> N;
    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
#include<wchar.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N; ll K; scanf("%d %lld", &N, &K);
    vec next(N), dist(N);
    vector<bool> visit(N, false);
    rep(i, N){
        scanf("%lld", &next[i]);
        next[i]--;
    }
    int x = 0;
    dist[0] = 0;
    visit[0] = true;

    while(!visit[next[x]]){
        dist[next[x]] = dist[x] + 1;
        x = next[x];
        visit[x] = true;
    }
    int start = next[x];
    ll cycle = dist[x] + 1 -dist[next[x]];

    if(K <= dist[start]){
        int y = 0;
        while(K > 0){
            y = next[y];
            K--;
        }
        printf("%d\n", y+1);
        return 0;
    }
    K -= dist[start];
    K = K % cycle;
    int z = start;
    while(K > 0){
        z = next[z];
        K--;
    }
    printf("%d\n", z+1);
}

Measured memory_bytes: 6460
#include "bits/stdc++.h"
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define ll long long

signed main() {
	int T; cin >> T;
	for (int _ = 0; _ < T; _++) {
		ll N, M, A, B; cin >> N >> M >> A >> B;
		cout << floor_sum(N, M, A, B) << endl;
	}
	return 0;
}


Measured memory_bytes: 3680
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    ll t;
    cin >> n >> t;
    ll ans = 0, b = 0;
    rep(i,n){
        ll a;
        cin >> a;
        if(b <= a){
            ans += t;
            b = a + t;
        }
        else{
            ans += a + t - b;
            b = a + t;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Cin(type, val) type val; cin >> val;
#define Cout(val) cout << (val) << "\n";
#define Range(container) container.begin(), container.end()
using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    vector<int> h(n);
    For(i, n) cin >> h[i];
    
    int ans = 0;
    for(int i = 100; i > 0; i --){
        bool f = true;
        for(int j = 0; j < n; j ++){
            if(h[j] == i){
                h[j] --;
                if(f) ans ++;
                f = false;
            }
            else{
                f = true;
            }
        }
    }
    Cout(ans);
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
S = [input().split() for _ in range(H)]

for i, s in enumerate(S):
    if "snuke" in s:
        print(ascii_uppercase[s.index("snuke")], i+1, sep="")
        break


Measured memory_bytes: 10588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 1000000007
//#define MOD 998244353
#define invp(a,p)pom(a,p-2,p)


typedef struct pair{ll x,y;}P;
int dicsort(const void*a,const void*b){
	P*p=(P*)a,*q=(P*)b;
	if((*p).x<(*q).x)return -1;
	if((*p).x>(*q).x)return  1;
	if((*p).y<(*q).y)return -1;
	return 1;
}

P a[3010];
ll dp[3010];//dp[i]=1~i-1の壁を踏まず、a[i]の壁にたどり着く場合の数
ll fact[200010];

ll calc(ll x,ll y){
	if(x<0||y<0)return 0;
	return fact[x+y]*invp(fact[x],MOD)%MOD*invp(fact[y],MOD)%MOD;
}

int main(){
	fact[0]=1;
	rep(i,1,200005)fact[i]=fact[i-1]*i%MOD;
	ll h,w,n;
	scanf("%lld%lld%lld",&h,&w,&n);
	h--,w--;
	rep(i,0,n){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		a[i].x=x-1;
		a[i].y=y-1;
	}
	qsort(a,n,sizeof(P),dicsort);
	a[n].x=h;
	a[n].y=w;
	
	rep(i,0,n+1){
		ll ans=calc(a[i].x,a[i].y);
		rep(j,0,i)ans=(ans-dp[j]*calc(a[i].x-a[j].x,a[i].y-a[j].y)%MOD+MOD)%MOD;
		dp[i]=ans;
	}
	printf("%lld\n",dp[n]);
	return 0;
}

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

int main() {
  int n, a[110] = {0};
  cin >> n;

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

  int count = 0;
  for(int i = 0; i < n - 1; i++){
    if(a[i] == a[i + 1]){
      count += 1;
      a[i + 1] = 0;
    }
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 888