akhauriyash/Code-Regression huggingface dataset:
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(0,a+1):
	for j in range(0,b+1):
		for k in range(0,c+1):
			if 500*i + 100*j + 50*k == x:
				ans+=1
print(ans)

Measured memory_bytes: 3060
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.insert(0,0)
b.insert(0,0)

sum_a = [0]
for i in range(1,n+1):
    sum_a.append(sum_a[i-1] + a[i])

sum_b = [0]
for i in range(1,m+1):
    sum_b.append(sum_b[i-1] + b[i])

ans = 0
for i in range(n+1):
    if sum_a[i] > k:
        break
    for j in range(m,-1,-1):
        if sum_a[i] + sum_b[j] <= k:
            ans = max(ans, i+j)
            m = j
            break
print(ans)


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

#define UNKNOWN 0
#define SHEEP 1
#define WOLF -1

#define SAME 1
#define OPPOSITE -1

#define HONEST 1
#define LIAR -1


int sub(int N, vi& same, int htype0, int htype1) {
    vi htypes(N, UNKNOWN);
    htypes[N-1] = htype0;
    htypes[0] = htype1;

    // htypes[N-1] = htypes[0] * htypes[1] * same[0];
    for (int i=0; i<N; ++i) {
        htypes[(i+1)%N] = htypes[i] * htypes[(i-1 +N)%N] * same[i];
        // 1,2,..N-1,0
    }
    if (htypes[N-1] == htype0 && htypes[0] == htype1) {
        // cerr << htypes << endl;
        rep(i,N) {
            putchar(htypes[i] == SHEEP ? 'S' : 'W');
        }
        putchar('\n');
        return 1;
    }
    return 0;
}

void solve(int N, string& s) {
    vector<int> same(N);
    rep(i,N) same[i] = (s[i] == 'o') ? SAME : OPPOSITE;

    int htype[2] = { HONEST, LIAR };

    rep(htype0,2) rep(htype1,2) {
        if (sub(N,same,htype[htype0],htype[htype1])) return;
    }
    cout << -1 << endl;
}

int main() {
    int N; cin >> N;
    string s; cin >> s;
    solve(N,s);
    return 0;
}


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


int main() {
    //input
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x = x2 - x1;
    int y = y2 - y1;
    printf("%d %d %d %d", x2 - y , y2 + x , x1 - y, y1 + x);

    return 0;
}

Measured memory_bytes: 256
while True:
    s = input()
    if s == "#":
        break
    g, y, m, d = s.split()
    if int(y) >= 32:
        g = "?"
        y = str(int(y)-30)
    elif int(y) == 31:
        if int(m) >= 5:
            g = "?"
            y = str(int(y)-30)
    print(g, y, m, d)


Measured memory_bytes: 5596
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll X, Y;
    cin >> X >> Y;
    ll ans = 0;
    while(X <= Y) {
        ans++;
        X *= 2;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
map<int,int>ans;
long long digui(long long i)
{
	if(ans[i])
		return ans[i];
	else
		return ans[i]=(digui(i/2)%mod+digui((i-1)/2)%mod+digui((i-2)/2)%mod)%mod;
}
int main()
{
	unsigned long long n;
	cin>>n;
	ans[0]=1;
	ans[1]=2;
	cout<<digui(n)<<endl;
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, A;
    cin >> N >> A;
    vector<ll> x(N);
    REP(i, N) cin >> x[i];

    ll ma = 3000;
    ll dp[55][55][ma];
    REP(i, 55)REP(j, 55)REP(k, ma) dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    REP(i, N){
    	REP(j, N){
    		REP(k, ma){
    			dp[i+1][j][k] += dp[i][j][k];
    			if(k+x[i] < ma)dp[i+1][j+1][k+x[i]] += dp[i][j][k];
    		}
    	}
    }
    ll res = 0;
    for(int i=1;i<=N;i++){
    	res += dp[N][i][A*i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 71168
import sys
input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15


def main():
    n = getN()
    line = []
    for i in range(n):
        line.append((getN(), "P"))
    for i in range(n):
        line.append((getN(), "C"))

    line.sort()
    pc = 0
    cn = 0
    ans = 1
    # print(line)
    for point in line:
        pt, st = point
        if st == "P":
            if pc == 0 and cn != 0:
                ans *= cn
                ans %= MOD
                cn -= 1
            else:
                pc += 1

        else:
            if cn == 0 and pc != 0:
                ans *= pc
                ans %= MOD
                pc-=1
            else:
                cn += 1

    print(ans)



if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Measured memory_bytes: 57468
#include<cstdio>
#include<algorithm>
long long a[300000];
int main(){
    int n;
    long long asum=0;
    scanf("%d",&n);
    for(int i=0;i<3*n;i++)scanf("%lld",&a[i]);
    std::sort(a,a+3*n);
    for(int i=n;i<3*n;i+=2)asum+=a[i];
    printf("%lld",asum);
    return 0;
}

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

int main() {
	int A, B, count = 0;
	cin >> A >> B;
	for (int i = 1; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				int x = i * 10001 + j * 1010 + k * 100;
				if (A <= x && x <= B) count++;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
import numpy as np

h, w, *s = open(0).read().split()
h = int(h)
w = int(w)
all = sum(t.count('#') for t in s)

inf = 1 << 30
d = np.full((h + 1, w + 1), inf, dtype=np.int)

d[0][0] = 0
q = [(0, 0)]
for v in q:
    for nv in [(0, 1), (1, 0), (-1, 0), (0, -1)]:
        ny = v[0] + nv[0]
        nx = v[1] + nv[1]
        if 0 <= nx < w and 0 <= ny < h and d[ny][nx] == inf and s[ny][nx] == '.':
            d[ny][nx] = d[v[0]][v[1]] + 1
            q.append((ny, nx))

if d[h - 1][w - 1] == inf:
    print(-1)
else:
    print(h * w - (d[h - 1][w - 1] + 1) - all)


Measured memory_bytes: 27356
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

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


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod//i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.MOD



@mt
def slv(N, M, K):
    m = Mod(998244353)
    C = Combination(N, 998244353)

    ans = 0
    for i in range(K+1):
        n = N - i
        tmp = m.mul(M, m.pow(M-1, n-1))
        tmp = m.mul(tmp, C(N-1, i))
        ans = m.add(ans, tmp)

    return ans


def main():
    N, M, K = read_int_n()
    print(slv(N, M, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 115004
#include <stdio.h>

long max(long a, long b) {
  if (a >= b) {
    return a;
  } else {
    return b;
  }
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n],b[n],c[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld %ld %ld", &a[i], &b[i], &c[i]);
  }
  long dp[n][3];
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for (long i = 1; i < n; i++) {
    dp[i][0] = a[i]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1] = b[i]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2] = c[i]+max(dp[i-1][0],dp[i-1][1]);
  }
  long answer = dp[n-1][0];
  if (dp[n-1][1] > answer) {
    answer = dp[n-1][1];
  }
  if (dp[n-1][2] > answer) {
    answer = dp[n-1][2];
  }
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;


public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        long m = sc.nextLong();
        long n = sc.nextLong();
        if (m * n % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }

}


Measured memory_bytes: 22740
#include <stdio.h>

int main(void){
  int h1, h2, m1, m2, k;
  int dif_time = 0;
  
  scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);

  if( ( h1 == h2 ) && ( m2 < m1 ) )
    dif_time = ( 24 * 60 ) + ( 60 - m1 ) + m2;
  else if( h1 == h2 )
    dif_time = m2 - m1;
  else if( h1 > h2 )
    dif_time = ( ( 24 - m1 ) + m2 ) * 60 + ( 60 - m1 ) + m2;
  else if( h1 < h2 )
    dif_time = ( h2 - ( h1 + 1 ) ) * 60 + ( 60 - m1 ) + m2;

  if( ( dif_time - k ) <= 0 )
    printf("0\n");
  else
    printf("%d\n",dif_time - k );

  return 0;
}
    
	


Measured memory_bytes: 1732
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  200005
ll dp[N],h[N];
int main()
{
	ios
	ll n,i,j,k;
	cin>>n>>k;
	for(i=0;i<N;i++)
		dp[i]=hell;
	for(i=0;i<n;i++)
		cin>>h[i];
	dp[0]=0;
	for(i=0;i<n;i++){
		for(j=1;j<=k;j++){
			dp[i+j]=min(dp[i]+abs(h[i+j]-h[i]),dp[i+j]);
		}
	}
	//for(i=1;i<n;i++)cout<<dp[i]<<" ";
	cout<<dp[n-1];
	return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ull unsigned long long 
#define int long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;
#define ordered_set tree<pair<int, int>, null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>






 
int power(int x, int y) 
{ 
   int res = 1;      
                                                              
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  
 
        y = y>>1; 
 
        if (x<=100000000)
        x = (long long)(x*x);
 
        //cout<<x<<'\n'; 
    } 
    return res; 
} 
 
int gcd (int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

int ceiling(int a,int b){
  if(a%b!=0){
    return (a/b)+1;

  }
  else
    return (a/b);
}
 

 void solve()
 {
  int n;
  cin>>n;
  int a[n];
  int count=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    if(i%2!=0 and a[i]%2!=0)
      count++;
  }

  cout<<count<<endl;
  


 





return;
}



 
 int32_t main()
 {
  IOS;
  int t;
  t=1;
  while(t--){
    solve();
  }

    return 0;
 }


Measured memory_bytes: 3644
/*
* @Author: 王文宇
* @Date:   2018-03-25 20:35:14
* @Last Modified by:   王文宇
* @Last Modified time: 2018-03-25 21:23:41
*/
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=a;i<=b;i++)
const int maxn = 1006;
char s[maxn][maxn];
int n,m;
int main(int argc, char const *argv[])
{
	cin>>n>>m;
	if(n<=m)
	{
		int l = 1;
		int r = 3;
		_for(i,1,1000)
		{
			_for(j,1,1000)s[i][j]='.';
		}
		_for(i,1,n-1)
		{
			s[l][r]='#';
			s[l+1][r]='#';
			s[l+1][r-1]='#';
			s[l][r-2]='#';
			s[l+1][r-2]='#';
			s[l-1][r]='#';
			s[l-1][r-1]='#';
			s[l-1][r-2]='#';
			r+=4;
			if(r>100)
			{
				r=2;
				l+=4;
			}
		}
		int k = 100;
		int h = 100;
		_for(i,1,m-n+1)
		{
			s[h][k]='#';
			k-=2;
			if(k<=0)
			{
				k=100;
				h-=2;
			}
		}
		cout<<100<<" "<<100<<endl;
		_for(i,1,100)
		{
				_for(j,1,100)
				{
					cout<<s[i][j];
				}
				cout<<endl;
		}			
	}	
	else
	{
		int l = 1;
		int r = 3;
		_for(i,1,1000)
		{
			_for(j,1,1000)s[i][j]='#';
		}
		_for(i,1,m-1)
		{
			s[l][r]='.';
			s[l+1][r]='.';
			s[l+1][r-1]='.';
			s[l][r-2]='.';
			s[l+1][r-2]='.';
			s[l-1][r]='.';
			s[l-1][r-1]='.';
			s[l-1][r-2]='.';
			r+=4;
			if(r>100)
			{
				r=2;
				l+=4;
			}
		}
		int k = 100;
		int h = 100;
		_for(i,1,n-m+1)
		{
			s[h][k]='.';
			k-=2;
			if(k<=0)
			{
				k=100;
				h-=2;
			}
		}
		cout<<100<<" "<<100<<endl;
		_for(i,1,100)
		{
				_for(j,1,100)
				{
					cout<<s[i][j];
				}
				cout<<endl;
		}		
	}
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

template <typename T = int> T gcd(T a, T b) {
    if (a < b)
        return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template <typename T = int> T lcm(T m, T n) {
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main() {
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll g = lcm(n, m);
    map<ll, char> ret;
    for (ll i = 0; i < n; ++i) {
        ret[i * g / n] = s[i];
    }
    for (ll i = 0; i < m; ++i) {
        if (ret.count(i * g / m) != 0 && ret[i * g / m] != t[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 6144
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                ans+=__gcd(__gcd(i,j),k);
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n) {
        if (i&1) continue;
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3656
d = int(input())
cl = list(map(int, input().split()))
sl = []
for _ in range(d):
    sl.append(list(map(int, input().split())))

tl = []
# for _ in range(d):
#     tl.append(int(input()))

last_di = [-1]*26
ans = 0
for day in range(d):
    best_t = 0
    best_t_val = 0
    for t in range(26):
        curr_val = sl[day][t]
        for i in range(26):
            if i == t: continue
            curr_val -= (day-last_di[i])*cl[i]
        if curr_val >= best_t_val:
            best_t = t
            best_t_val = curr_val
    tl.append(best_t+1)
    last_di[best_t] = day

for t in tl:
    print(t)

# for day, t in enumerate(tl):
#     ans += sl[day][t-1]
#     last_di[t-1] = day
#     for ld, c in zip(last_di, cl):
#         # if ld == -1: continue
#         ans -= (day-ld)*c
#     print(ans)

Measured memory_bytes: 68228
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

int main() {
    string s;
    cin >> s;
    int q, t, f;
    char c;
    vector<char> fr;
    vector<char> bc;
    bool rev = false;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> t;
        if (t == 1) {
            rev = !rev;
            continue;
        }
        cin >> f;
        cin >> c;
        if (f == 1) {
            if (rev) {
                bc.push_back(c);
            } else {
                fr.push_back(c);
            }
        } else {
            if (rev) {
                fr.push_back(c);
            } else {
                bc.push_back(c);
            }
        }
    }
    // cout << "start" << endl;
    for (auto e : bc) {
        // cout << e << endl;
        s += e;
    }
    // cout << "rev" << endl;
    reverse(s.begin(), s.end());
    for (auto e : fr) {
        // cout << e << endl;
        s += e;
    }
    // cout << "end" << endl;
    if (!rev) reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


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

typedef long long ll;

int main() {
    string n;
    cin >> n;
    int cur = 0;
    for (int i = 0; i < (int)n.size(); i++)
        cur = (cur + (int)(n[i]-'0')) % 9;
    if (cur == 0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3748
S = input()
prvs = ''
si = None
for i, s in enumerate(S):
  if prvs == s:
    if si is None: si = i
    print(i,i+1)
    exit()
  else:
    if si is not None:
      print(si, i)
  prvs = s

for i in range(len(S)-2):
  if len(set(S[i:i+3]))<=2:
    print(i+1, i+3)
    exit()
  
print(-1, -1)
  

Measured memory_bytes: 41196
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
ll inf=1000000007;



const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
    string s;
    cin>>s;
    
    int n;
    n=(int)s.size();
    
    ll dp[100010][4]={};
    dp[n][3]=1;
    for(int i=0;i<3;i++) dp[n][i]=0;
    for(int i=n-1;i>=0;i--){
        
        //char c=s[i];
        
        for(int j=3;j>=0;j--){
            /*if(i==n){
                dp[i][j] = (j == 3 ? 1 : 0);
                //if(j==3) dp[i][j]=1;
                //else dp[i][j]=0;
            }else{*/
                
                dp[i][j]=dp[i+1][j]*(s[i] =='?' ? 3LL : 1LL);
                if(j < 3 && (s[i] == '?' || s[i] == "ABC"[j])){
                        dp[i][j] += dp[i+1][j+1];

                }
                dp[i][j]%=inf;
            
            }
        //}
        
        /*if(c=='?'){
            //j=3
            //何を書くかで三通り
            dp[i][3]=3LL*dp[i+1][3];
            
            //j=2
            //?にA,B,Cを入れて丸しない
            dp[i][2]=3LL*dp[i+1][2];
            //cを入れて丸
            dp[i][2]+=dp[i+1][3];
            
            //j=1
            //A,B,Cで丸しない
            dp[i][1]=3LL*dp[i+1][1];
            //Bで丸
            dp[i][1]+=dp[i+1][2];
            
            //j=0
            //丸しない
            dp[i][0]=3LL*dp[i+1][0];
            //Aで丸
            dp[i][0]+=dp[i+1][1];
        }else if(c=='C'){
            //j=3
            dp[i][3]=dp[i+1][3];
            //j=2
            //丸をするかしないか
            dp[i][2]=dp[i+1][2]+dp[i+1][3];
            //j=1
            dp[i][1]=dp[i+1][1];
            //j=0;
            dp[i][0]=dp[i+1][0];
        }else if(c=='B'){
            //j=3
            dp[i][3]=dp[i+1][3];
            //j=2
            dp[i][2]=dp[i+1][2];
            //j=1
            dp[i][1]=dp[i+1][1]+dp[i+1][2];
            
            dp[i][0]=dp[i][0];
            
        }else if(c=='A'){
            //j=3
            dp[i][3]=dp[i+1][3];
            //j=2
            dp[i][2]=dp[i+1][2];
            
            dp[i][1]=dp[i+1][1];
            
            dp[i][0]=dp[i+1][0]+dp[i+1][1];
        }*/
        
        /*for(int j=0;j<4;j++){
            dp[i][j]%=inf;
        }*/
    }
    
    cout<<dp[0][0]<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3584
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,k) = get!(usize,usize);
    let a = get!([isize]);
    let mut psums = vec![0; n+1];
    let mut sums = vec![0; n+1];
    for i in 0..n {
        psums[i+1] = psums[i]+max!(a[i],0);
        sums[i+1] = sums[i] + a[i];
    }

    let mut mx = std::isize::MIN;
    for i in 0..n-k+1 {
        let val = psums[n]-psums[i+k]+psums[i]+max!(sums[i+k]-sums[i],0);
        mx = max!(mx, val);
    }
    println!("{}", mx);
}


Measured memory_bytes: 12668
n,m = map(int,input().split())
a=[]
for _ in range(n):
    t1 = input()
    t1 = list(t1)
    a.append(t1)

b=[]
for _ in range(m):
    t2 = input()
    t2 = list(t2)
    b.append(t2)

for i in range(n-m+1):
    for j in range(n-m+1):
        check = True
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    check = False
                    break
            if check == False:
                break
        if check:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 38256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n , a, i;
    int min=1000001 , max=-1000001;
    long sum=0;
    
    scanf("%d", &n);
    for(i=1; i<=n; i++){
        scanf("%d", &a);
        if(a>max){
            max=a;
        }
        if(a<min){
            min=a;
        }
        sum += a;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}



Measured memory_bytes: 2108
L = []
m,f,r = map(int, input().split())
while m != -1 or f != -1 or r != -1:
    L.append([m,f,r])
    m, f, r = map(int, input().split())
for i in range(len(L)):
    if L[i][0] == -1 or L[i][1] == -1:
        print('F')
    elif L[i][0]+L[i][1] >= 80:
        print('A')
    elif L[i][0]+L[i][1] >= 65:
        print('B')
    elif L[i][0]+L[i][1] >= 50 or L[i][2] >= 50:
        print('C')
    elif L[i][0]+L[i][1] >= 30:
        print('D')
    else:
        print('F')


Measured memory_bytes: 5608
#include<iostream>
using namespace std;
int n;
int a[1000000];
int ans[1000000];
long sum;
long sum_odd;
int main(){
    cin >> n;
    sum = 0;
    sum_odd = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
        if(i%2 == 1){
            sum_odd += a[i];
        }
    }
    ans[0] = sum - 2*sum_odd;
    for(int i=1;i<n;i++){
        ans[i] = 2*a[i-1]-ans[i-1];
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << " " ;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int a[200100];
long long sum[200100];
map<long long,int> mp;
int front[200100];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	long long ans=0;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),a[i]%=k;
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
	mp[0]=1;
	int l=1,r=0;
	for(long long i=1;i<=n;i++){
		if(i>=k)mp[(sum[i-k]-(i-k)+k)%k]--;
		if(mp[(sum[i]-i+k)%k]){
			ans+=mp[(sum[i]-i+k)%k];	
		}
		mp[(sum[i]-i+k)%k]++;
	}
	cout<<ans;
		
	return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include<limits.h>
using namespace std;
using T = tuple<int,int,int>;

#define gc getchar_unlocked
#define sdi(a, b)   si(a);si(b)
#define FOR(i, n)  for(int i = 0;i < n; i++) 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e9
#define ss second
#define ff first
#define vi vector<int>
#define pri(arr,a,b) repn(i,1,a){repn(j,i+1,b){cout<<arr[i][j]<<" ";}cout<<endl;}
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<int,pair<int,int>> piii;
 
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
 
const int mod=1e9+7;
//const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e6+10;



void solve()
{
    string s,t;
    cin>>s>>t;
    int cnt=0;
    rep(i,0,sz(s)){
        if(s[i]!=t[i]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("inputf.in", "r", stdin);
    //     freopen("outputf.in", "w", stdout);
    // #endif
    fast_cin();
    int T;
    //sieve();
    //cin>>T;
    T=1;
    int t1=1;
    while(true)
    {  
        
        solve(); 
        t1++;
        if(t1>T)
            break;
    }
}

Measured memory_bytes: 3876
N,W=map(int,input().split())
dp=[-1]*(W+1)
dp[0]=0
for _ in range(N):
    w,v=map(int,input().split())
    for i in range(W+1)[::-1]:
        if dp[i]!=-1 and i+w<=W:
            dp[i+w]=max(dp[i+w],dp[i]+v)
print(max(dp))    


Measured memory_bytes: 68064
/*
Author:Jenil Mehta
Not yet serious but trying to be serious :)
Coding is lub
*/
 
#include <iostream>
#include <sstream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
typedef long long int ll;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;
ll a[1002];
ll b[1002];
int dp[3000 + 5][3000 + 5];
 
int main() {
   /*
   Jab Bhi Koi Ladaki Dekhun Meraa Dil Divaanaa Bole
Ole Ole Ole, Ole Ole Ole
Gaao Taraanaa Yaaraa Jhum Jhum Ke Haule Haule
Ole Ole Ole, Ole Ole Ole
Mujhako Lubhaati Hai Javaaniya Masti Lutaati Zidagaani Yahaan
Maane Na Kahanaa Paagal Mast Pavan Saa Dil Ye Dole
Ole Ole Ole, Ole Ole Ole
Ole Ole Ole, Ole Ole Ole
Jab Bhi Koi Ladaki Dekhun Meraa Dil Divaanaa Bole
Ole Ole Ole, Ole Ole Ole
Gaao Taraanaa Yaaraa Jhum Jhum Ke Haule Haule
Ole Ole Ole, Ole Ole Ole
   */
    ll n;
    cin>>n;
    ll a[n];
    ll cnt[n+1]={0};
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<n;i++)
    cnt[a[i]]++;
    ll dp[n+1]={0};
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        dp[i]=cnt[i]*(cnt[i]-1)/2;
        sum+=dp[i];
    }
    for(ll i=0;i<n;i++)
    {
        ll x=cnt[a[i]]-1;
        ll ans=sum-dp[a[i]]+x*(x-1)/2;
        cout<<ans<<endl;
    }
}

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

const int x = 10;
const int y = 5;
const int z = 1;

int main(){
    int N, Y; cin >> N >> Y;
    Y /= 1000;
    
    int a =  1 * (Y-z*N);
    int b = -2 * (Y-z*N);
    int c;
    
    if(b < 0){
        int k = (-b+x-z-1)/(x-z);
        a -= k*(y-z);
        b += k*(x-z);
    }else{
        int k = b/(x-z);
        a += k*(y-z);
        b -= k*(x-z);
    }
    
    if(a<0 || b<0 || a+b>N)
        a = b = c = -1;
    else
        c = N-a-b;
    
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


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

int NILL = -1;
int a = 0;

struct node{
    int parent, left, right, depth, height;
    node(){
        parent = NILL;
        left = NILL;
        right = NILL;
        depth = NILL;
        height = NILL;
    }
};

std::vector<node> tree;


int findSlibing(int a){
    int parent = tree[a].parent;

    if(parent == NILL){
        return parent;
    }else if(tree[parent].right == a){
        return tree[parent].left;
    }else{
        return tree[parent].right;
    }
}

int countDegree(int a){
    int cnt = 0;
    if(tree[a].right != NILL){
        cnt++;
    }
    if(tree[a].left != NILL){
        cnt++;
    }
    return cnt;
}

int countDepth(int a, int p){
    if(a == NILL) return 0;
    tree[a].depth = p;
    countDepth(tree[a].left, p+1);
    countDepth(tree[a].right, p+1);
}

int setHeight(int a){
    int h1 = 0;
    int h2 = 0;
    if(tree[a].right != NILL){
        h1 = setHeight(tree[a].right) + 1;
    }
    if(tree[a].left != NILL){
        h2 = setHeight(tree[a].left) + 1;
    }
    return tree[a].height = std::max(h1, h2);
}

std::string judgeType(int a){
    if(tree[a].parent == -1){
        return "root";
    }else if(tree[a].left == NILL && tree[a].right == NILL){
        return "leaf";
    }else{
        return "internal node";
    }
}

int main(void){
    int n;
    std::cin >> n;
    tree.resize(n);
    int id, left, right;
    for(int i = 0; i < n; i++){
        std::cin >> id >> left >> right;
        tree[id].left = left;
        tree[id].right = right;
        tree[left].parent = tree[right].parent = id;
    }

    int root;
    for(int i = 0; i < n; i++){
        if(tree[i].parent == -1){
            root = i;
            break;
        }
    }
    countDepth(root, 0);

    setHeight(root);

    for(int i = 0; i < n; i++){
        std::cout << "node " << i << ": parent = " << tree[i].parent\
        << ", sibling = " << findSlibing(i) << ", degree = " << countDegree(i)\
        <<  ", depth = " << tree[i].depth << ", height = "\
        << tree[i].height << ", " << judgeType(i) << std::endl;
    }
    return 0;
}


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

using namespace std;

#define INF 1e+9
#define mp make_pair
#define pb push_back
#define fi first
#define fs first
#define se second
#define i64 long long
#define li long long
#define lint long long
#define pii pair<int, int>
#define vi vector<int>

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

int cnt[3];
int n;

int main() {
#ifdef LOCAL
    freopen("inp", "r", stdin);
    //freopen("outp", "w", stdout);
#else
    // freopen(TASKNAME ".in", "r", stdin);
    // freopen(TASKNAME ".out", "w", stdout);
#endif
    scanf("%d", &n);
    forn(j, n) {
        int x;
        scanf("%d", &x);
        if (x % 4 == 0)
            cnt[2]++;
        else if (x % 2 == 0)
            cnt[1]++;
        else cnt[0]++;
    }
    int prev = 2;
    forn(j, n) {
        bool ok = false;
        fore(chosen, 2 - prev, 2)
            if (cnt[chosen]) {
                cnt[chosen]--;
                prev = chosen;
                ok = true;
                break;
            }
        if (!ok) {
            printf("No");
            exit(0);
        }
    }
    printf("Yes");
}



Measured memory_bytes: 384
import java.util.*;
public class Main {
	Scanner sc;

	// 整数の入力
	int n;
	int a;
	int b;
	int c;
	int d;

	// 文字列の入力
	String s;
	String[] S;
	int[] Sn;
	int sna;
	int snb;

	boolean flg = true;

	Main(){
		sc = new Scanner(System.in);

		// 整数の入力
		n = sc.nextInt();
		a = sc.nextInt()-1;
		b = sc.nextInt()-1;
		c = sc.nextInt()-1;
		d = sc.nextInt()-1;

		// 文字列の入力
		s = sc.next();
		S = s.split("");
		Sn = new int[n];
		sna = a;
		snb = b;
		Sn[sna]=1;
		Sn[snb]=1;

		int befA;
		int befB;

		if(c>d){
			while(flg&&Sn[c]==0){
				befA = sna;
				sna = move(sna);
				if(befA==sna){
					if(Sn[d]==0){
						befB = snb;
						snb = move(snb);
						if(befB==snb)flg=false;
					} else {
						flg=false;
					}
				}
			}
			while(flg&&Sn[d]==0){
				befB = snb;
				snb = move(snb);
				if(befB==snb)flg=false;
			}
		} else {
			while(flg&&Sn[d]==0){
				befB = snb;
				snb = move(snb);
				if(befB==snb){
					if(Sn[c-1]==0){
						befA = sna;
						sna = move(sna);
						if(befA==sna)flg=false;
					} else {
						flg=false;
					}
				}
			}
			while(flg&&Sn[c]==0){
				befA = sna;
				sna = move(sna);
				if(befA==sna)flg=false;
			}

		}

		// 出力
		if(flg)System.out.println("Yes");
		else System.out.println("No");

	}

	public static void main(String[] args){
		new Main();
	}

	int move(int x){
		if(x>=n-1)return x;
		if(S[x+1].equals("#")||Sn[x+1]==1){
			if(S[x+2].equals("#")||Sn[x+2]==1){
				return x;
			} else {
				Sn[x]=0;
				Sn[x+2]=1;
				return x+2;
			}
		} else {
			Sn[x]=0;
			Sn[x+1]=1;
			return x+1;
		}
	}
}

Measured memory_bytes: 53284
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;


mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int d; cin >> d;
    for(int i=0;i<d;i++){
        cout << i%26+1 << endl;
    }
}

Measured memory_bytes: 3656
# Queue
class Array
  alias_method :enqueue, :push
  alias_method :dequeue, :shift
end

lines = $stdin.read
array = lines.split("\n")

Node = Struct.new(:u, :k, :v, :visited)

class Graph

  attr :nodes, :dist

  def initialize(n)
    @nodes = Array.new(n){ Node.new }
    @dist = Array.new(n)
  end

  def set_graph_node(u, k, v)
    @nodes[u-1].u = u
    @nodes[u-1].k = k
    @nodes[u-1].v = v
    @nodes[u-1].visited = false
  end

  def bfs(start = 0, queue)

    @nodes[start].visited = true
    # puts "visit = #{@nodes[start].u}, queue = #{queue.to_s}"
    @dist[start] = 0
    # puts "dist: @dist[#{start}] = 0"
    queue.enqueue(@nodes[start])

    while not queue.empty?

      node = queue.dequeue
      #puts "deq = #{node.u}, queue = #{queue.to_s}"

      for i in node.v
        unless @nodes[i-1].visited
          @nodes[i-1].visited  = true
          queue.enqueue(@nodes[i-1])
          #puts "enq = #{@nodes[i-1].u}, queue = #{queue.to_s}"
          @dist[@nodes[i-1].u - 1] = @dist[node.u-1] + 1
          #puts "dist: @dist[#{@nodes[i-1].u-1}] = #{@dist[node.u - 1] + 1}"
        end
      end
    end
  end
end

N     = array[0].to_i
graph = Graph.new(N)

for i in 1...array.length
  seps = array[i].split(" ")
  u = seps.drop(0).first.to_i
  k = seps.drop(1).first.to_i
  v = seps.drop(2).map(&:to_i)
  graph.set_graph_node(u, k, v)
end

# puts graph.nodes.to_s
graph.bfs(start = 0, [])

# puts "distances #{graph.dist.to_s}"

1.upto(N).each do |n|
  if graph.dist[n-1].nil?
    puts "#{n} -1"
  else
    puts "#{n} #{graph.dist[n-1]}"
  end
end

Measured memory_bytes: 8796
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
    
    
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Time> list = new ArrayList<Time>();
		int k = sc.nextInt();
		for(int i = 0; i < k; i++) {
			list.add(new Time(sc.next()));
		}
		int n = sc.nextInt();
		Time[][] C = new Time[n][];
		for(int i = 0; i < n; i++) {
			int K = sc.nextInt();
			C[i] = new Time[K];
			for(int j = 0; j < K; j++) {
				C[i][j] = new Time(sc.next());
			}
		}
		int m = sc.nextInt();
		Time[][] S = new Time[m][];
		for(int i = 0; i < m; i++) {
			int K = sc.nextInt();
			S[i] = new Time[K];
			for(int j = 0; j < K; j++) {
				S[i][j] = new Time(sc.next());
			}
		}
		int[] countA = new int[list.size()];
		int[] countB = new int[list.size()];
		for(int i = 0; i < list.size(); i++) {
			for(int j = 0; j < n; j++) {
				for(int K = 0; K < C[j].length; K++) {
					if(C[j][K].coverTo(list.get(i))) {
						countA[i]++;
						break;
					}
				}
			}
		}
		for(int i = 0; i < list.size(); i++) {
			for(int j = 0; j < m; j++) {
				for(int K = 0; K < S[j].length; K++) {
					if(S[j][K].coverTo(list.get(i))) {
						countB[i]++;
						break;
					}
				}
			}
		}
		int sum = 0;
		for(int i = 0; i < list.size(); i++) {
			sum += Math.min(countA[i], countB[i]);
		}
		System.out.println(sum);
		
	}
	
	static class Time implements Comparable<Time> {
		int startTime;
		int endTime;
		@Override
		public int compareTo(Time o) {
			if(this.startTime == o.startTime) return this.endTime - o.endTime;
			return this.startTime - o.startTime;
		}
		public Time(String a) {
			String[] A = a.split("-");
			String[] BA = A[0].split(":");
			String[] BB = A[1].split(":");
			startTime = Integer.parseInt(BA[0]) * 60 + Integer.parseInt(BA[1]);
			endTime   = Integer.parseInt(BB[0]) * 60 + Integer.parseInt(BB[1]);
		}
		public boolean coverTo(Time o) {
			return (this.startTime <= o.startTime && this.endTime >= o.endTime);
		}
	}
}

Measured memory_bytes: 65636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> MY(M);
  for(int i=0;i<M;i++){
    cin >> MY.at(i);
  }
  int l=0;
  int r=0;
  for(int i=0;i<M;i++){
    if(MY.at(i)<X){
      l++;
    }
    else r++;
  }
  cout << min(l,r) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc110_d
{
    class Program
    {
        static long mod = 1000000007;
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            int m = M;
            long ans = 1;
            for (int i = 2; i*i <= m; i++){
                if(m % i == 0){
                    int cnt=0;
                    while(m % i == 0){
                        cnt++; m /= i;
                    }
                    ans *= calcComb(N+cnt-1, cnt);
                    ans %= mod;
                }
            }
            if (m != 1) {
	            ans *= calcComb(N, N-1);
	            ans %= mod;
	        }
            WriteLine(ans);
        }

        static long modpow(long a, long p){
          if (p == 0) return 1;
          if (p % 2 == 0) {
            int halfP = (int)p/2;
            long half = modpow(a, halfP);
            return half * half % mod;
          } else {
            return a * modpow(a, p-1) % mod;
          }
        }

        static long calcComb(int a, int b){
            if(b > a-b) return calcComb(a, a-b);

            long ansMul = 1;
	        long ansDiv = 1;

            for (int i = 0; i < b; i++)
            {
                ansMul *= (a-i);
                ansDiv *= (i+1);
                ansMul %= mod;
                ansDiv %= mod;
            }

            long ans = ansMul * modpow(ansDiv, mod-2) % mod;
            return ans;

        }
    }
}

Measured memory_bytes: 13524
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long LL;

const int N = 5010;
const LL mod = 1e9 + 7;

struct V { int c, size; } v[N];
struct E { int t, next; } e[N << 1];
int num;

void add(int s, int t)
{
	e[++ num] = (E) { t, v[s].c }, v[s].c = num;
	e[++ num] = (E) { s, v[t].c }, v[t].c = num;
}

LL f[N][N][2], h[N][2], g[N];

void dfs(int x, int fa)
{
	v[x].size = 1;
	f[x][0][0] = 1;
	for (int i = v[x].c; i; i = e[i].next)
	{
		int c = e[i].t;
		if (c == fa) continue;
		dfs(c, x);
		memset(h, 0, sizeof h);
		for (int i = 0; i <= v[x].size; ++ i)
		{
			for (int j = 0; j <= v[c].size; ++ j)
			{
				(h[i + j][0] += f[x][i][0] * f[c][j][0]) %= mod;
				(h[i + j][0] += f[x][i][1] * f[c][j][1]) %= mod;
				(h[i + j][1] += f[x][i][0] * f[c][j][1]) %= mod;
				(h[i + j][1] += f[x][i][1] * f[c][j][0]) %= mod;
			}
		}
		memcpy(f[x], h, sizeof h);
		v[x].size += v[c].size;
	}
	if (x != 1)
	{
		for (int i = v[x].size; i >= 0; -- i)
		{
			(f[x][v[x].size][0] += f[x][i][1] * g[v[x].size - i]) %= mod;
			(f[x][v[x].size][1] += f[x][i][0] * g[v[x].size - i]) %= mod;
		}
	}
}

int n, s, t;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n - 1; ++ i)
	{
		scanf("%d %d", &s, &t);
		add(s, t);
	}
	g[0] = 1;
	for (int i = 2; i <= n; i += 2)
		g[i] = g[i - 2] * (i - 1) % mod;
	dfs(1, 0);
	LL ans = 0;
	for (int i = 0; i <= n; ++ i)
	{
		(ans += f[1][i][0] * g[n - i]) %= mod;
		(ans -= f[1][i][1] * g[n - i]) %= mod;
	}
	printf("%lld\n", (ans + mod) % mod);
}

Measured memory_bytes: 392320