akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int MOD = 1000000007;

int toNumAndMod(string s, int k){
	string sub = s.substr(k);
	return atol(sub.c_str()) % 2019;
}
const int m = 2019;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	// int cnt = 0;
	// vector<int> a(2019);
	// a.at(0) += 1;
	// for(int i=0;i<s.size();i++){
	// 	int tmp = toNumAndMod(s,i);
	// 	//cout << "tmp=" << tmp << ", i=" << i << endl; 
	// 	a.at(tmp)++;
	// }
	// for(int i=0;i<2019;i++){
	// 	if(a.at(i) > 1){
	// 		cnt += a.at(i)-1;
	// 	}
	// }
	// cout << cnt << endl;
	int n = s.size();
	reverse(s.begin(),s.end());
	int x = 1;
	int total = 0;
	vector<int> cnt(m);
	int ans = 0;
	rep(i,n){
		cnt[total]++;
		total += (s[i]-'0')*x;
		total %= m;
		ans += cnt[total];
		x = x*10%m;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=1e5+10;
struct data{
	int w,id;
	bool operator < (const data &C) const {
		return w>C.w;
	}
}a[N];
priority_queue<data>q;
char lx[N];

int main(){
	scanf("%s",lx+1);
	int n=strlen(lx+1);
	fr(o,1,26){
		while(!q.empty()) q.pop();
		int nw=0;a[0]=(data){nw,0};
		fr(i,1,n){
			int pos=lx[i]-'a'+1;
			if(pos==o) nw++;
			else nw--;
			a[i]=(data){nw,i};
		}
		fr(i,2,n){
			q.push(a[i-2]);
			data h=q.top();
			if(a[i].w-h.w>0) return printf("%d %d\n",h.id+1,i),0;
		}
	}
	printf("-1 -1\n");
	return 0;
}

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

using namespace std;

int a[5], k;

void cal() {
    for (int i = 0; i < 5; ++i) {
        for (int j = i + 1; j < 5; ++j) {
            if (abs(a[j] - a[i]) > k) {
                puts(":(");
                return;
            }
        }
    }
    puts("Yay!");
}

int main() {
    for (int i = 0; i < 5; ++i) scanf("%d", a + i);
    scanf("%d", &k);
    cal();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n,r; cin>>n>>r;
	if(n>=10) cout << r << endl;
	else cout << r+100*(10-n) << endl;
  return 0;
}


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

using namespace std;

int main() {
	int n, k, useless, ans;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> useless;
	if (k == 2)
		cout << n - 1;
	else if ((n % (k - 1)) <= 1)
		cout << (n / (k - 1));
	else
		cout << (n / (k - 1) + 1);
	return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int a=0,b=0,c=0,d=0,m=0,n=0,h=0,w=0,count=0,ans=0;
  string s;
  cin>>n;
  a=n/1000;
  b=(n-a*1000)/100;
  c=(n-a*1000-b*100)/10;
  d=n-a*1000-b*100-c*10;
  if(a+b+c+d==7){
    cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
  }else if(a+b+c-d==7){
    cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
  }else if(a+b-c+d==7){
    cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
  }else if(a+b-c-d==7){
    cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
  }else if(a-b+c+d==7){
    cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
  }else if(a-b+c-d==7){
    cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
  }else if(a-b-c+d==7){
    cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
  }else if(a-b-c-d==7){
    cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
  }
  
}
///////////////////////////


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 10005
#define lg 18
//<<fixed << setprecision(9)
ll dp[space][101][2];//to be or not to be
int main()
{
    int n,i,j,t;
    boost;

    string s;
    int d;
    cin>>s>>d;
    n=s.size();
    int x[n];
    rep(i,0,n)x[i]=s[i]-'0';
    rep(i,0,x[0])    
    {
        dp[0][i%d][0]+=1;
    }
    dp[0][x[0]%d][1]=1;
    int k;
    rep(i,1,n)
    {
        rep(j,0,d)
        {
            rep(k,0,10)
            {
                dp[i][(j+k)%d][0]+=dp[i-1][j][0];
                if(k<x[i]) dp[i][(j+k)%d][0]+=dp[i-1][j][1];
                else if(k==x[i])
                {
                      dp[i][(j+k)%d][1]+=dp[i-1][j][1];
                      dp[i][(j+k)%d][1]%=mod;
                }
                dp[i][(j+k)%d][0]%=mod;

            }
        }
    }

    cout<<(dp[n-1][0][0]+dp[n-1][0][1]-1+mod)%mod;

    return 0;
}



Measured memory_bytes: 16128
#include <cstdio>
#include <vector>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int x, y;
  cin >> x >> y;
  REP(i, x+1) {
    if(i*2 + (x-i)*4 == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3100
#include <iostream>

int main() {
  auto min = [](int a, int b) { return a < b ? a : b; };
  int N, K;
  std::cin >> N >> K;

  int res{0};
  for (int i = 0; i < N; i++) {
    int x;
    std::cin >> x;
    res += min(2 * x, 2 * (std::abs(K - x)));
  }
  std::cout << res << std::endl;
}

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

N = int(readline())

p = 0
ans = set()
for i in range(1,N + 1):
  p += i
  ans.add(i)
  if p >= N:
    break
    
if p == N:
  for a in ans:
    print(a)
  exit(0)
ans.remove(p - N)
for a in ans:
  print(a)


Measured memory_bytes: 9264
H,W = map(int,input().split())
sy,sx = map(int,input().split())
gy,gx = map(int,input().split())
sy,sx = sy-1,sx-1
gy,gx = gy-1,gx-1
S = [input() for i in range(H)]

from collections import deque
INF = float('inf')
dist = [[INF]*W for _ in range(H)]
dist[sy][sx] = 0
q = deque([(sx,sy)])
while q:
    x,y = q.popleft()
    for dx in range(-2,3):
        for dy in range(-2,3):
            if dx == dy == 0: continue
            nx,ny = x+dx,y+dy
            if not 0 <= nx < W: continue
            if not 0 <= ny < H: continue
            if S[ny][nx] == '#': continue
            if abs(dx)+abs(dy) <= 1:
                if dist[ny][nx] <= dist[y][x]: continue
                q.appendleft((nx,ny))
                dist[ny][nx] = dist[y][x]
            else:
                if dist[ny][nx] <= dist[y][x] + 1: continue
                q.append((nx,ny))
                dist[ny][nx] = dist[y][x] + 1

print(-1 if dist[gy][gx]==INF else dist[gy][gx])

Measured memory_bytes: 99704
# coding:utf-8


def main():
    # N = int(input())
    N, L = map(int, input().split())
    ans = 0
    min_azi = 101
    min_i = 0
    for i in range(1, N+1):
        temp = abs(L+i-1)
        # print(temp)
        if min_azi > temp:
            min_azi = temp
            min_i = i

    # print(min_i, min_azi)
    for i in range(1, N+1):
        if i == min_i:
            continue
        else:
            ans += L+i-1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

//const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,s;
  cin >> n >> s;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  vector<vector<mint>> dp(n+1, vector<mint>(s+1, 0));
  dp[0][0] = 1;
  REP(i,n) REP(j,s+1){
    dp[i+1][j] += dp[i][j] * 2;
    if(j - a[i] >= 0){
      dp[i+1][j] += dp[i][j-a[i]];
    }
  }
  cout << dp[n][s] << endl;
  return 0;
}


Measured memory_bytes: 73652
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,l ;
   cin >> n >> l ;
   
  int total = 0;
  int ans = 1000000;

   for(int i=1;i<=n;i++)
   {
     total+=l+i-1 ;
    if(abs(ans)>abs(l+i-1)) ans = l+i-1;
   }

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


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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {FIN;
   
    int n,m;cin>>n>>m;
    ll total = 0;
    int can = 0;
    int arr[n];
    fore(i,0,n){
        int cur;cin>>cur;arr[i]=cur;
        total+=cur;
    }fore(i,0,n){
        if(total<=arr[i]*4*m)can++;
    }if(can>=m)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int i,n;
    scanf("%d",&n);
    int a[n];
    for(i=1;i<n;i++){
        scanf("%d",&a[i]);
    }

    int s[n];
    for(i=0;i<n;i++){
        s[i]=0;
    }

    for(i=1;i<n;i++){
        s[a[i]-1]++;
    }

    for(i=0;i<n;i++){
        printf("%d\n",s[i]);
    }

    return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0){
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
    return 0;
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
        dp[i][0]=0;
    for(int i=0;i<=m;i++)
        dp[0][i]=0;
    for(int i=1;i<=n;i++)
    {
        for(int k=1;k<=m;k++)
        {
            if(s[i-1]!=t[k-1])
                dp[i][k]=max(dp[i-1][k],dp[i][k-1]);
            else
                dp[i][k]=1+dp[i-1][k-1];
        }
    }
    string ans="";
    int i=n,k=m;
    while(i>0 && k>0)
    {
        if(s[i-1]==t[k-1])
        {
            ans+=s[i-1];
            i--;k--;
        }
        else
        {
            if(dp[i-1][k]>=dp[i][k-1])
                i--;
            else
                k--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 35456
import math

li = list(map(int,input().split()))
a = li[0]
b = li[1]
c = li[2]

list = []

for i in range(a + 1):
  ans = 0
  tmp = i

  while(i >= 1):
    ans += i % 10
    i = math.floor(i / 10)

  if b <= ans <= c:
    list.append(tmp)

data = 0
for e in list:
  data += e

print(data)

Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll modpow(ll x,ll n)
{
	ll res=1;
	while(n>0)
	{
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[100005],R[100005];
void make(){
	F[0] = 1;
	for(int i=1;i<100005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<100005;i++) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
ll cc[2005][2005],rui[2005][2005],rui2[2005][2005];
int main(){
	make();
	int a,b;cin>>a>>b;
	cc[0][0]=1;
	for(int i=1;i<2005;i++) for(int j=0;j<=i;j++){
		if(j==0||j==i) cc[i][j]=1;
		else{
			cc[i][j] = cc[i-1][j-1]+cc[i-1][j];
			cc[i][j] %= mod;
		}
	}
	//cout<<cc[5][2]<<endl;
	for(int i=0;i<2005;i++){
		for(int j=0;j<=i;j++){
			if(j==0) rui[i][j] = cc[i][j];
			else rui[i][j] = (rui[i][j-1]+cc[i][j])%mod;
		}
	}
	for(int i=0;i<2005;i++){
		for(int j=0;j<=i;j++){
			if(j==0) rui2[i][j] = rui[i][j];
			else rui2[i][j] = (rui2[i][j-1]+rui[i][j])%mod;
		}
	}
	ll ans = 0;
	for(int x=0;x<=a;x++){
		for(int k=x;k<=a;k++){
		    if(b-1<k-x) continue;
			ll ret = C(b-1,k-x); //assert(b-1<k-x);
			if(x==k){
				ans=(ans+ret)%mod;
			}
			else{
				ll sum=0;
				if(a-k >= k-x-1){
					sum = (a-k) - (k-x-1);
					sum = sum*modpow(2,k-x-1)%mod;
					sum = (sum+rui2[k-x-1][k-x-1])%mod;
				}
				else{
					sum = rui2[k-x-1][a-k];
				}
				sum%=mod;
				ans += ret*sum%mod;
				ans %= mod;
			}
			
		}
	}
	cout<<ans%mod<<endl;
}

Measured memory_bytes: 94592
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e5+4 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
   int n , m ;
   cin >> n >> m ;
   vector < pair < int , int > > a(m) ;
   for( int i = 0 ; i < m ; i++) cin >> a[i].ff >> a[i].ss;
   sort(st(a));
   int ans = 1 ;
    pair < int , int > cur = a[0];
   for( int i = 1 ; i < m ; i++){
            if(a[i].ff>=cur.ss){
                ans++;
                cur = a[i];
            }
            else{
                cur.ff = max(cur.ff,a[i].ff);
                cur.ss = min(cur.ss,a[i].ss);
            }
   }
   cout << ans ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 1024
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    H, W = [int(x) for x in input().split()]
    A = [input().strip() for _ in range(H)]

    q = collections.deque()

    ans = [[0] * W for j in range(H)]

    for j in range(H):
        for i in range(W):
            if A[j][i] == '#':
                q.append((j, i, 0))
                ans[j][i] = -1

    while q:
        c = q.popleft()
        y, x, d = c[0], c[1], c[2]
        for ny, nx in [[0, 1], [1, 0], [0, -1], [-1, 0]]:
            if 0 <= y + ny < H and 0 <= x + nx < W:
                if ans[y + ny][x + nx] == 0:
                    ans[y + ny][x + nx] = d + 1
                    q.append((y + ny, x + nx, d + 1))

    a = 0
    for aa in ans:
        a = max(a, max(aa))
    print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 132828
$ans = 0
$H, $W, $K = gets.chomp.split(" ").map(&:to_i)

def count_black_math(color)
    res = 0
    $H.times do |i|
        $W.times do |j|
            res += 1 if color[i][j] == "#"
        end
    end
    $ans += 1 if res == $K
end

color = []
$H.times do
    color << gets.chomp.split("")
end

[0, 1].repeated_permutation($H) do |row_bits|
    [0, 1].repeated_permutation($W) do |column_bits|
        c = color.map(&:dup)
        row_bits.each_with_index do |row, i|
            if row == 1 then
                $W.times do |j|
                    c[i][j] = "x"
                end
            end
        end
        column_bits.each_with_index do |column, i|
            if column == 1 then
                $H.times do |j|
                    c[j][i] = "x"
                end
            end
        end
        count_black_math(c)
    end
end

puts $ans

Measured memory_bytes: 14176
import java.util.*;
public class Main {
	int i,runner;
	String time;
	Runner timeArray[] = new Runner[24];
	int flag[] = new int[timeArray.length];
	Runner subArray[] = new Runner[timeArray.length];
	
	void doIt(){
		Scanner sc = new Scanner(System.in);
		for(i = 0; i < timeArray.length; i ++ ){
			runner = sc.nextInt();
			time = sc.next();
			timeArray[i] = new Runner(runner,time);
		}
		for(i = 0; i < 3; i ++ ){
			Arrays.sort(timeArray,i * 8,i * 8 + 8);
			System.out.println(timeArray[i * 8].runner+" "+timeArray[i * 8].time);
			System.out.println(timeArray[i * 8 + 1].runner+" "+timeArray[i * 8 + 1].time);
			flag[i * 8] = 1;
			flag[i * 8 + 1] = 1;
		}
		subArray = timeArray.clone();
		for(i = 0; i < subArray.length; i ++ ){
			if(flag[i] == 1)subArray[i].time = "Integer.MAX_VALUE";
		}
		Arrays.sort(subArray);
		System.out.println(subArray[0].runner+" "+subArray[0].time);
		System.out.println(subArray[1].runner+" "+subArray[1].time);
	}
	
	class Runner implements Comparable<Runner>{
		int runner;
		String time;
		Runner(int runner,String time){
			this.runner = runner;
			this.time = time;
		}
		@Override
		public int compareTo(Runner r){
			return time.compareTo(r.time);
		}
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int INF = 1e9+5;

int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    	cout.precision(10);
    	cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif
        
	int n,k;
	cin>>n>>k;
	vi arr(n);
	forn(i,n) cin>>arr[i];

	vi dp(n,INF);
	dp[0]=0;
	forn(i,n){	
	 	fore(j,i+1,i+k){
	 	 	if(j<n)
	 	 		dp[j] = min(dp[i]+abs(arr[j]-arr[i]),dp[j]);
	 	}

	}
	cout<<dp.back()<<endl;

        #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

	return 0;
}	



Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){

    string s;
    cin >> s;

    for(int i=0; i<s.size(); i++){

        if(i&1){
            if(s.at(i) == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(s.at(i) == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <vector>
using namespace std;

template<typename T>
struct BIT{//0-indexed
private:
  vector<T> data;
  const int n;
public:
  BIT(int sz) : data(sz+1,0), n(sz) {}
  T sum(size_t i){//sum[0,i)
    //++i;
    T s = 0;
    while(i > 0){
      s += data[i];
      i -= i&(-i);
    }
    return s;
  }

  T sum(size_t i, size_t j){ return sum(j) - sum(i); }//sum[i,j)

  void add(int i, T x){
    ++i;
    assert(i > 0);
    while(i <= n){
      data[i] += x;
      i += i&(-i);
    }
  }
};

int main(){
  int N, Q;
  cin >> N >> Q;
  BIT<long long> bit(N);
  for(int i = 0; i < N; ++i){
    int a;
    cin >> a;
    bit.add(i,a);
  }
  while(Q--){
    int t;
    cin >> t;
    if(t){
      int l, r;
      cin >> l >> r;
      cout << bit.sum(l,r) << '\n';
    }else{
      int p, x;
      cin >> p >> x;
      bit.add(p,x);
    }
  }
}


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

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

    int ans = 0;
    if (A % 2 == 0) {
        if ((B % 2 == 1) && (C % 2 == 1)) {
            ++ans;
            ++B;
            ++C;
        } else if (B % 2 == 1) {
            ++ans;
            ++A;
            ++C;
        } else if (C % 2 == 1) {
            ++ans;
            ++A;
            ++B;
        }
    } else {
        if ((B % 2 == 0) && (C % 2 == 0)) {
            ++ans;
            ++B;
            ++C;
        } else if (B % 2 == 0) {
            ++ans;
            ++A;
            ++C;
        } else if (C % 2 == 0) {
            ++ans;
            ++A;
            ++B;
        }
    }
    int maxABC = max(A, max(B, C));
    ans += (3 * maxABC - (A + B + C)) / 2;

    cout << ans << endl;

    return 0;
}

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

int main() {
  int K,S;
  cin >> K >> S;
  int x,y,z;
  int ans=0;
  for(x=0;x<=K;x++) {
    for(y=0;y<=K&&y<=S-x;y++) {
      z=S-x-y;
      if(z<=K) {
        ans++;
      }
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc127_b

#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)                \
    cerr << #v << ": ";             \
    REP(__i, (v).size())            \
        cerr << ((v)[__i]) << ", "; \
    cerr << endl

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

int main()
{
    ios::sync_with_stdio(false);
    int r, D, x;
    cin >> r >> D >> x;
    REP(i, 10) {
        x = r * x - D;
        cout << x << endl;
    }
    
    return 0;
}


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

const int N = 2e5+5;

int n, A[N];
int nxt[N];

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) scanf("%d", A+i);
    int track = n+1;
    for(int i = n; i; --i) {
        if(A[i]) track = i;
        else nxt[i] = track - 1;
    }
    long cnt = 0;
    for(int i = 1; i <= n; ++i) {
        int val = 0;
        for(int j = i; j <= n+1; ++j) {
            if((val & A[j]) == 0 && j <= n) {
                if(A[j] == 0) j = nxt[j];
                else val |= A[j];
            } else { cnt += j-i; break; }
        }
    }
    printf("%lld\n", cnt);
}

Measured memory_bytes: 1792
use std::io::BufRead;

fn main() {
    let handle = std::io::stdin();
    let mut s = String::new();
    handle.lock().read_line(&mut s).ok();
    print!("{}", s.chars().map(|a| upper_lower(a)).collect::<String>());
}

fn upper_lower(c: char) -> char {
    if c.is_uppercase() {
        c.to_lowercase().next().unwrap()
    } else if c.is_lowercase() {
        c.to_uppercase().next().unwrap()
    } else { c }
}



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

int main(){
    long int n=0, money=100;
    long int x;
    cin >> x;
    while(1){
        money *= 1.01;
        n++;
        if(money >= x){
            break;
        }
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,p,d[10002];
	int i,j,mn,migi,hida,x;
	scanf("%d %d %d",&n,&m,&p);
	for(i=0;i<m;i++)	{
		scanf("%d",&d[i]);
	}
	d[m]=p;
	sort(d,d+m+1);
	d[m+1]=d[0];
	mn=100000000;
	for(i=0;i<=m;i++)	{
		hida=d[i]-p;
		if(hida<0)	hida+=n;
		migi=p-d[i+1];
		if(migi<0)	migi+=n;
		
//		printf("  %d %d\n",migi,hida);
		
		mn=min(mn,hida*2+migi);
		mn=min(mn,hida+migi*2);
	}
	printf("%d\n",mn*100);
	return 0;
}


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

int main() {
  int n, x = 0, m = 0;
  string s;
  cin >> n >> s;
  rep(i, n){
    if(s[i] == 'D') --x;
    else if(s[i] == 'I'){
      ++x;
      m = max(m, x);
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * ITP1_5B.c
 *
 *  Created on: 2016/05/28
 *      Author: TakaakiShogaki
 */

#include<stdio.h>

int main(){
	int H,W,i,j;

	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 &&W==0)
			break;
		for(i=0;i<H;i++){
            if(i%2==0){
                for(j=0;j<W;j++){
                    printf("#");
                    j++;
                    if(j<W)
                        printf(".");
                        //j++;
                    else
                        break;
                }
                printf("\n");
            }
            else{
                 for(j=0;j<W;j++){
                    printf(".");
                    j++;
                    if(j<W)
                        printf("#");
                        //j++;
                    else
                        break;
                }
                printf("\n");

            }
		}
		printf("\n");
	}
return 0;
}

Measured memory_bytes: 572
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static long mod=1000000007;
	static int n;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		long k=sc.nextLong();
		long[][] a=new long[n][n];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				a[i][j]=sc.nextLong();
			}
		}
		long[][] b=new long[n][n];
		for(int i=0; i<n; i++){
			b[i][i]=1;
		}
		while(k>0){
			if((k&1)==1){
				b=mul(a,b);
			}
			k>>=1;
			a=mul(a,a);
		}
		long ans=0;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				ans=(ans+b[i][j])%mod;
			}
		}
		System.out.println(ans);
	}
	static long[][] mul(long[][] a,long[][] b){
		long[][] re=new long[n][n];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				for(int k=0; k<n; k++){
					re[i][j]=(re[i][j]+a[i][k]*b[k][j])%mod;
				}
			}
		}
		return re;
	}
}


Measured memory_bytes: 28060
#include <bits/stdc++.h>
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int n;
	cin >> n;
	cout << a[n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define zz 25000
int n,wi[20005],a[20005],b[20005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&wi[i]);
	a[1]=b[n]=1; for(int i=2;i<=n;i++) b[n-i+1]=a[i]=a[i-1]+zz;
	for(int i=2;i<=n;i++){b[wi[i]]+=i-1;}
	for(int i=1;i<=n;i++) printf("%d ",a[i]);
	puts("");
	for(int i=1;i<=n;i++) printf("%d ",b[i]);
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n; cin >>n;
	vector<int> w(n);
	cinf(n,w);
	int sum=0;
	int ans=1e9;
	for(int i=0;i<n;i++){
		sum+=w[i];
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		cnt+=w[i];
		sum-=w[i];
		ans=min(ans,abs(cnt-sum));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

N = int(input())
D = sorted(list(map(int,input().split())))

if N % 2 != 0:
    print(0)
    sys.exit()

low  = D[0:N//2]
high = D[N//2::]

flg  = all( low[-1] + 1 >  x for x in low )
flg |= all( high[0] - 1 >= x for x in high )

if flg == True:
    print(high[0] - low[-1])
else:
    print(0)



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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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 */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int h, w, hh, ww;
    cin >> h >> w >> hh >> ww;
    cout << (h - hh) * (w - ww) << endl;
    return 0;
}

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

int main(void){
    string s, t;
    cin >> s;
    cin >> t;
    int c = 0;
    for(int i = 0; i < 3; i++) if(s.at(i) == t.at(i)) c++;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <utility>
#include <map>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<string, PII> PSI;
typedef pair<vector<int>, vector<int>> PVV;
const int INF = 1 << 29;	// 十分大きい値にする, INT_MAX にしないのはオーバーフロー対策

void solve()
{
	int N;
	int W[101];
	int dp[102];
	int sum;
	int diff_min;
	int S1, S2;

	cin >> N;
	FOR(i, 0, N) {
		cin >> W[i];
	}

		// 重りの合計値を計算
	sum = 0;
	FOR(i, 0, N) {
		sum += W[i];
	}

	// 最小値を求める
	diff_min = INF;
	S1 = 0;
	FOR(T, 0, N) {
		S1 += W[T];
		S2 = sum - S1;
		if (abs(S2 - S1) < diff_min) {
			diff_min = abs(S2 - S1);
		}
	}

	cout << diff_min << endl;
}

int main(void)
{
	solve();

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

bool f;
int n, num;
vector<int> vi, vi2[10];
char c;

void solve(int num, int a[]){
	if (num == 10){
		REP(i, 10){
			if (a[i])return;
		}
		f = 1;
		return;
	}

	if (a[num] >= 3){
		a[num] -= 3;
		if (a[num] > 0)solve(num, a);
		else solve(num + 1, a);
		a[num] += 3;
	}
	else if (a[num] >= 1){
		if (num + 2 <= 9){
			if (a[num] >= 1 && a[num + 1] >= 1 && a[num + 2] >= 1){
				a[num]--;
				a[num + 1]--;
				a[num + 2]--;
				if (a[num] > 0)solve(num, a);
				else solve(num + 1, a);
				a[num]++;
				a[num + 1]++;
				a[num + 2]++;
			}
		}
		else solve(num + 1, a);
	}
	else solve(num + 1, a);
}

int main(){
	cin >> n;
	REP(k, n){
		vi.clear();
		REP(i, 10)vi2[i].clear();
		REP(i, 9){
			cin >> num;
			vi.push_back(num);
		}
		REP(i, 9){
			cin >> c;
			if (c == 'R')vi2[0].push_back(vi[i]);
			else if (c == 'G')vi2[1].push_back(vi[i]);
			else vi2[2].push_back(vi[i]);
		}
		if (vi2[0].size() % 3 != 0 || vi2[1].size() % 3 != 0 || vi2[2].size() % 3 != 0){
			cout << 0 << endl;
			continue;
		}
		bool F = 1;
		REP(i, 3){
			f = 0;
			int a[10] = {};
			REP(j, vi2[i].size()){
				a[vi2[i][j]]++;
			}
			//cout << "!" << f << endl;
			solve(1, a);
			if (!f)F = 0;
		}
		if (F)cout << 1 << endl;
		else cout << 0 << endl;
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 1e6;
int main(){
  ll n; cin >> n;
  string s; cin >> s;
  vector<ll> left(n+1,0), right(n+1,0);
  for(int i=0 ; i<n ; i++){
      left[i+1] = left[i];
      if(s[i]=='W') left[i+1]++;
  }
  for(int i=n-1 ; i>=0 ; i--){
      right[i] = right[i+1];
      if(s[i]=='E') right[i]++;
  }
  ll mi = 1e15;
  for(int i=0 ; i<n ; i++){
    mi = min(mi, left[i]+right[i+1]);
  }
  cout << mi << endl;
}


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

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n; 
  cin >> n;
  vector<int> d(n);
  rep(i, n) {
    cin >> d[i];
  }

  sorti(d);

  int man = n / 2;
  int ans = d[man] - d[man - 1];

  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int N;
	cin >> N;

	int AC = 0;
	int WA = 0;
	int TLE = 0;
	int RE = 0;

	for (int i = 0; i < N; i++) {
		string tmp;
		cin >> tmp;
		if (tmp == "AC") AC++;
		else if (tmp == "WA") WA++;
		else if (tmp == "TLE") TLE++;
		else if (tmp == "RE") RE++;
	}

	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;

	return 0;
}


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

bool check(int x)
{
    string s = to_string(x);
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main()
{
    int l, r;
    cin >> l >> r;
    int ans = 0;
    for (int i = l; i <= r; i++)
        ans += check(i);
    cout << ans << endl;
}

Measured memory_bytes: 384
from collections import defaultdict

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

evens = defaultdict(lambda: 0)
odds = defaultdict(lambda: 0)
for i in range(0, n, 2):
    evens[numbers[i]] += 1
    odds[numbers[i + 1]] += 1

evens = list(evens.items())
odds = list(odds.items())

evens.sort(key=lambda pair: pair[1], reverse=True)
odds.sort(key=lambda pair: pair[1], reverse=True)

if len(evens) == 1 and len(odds) == 1:
    if evens[0][0] == odds[0][0]:
        print(n // 2)
    else:
        print(0)
    exit()

if len(evens) == 1 or len(odds) == 1:
    pairs = evens if len(evens) > len(odds) else odds
    if evens[0][0] == odds[0][0]:
        del pairs[1]
    else:
        del pairs[0]
    print(sum([v for _, v in pairs]))
    exit()

if evens[0][0] == odds[0][0]:
    if evens[0][1] == odds[0][1]:
        if evens[1][1] > odds[1][1]:
            del evens[1]
            del odds[0]
        else:
            del evens[0]
            del odds[1]
    elif evens[0][1] > odds[0][1]:
        del evens[0]
        del odds[1]
    else:
        del evens[1]
        del odds[0]
else:
    del evens[0]
    del odds[0]
print(sum([v for _, v in evens]) + sum([v for _, v in odds]))


Measured memory_bytes: 19544
#include<cstdio>
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int h,w;
bool a[505][505],b[505][505];
int main(){
	h=read();w=read();
	for(int i=1;i<=h;i++) a[i][1]=true;
	for(int i=1;i<=h;i+=2) for(int j=1;j<w;j++) a[i][j]=true;
	for(int i=1;i<=h;i++) b[i][w]=true;
	for(int i=2;i<=h;i+=2) for(int j=2;j<=w;j++) b[i][j]=true;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++){
			char c=getchar();
			while(c!='.'&&c!='#') c=getchar();
			a[i][j]=((c=='#')||a[i][j]);
			b[i][j]=((c=='#')||b[i][j]);
		}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++) putchar(a[i][j]?'#':'.');
		puts("");
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++) putchar(b[i][j]?'#':'.');
		puts("");
	}
	return 0;
}

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

int main() {
    ll N, W; cin >> N >> W;
    vector<vector<ll>> a(4);
    ll w0;
    for (int i = 0; i < N; i++)
    {
        ll w, v; cin >> w >> v;
        if(i==0) w0 = w;
        if(w==w0)        a[0].push_back(v);
        else if(w==w0+1) a[1].push_back(v);
        else if(w==w0+2) a[2].push_back(v);
        else if(w==w0+3) a[3].push_back(v);
    }
    for(auto &i : a){
        i.push_back(0);
        sort(i.begin(),i.end(), greater<int>());
    }

    for (auto &i : a)
    {
        ll prev;
        for (int j = 1; j < i.size(); j++)
        {
            i[j] = i[j] + i[j-1];
        }
    }
    
    ll ans = 0;
    for (int i = 0, n=a[0].size(); i <n ; i++)
    {
        for (int j = 0, m=a[1].size(); j < m; j++)
        {
            for (int k = 0, p=a[2].size(); k < p; k++)
            {
                for (int l = 0, q=a[3].size(); l < q; l++)
                {
                    if(w0 * i + (w0+1) * j + (w0+2) * k + (w0+3) * l > W) continue;
                    ll tmp = 0;
                    if(i>0) tmp += a[0][i-1];
                    if(j>0) tmp += a[1][j-1];
                    if(k>0) tmp += a[2][k-1];
                    if(l>0) tmp += a[3][l-1];
                    ans = max(ans, tmp);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n;
    long long ans=0;
    cin >> n;
    vector<long long> a(n);
    vector<long long> b(n);
    vector<long long> c(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        cin >> c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    for(int i=0;i<n;i++){
        long long x = lower_bound(a.begin(),a.end(),b[i])-a.begin();
        long long y = c.end()-upper_bound(c.begin(),c.end(),b[i]);
        ans +=x*y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <climits>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

constexpr int MAX_N = 10;
int n;
int w[MAX_N], s[MAX_N];
string name[MAX_N];

int ans_g;
vector<int> ans;

void dfs(int rest, int used, int g, vector<int> &order) {
	if(g >= ans_g) return;
	if(rest == 0) {
		ans = order;
		ans_g = g;
		return;
	}

	int sum_wait = 0;
	for(int i = 0; i < n; ++i) {
		if((1 << i) & used) continue;
		sum_wait += w[i];
	}

	for(int i = 0; i < n; ++i) {
		if((1 << i) & used) continue;
		if(sum_wait - w[i] > s[i]) continue;

		order.emplace_back(i);
		dfs(rest - 1, used | (1 << i), g + (n - rest + 1) * w[i], order);
		order.pop_back();
	}
}

int main() {
	while(cin >> n && n) {
		for(int i = 0; i < n; ++i) {
			cin >> name[i] >> w[i] >> s[i];
		}

		vector<int> tmp;
		ans_g = INT_MAX;
		ans.clear();
		dfs(n, 0, 0, tmp);

		for(const auto &idx : ans) {
			cout << name[idx] << endl;
		}
	}

	return EXIT_SUCCESS;
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (b - a > 0) {
    if ((b - a) > x) {
      cout << "dangerous" << endl;
    } else {
      cout << "safe" << endl;
    }
    
    
  } else {
    cout << "delicious" << endl;
  }
  return 0;
}


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

typedef long double                 ld;
typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define endl                        '\n'
#define file_io                     freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define kill(x)                     return cout << x << endl , 0;
#define pb                          push_back

const ll MXN = 3e3 + 3;
const ll MX5 = 3e5 + 3;
const ll MX6 = 1e6 + 3;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; //998244353;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}
string base2(ll n){
    string a="";while(n>=2){a+=(char)(n%2+'0');n/=2;}a+=(char)(n+'0');reverse(all(a));return a;
}

ll dp[MXN][MXN];
pll par[MXN][MXN];
string s, t;
void init(){
    s = '.' + s;
    t = '.' + t;
    for(int i = 0; i < MXN; i++){
        for(int j = 0; j < MXN; j++){
            par[i][j]={-1,-1};
        }
    }
    return;
}

int main(){
    //fast_io
    //file_io

    cin >> s >> t;
    ll n = s.size(), m = t.size();
    init();
    /*
    bool f = 0;
    ll last;
    for(int j = 1; j <= m; j++){
        if(f){
            dp[1][j] = 1;
            par[1][j] = {1, last};
        }
        else{
            if(t[j] == s[1]){
                dp[1][j] = 1;
                f = 1;
                last = j;
            }
        }
    }*/
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(s[i] == t[j]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
                par[i][j] = {i - 1, j - 1};
            }
            else{
                //dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                if(dp[i - 1][j] >= dp[i][j - 1]){
                    dp[i][j] = dp[i - 1][j];
                    par[i][j] = {i - 1, j};
                }
                else{
                    dp[i][j] = dp[i][j - 1];
                    par[i][j] = {i, j - 1};
                }
            }
        }
    }
    //cout << dp[n - 1][m - 1];
    string ans = "";
    ll a = n, b = m;
    while(par[a][b].F != -1){
        if(s[a] == t[b]){
            ans = s[a] + ans;
        }
        ll ap = par[a][b].F, bp = par[a][b].S;
        a = ap, b = bp;
    }
    if(s[a] == t[b]){
        ans = s[a] + ans;
    }
    if(ans[0] == '.'){
        for(int i = 1; i < ans.size(); i++){
            cout << ans[i];
        }
        return 0;
    }
    cout << ans;
    return 0;
}
//! N.N


Measured memory_bytes: 211584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();

		char[] c = s.toCharArray();
		for(int i = 0 ; i < s.length() ; i++) {
			for(int j = 0 ; j< c.length ; j++) {
				c[j] = s.charAt((j + i) % c.length);
			}
			if(String.valueOf(c).equals(t)) {
				System.out.println("Yes");
				sc.close();
				return;
			}
		}
		System.out.println("No");

		sc.close();

	}

}


Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
using namespace std;
int x,y,ans=10000000000;
int main()
{
    cin>>x>>y;
    if(x==y){cout<<0<<endl;return 0;}
    if(y>x)ans=min(y-x,abs(y+x)+1);
    else ans=min(abs(x+y)+1,2+abs(x-y));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=input()
tmp=sum(map(int,list(n)))
print("No") if int(n)%tmp else print("Yes")

Measured memory_bytes: 68824