akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = Reader.NextUInt;
        int last = 0;
        int cur = 0;
        int max = 0;
        for (int i = 0; i < n; i++)
        {
            var h = Reader.NextUInt;
            if (last >= h) max = Max(max, ++cur);
            else cur = 0;
            last = h;
        }
        Console.WriteLine(max);
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] buffer = new byte[BUF_SIZE];
    static int ptr = 0;

    private static void Read()
    {
        Stream.Read(buffer, 0, BUF_SIZE);
    }

    private static byte Next { get { if (ptr >= buffer.Length) { Read(); ptr = 0; } return buffer[ptr++]; } }

    public static int NextUInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; byte next;
            do { next = Next; } while (next < 48);
            do { res = res * 10 + next - 48; next = Next; } while (48 <= next);
            return res;
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main(){
	int S,h, s, m;
	cin >> S;
	h = S / 3600;
	m = S / 60 % 60;
	s = S % 3600 % 60;
	cout << h << ":" << m << ":" << s<<endl;
	return 0;
}

Measured memory_bytes: 3088
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
void solve() {
    ll a, b, x;
    while(cin >> a) {
        cin >> b >> x;
        ll t = b / x - a / x;
        if(a % x == 0) t++;
        cout << t << endl;
    }
}
int main() {
   // freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = []
b.append(list(map(int, input().split())))
b.append(list(map(int, input().split())))
c = 0
for i in range(a):
    if b[0][i] > b[1][i]:
        c += b[0][i] - b[1][i]
print(c)


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

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

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

	int n;
	cin >> n;
	int ct = 0;
	for(int i = 1; i <= n; i++)
		if((int)log10(i) % 2 == 0) ++ct;

	cout << ct;
	
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 640
#include <fstream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <bitset>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <set>
#include <complex>

using namespace std;

const int SIZE = 1 << 10;

int pointer = SIZE;
char buffer[SIZE];

char Advance() {
    if (pointer == SIZE) {
        fread(buffer, 1, SIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0;
    char ch = Advance();
    while (!isdigit(ch))
        ch = Advance();
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer;
}

const int INF = 2000000000;

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int n;
    long long answer = 0;
    int smallB = INF;
    scanf("%d", &n);
    bool all = true;
    for (int i = 1; i <= n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        if (a != b) {
            all = false;
            if (a > b)
                smallB = min(smallB, b);
        }
        answer += a;
    }
    if (all)
        printf("0");
    else {
        answer -= smallB;
        printf("%lld\n", answer);
    }
    return 0;
}


Measured memory_bytes: 128
from collections import defaultdict

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

a_cs = [0] * (n + 1)
for i in range(n):
    a_cs[i + 1] = (a_cs[i] + a[i])

d = defaultdict(int)
for i in range(1, n + 1):
    d[a_cs[i] % m] += 1

ans = 0
for k, v in d.items():
    if k == 0:
        ans += v * (v - 1) // 2 + v
    else:
        ans += v * (v - 1) // 2

print(ans)


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

#define ll long long

using namespace std;

ll f(char i){
	if(i == '#')
		return 0;
	return 1;
}

int main(){

	ll n,m;
	cin >> n >> m;

	vector<vector<ll>> dp(n, vector<ll>(m));

	vector<vector<char>> v(n, vector<char>(m));
	char val;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> v[i][j];
		}
	}

	
	ll mod = 1e9 + 7;
	//base cases
	ll x=1;
	for(int i = 0; i < n; i++){
		x = min(x,f(v[i][0]));
		dp[i][0] = x;
	}

	x = 1;
	for(int i = 0; i < m; i++){
		x = min(x,f(v[0][i]));
		dp[0][i] = x;
	}

	
	
	for(int i = 1; i < n; i++){
		for(int j = 1; j < m; j++){	
			if(v[i][j] == '#'){
				dp[i][j] = 0;
			}
			else{
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
			}
		}
	}

	cout << dp[n-1][m-1] << "\n";
}

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

int read_int(int n) {
    int s = 0;
    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;
        s = 10 * s + m;
    }

    return s;
}

int p, q;
int cnt_p, cnt_q;

int cnt = 0;
void func(int s, vector<int> a) {
    if (a.size() == 0) {
        cnt++;
        if (s == p)
            cnt_p = cnt;
        if (s == q)
            cnt_q = cnt;

        return;
    }

    for (int i = 0, n = a.size(); i < n; i++) {
        vector<int> _a = a;
        _a.erase(vector<int>::const_iterator(_a.begin() + i));
        func(10 * s + a.at(i), _a);
    }
}

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

    p = read_int(n);
    q = read_int(n);

    vector<int> a(n);
    for (int i = 0; i < n; i++)
        a.at(i) = i + 1;

    func(0, a);

    cout << abs(cnt_p - cnt_q) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int n, k, intersect, dist;
pair <int, int> a[2];

#define F first
#define S second

bool check(long long num) {
    int get = a[1].S - min(a[0].F, a[1].F) - intersect; /// getfull point
    int cost = a[1].S - a[0].S + abs(a[0].F - a[1].F); /// cost to getfull

    if(cost == 0) {
        return num/2 >= k;
    }


    if(num < cost) {
        long long xx = num - dist;
        return (xx >= k);
    }

    long long ret = get;
    num -= cost;

    long long val1 = ret + num/2;

    long long val2 = ret;
    long long block = num/cost;
    if(block >= n-1) {
        val2 += 1ll*(n-1)*get;
        val2 += (num - 1ll*(n-1)*cost)/2;
    } else {
        val2 += 1ll*block*get;
        int du = num % cost;
        val2 += max(du/2, max(0, du-dist));
    }
    ret = max(val1, val2);
    return ret >= k;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(fopen(".inp", "r")) freopen(".inp", "r", stdin);
    int x; cin >> x;
    cout << (x >= 30 ? "Yes" : "No");

    return 0;
}


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

int main(){
  	int N;
  	string a;
  	cin >> N >> a;
  	if(N % 2 == 1){
    	cout << "No" << endl;
    } else {
      	int i;
    	for(i = 0 ; i < N /2 ; i ++){
         	if(a[i] != a[i + N / 2]) break;
          	if(i == N / 2 - 1) i ++;
        }
      	if(i < N /2) cout << "No" << endl; else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b;
    cin >> a >> b;
    //処理
    //出力
    cout << 2*b-a << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long a,b,ans=0;
    cin>>a>>b;
    f(i,a,b+1){
        if(i/10000==i%10&&(i/1000)%10==(i%100)/10){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3600
S = input()
Q = int(input())

forward = []
backend = []
reverse = 0

for i in range(Q):
        s = input()
        s1 = list(s)

        if s1[0] == '1':
            reverse += 1
        else:
            if s1[2] == '1':
                if reverse % 2 == 0:
                    forward.append(s1[4])
                else:
                    backend.append(s1[4])
            else:
                if reverse % 2 == 0:
                    backend.append(s1[4])
                else:
                    forward.append(s1[4])

if reverse % 2 == 0:
    for i in forward[::-1]:
        print(i, end="")
    
    print(S,end="")

    for i in backend:
        print(i,end="")

    print()
else:
    for i in backend[::-1]:
        print(i,end="")
    
    for i in list(S)[::-1]:
        print(i,end="")

    for i in forward:
        print(i,end="")

    print()

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


void solve(long long A, long long B)
{
    cout<<6-A-B<<endl;
}

int main()
{
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
s = list(input())
k = int(input())
sub = []
for i in range(1, min(len(s) + 1, k + 1)):
    for j in range(1, len(s) + 2 - i):
        if not([s[s_i - 1] for s_i in range(j, j + i)] in sub):
            sub.append([s[s_i - 1] for s_i in range(j, j + i)])
sub.sort()
print(''.join(sub[k-1]))


Measured memory_bytes: 4980
#include<stdio.h>
int main()
{
	int m,n,t,i,num=0,j;
	while(~scanf("%d %d",&n,&m))
	{
		if(n==m||n%m==0)
		{
			printf("-1\n");
			return 0;
		}
		for(i=n+1,j=1;i<1000000000000000000;i=n*(j+1),j++)
		{
			if(i%n==0&&i%m!=0)
			{
				printf("%d\n",i);
				num++;
				return 0;
			}
		}
		if(num==0)
		printf("-1\n");
	}
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))

const ll INF = 1LL << 60;
ll h[110000];
ll dp[110010];

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


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int[] a=new int[26];
		while(scan.hasNext()){
		
			String str = scan.nextLine();
			str = str.toLowerCase();
		
			for(int i=0;i<str.length();i++)
				if(str.charAt(i) >= 'a' && str.charAt(i) <= 'z')
					a[str.charAt(i)-'a']++;
		}
		
		for(int i=0;i<26;i++)
			System.out.printf("%c : %d\n",i+'a',a[i]);
	}
}


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



int n,m,T;
string s;

int main()
{
	getline(cin,s);
	if(s[s.length()-1] == 's')	
	
	cout << s+"es" << endl;
	else cout << s+ 's'<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 3628
w, h, n = map(int, input().split())

xy = []
for i in range(h):
    tmp = [0] * w
    xy.append(tmp)


lis = []
for _ in range(n):
    t = list(map(int, input().split()))
    lis.append(t)

for i in lis:
    if i[2] == 1:
        for j in range(h):
            for k in range(i[0]):
                xy[j][k] = 1
    elif i[2] == 2:
        for j in range(h):
            for k in range(i[0], w):
                xy[j][k] = 1
    elif i[2] == 3:
        for j in range(i[1]):
            for k in range(w):
                xy[j][k] = 1
    elif i[2] == 4:
        for j in range(i[1], h):
            for k in range(w):
                xy[j][k] = 1

ans = 0
for i in xy:
    for j in i:
        if j == 0:
            ans += 1

print(ans)

Measured memory_bytes: 9176
from collections import deque
s = input()
Q = int(input())
que = deque(s)
cnt = 0
for i in range(Q):
    q = input().split()
    if q[0] == '1':
        cnt += 1
    else:
        reverse = cnt % 2
        if q[1] == '1':
            if reverse == 0:
                s = que.appendleft(q[2])
            else:
                s = que.append(q[2])
        else:
            if reverse == 0:
                s = que.append(q[2])
            else:
                s = que.appendleft(q[2])

ans = ''.join(que)
if cnt % 2 == 0:
    print(ans)
else:
    print(ans[::-1])

Measured memory_bytes: 14184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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() {
    ll n;
    cin >> n;
    ll ans = 0;
    ans += 2 * (n/11);
    ll res = n % 11;
    ans += (res > 0) + (res > 6);
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3648
from heapq import heappush, heappop, heapify

def neg_int(n):
    return -int(n)
    
N, M = map(int, input().split())
a_list = list(map(neg_int, input().split()))
heapify(a_list)
for _ in range(M):
    a = -heappop(a_list)
    a //= 2
    heappush(a_list, -a)
print(-sum(a_list))

Measured memory_bytes: 20460
#include<iostream>

using namespace std;

int main() {
	int S;
	cin >> S;
	int YY;
	int MM;
	YY = S / 100;
	MM = S % 100;
	if (YY>=1&&YY<=12) {
		if (MM >= 1 && MM <= 12) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
	}
	else {
		if (MM >= 1 && MM <= 12) {
			cout << "YYMM" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ForAizuSol
{
    class Program
    {
        static void Main(string[] args)
        {
            var inSec = int.Parse(Console.ReadLine());

            var hou = inSec / (60 * 60);
            inSec -= hou * 60 * 60;
            var min = inSec / 60;
            inSec -= min * 60;
            var sec = inSec;

            Console.WriteLine(hou.ToString() + ":" + min.ToString() + ":" + sec.ToString());
        }
    }
}


Measured memory_bytes: 18012
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 400000;







int main() {

	int N, M;
	cin >> N >> M;

	int S[3000], T[3000];
	
	rep(i, N) {
		cin >> S[i];
	}
	
	rep(i, M) {
		cin >> T[i];
	}

	ll D[2100][2100];
	ll line[2100][2100];
	ll seq[2100][2100];
	ll sum[2100][2100];

	rep(i, N) {
		rep(j, M) {
			if (j == 0) { line[i][j] = 0; }
			else { line[i][j] = (line[i][j - 1] + D[i][j - 1]) % MOD; }

			if (i == 0) { seq[i][j] = 0; }
			else { seq[i][j] = (seq[i - 1][j] + D[i - 1][j]) % MOD; }

			if (i == 0 || j == 0) { sum[i][j] = 0; }
			else { sum[i][j] = (sum[i - 1][j - 1] + line[i - 1][j - 1] + seq[i - 1][j - 1] + D[i - 1][j - 1]) % MOD; }

			if (S[i] != T[j]) { D[i][j] = 0; }
			else { D[i][j] = sum[i][j] + 1; }

			
		}
	}

	ll ans = (1+ sum[N - 1][M - 1] + line[N - 1][M - 1] + seq[N - 1][M - 1] + D[N - 1][M - 1]) % MOD;

	cout << ans;
	system("PAUSE");

}

Measured memory_bytes: 139648
object Main extends App{
  val n = scala.io.StdIn.readInt
  val a = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  var arr: Array[Int] = new Array[Int](n)
  for(count <- 0 until n) arr(a(count)-1) = count+1
  println(arr.mkString(" "))
}

Measured memory_bytes: 45544
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RDA;
	auto b = new long[](N+1);
	foreach (i; 0..N)
	{
		b[i+1] = b[i] + A[i];
	}

	long d = long.max;
	foreach (i; 1..N)
	{
		d = min(d, abs(b[N] - b[i] - b[i]));
	}

	writeln(d);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 11648
package main

import (
	"fmt"
	"sort"
)

// 集合にして昇順ソートしてJoinか空文字で出力して最後に改行

func main() {
	var n, l int
	fmt.Scan(&n, &l)
	s := make([]string, n)
	for i := 0; i < n; i++ {
		var t string
		fmt.Scan(&t)
		s[i] = t
	}
	sort.Strings(s)
	for _, v := range s {
		fmt.Print(v)
	}
	fmt.Println()
}


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


using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;
bool isPrime[MAXN];
void sevie() {
    memset(isPrime, 1, sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i * i <= MAXN; i++) {
        if (isPrime[i]) {
            for (ll j = i * 2; j <= MAXN; j += i) {
                isPrime[j] = 0;

            }
        }
    }
}
ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}
//__builtin_popcount ();
bool isPrim(int n) {
    if (n == 1 || n == 0)
        return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}




int main() {
    FAST
int x;
    cin>>x;
    int num500=x/500;
    x%=500;
    int num5=x/5;
    x%=5;
    cout<<num500*1000+ (num5*5)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    private static FastReader fr = new FastReader();
    private static PrintWriter out=new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        StringBuilder sb = new StringBuilder();
        // code goes here
        int n = fr.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        long min1 = Long.MAX_VALUE;
        long min2 = Long.MAX_VALUE;
        for(int i = 0; i < n; i++){
            int x = fr.nextInt();
            int y = fr.nextInt();
            a[i] = x + y;
            b[i] = x - y;
            min1 = Math.min(min1, a[i]);
            min2 = Math.min(min2, b[i]);
        }

        long max = Long.MIN_VALUE;
        for(int i = 0; i < n; i++){
            max = Math.max(max, a[i] - min1);
            max = Math.max(max, b[i] - min2);
        }

        sb.append(max);
        System.out.print(sb.toString());
    }

    static class FastReader{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

        public String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long[] nextLongArray(int n) {
            long[] a=new long[n];
            for (int i=0; i<n; i++) a[i]=nextLong();
            return a;
        }
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


Measured memory_bytes: 59012
n=int(input())
t, a=map(int, input().split())
h=list(map(int, input().split()))

mtd=float('inf')
ans=0

for i in range(n):
  td = abs(t-h[i]*0.006-a)
  if td<mtd:
    mtd=td
    ans=i+1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> S(N);
  for(int i;i<N;i++) {
  cin >> S.at(i);}
  sort(S.begin(),S.end());
  cout << S.at(N-1)-S.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
typedef long long ll;

int main(){

  int n;
  cin >> n;
  int score[101];
  bool adjacent_graph[101][101];
  rep(i,101){
    score[i] = -1;
    rep(j,101) adjacent_graph[i][j] = false;
    }

  int vertex,edge,direction;
  rep(i,n){
    cin >> vertex >> edge;
    rep(j,edge){
      cin >> direction;
      adjacent_graph[vertex][direction]  = true;
      // adjacent_graph[direction][vertex]  = true;
    }
  }
  queue<int> que;
  que.push(1);
  score[1] = 0;
  while(!que.empty()){
    int now = que.front();que.pop();
    rep(i,n+1) {
      if(adjacent_graph[now][i] && score[i] == -1){
        score[i] = score[now]+1;
        que.emplace(i);
      }
    }
  }

  rep(i,n) cout  << i+1 << " " << score[i+1] << endl;

  return 0;
}


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

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("at_B.in","r",stdin);
    //freopen("at_B.out","w",stdout);
#endif
	int n,k;
	ll ans = 1;
	cin>>n>>k;
	ans = k;
	for(int i=2; i<=n; i++)
	{
		ans *= (k-1);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int x1,x2,a;
	scanf("%d %d",&x1,&x2);
	if(x1<x2){
		printf("%d\n",x2-x1);
	}
	else{
		printf("%d\n",x1-x2);
	}
	return 0;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>x(n,0);
  for(int i=0;i<k;i++){
  int d;
  cin>>d;
  for(int j=0;j<d;j++){
  int a;
  cin>>a;
  x[a-1]=1;
  }
  }
  int ans=0;
  for(int k=0;k<n;k++){
  if(x[k]==0){
  ans++;
  }
  }
  cout<<ans<<endl;
}

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

typedef long long ll;
const int N = 3054;

int mod, n;
int pw2[N], gw2[N];
int C[N][N], S2[N][N];

inline void add(int &x, const int y) {x += y - mod, x += x >> 31 & mod;}

void init(int n) {
	int i, j;
	for (*pw2 = i = 1; i <= n; ++i) pw2[i] = pw2[i - 1] * 2 % mod;
	for (*gw2 = 2, i = 1; i <= n; ++i) gw2[i] = (ll)gw2[i - 1] * gw2[i - 1] % mod;
	for (**C = i = 1; i <= n; ++i)
		for (*C[i] = j = 1; j <= i; ++j)
			add(C[i][j] = C[i - 1][j], C[i - 1][j - 1]);
	for (**S2 = i = 1; i <= n; ++i)
		for (j = 1; j <= i; ++j)
			S2[i][j] = ((ll)S2[i - 1][j] * j + S2[i - 1][j - 1]) % mod;
}

int solve(int num) {
	int set, rem = n - num, S = 0;
	for (set = num; set >= 0; --set) S = ((ll)S * pw2[rem] + S2[num + 1][set + 1]) % mod;
	return (ll)S * gw2[rem] % mod * C[n][num] % mod;
}

int main() {
	int i; ll ans = 0;
	scanf("%d%d", &n, &mod), init(n + 1);
	for (i = 0; i <= n; ++i) i & 1 ? ans -= solve(i) : ans += solve(i);
	ans %= mod, printf("%d\n", int(ans + (ans >> 63 & mod)));
	return 0;
}

Measured memory_bytes: 71168
from collections import deque
from bisect import bisect_left

n=int(input())
a=[int(input()) for i in range(n)]

d=deque()
for i in range(n):
  b=bisect_left(d,a[i])
  if b==0:
    d.appendleft(a[i])
  else:
    d[b-1]=a[i]
    
print(len(d))


Measured memory_bytes: 13884
#include<iostream>
using namespace std;
typedef long long ll;
int main () {
  ll N, M;
  cin >> N >> M;
  if (N == 1 || M == 1) {
    if (N == 1 && M == 1) {
      cout << 1 << endl;
    }
    else {
      cout << max(N, M) - 2 << endl;
    }
    return 0;
  }
  cout << (N - 2) * (M - 2)<< endl;
}

Measured memory_bytes: 3592
import numpy as np
import math 

N = int(input())

ans = 1e+99
for a in range(1,math.floor(np.sqrt(N))+1):
  if N % a == 0:
    b = N // a
  else:
    continue
  d_a = 1 + int(np.log10(a))
  d_b = 1 + int(np.log10(b))
  F = max(d_a, d_b)
  if F < ans:
    ans = F
print(ans)

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

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int cnt = k;
    bool can = false;
    // if(a < b && b < c){
    //     cout << "Yes" << endl;
    //     return 0;
    // }
    rep(i,k){
        if(b > a) break;
        b *= 2;
        --cnt;
        if(b > a || cnt <= 0) break;
    }
    // cout << b << " " << cnt << endl;
    // int cnt2 = cnt;
        // rep(i,cnt){
        //     c *= 2;
        //     --cnt2;
        //     if(cnt2 <= 0 || c > b) break;
        // }
    while(cnt > 0){
        c *= 2;
        --cnt;
    }
    // cout << c << " " << cnt << endl;
    if(c > b && b > a) can = true;
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3580
/*
 * ex7-3
 * kamecha
 */
#include<stdio.h>
#include<stdlib.h>

#define rep(i, n)   for(int i = 0; i < (n); i++)

/*
 * 全部'.'だと1を返す関数
 */
int check_row(char **grid, int line, int row){
    int flag = 1;
    rep(i, line){
        if(grid[i][row] == '#')  flag = 0;
    }
    if(flag)    return 1;
    else        return 0;
}

int check_line(char **grid, int line, int row){
    int flag = 1;
    rep(i, row){
        if(grid[line][i] == '#')  flag = 0;
    }
    if(flag)    return 1;
    else        return 0;
}

int main(void){
    int height, width;  scanf("%d %d", &height, &width);
    char **grid;
    int *del_row;
    int *del_line;
    int max_row = 0, max_line = 0;
    int flag = 0;
    grid = (char**)calloc(height, sizeof(char*));
    if(grid == NULL){
        exit(1);
    }
    rep(i, height){
        grid[i] = (char*)calloc(width, sizeof(char));
        if(grid[i] == NULL){
            exit(1);
        }
    }
    del_row = (int*)calloc(height, sizeof(int));
    del_line = (int*)calloc(width, sizeof(int));
    rep(i, height)  rep(j, width)   scanf(" %c", &grid[i][j]);
    /*
     * 圧縮する行、列を確認する
     */
    rep(i, height){
        if(check_line(grid, i, width))  del_line[max_line++] = i;
    }
    rep(i, width){
        if(check_row(grid, height, i))  del_row[max_row++] = i;
    }
    /*
     * 圧縮されてる所を飛ばして表示
     */
    rep(i, height){
        rep(j, max_line)    if(i == del_line[j])    flag = 1;
        if(flag){
            flag = 0;
            continue;
        }
        rep(j, width){
            rep(k, max_row) if(j == del_row[k]) flag = 1;
            if(flag){
                flag = 0;
                continue;
            }
            printf("%c", grid[i][j]);
        }
        printf("\n");
    }
    /*
     * メモリ解放
     */
    rep(i, height)   free(grid[i]);
    free(grid);
    free(del_row);
    free(del_line);
    return 0;
}


Measured memory_bytes: 1648
# https://atcoder.jp/contests/abc173/tasks/abc173_b

N = gets.to_i
Ss = Array.new(N) { gets.chomp }
h = Ss.group_by(&:itself)
%w[AC WA TLE RE].each do |k|
  v = h[k]&.size || 0
  puts "#{k} x #{v}"
end


Measured memory_bytes: 21660
#include <stdio.h>
int main()
{
	int n,k,x,y,sum;
	scanf("%d\n%d\n%d\n%d",&n,&k,&x,&y);
	if(n>k)
	{
		sum=(n-k)*y+k*x;
	}else sum=n*x;
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e6;
ll n, k;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  n %= k;
  cout << min(n, k-n) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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;
}
// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

// mod add
const int MOD = 1000000007;
void add(long long &a, long long b) {
    a += b;
    if(a >= MOD)
        a -= MOD;
}

long long solve(int N) {
    auto dp = make_vec<long long>(N + 1, 5, 5, 5);

    dp[0][0][0][0] = 1;

    rep(i, 0, N) {
        rep(a, 0, 5) {
            rep(b, 0, 5) {
                rep(c, 0, 5) {
                    rep(d, 1, 5) {
                        if(a == 1 && c == 2 && d == 3) {
                            continue;
                        }
                        if(a == 1 && b == 2 && d == 3) {
                            continue;
                        }
                        if(b == 1 && c == 2 && d == 3) {
                            continue;
                        }
                        if(b == 2 && c == 1 && d == 3) {
                            continue;
                        }
                        if(b == 1 && c == 3 && d == 2) {
                            continue;
                        }
                        add(dp[i + 1][b][c][d], dp[i][a][b][c]);
                    }
                }
            }
        }
    }
    long long res = 0;
    rep(i, 1, 5) {
        rep(j, 1, 5) {
            rep(k, 1, 5) { add(res, dp[N][i][j][k]); }
        }
    }
    return res;
}
int main() {
    int N;
    cin >> N;
    cout << solve(N) << endl;
}

Measured memory_bytes: 384
import sys
N,K=map(int,input().split())
A=sorted([int(i) for i in input().split()])
sa=sum(A)
def f(x):
    y=A[x]
    if y>=K:
        return True
    dp=[False]*(K)
    dp[0]=True
    t=0
    for i in range(N):
        if i==x:
            continue
        s=A[i]
        for k in range(t,-1,-1):
            if k+s>=K:
                continue
            dp[k+s]=dp[k+s]|dp[k]
        t=min(t+s,K-1)
    if sum(dp[K-y:K]):
        return True
    else:
        return False
ma=N-1
mi=0
if not f(N-1):
    print(N)
    sys.exit()
if f(0):
    print(0)
    sys.exit()
while ma-mi>1:
    #print(ma,mi)
    a=(ma+mi)//2
    if f(a):
        ma=a
    else:
        mi=a
print(ma)





Measured memory_bytes: 42608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		long N;
		long K;
		Scanner sc = new Scanner(System.in);
		N = sc.nextLong();
		K = sc.nextLong();
		long mod = N % K;
		System.out.println(Math.min(mod, Math.abs(mod - K)));
		sc.close();
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
char r[105];
int main(){
	cin>>r;
	int n=strlen(r);
	for(int i=0;i<=n;i++)
		for(int j=i;j<=n;j++){
			string S="";
			for(int k=0;k<i;k++)
				S+=r[k];
			for(int k=j;k<n;k++)
				S+=r[k];
			if(S.size()==7&&S=="keyence"){
				cout<<"YES";
				return 0;
			}
		}
	cout<<"NO";
	return 0;
}

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

using namespace std;

using ll = long long;

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

    vector<int> deg(4);
    for (int i = 0, a, b; i < 3; ++i) {
        cin >> a >> b;
        ++deg[a - 1]; ++deg[b - 1];
    }
    cout << ((count(deg.begin(), deg.end(), 3) == 0) ? "YES" : "NO")
         << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n;
  cin>>n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin>>s;
    mp[s]++;
  }
  int ans=mp.size();
  cout<<ans<<endl;
  return 0;
}


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

int main()
{    
    long long N;
    cin >> N;

    long long dp[N];

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

    std::sort(dp,dp+N);

    string ans="YES";

    for (int i = 1; i < N; ++i) {
        if (dp[i]==dp[i-1]){
            ans="NO";
            break;
        }
    }

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

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#define rep(i, k, n) for(int i=k; i<n; i++)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> A;
    int tmp;
    rep(i, 0, n) {
        cin >> tmp;
        A.push_back(tmp);
    }
    vector<int> SelectionSort(vector<int> vec);
    vector<int> answer = SelectionSort(A);
    rep(i, 1, n) cout << answer.at(i) << " ";
    cout << answer.at(n) << endl;
    cout << answer.at(0) << endl;
}

vector<int> SelectionSort(vector<int> vec) {
    int swap_count = 0;
    int size = vec.size();
    rep(i, 0, size) {
        int tmp = i;
        rep(j, i, size) { // Get number of the minimum value
            if (vec.at(tmp) > vec.at(j)) {
                tmp = j;
            }
        }
        if (tmp != i){
            swap(vec.at(tmp), vec.at(i));
            swap_count++;
        }
    }
    vector<int> answer;
    answer.push_back(swap_count);
    rep(i, 0, size) answer.push_back(vec.at(i));
    return answer;
}


Measured memory_bytes: 3160
#include <stdio.h>

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    int a, b;
    while (scanf("%d %d", &a, &b), a != 0 || b != 0) {
        int num = 0;
        for(int i = 1; i <= a - 2; ++i) {
            int j = i + 1, k = a;
            while (j < k) {
                if(i + j + k < b) j++;
                else if (i + j + k > b) k--;
                else {
                    num++;
                    j++;
                    k--;
                }
            }
        }
        printf("%d\n", num);
    }
    return 0;
}



Measured memory_bytes: 2052
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=550;
//ここまでテンプレ
//vを1つ前に動かす関数
void back(vint& v,int K,int N){
	//一番最後が1であれば取り除く
	if(v.back()==1)
		v.pop_back();
	//一番最後が1でなければ、1減らしてN文字になるまでKをつける
	else{
		v.back()--;
		for(int i=v.size();i<N;i++)
			v.pb(K);
	}
	return;
}
int main(){
	int K,N;
	cin>>K>>N;
	vint ans;
	//Kが偶数のとき
	if(K%2==0){
		ans.pb(K/2);
		for(int i=1;i<N;i++)
			ans.pb(K);
		for(int i=0;i<ans.size();i++)
			cout<<ans[i]<<(i==ans.size()-1?'\n':' ');
			return 0;
	}
	//Kが奇数のとき、(K+1)/2をN個並べたものからN-1個前のもの
	for(int i=0;i<N;i++)
		ans.pb((K+1)/2);
	for(int i=0;i<(N)/2;i++)
		back(ans,K,N);
	for(int i=0;i<ans.size();i++)
		cout<<ans[i]<<(i==ans.size()-1?'\n':' ');
	return 0;
}

Measured memory_bytes: 3568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class CColoringColorfully {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            char[] s = in.nextString().toCharArray();
            int n = s.length;

            int ans1 = 0;
            int ans2 = 0;
            for (int i = 0; i < n; ++i) {
                if (i % 2 == 0) {
                    if (s[i] != '0') ++ans1;
                } else {
                    if (s[i] != '1') ++ans1;
                }
            }

            for (int i = 0; i < n; ++i) {
                if (i % 2 == 0) {
                    if (s[i] != '1') ++ans2;
                } else {
                    if (s[i] != '0') ++ans2;
                }
            }
            out.println(Math.min(ans1, ans2));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = pread();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 23380
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int D;
vector<LL> c(26);
vector<vector<LL>> s;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

LL solve(const vector<LL>& t) {
  LL ans = 0;
  vector<LL> last(26, 0);
  for (int d = 1; d <= D; ++d) {
    int i = d - 1;
    int j = t[i];
    last[j] = d;
    ans += s[i][j];
    for (int k = 0; k < 26; ++k) {
      ans -= c[k] * (d - last[k]);
    }
  }
  return ans;
}

int main() {
  cin >> D;
  cin >> c;
  s.resize(D, vector<LL>(26, 0));
  for (int i = 0; i < D; ++i) cin >> s[i];

  vector<LL> t(D);
  for (int d  =  0; d < D; ++d) t[d] = d % 26;

  LL prev = solve(t);
  int d = 0;
  for (int i = 0; i < 200000; ++i) {
    auto t_bk = t;
    t[d % D] = rand() % 26;

    LL score = solve(t);
    if (score > prev) {
      prev = score;
      t[d % D] = (t[d % D] + 1) % 26;
    } else {
      t = t_bk;
      d = rand() % D;
    }
  }

  for (int x : t) cout << x + 1 << endl;
}


Measured memory_bytes: 3728
#include <stdio.h>

int main(void)
{
	char inst[10];
	int n;
	int t;
	int ans;
	
	while (1){
		int dice[6] = {1, 2, 6, 5, 3, 4};
		
		scanf("%d", &n);
		if (!n)break;
		
		ans = 1;
		for (int i = 0; i < n; i++){
			scanf("%s", inst);
			
			switch (inst[0]){
			  case 'N':
			  	t = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[3];
				dice[3] = t;
				break;
			  case 'E':
			  	t = dice[0];
				dice[0] = dice[5];
				dice[5] = dice[2];
				dice[2] = dice[4];
				dice[4] = t;
				break;
			  case 'W':
			  	t = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[2];
				dice[2] = dice[5];
				dice[5] = t;
				break;
			  case 'S':
			  	t = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[2];
				dice[2] = dice[1];
				dice[1] = t;
				break;
				
			  case 'R':
			  	t = dice[1];
				dice[1] = dice[4];
				dice[4] = dice[3];
				dice[3] = dice[5];
				dice[5] = t;
				break;
				
			  case 'L':
			  	t = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[3];
				dice[3] = dice[4];
				dice[4] = t;
			  break;
			}
			ans += dice[0];
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val S = readLine()!!.split("")
    var pre = ""
    var cnt = -1
    var i = 0
    while (i < S.size) {
        if(S[i].toString() != pre) {
            pre = S[i]
            i += 1
            cnt += 1
        } else {
            pre = S[i] + S[i+1]
            i += 2
            cnt += 1
        }
    }
    println(cnt)
}

Measured memory_bytes: 58400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

vector<pair<ll, ll>>prime_fact(ll n) {
  vector<pair<ll, ll>>res;
  for(int a = 2; a*a <= n; a++) {
    if(n % a != 0) { continue;}
    ll ex = 0;
    while(n % a == 0) {
      ex++;
      n /= a;
    }
    res.push_back({a, ex});
  }
  if(n != 1) { res.push_back({n, 1});}
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<pair<ll, ll>>res = prime_fact(n);
  printf("%d:",n);
  for(auto p: res) {
    int a = p.first;
    int ex = p.second;
    rep(i, ex) {
      printf(" %d", a);
    }
  }
  printf("\n");
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    N = N / 1000;

    string ans = "ABC";
    for (int i = 0; i < N; i++)
    {
        ans[2]++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=15,M=1e5+10;
int a[N][M],n,m,x,c[N],ans,now[N];
void dfs(int id,int val)
{
    if(val>ans) return ;
    if(id>n){
        int flag=1;
        rep(i,1,m) if(now[i]<x) flag=0;
        if(flag) ans=min(ans,val);
        return ;
    }
    dfs(id+1,val);
    for(int i=1;i<=m;++i) now[i]+=a[id][i];
    dfs(id+1,val+c[id]);
    for(int i=1;i<=m;++i) now[i]-=a[id][i];
}
void solve()
{
    cin>>n>>m>>x;
    rep(i,1,n)
    {
        cin>>c[i];
        rep(j,1,m) cin>>a[i][j];
    }
    ans=1e9;
    dfs(1,0);
    if(ans==1e9) ans=-1;
    printf("%d\n",ans);

}
int main()
{
	solve();

}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	const ll mod = 1000000007;
	ll N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	ll col[3] = {0, 0, 0}; // R, B, G
	ll ans = 1;
	rep(i, N) {
		ll cnt = 0;
		rep(j, 3) {
			if(col[j]==A[i]) {
				if(cnt==0) col[j]++;
				cnt++;
			}
		}

		ans *= cnt;
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024