akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct Node{
  int key;
  struct Node *next;
  struct Node *prev;
}Node;

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if (cur == nil) break;
    if(isf > 0) printf(" ");
    printf("%d",cur-> key);
    cur = cur->next;
    isf++;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key,n,i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d",&n);
  init();
  for(i = 0; i < n; i++){
    scanf("%s %d",com,&key);
    if(com[0] == 'i'){ insert(key); np++; size++;}
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F') deleteFirst();
	else if(com[6] == 'L') deleteLast();
      }
      else{
	deleteKey(key);
	nd++;
      }
      size--;
    } 
  }
  printList();
  return 0;
}



Measured memory_bytes: 32976
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 1000000000000000007
#define MOD 1000000007
#define int long// long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};
typedef long long ll;

int ans;

signed main(){

    int n,m,a[111111];
    int dp[111111]={0};
    cin>>n>>m;
    int f[111111]={0};
    rep(i,m){
        cin>>a[i];
        f[a[i]]=1;
    }
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    dp[0]=1;
    rep(i,n-1){
        if(!f[i+1])if(i==0)dp[i+1]=dp[i]%MOD;
        if(!f[i+2])dp[i+2]=(dp[i]+dp[i+1])%MOD;
        //dp[i+2]%=MOD;
    }
    //rep(i,n+1)cout<<dp[i]<<" ";
    //cout<<endl;
    cout<<dp[n]<<endl;
}


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

using namespace std;
using ll = long long;

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

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

  int ans = max(0, c - (a - b));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
    int a,b;
    cin >>a>>b;
    if(a>b){
        cout << "a > b" << endl;
    }
    else if(a==b){
        cout << "a == b" << endl;
    }
    else cout << "a < b" << endl;
}


Measured memory_bytes: 3112
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int five,seven;
  five =0;
  seven =0;
  if(a==5)five++;
  if(a==7)seven++;
  if(b==5)five++;
  if(b==7)seven++;
  if(c==5)five++;
  if(c==7)seven++;
  if(five == 2 && seven == 1){
    cout << "YES" << endl;  
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
from collections import deque
import copy
s = input()
q_ = int(input())
query = [input().split() for _ in range(q_)]
l = deque(s)
flag = 0

for q in query:
    if q[0] == '1':
        flag += 1
        continue
    elif q[0] == '2':
        if (int(q[1]) + flag) % 2 == 1:
            l.appendleft(q[2])
        else:
            l.append(q[2])

if flag % 2 == 1:
    l.reverse()

print(''.join(l))

Measured memory_bytes: 44788
#C
import itertools
import math
n = int(input())
adress = []
dstnc = []
for i in range(n):
    adress.append(list(map(int, input().split())))
p = list(itertools.permutations(adress))
for route in p:
    s = 0
    state = route[0]
    for i in range(1,n):
        s += ((state[0] - route[i][0])**2 + (state[1] - route[i][1])**2)**(1/2)
        state = route[i]
    dstnc.append(s)
print(sum(dstnc)/math.factorial(n))

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

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define ff first
#define ss second
#define err stderr
#define out stdout

typedef long long int ll;
typedef long double ld;
typedef short int sh;

inline void readI(int *i)
{
	register int t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=(t*znak);
}
inline void readUI(int *i)
{
	register int t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=t;
}
inline void readL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak*=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=(t*znak);
}
inline void readUL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=t;
}
inline void writeL(ll l)
{
	if (l==0)
	{
		putchar(48);
	}
	else
	{
		if (l<0)
		{
		   l*=-1;
		   putchar(45);
		}
		int _tab[21];
		int wsk=0;
		while (l>0)
		{
			++wsk;
			_tab[wsk]=(l%10)+48;
			l/=10;
		}
		for (int j=wsk; j>=1; --j)
		{
			putchar(_tab[j]);
		}
	}
}
inline void writeS(string s)
{
	int l=s.length();
	for (int i=0; i<l; ++i)
	{
		putchar(s[i]);
	}
}
inline void space()
{
	putchar(32);
}
inline void endl()
{
	putchar(10);
}

#define debug if(1)
#define debug2 if(1)
#define debug3 if(1)
#define debug4 if(1)
#define MAXN (int)(1e5)+5

int n;
int h[MAXN];
int dp[MAXN];

int main()
{
	readUI(&n);
	for (int i=1; i<=n; ++i)
	{
		readUI(&h[i]);
		if (i==2)
		{
			dp[i]=abs(h[i]-h[i-1]);
		}
		else if (i>2)
		{
			dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
		}
	}
	fprintf (out, "%d\n", dp[n]);
	return 0;
}
/*
*/




Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int a , b , s = 0 ;
    cin >> a >> b ;

    if (a<=b){
            s += b ;
            b-- ;
    }
    else {
            s += a ;
            a-- ;
    }
    if (a<=b){
            s += b ;
            b-- ;
    }
    else {
            s += a ;
            a-- ;
    }
    cout << s ;
    return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;

const int INF = 1e9;
const int MAX = 2500;

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

    vector<vector<int> > list(n, vector<int>(n));
    vector<vector<bool> > flag(n, vector<bool>(n, false));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> list[i][j];
            flag[i][j] = true;
        }
    }
    
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j || j == k || k == i) {
                    continue;
                }
                if (list[i][j] > list[i][k] + list[k][j]) {
                    cout << "-1" << endl;
                    return 0;
                }
                if (list[i][j] == (list[i][k] + list[k][j])) {
                    flag[i][j] = false;
                }
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (flag[i][j]) {
                ans += list[i][j];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4000
#include<bits/stdc++.h>
#define hell (int)(1e9+7)
#define int long long int
#define inf 1000000000000

using namespace std;

void solve(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    while(n>0){
        n/=k;
        ans++;
    }
    cout<<ans;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

int main()
{
    string a;
    cin >> a;
    vector<char> c(a.size());
    for (int i = 0; i < a.size(); i++){
        if(a.at(i)=='1'){
            c.at(i) = '9';
        }
        else if(a.at(i)=='9'){
            c.at(i) = '1';
        }
        else{
            c.at(i) = a.at(i);
        }

        cout << c.at(i);
    }
    cout << endl;

}


Measured memory_bytes: 256
import itertools

n = int(input())
A = [list(map(int, input().strip().split(' '))) for _ in range(n)]
uvc = [] # A list of tuples of start, end, and cost
for i in range(n-1):
    for j in range(i+1, n):
        if A[i][j] >= 0:
            uvc.append((i, j, A[i][j]))

# コストでソート
uvc.sort(key=lambda x: x[2])

uf = list(range(n))

def find_root(x):
    global uf
    if x == uf[x]:
        return x
    else:
        uf[x] = find_root(uf[x])
        return uf[x]

def union(x, y):
    global uf
    uf[find_root(x)] = find_root(y)

def is_same_set(x, y):
    return find_root(x) == find_root(y)

def costs():
    global uvc
    for u, v, c in uvc:
        if not is_same_set(u, v):
            union(u, v)
            yield c
print(sum(itertools.islice(costs(), n - 1)))




Measured memory_bytes: 6252
#include <bits/stdc++.h>
using namespace std;
string solve()
{
	int k;
	string s;
	cin>>k>>s;
	int l=s.length();
	if(k>=l) return s;
	else 
	{
		string ans="";
		for(int i=0;i<k;i++)
		ans+=s[i];
		ans= ans+"...";
		return ans;
	}
}

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

Measured memory_bytes: 3572
a=%w(012345 152304 215043 310542 402351 513240).map{|l|l.chars.map &:to_i}
b=[nil,[0,3,1,4,2,5],a[0],[0,4,3,2,1,5],[0,2,4,1,3,5]]
p (n=$_.to_i)-(1..n).map{l=gets.split
m=a[l.index"Red"].map{|i|l[i]}
(b[m.index"Blue"]||b[m.index"Cyan"]).map{|i|m[i]}}.uniq.size while gets>?1

Measured memory_bytes: 6120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 100000000;
 
ll n,k;
 
int64_t intceil(int64_t a, int64_t b){
    if(a >= 0){
        return (a+b-1)/b;
    }else{
        return a/b;
    }
}
int64_t intfloor(int64_t a, int64_t b){
    if(a < 0){
        return (a-b+1)/b;
    }else{
        return a/b;
    }
}
 
int main(){
    cin>>n>>k;
    vector<int> a(n);
    vector<ll> b(n);
    for(int i=0;i<n;i++){
        ll z;cin>>z;
        a[i] = z;
        b[i] = z*z;
    }
    sort(a.begin(),a.end());
    ll lb = -1e18-1, ub=1e18;
    int i=0;
    while (lb+1<ub){
        bool fl = lb<ub;
        ll mid = (ub+lb)/2;
        ll cnt = 0;//mid以下の個数
        for (int i=0;i<n;i++){
            if (a[i]<0){
                cnt += a.begin()+i - lower_bound(a.begin(), a.begin()+i, intceil(-mid,-a[i]));
            }else if(a[i]>0){
                // cnt+=upper_bound(a.begin(),a.end(),intfloor(mid,a[i]))-a.begin();
                cnt += upper_bound(a.begin(), a.begin()+i, intfloor(mid,a[i])) - a.begin();
            }else{
                if (mid>=0){
                    cnt+=i;
                }
            }
            // if (b[i]<=mid) cnt--;
        }
        // cnt/=2;
        if (cnt>=k){
            ub = mid;
        }else{
            lb = mid;
        }
    }
    cout<<ub<<endl;
}

Measured memory_bytes: 5596
A,B,C=map(int,input().split())
K=int(input())
while(True):
    if A>=B:
        B*=2
        K=K-1
    else: break
while(True):
    if B>=C:
        C*=2
        K=K-1
    else: break
if K<0: print('No')
else: print('Yes')

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#include <iostream> 
using namespace std;
int main()
{
long long int n,d,i,x,y,ans=0,c=0,p;
cin>>n;
cin>>d;
p=d*d;
for(i=0;i<n;i++)
{
cin>>x;
cin>>y;
ans=(x*x)+(y*y);
if(p>=ans)
c++;
}
cout<<c;
return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	float s=(a[1]+a[2])*1.0/2.0;
	for(int i=3;i<=n;i++)
	{
		s=(s+a[i])*1.0/2.0;
	}
	cout<<s;
 } 

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
const int N = 1e5 + 7, MOD = 1e9 + 7;
int n, cnt[N];
void err() { cout << 0; exit(0); }
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
  cin >> n;
  rep(i, 0, n) {
  	int ai; cin >> ai;
  	int tmp = n - 1 - ai;
		if (tmp & 1) err();
		if (++cnt[tmp >> 1] > 1 + (ai > 0)) err();
	}
	int ans = 1;
	rep(i, 0, n >> 1) if ((ans += ans) >= MOD) ans -= MOD;
	cout << ans;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b))
    {
        printf("2\n");
    }
    else if(a==b&&b==c)
        printf("1\n");
    else
       printf("3\n");

       return 0;
}


Measured memory_bytes: 1588
def inpl(): return [int(i) for i in input().split()]
import numpy as np
ans = float('inf')
N = int(input())
a = np.cumsum(np.array(inpl()))
suma = a[-1]
a = np.delete(a, -1)
for i in a:
    ans = min(ans, abs(suma-2*i))
print(ans)

Measured memory_bytes: 32964
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)

	a := make([]int, n)
	b := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		b[i] = a[i]
	}

	var c1 int64
	if a[0] <= 0 {
		c1 = int64(-a[0] + 1)
		a[0] = 1
	}
	c1 += solve(a)

	var c2 int64
	if b[0] >= 0 {
		c2 = int64(b[0] + 1)
		b[0] = -1
	}
	c2 += solve(b)

	fmt.Printf("%d\n", min(c1, c2))
}

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

func solve(a []int) int64 {
	n := len(a)

	var count int64
	for i := 1; i < n; i++ {
		a[i] += a[i-1]
		if a[i-1] < 0 && a[i] <= 0 {
			count += int64(-a[i] + 1)
			a[i] = 1
		} else if a[i-1] > 0 && a[i] >= 0 {
			count += int64(a[i] + 1)
			a[i] = -1
		}
	}

	return count
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h,w;
int main(){
	cin>>h>>w;//输入行和列
	ll sum=0;
	if(h==1){//只有一行 
		sum=1;
	}else if(w==1){
		sum=1;
	}else{//至少有两行 
		ll a=w;
		if(h%2==0){//偶数 
			sum=a*(h/2);
		}else{//奇数 
			sum=a*(h/2);
			if(w%2!=0){
				w++;
			}
			sum=sum+w/2;
		}
	}
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
n, c = gets.split.map(&:to_i)
max_v = 0
already = {0=>0}
n.times{
  w, v = gets.split.map(&:to_i)
  already.map{|aw, av|
    [aw+w, [already[aw+w], av+v].compact.max]
  }.each{|nw, nv|
    if nw<=c
      already[nw] = nv
      max_v = [max_v, nv].max
    end
  }
}
p max_v


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var ans = a.Where(tmp => tmp % 2 == 0).All(tmp => tmp % 3 == 0 || tmp % 5 == 0);
            Console.WriteLine(ans ? "APPROVED" : "DENIED");
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
//define
typedef pair<int,int>pi;
#define int long long
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a){
  int b=0;
  while(a){
    b+=a%10;
    a/=10;
  }
  return b;
}
signed main(){
  int N,M,O,P=0,c=0,co=1,cou=0,minN=mod;
  double D,Do;
  char C,Ca;
  str S,T;
  cin>>N;
  vtr A(N);
  pi pp;
  vector<pair<int,int>>p(0);
  rep(0,N)cin>>A[i];
  sort(all(A));
  rep(0,N-1){
    pp.first=i;
    if(A[i]==A[i+1]){
      c=i;
      while(true){
        co++;
        if(c==N-1)break;
        if(A[c]!=A[c+1])break;
        c++;
      }
      i+=c-i;
      c=0;
    }
    pp.second=co;
    if(p.size()==0)p.pb(pp);
    else if(p[0].second<pp.second){
      p.clear();
      p.pb(pp);
    }
    else if(p[0].second==pp.second){
      p.pb(pp);
    }
    co=1;
  }
  pp.first=N-1;
  pp.second=1;
  if(p.size()==0)p.pb(pp);
  else if(p[0].second<pp.second){
    p.clear();
    p.pb(pp);
  }
  else if(p[0].second==pp.second){
    p.pb(pp);
  }
  for(int i=0;i<p.size();i++)cout<<A[p[i].first]<<endl;
}


Measured memory_bytes: 18676
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    long long a;
    int ans[2] = {0};
    for (int i = 0; i < n; i++) {
        cin >> a;
        ans[a % 2]++;
    }
    if (ans[1]%2)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	string a, b, c;
	int now = 0;
	cin >> a >> b >> c;
	REP(i, INF) {
		if (now == 0) {
			if (a.size() == 0) {
				cout << "A" << endl;
				return 0;
			}
			else {
				now = a[0] - 'a';
				a.erase(a.begin());
			}
		}
		else if (now == 1) {
			if (b.size() == 0) {
				cout << "B" << endl;
				return 0;
			}
			else {
				now = b[0] - 'a';
				b.erase(b.begin());
			}
		}
		else if (now == 2) {
			if (c.size() == 0) {
				cout << "C" << endl;
				return 0;
			}
			else {
				now = c[0] - 'a';
				c.erase(c.begin());
			}
		}
	}
}


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

int main() {
  ll n; cin >> n;
  string a,b; cin >> a >> b;
  string ans; 
  for(ll i = 0; i<n; i++){
    ans+=a[i];
    ans+=b[i];
  }
  cout << ans << endl;
  
  return 0;
}





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

n, k = map(int, readline().split())
x = list(map(int, readline().split()))
p = []
m = [0]
for i, xx in enumerate(x):
    if xx > 0:
        m += x[i:]
        break
    p.append(abs(xx))
p = [0] + p[::-1]
sizep = len(p) - 1
sizem = len(m) - 1
ans = float('inf')
for i in range(k):
    pp = k - i
    mm = i
    if sizep < pp:
        mm += pp - sizep
        pp = sizep
    if sizem < mm:
        pp += mm - sizem
        mm = sizem
    v = p[pp] + m[mm]
    if pp != 0 and mm != 0:
        v += min(p[pp], m[mm])
    ans = min(ans, v)
print(ans)


Measured memory_bytes: 12988
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define maxn 100010
#define inf 1000000007
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int b[4][maxn],a[maxn];
int calc(int x,int y,int z)
{
    int op1=(x<y),op2=(y<z);
    if(op1!=op2)  return inf;
    if(abs(x-y)!=1||abs(y-z)!=1)  return inf;
    if(x<y)  return z/3;
    else     return -x/3;
}
int need[2],have[2];
int vis[maxn];
int main()
{
    n=read();
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=n;j++)  b[i][j]=read();
    }
    for(int i=1;i<=n;i++)  a[i]=calc(b[1][i],b[2][i],b[3][i]);
    for(int i=1;i<=n;i++)
    {
        if(a[i]==inf)
        {
            puts("No");
            return 0;
        }
        if((abs(a[i])&1)!=(i&1))
        {
            puts("No");
            return 0;
        }
    }
    for(int i=1;i<=n;i++)  need[i&1]^=(a[i]<0)^(abs(i-abs(a[i]))/2&1);
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            int x=i,size=0;
            while(!vis[x])
            {
                size++;
                vis[x]=1;
                x=abs(a[x]);
            }
            have[i&1]^=(size&1^1);
        }
    }
    if(need[0]!=have[1]||need[1]!=have[0])
    {
        puts("No");
        return 0;
    }
    puts("Yes");
    return 0;
}

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

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

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
  return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 998244353;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

template<typename T>
struct BIT {
  vector<T> bit;
  int sz;
  BIT(int n) : sz(n+1), bit(n+1) {}
  void add(int i, T x) {
    i += 1;
    while (i < sz) { (bit[i] += x) %= MOD; i += i & -i; }
  }
  T sum(int i) {
    i += 1; T s = 0;
    while (i > 0) { (s += bit[i]) %= MOD; i -= i & -i; }
    return s;
  }
};

template<typename T>
struct RangeAdd {
  BIT<T> bit1, bit2;

  RangeAdd(int n): bit1(BIT<T>(n+1)), bit2(BIT<T>(n+1)) {
  }

  // [l, r)にvalを加算
  void add(int l, int r, T val) {
    bit1.add(l, (MOD-l*val%MOD)%MOD);
    bit1.add(r, r*val%MOD);
    bit2.add(l, val%MOD);
    bit2.add(r, (MOD-val)%MOD);
  }

  // [0, idx)の和を取得
  T sum(int idx) {
    return (bit1.sum(idx) + idx * bit2.sum(idx) % MOD) % MOD;
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, k; cin >> n >> k;

  RangeAdd<ll> bit(n+1);
  bit.add(0, 1, 1);

  vector<bool> v(n);
  REP(i, k) {
    int l, r; cin >> l >> r;
    r++;
    FOR(j, l, r) {
      v[j] = true;
    }
  }
  //cout << v << endl;

  vector<P> kukan;
  int nowl = -1, nowr = -1;
  REP(i, n) {
    if(v[i]) {
      if(nowl == -1) {
        nowl = i;
        nowr = i+1;
      } else {
        nowr++;
      }
    } else {
      if(nowl != -1) {
        kukan.push_back({nowl, nowr});
        nowl = -1;
        nowr = -1;
      }
    }
  }
  if(nowl != -1) {
    kukan.push_back({nowl, nowr});
  }


  REP(i, n-1) {
    ll val = 1;
    if(i != 0) val = (bit.sum(i+1) - bit.sum(i) + MOD) % MOD;
    //cout << val << endl;
    REP(j, SZ(kukan)) {
      if(i + kukan[j].first < n) {
        bit.add(i + kukan[j].first, min(n, i + kukan[j].second), val);
      }
    }

  }

  cout << (bit.sum(n) - bit.sum(n-1) + MOD) % MOD << endl;


  return 0;
}

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

int main(){
    string s;
    while(cin >> s){
        char res = 'd';
        for(int i=0; i<3; i++){
            int b=i*3;
            if(s[b]==s[b+1] && s[b]==s[b+2] && s[b]!='s') res = s[b];
            if(s[i]==s[i+3] && s[i]==s[i+6] && s[i]!='s') res = s[i];
        }
        if(s[4]!='s'){
            if((s[0]==s[4] && s[0]==s[8]) || (s[2]==s[4] && s[2]==s[6])){
                res = s[4];
            }
        }
        cout << res << endl;
    }
    return 0;
}



Measured memory_bytes: 3176
def dfs(c, x, y, w, h):
    c[y][x] = -1

    for i in range(-1, 2):
        for j in range(-1, 2):
            if i == 0 and j == 0:
                continue
            x_ = x + i
            y_ = y + j
            if 0 <= x_ < w and 0 <= y_ < h and c[y_][x_] == 1:
                dfs(c, x_, y_, w, h)

def solve(w, h):
    c = []
    ans = 0

    for _ in range(h):
        c.append(list(map(int, input().split())))

    for y in range(h):
        for x in range(w):
            if c[y][x] == 1:
                ans += 1
                dfs(c, x, y, w, h)

    print(ans)

if __name__ == "__main__":
    import sys
    sys.setrecursionlimit(10000)
    while True:
        w, h = map(int, input().split())
        if w * h == 0:
            break
        solve(w, h)



Measured memory_bytes: 8080
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15

signed main(){
  fast;
  int n,  k;
  cin>>n>>k;
  string s; cin>>s;
  s[k-1] = char((int)s[k-1] + 32);
  cout<<s<<endl;

}
  


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

const ll INF = 1LL << 60;

ll N;
vector<ll> A;
int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    map<ll, ll> mp;
    rep(j, N) {
        mp[j + 1 - A[j]]++;
    }

    // for (auto iter = mp.begin(); iter != mp.end(); iter++) {
    //     cout << iter->first << " " << iter->second << endl;
    // }

    ll ans = 0;
    rep(i, N) {
        ll target = (i + 1) + A[i];
        ans += mp[target];
    }
    cout << ans << endl;
}

Measured memory_bytes: 27544
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
S = 0
ans = 0
for i in range(M):
  S += B[i]
  if S > K:
    b = i - 1
    S -= B[i]
    break
  else:
    ans += 1
    if i==M-1:
      b = M-1
if b==0:
  ans = 0
  S = 0
  for a in A:
    if S + a <= K:
      S += a
      ans += 1
    else:
      break
  if S + B[0]<=K:
    ans+=1
  print(ans)
else:
  a = 0
  max_ans = ans
  while a<N:
    if S + A[a] <= K:
      S += A[a]
      ans += 1
      a += 1
    else:
      break
  max_ans = max(max_ans, ans)
  for j in range(b, -1, -1):
    S -= B[j]
    ans -= 1
    while a<N:
      if S + A[a] <= K:
        S += A[a]
        ans += 1
        a += 1
      else:
        break
      
    max_ans = max(max_ans, ans)
  print(max_ans)

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

using namespace std;

#define MAX_N 1000001
 
int n,k,sa[MAX_N];
int rank[MAX_N],tmp[MAX_N];
 
bool compare_sa(int i,int j){
    if(rank[i] != rank[j]){
        return rank[i] < rank[j];
    }else{
        int ri = i + k <= n ? rank[i+k] : -1;
        int rj = j + k <= n ? rank[j+k] : -1;
        return ri < rj;
    }
}

void construct_sa(string &S,int *sa){
    n = S.length();
   
    for(int i = 0 ; i <= n ; i++){
        sa[i] = i;
        rank[i] = i < n ? S[i] : -1;
    }
 
    for(k = 1 ; k <= n ; k *= 2){
        sort(sa,sa+n+1,compare_sa);
     
        tmp[sa[0]] = 0;
        for(int i = 1 ; i <= n ; i++){
            tmp[sa[i]] = tmp[sa[i-1]] + (compare_sa(sa[i-1],sa[i]) ? 1 : 0);
        }
        for(int i = 0 ; i <= n ; i++){
            rank[i] = tmp[i];
        }
    }
}
 
bool contain(string &S,int *sa,string &T){
    int a = 0, b = S.length();
    while(b - a > 1){
        int c = (a + b) / 2;
        if(S.compare(sa[c],T.length(),T) < 0) a = c;
        else b = c;
    }
    return S.compare(sa[b],T.length(),T) == 0;
}
 
int main(){
    ios::sync_with_stdio(0);
    
    int Q,l;
    string S,T;
    cin >> S >> Q;
    construct_sa(S,sa);
    l = S.size();
    while(Q--){
        cin >> T;
        if(l < T.size()){ cout << '0' << '\n'; continue; }
        cout << (contain(S,sa,T) ? '1' : '0') << '\n';
    }
    return 0;
}

Measured memory_bytes: 13920
print((lambda i, j, k: "{} {} {}".format(i, j, k))(*(lambda n, y: next(([i, j, k] for i in range(n + 1) for j in range(n - i + 1) for k in [n - i - j] if i * 10000 + j * 5000 + k * 1000 == y), [-1, -1, -1]))(*[int(s) for s in input().split(" ")])))

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, M; cin >> N >> M;
	string s; cin >> s;
	vector<int>v(s.size());
	v[N] = N;
	rrep(i, 0, N) {
		if (s[i] == '1') {
			v[i] = v[i + 1];
		}
		else {
			v[i] = i;
		}
	}
	dump(v);

	vector<int>ans;
	int cur = N;
	while (cur != 0) {
		int nxt = max(0ll, cur - M);
		int nnxt = v[nxt];
		if (cur == nnxt) {
			cout << -1 << endl; return 0;
		}
		ans.eb(cur - nnxt);
		cur = nnxt;
	}
	reverse(all(ans));
	rep(i, 0, ans.size()) {
		cout << ans[i] << (i == ans.size() - 1 ? '\n' : ' ');
	}

	return 0;
}


Measured memory_bytes: 2248
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}

int main(){
  int a = getint(), b = getint(), c = getint();
  if(a == b && b == c) puts("Yes");
  else puts("No");
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  // vector<char> v(s.begin(),s.end());
  int i = 0,cnt_e = 0 ,cnt_o = 0;
  for(char c : s){
    if(i%2 == 0){
      if(c == '0'){
        cnt_o++;
      }else{
        cnt_e++;
      }
    }else{
      if(c == '0'){
        cnt_e++;
      }else{
        cnt_o++;
      }
    }
    i++;
  }
  cout << min(cnt_o,cnt_e) << endl;
}

Measured memory_bytes: 512
/*
 * Author: Dumbear
 * Created Time:  2011/8/31 13:31:27
 * File Name: E.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

int n, m, r, xa[100010], ya[100010], xb[100010], yb[100010];
vector<double> vec[10010];

bool solve();

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

bool solve() {
    scanf("%d%d%d", &n, &m, &r);
    if (n == 0 && m == 0 && r == 0)
        return false;
    for (int i = 0; i < n; ++i)
        scanf("%d%d", &xa[i], &ya[i]);
    for (int i = 0; i <= 10000; ++i)
        vec[i].clear();
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &xb[i], &yb[i]);
        vec[xb[i]].push_back((double)yb[i]);
    }
    for (int i = 0; i <= 10000; ++i)
        sort(vec[i].begin(), vec[i].end());
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int x1 = xa[i] - 4 * r, x2 = xa[i] + 4 * r;
        for (int j = x1; j <= x2; ++j) {
            double d = sqrt(abs((4.0 * r) * (4.0 * r) - (double)(j - xa[i]) * (j - xa[i])));
            double y1 = ya[i] - d, y2 = ya[i] + d;
            ans += upper_bound(vec[j].begin(), vec[j].end(), y2 + 1e-8) - lower_bound(vec[j].begin(), vec[j].end(), y1 - 1e-8);
        }
    }
    printf("%d\n", ans);
    return true;
}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 2e6 + 10;
const ll mod = 1e9 + 7;
int n, m, k;
ll a[3010][3010];
ll dp[3010][3010][4];
int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= k; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		scanf("%lld", &a[x][y]);
	}
	for (int i = 0; i <= n; i++)for (int j = 0; j <= m; j++)for (int x = 0; x <= 3; x++)dp[i][j][x] = -inf;
	for (int i = 0; i <= n; i++)for (int j = 0; j <= m; j++)dp[i][j][0] = 0;
	dp[1][1][0] = 0; dp[1][1][1] = a[1][1];
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][0]);
			for (int x = 0; x <= 3; x++)dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][x]), dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][x] + a[i][j]);
			for (int x = 1; x <= min(j, 3); x++) {
				dp[i][j][x] = max(dp[i][j][x], max(dp[i][j - 1][x], dp[i][j - 1][x - 1] + a[i][j]));
			}
		}
	}
	for (int i = 0; i <= 3; i++)ans = max(ans, dp[n][m][i]);
	printf("%lld\n", ans);
	return 0;
}


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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(all(a));

    int ans = p - 1;
    a.resize(n - p + 1);
    ll s = 0;
    for (int i = n - p; i >= 0; --i) {
        if (i == n - p || a[i] == a[i + 1]) {
            ++ans;
        } else {
            if (a[i] + m < a.back()) {
                break;
            }
            ll lt = (a[i] + m) * (n - p - i) - s;
            if (lt < (v - p - i) * m) {
                break;
            }
            ++ans;
        }
        s += a[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<random>
using namespace std;

int main(){

  int s3x[12] = {0, 1, 0, -1, 1, 1, -1, -1, 0, 2, 0, -2};
  int s3y[12] = {1, 0, -1, 0, 1, -1, 1, -1, 2, 0, -2, 0};

  vector< vector<int> > p( 10, vector<int> (10, 0) );
  int x, y, s;
  int cnt = 0;
  int mx = 0;

  while( scanf("%d,%d,%d", &x, &y, &s) != EOF ){
    p[ x ][ y ]++;
    mx = max(mx, p[x][y]);
    cnt++;
    for(int i=0; i<s*4; i++){
      int tx = x + s3x[i];
      int ty = y + s3y[i];
      if( tx < 0 || ty < 0 || tx >= 10 || ty >= 10 ) continue;
      p[tx][ty]++;
      cnt++;
      mx = max(mx, p[tx][ty]);
    }
    // cerr << cnt << endl;
  }
  int ans = 0;
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      if( p[i][j] == 0 ) ans++;
    }
  }
  cout << ans << endl;
  cout << mx << endl;
  return 0;
}




// EOF

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

typedef long long ll;

ll getnum(ll A, ll B){
  
  if(B%A==0) return B/A*A;
  
  return B/A*A+A;
}

ll n, A[100005];

int main(){
  
  cin>>n;
  
  for(int i=0;i<n;i++) cin>>A[i];
  
  if(A[n-1]!=2){
    cout<<-1<<endl;
    return 0;
  }
  
  ll minv=2, maxv=3;
  
  for(int i=n-2;i>=0;i--){
    
    minv=getnum(A[i], minv);
    maxv=getnum(A[i], maxv+1)-1;
    
    if(minv>maxv){
      cout<<-1<<endl;
      return 0;
    }
    
  }  
  
  cout<<minv<<' '<<maxv<<endl;
  
  return 0;
}


Measured memory_bytes: 1024
using System;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int ret = 0;
            for(int i = 103; i <= a; i += 2)
            {
                int cnt = 0;
                for(int j = 1; j * j <= i; j += 2)
                {
                    if (i % j != 0) continue;
                    if (j * j == i) cnt++;
                    else cnt += 2;
                }
                if (cnt == 8) ret++;
            }
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 13140
#from functools import lru_cache
import sys
from itertools import product,combinations,accumulate
from functools import reduce,lru_cache
import heapq

def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def list_t(l): return vfunc(lambda *args:args)(*l)

def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

s = reader()[0][0]
score = [0]
for i in s:
    if i in 'ACGT':score.append(score[-1]+1)
    else:score.append(0)
print(max(score))

Measured memory_bytes: 67156
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int64
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)

	var index int64
	var stack []string
	stack = make([]string, 3)
	stack[1] = s[0:1]
	stack[2] = s[1:2]
	answer := 0

	for index = 2; index < n; index++ {
		stack[0] = stack[1]
		stack[1] = stack[2]
		stack[2] = s[index : index+1]
		if strings.Join(stack, "") == "ABC" {
			answer++
		}
	}

	fmt.Println(answer)
}

func scanNums(len int64) (nums []int64) {
	var num int64
	var i int64
	for i = 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);;
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a>b){
            System.out.println("a"+" > "+"b");
        }else if(a<b) {
            System.out.println("a"+" < "+"b");
        }else{
            System.out.println("a"+" == "+"b");
        }
    }

}



Measured memory_bytes: 26396
package main

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

var sc = bufio.NewScanner(os.Stdin)
var llist [9923456]int
var llistIdx int

func main() {
	scanInit()

	k := nextInt()

	for i := 1; i < 10; i++ {
		push(i)
	}

	// BFS
	llistIdx = 0
	for queue.Len() > 0 {
		now := pop()
		llist[llistIdx] = now
		llistIdx++

		if keta(now) < 10 {
			base := now % 10
			push(now*10 + base)
			if base == 0 {
				push(now*10 + 1)
			} else if base == 9 {
				push(now*10 + 8)
			} else {
				push(now*10 + base - 1)
				push(now*10 + base + 1)
			}
		}

	}

	anslist := llist[:llistIdx]
	sort.Ints(anslist)

	fmt.Println(anslist[k-1])

}

var queue = list.New()

func push(a int) {
	queue.PushBack(a)
}
func pop() int {
	e := queue.Front()
	queue.Remove(e)
	return e.Value.(int) // 明示的キャストが必要
}

// 正数の桁数を返す
func keta(n int) int {
	keta := 0
	if n == 0 {
		return 1
	}
	for n > 0 {
		keta++
		n /= 10
	}
	return keta
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main() {
  int n;
  cin >> n;
  char color;
  string ans = "Three";
  
  for (int i = 0; i < n; i++) {
    cin >> color;
    if (color == 'Y'){
      ans = "Four";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int N, X;

llong D;

llong x[100200];

int main() {
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}

	sort(x, x + N);

	if (N != 1) {
		D = x[1] - x[0];

		for (int i = 1; i < N - 1; i++) {
			D = gcd(D, x[i + 1] - x[i]);
		}

		

		llong ans = gcd(D, abs(X - x[0]));

		

		

		cout << ans;
	}

	else {
		cout << abs(X - x[0]);
	}

	
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int main() {
  int n,k;
  S2(n,k);
  if(n % k) P(1);
  else P(0);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

void solve() {
    int n, m;
    std::cin >> n >> m;

    int max = 0, sum = 0;
    while (m--) {
        int a, b;
        std::cin >> a >> b;

        int c = std::max(0, n - a);
        sum += c;
        max = std::max(max, c);
    }

    std::cout << sum - max << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int y, m, d;
        scanf("%d %d %d", &y, &m, &d);
        int ans = 0;
        while(y != 1000 || m != 1 || d != 1){
            d++;
            if(y%3 && m%2 == 0){
                if(d > 19) d = 1, m++;
            }else {
                if(d > 20) d = 1, m++;
            }
            if(m > 10) m = 1, y++;
            ans++;
        }
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 3216
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
//#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


//namespace mp = boost::multiprecision;

//using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main(){
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	vector<int>len(N);
	rep(i, N) {
		cin >> len[i];
	}
	int ans = 1e6;
	int i = 0;
	while (i < pow(4, N)) {
		deque<int>tmp;
		int a=0, b=0, c=0;
		int tmpi = i;
		while (tmpi > 0) {
			tmp.push_front(tmpi % 4);
			tmpi /= 4;
		}
		while (tmp.size() <N) {
			tmp.push_front(0);
		}
		
		int count = 0;
		rep(j, N) {
			if (tmp[j] == 1) {
				if (a != 0) {
					count++;
				}
				a += len[j];
			}	
			else if (tmp[j] == 2) {
				if (b != 0) {
					count++;
				}
				b += len[j];
			}
			else if (tmp[j] == 3) {
				if (c != 0) {
					count++;
				}
				c += len[j];
			}
		}
		if (a != 0 && b != 0 && c != 0) {
			
			a = abs(A - a);
			b = abs(B - b);
			c = abs(C - c);
			ans = min(ans, a + b + c + count * 10);
		}
		i++;
	}
	cout << ans << endl;


}


Measured memory_bytes: 256