akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
//const int mod = 1e9 + 7;
const int mod = 100000;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


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




/* main */
int ceil(int a, int b){
    if(a % b == 0) return a /b;
    else return a /b + 1;
}


signed main(){

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

    
    int a, b, c; cin >> a >> b >> c;

    print(b - a == c - b ? "YES" : "NO");




    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










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

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

mod=10**9+7

D=[]

for i in range(1,N):
    D.append(X[i]-X[i-1])

FACT=[1]
for i in range(1,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)

INV2=pow(2,mod-2,mod)

K=[1]

for i in range(2,10**5+3):
    K.append(K[-1]+pow(i,mod-2,mod))


ANS=0

for i in range(N-1):
    ANS=(ANS+K[i]*D[i])%mod
    
print(ANS*FACT[N-1]%mod)


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> left(n);
    if (s[0] == 'W') left[0] = 1;
    for (int i = 1; i < n; ++i) left[i] = s[i] == 'W' ? left[i - 1] + 1 : left[i - 1];
    vector<int> right(n);
    if (s[n - 1] == 'E') right[0] = 1;
    for (int j = 1; j < n; ++j) right[j] = s[n - j - 1] == 'E' ? right[j - 1] + 1 : right[j - 1];
    int ans = 1001001001;
    for (int k = 0; k < n; ++k) {
        int cnt = 0;
        if (k != 0) cnt += left[k - 1];
        if (k != n - 1) cnt += right[n - k - 1];
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int ans = 0;
    for (int l = 0; l <= k; l++) {
        for (int r = 0; r <= k-l; r++) {
            if (l+r > n) continue;
            int d = k-l-r;
            int now = 0;
            vector<int> s;
            for (int i = 0; i < l; i++) {
                now += v[i];
                s.push_back(v[i]);
            }
            for (int i = n-r; i <= n-1; i++) {
                now += v[i];
                s.push_back(v[i]);
            }
            sort(s.begin(), s.end());
            rep(i,d) {
                if (i >= s.size()) break;
                if (s[i] > 0) break;
                now -= s[i];
            }
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
a,b,c,d=list(map(str,input()))

def solve(m,n):
    if eval(m)==7:
        print(m+"=7")
        exit(0)
    elif n<7:
        solve(m,n+2)
        solve(m[:n]+"-"+m[n+1:],n+2)

solve(a+"+"+b+"+"+c+"+"+d,1)


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

sum = 0
ans = None

for a in A:
    sum = sum + a
    if H < a:
        ans = "Yes"
        break
if H > sum and ans == None:
    ans = "No"
else:
    ans = "Yes"

print(ans)

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

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif
/*---------------------------Defines----------------------*/
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
/*-----------------------Modular Arithmetic---------------*/
inline ll add(ll x,ll y,ll mod){x+=y; if(x>=mod) return x-mod; return x;}
inline ll sub(ll x,ll y,ll mod){x-=y; if(x<0) return x+mod; return x;}
inline ll mul(ll x,ll y,ll mod){return (x*1ll*y)%mod;}
inline ll power(ll x,ll y,ll mod){ll ans=1; while(y){if(y&1) ans=mul(ans,x,mod); x=mul(x,x,mod); y>>=1;} return ans;}
inline ll inv(ll x,ll mod){return power(x,mod-2,mod);}
/*-----------------------------Code begins----------------------------------*/

const ll INF = 1e18;

void solve(){
    ll a,b;cin>>a>>b;
    cout<<a*b<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);
    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int sum,n,d,x,day;
int main()
{
	scanf("%d%d%d",&n,&d,&x);
	for(int i=1;i<=n;i++)
	{
		int t;day=1;
		scanf("%d",&t);
		while(day<=d)
		{
			day+=t;
			sum++;
		}	
	}
	printf("%d",sum+x);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "stdc++.h"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = max(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

	char a, b;
	cin >> a >> b;
	string s(b - '0', a);
	string t(a - '0', b);
	cout << min(s, t) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl a(n);
  ll sum=0;
  rep(i,n){
    cin >> a[i];
    a[i]-=i+1;
    sum +=a[i];
  }
  /*rep(i,n){
    cout << a[i] << endl;
  }*/
  sort(a.begin(),a.end());
  ll t;
  if(n%2==0){
    t=a[n/2];
  }
  else{
    t=a[(n+1)/2-1];
  }
  //cout << t << endl;
  ll ans=0;
  rep(i,n){
    ans +=abs(a[i]-t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int n,q;
char a[200005],b[200005];
string s;
int sol(int x,int u)
{
    x--;
    for(int i=1;i<=q;i++)
        if(a[i]==s[x])
    {
        if(b[i]=='L')
        {
            x--;
            if(x<0&&!u) return 1;
        }
        else
        {
            x++;
            if(x==n&&u) return 1;
        }
    }
    return 0;
}
int main()
{
    cin>>n>>q;
    cin>>s;
    for(int j=1;j<=q;j++)
        cin>>a[j]>>b[j];
    int rez=n+1,rez1=0;
    for(int step=1<<17;step;step>>=1)
        if(rez-step>=0&&sol(rez-step,1)) rez-=step;
    for(int step=1<<17;step;step>>=1)
        if(rez1+step<=n&&sol(rez1+step,0)) rez1+=step;
    if(rez>rez1)
    cout<<rez-rez1-1;
    else cout<<0;
}


Measured memory_bytes: 900
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    n, m = read_ints()
    X = read_ints()
    Y = read_ints()
    areaX = [0]*n
    modulo = 10**9+7
    for i in range(1, len(X)):
        areaX[i] = (areaX[i-1]+i*(X[i]-X[i-1]))%modulo
    areaY = [0]*m
    for i in range(1, len(Y)):
        areaY[i] = (areaY[i-1]+i*(Y[i]-Y[i-1]))%modulo
    return (sum(areaX)*sum(areaY))%modulo


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 92504
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main() {
    int a, b;
    top = 0;
    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b=pop();
            push(a+b);
            
        } else if (s[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        } else if (s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        } else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    
    return 0;
}

Measured memory_bytes: 1848
n = gets.to_i
ary = gets.strip.split.map(&:to_i)
cnt = 0
ary.each_with_index do |p, i|
  break if i+2 == ary.length
  new_ary = ary[i], ary[i+1], ary[i+2]
  cnt+=1 if new_ary.max == new_ary[0] && new_ary.min == new_ary[2] || new_ary.min == new_ary[0] && new_ary.max == new_ary[2]
end
puts cnt

Measured memory_bytes: 1788
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(void)
{
	int a,b,C;
	double S,L,h,d;
	cin>>a>>b>>C;
	d=(acos(-1.0)*C)/180.0;//acos()は、余弦を表すcos()の逆関数
	S=a*b*sin(d)/2.0;
	L=a+b+sqrt(a*a+b*b-2*a*b*cos(d));
	h=b*sin(d);
	printf("%lf\n%lf\n%lf\n",S,L,h);
	return 0;
}


Measured memory_bytes: 3364
var
	n,A,j,k,x:Longint;
	dp:array[1..51,-5000..5000]of int64;
begin
	read(n,A);
	dp[1,0]:=1;
	for k:=1 to n do begin
		read(x);
		dec(x,A);
		for j:=-5000 to 5000 do begin
			inc(dp[k+1,j],dp[k,j]);
			if(j+x<=5000)and(j+x>=-5000)then inc(dp[k+1,j+x],dp[k,j]);
		end;
	end;
	writeln(dp[n+1,0]-1);
end.



Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  string s,t;
  cin >>s>>t;
  
  int ans=0;
  
  rep(i,3) {
    if(s[i]==t[i]) ans++;
  }
  
  cout <<ans <<endl;
  
}

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

const char stand = '0';
const char handstand = '1';
int N, K;
string S;

int main(void) {
  cin >> N >> K;
  cin >> S;

  vector<int> nums;
  char cur = handstand;
  int cnt = 0;

  // C0: chunk of 0
  // C1: chunk of 1
  // make C1, C0, C1, C0...C1
  for (int i = 0; i < N; i++) {
    if (S[i] == cur) {
      cnt++;
    } else {
      nums.push_back(cnt);
      cnt = 1;
      cur = S[i];
    }
  }
  if (cnt != 0)
    nums.push_back(cnt);

  if (nums.size() % 2 == 0)
    nums.push_back(0);

  // C1, C0, C1, C0...C1
  const int addindex = 2 * K + 1;
  int left = 0, right = 0;
  int tmp = 0;

  int ans = 0;
  for (int i = 0; i < nums.size(); i += 2) {

    int nextleft = i;
    int nextright = min(i + addindex, (int)nums.size());

    while (left < nextleft) {
      tmp -= nums[left++];
    }
    while (right < nextright) {
      tmp += nums[right++];
    }

    ans = max(ans, tmp);
  }

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


Measured memory_bytes: 1148
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int,read().split())

res = [(0,-1)]+[(a[i],i) for i in range(n)]
res.sort()

ans = [0]*n
num = 0
cnt = 0
midx = idx = n-1
v = res[-1][0]

#print(res)
while res:
    #print(num,cnt,idx)
    ans[midx] += (v-res[-1][0])*cnt
    v = res[-1][0]

    while res and res[-1][0]==v:
        ai,idx = res.pop()        
        cnt += 1
    midx = min(midx,idx)

print(*ans,sep="\n")







Measured memory_bytes: 24740
#include<stdio.h>
#include<stdlib.h>
#define N 256
#define O 0
#define S 6

typedef struct Node {
  int x;
  struct Node *prev;
  struct Node *next;
} Node;

Node *head,*tail;

void dump(void);
void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);

int main(int argc,char **argv) {

  int i,n,x;
  char buf[N],tmp[N];
    scanf("%d\n",&n);
  for (i=O;i<n;++i) {
    fgets(buf,N, stdin);
    if (buf[O]=='i' || buf[S]==' '){
      sscanf(buf,"%s %d",tmp,&x);
      if (buf[0]=='i'){
	insert(x);
      }
      else{
	delete(x);
      }
    }
    else if(buf[S]=='F'){
      deleteFirst();
    }
    else if (buf[S]=='L'){
      deleteLast();
    }
  }
  dump();
  return O;
}

void dump(){
  int m=O;
  Node *p=head;
  while (p!=NULL) {
    if (m==O){
      printf("%d",p->x);
    }
    else{
      printf(" %d",p->x);
    }
    ++m;
    p=p->next;
  }
  printf("\n");
}

void insert(int x) {
  Node *nod=malloc(sizeof(Node));;
  nod->x=x;
  nod->prev=NULL;
  nod->next=NULL;

  if(head==NULL) {
    head=nod;
    tail=nod;
  }
  else{
    nod->next=head;
    head->prev=nod;
    head=nod;
  }
}

void delete(int x) {
  Node *p=head;
  int flg=O;

  while(flg==O && p!=NULL){
    if(p->x==x){
      Node *c=p;
      if(c->prev!= NULL) {
        p->prev->next=c->next;
      }
      else{
        head=c->next;
      }
      if(c->next!=NULL){
        p->next->prev=c->prev;
      }
      else{
        tail=c->prev;
      }
      flg=1;
    }
    else{
      p=p->next;
    }
  }
}
void deleteFirst() {
  if(head==tail) {
    head = NULL;
    tail = NULL;
  } else if(head!= NULL) {
    if (head->next!=NULL){
      head->next->prev=NULL;
    }
    head=head->next;
  }
}

void deleteLast(){
  if(head==tail){
    head=NULL;
    tail=NULL;
  }
  else if(tail!=NULL){
    if(tail->prev!= NULL){
      tail->prev->next=NULL;
    }
    tail=tail->prev;
  }
}





Measured memory_bytes: 36076
n = input()
op_cnt = len(n) - 1  # すき間の個数
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き

    formula = ""
    for p_n, p_o in zip(n, op + [""]):  # 少々モヤッとする
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main() {
	string s;
	vector<int> a(4);
	int A,B,C,D;
	char P,Q,R;
	cin>>s;
	for(int i=0;i<4;i++){
		a.at(i)=ctoi(s.at(i));
	}
	

	A=a.at(0);
	B=a.at(1);
	C=a.at(2);
	D=a.at(3);
	
	if(A+B+C+D==7){
	    P='+';
	    Q='+';
	    R='+';
	}
	else if(A-B+C+D==7){
	    P='-';
	    Q='+';
	    R='+';
	}
	else if(A+B-C+D==7){
	    P='+';
	    Q='-';
	    R='+';
	}
	else if(A+B+C-D==7){
	    P='+';
	    Q='+';
	    R='-';
	}
	else if(A-B-C+D==7){
	    P='-';
	    Q='-';
	    R='+';
	}
	else if(A+B-C-D==7){
	    P='+';
	    Q='-';
	    R='-';
	}
	else if(A-B+C-D==7){
	    P='-';
	    Q='+';
	    R='-';
	}
	else if(A-B-C-D==7){
	    P='-';
	    Q='-';
	    R='-';
	}
	cout<<A<<P<<B<<Q<<C<<R<<D<<"="<<7<<endl;
	return 0;
}

Measured memory_bytes: 256
from math import inf
from random import randint,random
import time
START=time.time()
PROB=0.9999

def f(a,d,T):
    try:
        return T[d:].index(a)+d
    except ValueError:
        return len(T)

from random import randint
A=26

D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))
 
def g(d,q,S,C,T):
    p=T[d]

    a=f(p,d+1,T)
    b=f(q,d+1,T)
    
    Y=0
    h=L[d-1][p]
    for i in range(d,a):
        h+=1
        Y+=h-L[i][p]
        
    m=0
    Z=0
    for j in range(d,b):
        Z-=m-L[j][q]
        m+=1
        
    return (S[d][q]-S[d][p])+Z*C[q]-Y*C[p]

T=[0]
L=[[0]*(A+1) for _ in range(D+1)]
for d in range(1,D+1):
    M=-inf
    E=0

    for j in range(1,A+1):
        X=0
        for k in range(1,A+1):
            if j!=k:
                X-=C[k]*L[d][k]
                
        if M<=X+S[d][j]:
            M=X+S[d][j]
            E=j

    T.append(E)
    for j in range(1,A+1):
        if j!=E:
            L[d][j]=L[d-1][j]+1
        else:
            L[d][j]=0

while time.time()-START<=1.72:
    e=randint(1,D)
    q=randint(1,A)

    V=g(e,q,S,C,T)
    if V>0 or random()>PROB:
        p=T[d]

        a=f(p,d+1,T)
        b=f(q,d+1,T)
        
        h=L[d-1][p]
        for i in range(d,a):
            h+=1
            L[i][p]=h

        m=0
        for j in range(d,b):
            L[j][q]=m
            m+=1
        T[d]=q

for i in range(1,D+1):
    print(T[i])


Measured memory_bytes: 88632
from collections import defaultdict

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

if len(set(L)) == 1:
    print(N//2)
    exit()
if N == 2:
    print(0)
    exit()


d_even = defaultdict(int)
d_odd = defaultdict(int)

for i in range(N):
    v = L[i]
    if i % 2 == 0:
        d_even[v] += 1
    else:
        d_odd[v] += 1

l_even = sorted(d_even.items(), key=lambda x: -x[1])
l_odd = sorted(d_odd.items(), key=lambda x: -x[1])

if l_even[0][0] != l_odd[0][0]:
    print(N - l_odd[0][1] - l_even[0][1])
    exit()

ans = N
ans = min(ans, N - l_odd[0][1] - l_even[1][1])
ans = min(ans, N - l_odd[1][1] - l_even[0][1])
print(ans)


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

#define int long long
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
//const int MOD = 10000;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
int gcd(int x,int y){if(y==0) return x; return gcd(y, x%y);}
int lcm(int x,int y){return x/gcd(x,y)*y;}

signed main() {
    long double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    
    if(x < a*b/2){
        printf("%.10Lf\n", 90 - atan(2*x/(b*b))*180/M_PI);
    }else{
        printf("%.10Lf\n", atan(2*(b-x/a)/a)*180/M_PI);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int H,W,i,k;
  while(true)
  {
    cin>>H>>W;
      if(H==0 && W==0){break;}
    for(i=0;i<H;i++)
    {
      for(k=0;k<W;k++)
      {
        if(k==0 || k==W-1 || i==0 || i==H-1)
        {
        cout<<"#";
      }else{
        cout<<".";
      }
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3072
ans = [1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]
print(ans[int(input())-1])

Measured memory_bytes: 9380
n = int(input())
s = list(input())
ans = 10**6
w = [0]
for i in range(n):
    w.append(w[i] + (s[i] == "."))

for i in range(n + 1):
    ans = min(ans, i - w[i] + (w[-1] - w[i]))

print(ans)


Measured memory_bytes: 18408
from collections import deque

N, M = map(int, input().split())
G = [[] for _ in range(N)]
R = [-1] * N
# D = [-1] * N
# D[0] = 0

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)
    G[b].append(a)

d = deque()
d.append(0)

while d:
    v = d.popleft()
    for g in G[v]:
        if g != 0 and R[g] == -1:
            d.append(g)
            R[g] = v + 1

if -1 in R[1:]:
    print("No")
else:
    print("Yes")
    for r in R[1:]:
        print(r)


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

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  if (a <= c and c <= b or b <= c and c <= a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  if (N%1000 == 0) {
    cout << 0 << endl;
  }
  else { 
    cout << (N/1000)*1000-N+1000 << endl;
  } 
    
}

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

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue
#define    nl           "\n"
#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mpi map<int,int>
#define mpl map<ll,ll>
#define umpi unordered_map<int,int>
#define umpl unordered_map<ll,ll>
#define si set<int>
#define sl set<ll>
#define msi multi_set<int>
#define msl multi_set<ll>

#define mem(v,i) memset(v,i,sizeof(v)) 


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)
#define tc int t;cin>>t;while(t--)


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

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}


int main()
{   
    
    fast
    int n,d;
    cin>>n>>d;
    double x,y,dis;
    int ans=0;
    rep(i,n){
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=d)
        ans++;
    }
    cout<<ans<<nl;
    return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  set<int> s;
  REP(i,3){
    cin >> a;
    
    s.insert(a);

  }
  cout << s.size() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    ll arr[120];
    ll nCr(ll n, ll r)
    {
        ll C[r+1];
        memset(C, 0, sizeof(C));
        C[0] = 1;
        for (ll i = 1; i <= n; i++)
        {
            for (ll j = min(i, r); j > 0; j--)
                C[j] = (C[j] + C[j-1]);
        }
        return C[r];
    }
    int main()
    {
        ll tot=0;
        long double ans=0,sum=0,cnt=0;
        map<ll,int>N,R;
        int n,a,b;
        cin>>n>>a>>b;
        for(int i=0; i<n; i++){
        	cin>>arr[i];
			N[arr[i]]++;
		}
        sort(arr,arr+n);
        ll last ;
        for(int i=n-1; i>=0; i--)
        {
            sum+=arr[i];
            R[arr[i]]++;
            cnt++;
            if(cnt>b)
                break;
            if(cnt==a)
            {
                last = arr[n-1];
                ans=sum/cnt;
            }
            if(cnt>=a)
            {
                long double cur=(sum/cnt);
                if(cnt==a)
                    {tot+=nCr(N[arr[i]],R[arr[i]]);
                    }
                else if(arr[i]==last)
                {
                 tot+=nCr(N[arr[i]],R[arr[i]]);
                }
            }
        }
        cout<<setprecision(18)<<fixed<<ans<<endl;
        cout<<tot<<endl;
        return 0;
    }


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

long double f(int x, long double p)
{
    if(x % 2 == 1){
        return p * f(x - 1, p) + (1 - p) * f(x + 1, p) + 1;
    }
    return (x / 2) * (1 / p);
}

int main() {
    cout.precision(10);
    int x;
    long double p;
    cin >> x >> p;
    p = p / 100;
    cout << f(x, p) << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
template <typename F,typename T>
struct SegTree{
  // 二項演算merge,単位元identify
  T identity;
  F merge; 
  int size;
  vector<T> dat;
  
  // 二項演算fと単位元idを渡して宣言する
  SegTree(F f,T id):merge(f),identity(id){}

  // データの要素の数nを渡して初期化、sizeはnより大きい2の冪乗
  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
  }

  // 配列を渡して0(n)で初期化
  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }
  
  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  // index kの要素をaに変更
  void update(int k,T a){
    k += size - 1;
    dat[k] += a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  // 区間[a,b)に対するクエリに答える。(k,l,r)=(0,0,size)
  T query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return identity;
    
    if(a<=l&&r<=b) return dat[k]; 
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
  }
  
};

vector<ll> compress(vector<ll> a) {
  ll n = a.size();
  vector<ll> vals;
  rep(i,n) vals.push_back(a[i]);

  sort(vals.begin(), vals.end());
  vals.erase(unique(vals.begin(), vals.end()), vals.end());

  vector<ll> res;
  rep(i,n) {
    ll id = lower_bound(vals.begin(), vals.end(), a[i]) - vals.begin();
    res.push_back(id);
  }

  return res;
}

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

  vector<ll> sum(n+1);
  sum[0] = 0;
  rep(i,n) sum[i+1] = sum[i] + a[i];

  vector<ll> vec(n+1);
  rep(i,n+1) vec[i] = sum[i] - k*i;
  vec = compress(vec);
  
  auto f = [](ll a, ll b) { return a+b; };
  ll id = 0;
  SegTree<decltype(f),ll> seg(f,id);
  seg.init(n+1);
  ll res = 0;
  rep(i,n+1) {
    res += seg.query(0, vec[i]+1, 0, 0, seg.size);
    seg.update(vec[i], 1);
  }

  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 11120
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

dp = [[None]*(n+1) for _ in range(n+1)] # a[i:j]に対する解
for i in range(n+1):
    dp[i][i] = 0
for d in range(1,n+1):
    for i in range(n-d+1):
        j = i + d
        if (n - d)%2==0:
            # 先手
            dp[i][j] = max(dp[i+1][j]+a[i], dp[i][j-1]+a[j-1])
        else:
            dp[i][j] = min(dp[i+1][j]-a[i], dp[i][j-1]-a[j-1])
print(dp[0][n])

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

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



int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N, M, C; cin >> N >> M >> C;
	vector<ll> B(M); REP(i, M) cin >> B[i];
	vector<vector<ll>> A(N, vector<ll>(M));
	REP(i, N) REP(j, M) cin >> A[i][j];

	ll res{0};
	REP(i, N)
	{
		ll tmp{0};
		REP(j, M)
		{
			tmp += B[j] * A[i][j];
		}
		tmp += C;
		res += (tmp > 0);
	}

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


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  string s, t; cin >> s >> t;
  vvll dp(s.size()+1, vll(t.size()+1, 0));
  rep(i, 1, s.size()+1)
    rep(j, 1, t.size()+1)
      if (s.at(i-1) == t.at(j-1)) dp.at(i).at(j) = dp.at(i-1).at(j-1) + 1;
      else dp.at(i).at(j) = max(dp.at(i-1).at(j), dp.at(i).at(j-1));

  string ans;
  ll ss = s.size(), ts = t.size();
  while (ss>0 && ts>0) {
    if (s.at(ss-1) == t.at(ts-1)) {
      ans += s.at(ss-1);
      ss--; ts--;
    } else if (dp.at(ss-1).at(ts) > dp.at(ss).at(ts-1)) ss--;
    else ts--;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    int A,B,X;
    cin >> A >> B >> X;

    if( A <= X && X <= A+B ) cout << "YES" << endl;
    else cout << "NO" << endl;

}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
  static long n = long.Parse(Console.ReadLine());
  static long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
  static long numsSum = 0;//数列の総和
  static long answer = long.MaxValue;

	static void Main()
	{
      for(long i = 0; i < n; i++) numsSum += nums[i];
      
      long partitionLeft = 0;//仕切りの位置。数字が左に1個だけある状態が0
      long partitionRight = 2;
      long sumLeftLeft = nums[0];
      long sumLeft = nums[1];
      long sumRight = nums[2];
      long sumRightRight = numsSum-nums[0]-nums[1]-nums[2];

      for(long partitionMiddle = 1; partitionMiddle < n-2; partitionMiddle++)//中央の仕切りの位置
      {
      //Console.WriteLine(partitionLeft + " " + partitionMiddle + " " + partitionRight);
        while(true)//左の仕切りを右側へ移動
        {
          if(partitionLeft < partitionMiddle - 1 && 
            Math.Abs(sumLeftLeft + 2*nums[partitionLeft+1] - sumLeft)
              < Math.Abs(sumLeftLeft - sumLeft))
              {
                sumLeftLeft += nums[partitionLeft + 1];
                sumLeft -= nums[partitionLeft + 1];
                partitionLeft++;
              }else
              {
                break;
              }
        }

        while(true)//右の仕切りを右側へ移動
        {
          if(partitionRight < n-2 && 
            Math.Abs(sumRight + 2*nums[partitionRight+1] - sumRightRight)
              < Math.Abs(sumRight - sumRightRight))
              {
                sumRight += nums[partitionRight + 1];
                sumRightRight -= nums[partitionRight + 1];
                partitionRight++;
              }else
              {
                break;
              }
        }
        
        long[] memoLong = new long[6];
        memoLong[0] = Math.Abs(sumLeftLeft - sumLeft);
        memoLong[1] = Math.Abs(sumLeftLeft - sumRight);
        memoLong[2] = Math.Abs(sumLeftLeft - sumRightRight);
        memoLong[3] = Math.Abs(sumLeft - sumRight);
        memoLong[4] = Math.Abs(sumLeft - sumRightRight);
        memoLong[5] = Math.Abs(sumRight - sumRightRight);
        answer = Math.Min(answer, memoLong.Max());//最小値の更新
        //Console.WriteLine(sumLeftLeft + " " + sumLeft + " " + sumRight + " " + sumRightRight);

        sumLeft += nums[partitionMiddle+1];
        sumRight -= nums[partitionMiddle+1];
        if(partitionRight == partitionMiddle+1)
        {
          partitionRight++;
          sumRight += nums[partitionMiddle+2];
          sumRightRight -= nums[partitionMiddle+2];
        }
      }

      Console.WriteLine(answer);
	}
  
}


Measured memory_bytes: 32860
#pragma region template 2.2
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    ll ans = 0;
    REP1(i, N)
    {
        if (i % 3 != 0 and i % 5 != 0)
        {
            ans += i;
        }
    }
    OUT(ans);
}

Measured memory_bytes: 3636
from sys import exit

S = input()

if len(S) % 2 != 0:
    print("No")
    exit()

for i, s in enumerate(S):
    if i % 2 == 0:
        if s != "h":
            print("No")
            exit()
    else:
        if s != "i":
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 38324
a = gets
b = a.split(" ")
c = b[0].to_i
d = b[1].to_i
if c < d then
print ("a"),(" "),("<"),(" "),("b"),("\n")
elsif c > d then
print ("a"),(" "),(">"),(" "),("b"),("\n")
else 
print ("a"),(" "),("=="),(" "),("b"),("\n")
end

Measured memory_bytes: 6096
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

int N, M;

int main() {

//  freopen("input.in","r",stdin);
  // freopen("output.out","w",stdout);

  cin >> N >> M;
  int i = 1, j = N;
  vector<pair<int,int>> ans;
  if(N & 1) {
    while(i < j) {
      ans.pb(mp(i, j));
      i++;j--;
    }
  } else {
    int ne = 0;
    if(N % 4 == 0) ne = N/4;
    else ne = (N-2)/4;
    rep(i, ne) {
      ans.pb(mp(i+1,N-i));
    }
    i = ne+1;
    j = N-ne-1;
    while(i < j) {
      ans.pb(mp(i, j));
      i++;j--;
    }
  }
  rep(i, M) cout << ans[i].F << " " << ans[i].S << endl;


  return 0;
}


Measured memory_bytes: 4232
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

bool isok(int pat, const  vector< vector< pint > > &A) {
  int N = A.size();
  vector<int> B(N);
  REP(i,N) {
    B[i] = (pat>>i) & 1;
  }
  //  pp(B, N);
  REP(i,N) {
    if(B[i]) {
      REP(j, A[i].size()) {
	int x = A[i][j].first;
	int y = A[i][j].second;
	if(B[x] != y) return false;
      }
    } else {
      /*
      REP(j, A[i].size()) {
	int x = A[i][j].first;
	int y = A[i][j].second;
	if(B[x] == y) return false;
      }
      */

    }
  }
  return true;
}

int cnt(int pat) {
  int ans = 0;
  while(pat != 0) {
    ans += (pat & 0x1);
    pat = (pat >> 1);
  }
  return ans;
}

int main() {
  int N; cin>>N;
  vector<vector< pint > > A(N);
  REP(i,N) {
    int n; cin>>n;
    REP(j,n) {
      int x, y;
      cin>>x>>y; x--;
      A[i].push_back(make_pair(x, y));
    }
  }
  int ans = 0;
  REP(pat , 1<<N) {
    bool res = isok(pat, A);
    //    cout << pat << " " << res << endl;
    if(res) {
      int tmp = cnt(pat);
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define PI 3.1415926535897932
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i, a, n) for (int i = a; i < n; i++)
using namespace std;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m;
    cin >> n >> m;
    vi a(m);
    int sum = 0;
    f(i, 0, m)
    {
        cin >> a[i];
        sum += a[i];
    }
    cout << (sum <= n ? n - sum : -1);

    return 0;
}

Measured memory_bytes: 3664
import numpy as np
N, K = [int(x) for x in input().split()]
#print(N,K)

list = []
for i in range(N):
    a,b = [int(x) for x in input().split()]
    list.append([a, b])
list.sort()
#print(list)
nth = 0
for i in range(N):
    a,b = list[i]
    nth += b 
    if K<=nth:
        break
#    elif nth==K:
#        a,b = list[i-1]
#        break
#print(a,b)
print(a)

Measured memory_bytes: 29156
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double area = r * r * Math.PI;
        double circumference = r * 2 * Math.PI;
        System.out.printf("%f %f", area, circumference);
        sc.close();
    }
}


Measured memory_bytes: 28000
a,b = map(int,input().split())
mine = 2019
if b - a > 2017:
    print(0)
else:
    a = a%2019
    b = b%2019
    if a>b :
        print(0)
    else:
        for i in range(b-a):
            for f in range(b-a-i):
                mine = min(mine, ((a+i)*(a+i+1+f))%2019)
        print(mine)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
// #include <atcoder/all>
// using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

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

ll maisu_all (ll level) {
    if (level <= 0) return 1;
    return 3 + 2 * maisu_all(level - 1);
}

ll maisu_p (ll level) {
    if (level <= 0) return 1;
    return 1 + 2 * maisu_p(level - 1);
}

ll burger (ll level, ll k) {
    eprintf("level:%lld x:%lld\n", level, k);
    ll m = maisu_all(level - 1);
    if (k == 0) return 0;
    else if (level <= 0) return 1;
    else if (k <= 1) return 0;
    else if (k <= 1 + m) return burger(level - 1, k - 1);
    else if (k <= 2 + 2 * m) return maisu_p(level - 1) + 1 + burger(level - 1, k - m - 2);
    else return maisu_p(level);
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, x; cin >> n >> x;
    cout << burger(n, x) << "\n";
    // rep (i, 51) eprintf("%lld ", maisu_all(i)); eprintf("\n");
    // rep (i, 51) eprintf("%lld ", maisu_p(i)); eprintf("\n");
    /***************************************************/
    /* Use "submit code (with ACL v1)" when using ACL! */
    /***************************************************/
    return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;cin >> a >> b >> c >> d;
    if(a+b>c+d){
        cout << "Left" << endl;
    }
    else if(a+b==c+d){
        cout << "Balanced" << endl;
    }
    else{
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 3584