akhauriyash/Code-Regression huggingface dataset:
import functools
import itertools

import os
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        ret = fn(*args, **kwargs)
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        print(ret)
        return ret

    return wrapper


def count_mp(target, sizes):
    return (len(sizes) - 1) * 10 + abs(target - sum(sizes))


N, A, B, C = map(int, input().split())
sizes = []
for _ in range(N):
    sizes.append(int(input()))

ans = INF
for allocs in itertools.product('abc_', repeat=N):
    a = []
    b = []
    c = []
    mp = 0
    for i, al in enumerate(allocs):
        if al == 'a':
            a.append(sizes[i])
        if al == 'b':
            b.append(sizes[i])
        if al == 'c':
            c.append(sizes[i])
    if not a or not b or not c:
        continue
    ans = min(ans, count_mp(A, a) + count_mp(B, b) + count_mp(C, c))
    if ans == 0:
        break
print(ans)


Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

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

  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  ll numer = 10;
  while(N/numer >= 1) {
    ans += N/numer;
    numer *= 5;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k&1){
    cout<<b-a<<endl;
  }
  else{
    cout<<a-b<<endl;
  }
  return(0);
}

Measured memory_bytes: 3536
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int32_t main()
{
    #ifdef DEBUG
    freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    ll N,A,B,C,D;
    scanf("%lld %lld %lld %lld %lld",&N,&A,&B,&C,&D);
    ll goal = fabs(A-B);
    N -= 1;
    string ans = "NO";

    for (ll pairs=0; pairs<N/2; pairs++) {
        ll range = pairs*(D-C);
        ll n = N-2*pairs;
        ll low_goal = goal-range;
        ll high_goal = goal+range;
        ll min_possible = C*n;
        ll max_possible = D*n;

        //check for overlap in the intervals
        if (min_possible <= low_goal && low_goal <= max_possible ||
            low_goal <= min_possible && min_possible <= high_goal) {
            ans = "YES";
            break;
        }
    }

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int64 a, b, k;
  cin >> a >> b >> k;
  int64 used = min(a, k);
  a -= used;
  k -= used;
  if (k > 0) {
    used = min(b, k);
    b -= used;
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

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

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  complex<double> p1(x1, y1), p2(x2, y2);
  auto p3 = p2 + (p2 - p1) * complex<double>(0, 1);
  auto p4 = p3 + (p3 - p2) * complex<double>(0, 1);
  cout << int(p3.real()) << " " << int(p3.imag()) << " " << int(p4.real()) << " " << int(p4.imag()) << endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

import static java.util.Arrays.binarySearch;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 1000000007;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
//        int a = in.nextInt();
//        int b = in.nextInt();
//        int ans = 1000000;
//        for (int i = 1; i < 100; i++) {
//            for (int j = 1; j <= 5; j++) {
//                if ((a * i + b * j) % 10000 < ans) {
//                    ans = (a * i + b * j) % 10000;
//                    out.println(ans + " " + i + " " + j);
//                }
//            }
//        }
        int n = in.nextInt();
        int x = in.nextInt();
        int y = in.nextInt();
        int[] dis = new int[n];
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                int minDis = Math.min(Math.abs(j - x) + Math.abs(y - i) + 1, Math.abs(j - y) + Math.abs(x - i) + 1);
                minDis = Math.min(j - i, minDis);
                dis[minDis]++;
            }
        }
        for (int i = 1; i < n; i++) {
            out.println(dis[i]);
        }
    }


}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

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

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

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


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

int main(){
    int n=0,sum1=0,sum2=0;
    string str1,str2;
    cin >> n;
    for(int i=0;n>i;i++){
        cin >> str1 >> str2;
        if(str1==str2){
            sum1++;
            sum2++;
        }
        else if(str1>str2) sum1+=3;
        else if(str1<str2) sum2+=3;
        str1="";
        str2="";
    }
    cout << sum1 << " " << sum2 << endl;
}


Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		String S = in.next();
		int block = 1;
		char prev = S.charAt(0);
		for (int i = 1; i < S.length(); i++) {
			if(prev != S.charAt(i)) {
				block ++;
			}
			prev = S.charAt(i);
		}
		int unhappy = Math.max(1, block - 2*K);
		System.out.println(S.length()-unhappy);
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 24904
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

int main(){

  int x,y,z;
  int tri=0;
  int t=0;
  int e=0;
  int d=0;
  while(cin>>x>>y>>z){
    vector<int> v;
    v.push_back(x);
    v.push_back(y);
    v.push_back(z);
    sort(v.begin(),v.end());
    if(v[0]+v[1]<=v[2])break;
    else{
      tri++;
      if(v[0]*v[0]+v[1]*v[1]==v[2]*v[2])t++;
      else if(v[0]*v[0]+v[1]*v[1]>v[2]*v[2])e++;
      else d++;
    }
  }
  cout<<tri<<" "<<t<<" "<<e<<" "<<d<<endl;
  
  return 0;
}

Measured memory_bytes: 1224
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <stdio.h>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
ull gcd(ull a, ull b){return b? gcd(b, a%b):a;}
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for(int i = 0; i <= 50000; i++){
		int price = floor(i * 1.08);
		if(price == N){
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char c[] = s.toCharArray();
		
		int t = (c.length - 2);
		
		System.out.print(c[0]);
		System.out.print(t);
		System.out.print(c[c.length -1]);
		
	}
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
  cerr << ' ' << head;
  debug_cerr(tail...);
}
void chmax(lint &a, lint b) { if (a < b) a = b; }
void chmin(lint &a, lint b) { if (a > b) a = b; }
struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} iosetup;
lint gcd(lint a,lint b){return b?gcd(b,a%b):a;};
lint lcm(lint a,lint b){return a * b / gcd(a, b);};

int main() {
  lint a, b;
  cin >> a >> b;
  cout << lcm(a, b) << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,i,total=0;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if(c%i==0){
      total++;
    }
  }
  printf("%d\n",total);
  return(0);
}

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

unordered_map<int, bool> mp;
const int nax = 1e4;

int main() {

    int k;
    cin >> k;
    string s; cin >> s;

    if(s.length() <= k) {
        cout << s << "\n";
    }else {
        string t = s.substr(0, k);
        t += "...";
        cout << t << "\n";
    }
    return 0;
}




Measured memory_bytes: 3612
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	int n;
	cin >> n;
	vector<pair<double, string>> otoshidama(n);
	rep(i, 0, n) cin >> otoshidama[i].first >> otoshidama[i].second;

	double ans = 0;
	rep(i, 0, n) {
		if (otoshidama[i].second == "JPY") ans += otoshidama[i].first;
		else ans += (otoshidama[i].first * 380000.0);
	}

	cout << fixed << setp(8);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;
vector<int> g[101010], rg[101010];
int a, b;
int indeg[101010];
vector<int> t;
int ans[101010];
int d[101010];

void tsort(int i){
    queue<int> q;
    q.push(i);
    while((int)q.size()){
        int cur = q.front();
        q.pop();
        t.emplace_back(cur);
        REP(i, (int)g[cur].size()){
            indeg[g[cur][i]]--;
            if(indeg[g[cur][i]] == 0)q.push(g[cur][i]);
        }
    }
}

int main(){
    cin >> n >> m;
    REP(i, n - 1 + m){
        cin >> a >> b;
        g[a].emplace_back(b);
        rg[b].emplace_back(a);
        indeg[b]++;
    }
    for(int i = 1;i <= n;i++){
        if(indeg[i] == 0){
            tsort(i);
        }
    }
    for(int i = 1;i < (int)t.size();i++){
        int maxl = 0, maxpos = 0;
        REP(j, (int)rg[t[i]].size()){
            if(maxl <= d[rg[t[i]][j]]){
                maxl = d[rg[t[i]][j]];
                maxpos = rg[t[i]][j];
            }
        }
        d[t[i]] = maxl + 1;
        ans[t[i]] = maxpos;
    }
    for(int i = 1;i <= n;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 13816
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct {
	int top;         // スタックポインタ(一番上の位置)
	int S[MAX];
} Stack;


// スタック st の初期化
void initialize(Stack *st)
{
	st->top = 0;
	st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
	return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{
	return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
	if (isFull(st))
		exit(1);

	st->top++;
	st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
	if (isEmpty(st))
		exit(1);

	st->top--;
	return st->S[st->top+1];
}


int main(void)
{
	Stack st1;     // '\' の開始位置を格納するスタック
	Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
	Stack st2_a;   // 各水たまりの水量を格納するスタック

	// スタック初期化
	initialize(&st1);
	initialize(&st2_j);
	initialize(&st2_a);

	char c;
	int sum = 0;  // 水たまりの総水量
	int j;
	// 地形を読み込み，各水たまりの水量を計算
	for (int i = 0; (c = getchar()) != EOF; i++) {
		if (c == '\\') {
			push(i,&st1);                                 // '\' が出た時の処理
			// 位置 i を st1 にプッシュ(write your code)

		} else if (!isEmpty(&st1) && c == '/')
		{


			// '/' が出た時の処理
			// 水たまりの総水量 sum を更新(write your code)

			// st2_j と st2_a を用いて水たまりの水量を更新
			j=pop(&st1);
			int a = i - j;
			sum+=a;  // 更新する水たまりの水量を a に格納していく
			while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
				a+=pop(&st2_a);
				pop(&st2_j);

			}
				push(a,&st2_a);
				push(j,&st2_j);
		}
	}
	// 水たまりの水量を求めていく (write your code)
// 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)

printf("%d\n", sum);       // 水たまりの総水量を出力
printf("%d", st2_a.top);   // 水たまりの個数を出力

// 各水たまりの水量を断面図の左から出力(スタックの底から出力)
for (int i = 1; i <= st2_a.top; i++)
	printf(" %d", st2_a.S[i]);
printf("\n");

return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int main()
{
	ll x, y;
	cin >> x >> y;
	if (labs(x - y) > 1) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Brown" << endl;
	}
	return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int K,x;cin>>K>>x;
	for(int i=max(-1000000,x-K+1);i<=min(1000000,x+K-1);i++){
		cout<<i<<' ';
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[101][4][4][4];
int mod=1e9+7;
int main(){
	int n;
	cin>>n;
	dp[0][3][3][3]=1;
	for(int len=0;len<n;len++)
	 
	 	for(int c1=0;c1<4;c1++)
	 	
	 		for(int c2=0;c2<4;c2++)
	 		
	 			for(int c3=0;c3<4;c3++)
	 			
	 			{
					 	if(dp[len][c1][c2][c3]==0)continue;
	 				for(int a=0;a<4;a++)
	 				{
					 
	 					if(a==2&&c1==1&&c2==0)continue;
	 					if(a==2&&c1==0&&c2==1)continue;
	 					if(a==1&&c1==2&&c2==0)continue;
	 					if(a==2&&c1==1&&c3==0)continue;
	 					if(a==2&&c2==1&&c3==0)continue;
	 					dp[len+1][a][c1][c2]+=dp[len][c1][c2][c3];
						dp[len+1][a][c1][c2]%=mod;  }
			}
	 int ans=0;
	 for(int c1=0;c1<4;c1++)
	 
	 	for(int c2=0;c2<4;c2++)
	 	
	 		for(int c3=0;c3<4;c3++)
	 		
	 			{
				 ans+=dp[n][c1][c2][c3];
	 			ans%=mod;}
	
	 cout<<ans<<endl;
} 

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e3 + 5;
const double eps = 1e-9;
char a[MAXN][MAXN];
pair<char,char> x = mp('a','b'), y = mp('d', 'e');
pair<char,char> cur;

void put3(int i, int j) { // 1
	a[i][j] = a[i+1][j] = a[i+2][j+1] = a[i+2][j+2] = 'c';
}

void put32(int i, int j) { // 2
	a[i][j] = a[i+1][j] = a[i+1][j+2] = a[i+2][j+2] = 'a';
	a[i+2][j] = a[i+2][j+1] = a[i][j+1] = a[i][j+2] = 'b';
}

void put4(int i, int j) { // 3
	a[i][j] = a[i][j+1] = a[i+2][j+2] = a[i+2][j+3] = 'a';
	a[i+1][j] = a[i+1][j+1] = a[i+3][j+2] = a[i+3][j+3] = 'b';
	a[i][j+2] = a[i+1][j+2] = a[i+2][j] = a[i+3][j] = 'c';
	a[i][j+3] = a[i+1][j+3] = a[i+2][j+1] = a[i+3][j+1] = 'd';
}

void put5(int i, int j) { // 3
	a[i][j] = a[i+1][j] = a[i+4][j] = a[i+4][j+1] = a[i+4][j+4] = a[i+3][j+4] = a[i][j+4] = a[i][j+3] = 'a';
	a[i+2][j] = a[i+3][j] = a[i+4][j+2] = a[i+4][j+3] = a[i+2][j+4] = a[i+1][j+4] = a[i][j+2] = a[i][j+1] = 'b';
	a[i+1][j+1] = a[i+2][j+1] = a[i+3][j+2] = a[i+3][j+3] = 'c';
}

void put6(int i, int j) { // 1
	put3(i+3, j);
	put3(i, j+3);
	put32(i, j);
	put32(i+3, j+3);
}

void put7(int i, int j) { // 3
	for (int k = 1; k < 6; k += 2)
		if (k/2 & 1)
			a[i][j+k] = a[i][j+k+1] = a[i+k][j] = a[i+k+1][j] = 'a';
		else
			a[i][j+k] = a[i][j+k+1] = a[i+k][j] = a[i+k+1][j] = 'b';
	for (int k = 1; k < 5; k += 3)
		for (int e = 1; e < 5; e += 3)
			a[i+k][j+e] = a[i+k+1][j+e] = a[i+k+2][j+e+1] = a[i+k+2][j+e+2] = 'c';
}

int main() {
	int n; scanf("%d", &n);
	if (n <= 2) return !printf("-1\n");
	for (int i = 0; i < n; i++) 
		for (int j = 0; j < n; j++)
			a[i][j] = '.';
	if (n == 3) {
		put3(0, 0);
	} else if (n % 4 == 3) {
		for (int i = 0; i+7 < n; i += 4)
			put4(i, i);
		put7(n-7, n-7);
	} else if (n % 4 == 1) {
		for (int i = 0; i+5 < n; i += 4)
			put4(i, i);
		put5(n-5, n-5);
	} else if (n % 4 == 2) {
		for (int i = 0; i+6 < n; i += 4)
			put4(i, i);
		put6(n-6, n-6);
	} else if (n % 4 == 0) {
		for (int i = 0; i < n; i += 4)
			put4(i, i);
	}
	for (int i = 0; i < n; i++)
		printf("%s\n", a[i]);
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
const int maxn = 444;
int main(){
  vector<vector<int> > f(maxn, vector<int>(maxn, 1<<30)), nf;
  int n, m0, m1; cin >> n >> m0 >> m1;
  f[0][0] = 0;
  for(int i = 0; i < n; i++){
  	nf = f;
    int a, b, c; cin >> a >> b >> c;
    for(int j = 0; j < maxn - a; j++){
      for(int k = 0; k < maxn - b; k++){
      	nf[j + a][k + b] = min(nf[j + a][k + b], f[j][k] + c);
      }
    }
    f = nf;
  }	
  int ans = 1<<30;
  for(int i = 1; i < maxn; i++) for(int j = 1; j < maxn; j++) {
  	if(i * m1 == m0 * j) ans = min(ans, f[i][j]);
  }
  if(ans == (1<<30)) ans = -1;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef pair<int, int> ii;

vector<int> rem[200005];

int main(){
    int N; long long K;
    scanf("%d%lld", &N, &K);

    set<ii> s;
    long long sum = 0;
    s.insert(ii(0, 0));
    rem[0].push_back(0);
    int cnt = 1;
    for(int i = 1; i <= N; i ++){
        long long temp;
        scanf("%lld", &temp);
        temp = (temp+K-1)%K;
        sum = (sum+temp)%K;

        //printf("debug: %d %lld\n", i, sum);

        auto it = s.lower_bound(ii(sum, -1));
        if(it == s.end()){
            rem[cnt].push_back(i);
            s.insert(ii(sum, cnt));
            cnt ++;
        }else{
            int temp2 = (*it).first;
            if(temp2 == sum){
                rem[(*it).second].push_back(i);
            }else{
                rem[cnt].push_back(i);
                s.insert(ii(sum, cnt));
                cnt ++;
            }
        }
    }

    long long ans = 0;
    for(int i = 0; i < cnt; i ++){
        /*printf("rem[%d]: ", i);
        for(int j = 0; j < (int)rem[i].size(); j ++){
            printf("%d, ", rem[i][j]);
        }
        printf("\n");*/
        for(int j = 0; j < (int)rem[i].size(); j ++){
            int indx1 = lower_bound(rem[i].begin(), rem[i].end(), rem[i][j]+K)-rem[i].begin();
            ans += (indx1-j-1);
            //printf("%d %d %d\n", rem[i][j], indx1, j);
        }
    }

    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int n,k;
  ll s;
  cin>>n>>k>>s;
  ll a[n];
  int i;
  for(i=0;i<k;i++)
    a[i]=s;
  ll p;
  if(s!=1e9)
    p=1e9;
  else
    p=1e9-1;
  for(;i<n;i++)
    a[i]=p;
  for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
  cout<<"\n";
  return 0;
}

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

int main() {

  // 必ず 3桁の数字 (0, 1 からなる)
  int s;
  cin >> s;

  // 2 で割って奇数だったら 最後尾の数は 1
  int cnt = 0;
  cnt += s % 2;

  // 10 で 1回割る <= 2桁目の数が1桁目に降ってくる
  int second = s / 10;
  cnt += second % 2;

  // 10 で "もう1回" 割る <= 3桁目の数が1桁目に降ってくる
  int third = second / 10;
  cnt += third % 2;

  cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		String string = sc.next();
		int ans = 0;
		int gnum = 0;
		for(int i = 0;i < string.length();i++){
			if(gnum == 0){
				if(string.charAt(i) == 'p'){			//相手がパー
					ans--;
					gnum++;
				}else{
					gnum++;
				}
			}else{
				if(string.charAt(i) == 'p'){			//相手がパー
					gnum--;
				}else{
					ans++;
					gnum--;
				}
				
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24712
import java.util.*;
import java.awt.geom.*;

public class Main{
	double EPS = 1.0e-08;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [][] data = new int[n][3];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < 3; j++){
					data[i][j] = sc.nextInt();
					
				}
			}
			int m = sc.nextInt();
			int [] dataM = new int[m];
			for(int i = 0; i < m; i++){
				dataM[i] = sc.nextInt();
			}
			
			int [] dp = new int[394];
			for(int i = 0; i < n; i++){
				for(int j = data[i][0]; j <= data[i][1]; j++){
					dp[j] = Math.max(dp[j], data[i][2]);
				}
				for(int j = 0; j <= 393; j++){
					if(dp[j] == 0)continue;
					for(int k = data[i][0]; k <= data[i][1]; k++){
						int next = j + k;
						int value = dp[j] + data[i][2];
						if(next > 393) continue;
						dp[next] = Math.max(dp[next], value);
					}
				}
			}
			StringBuilder sb = new StringBuilder();
			boolean flg = true;
			for(int i = 0; i < m; i++){
				if(dp[dataM[i]] == 0){
					flg = false;
					break;
				}
				sb.append(dp[dataM[i]]+"\n");
			}
			if(flg){
				System.out.print(sb.toString());
			}
			else{
				System.out.println(-1);
			}
		}
	}
	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 23668
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
int32_t main()
{
	fast;
	int n, k, q;
	cin>>n>>k>>q;
	vector<int> v(n, 0);
	for(int i=0;i<q;i++)
	{
		int x;
		cin>>x;
		v[x-1]++;
	}
	// vector<int> v1(n, 0);
	// vector<int> v2(n, 0);
	int s=0;
	for(int i=0;i<n;i++)
	{
		s+=v[i];
	}
	// s=0;
	// for(int i=n-1;i>=0;i--)
	// {
	// 	s+=v[i];
	// 	v2[i]=s;
	// }
	for(int i=0;i<n;i++)
	{
		if(s-v[i]>=k)
		{
			cout<<"No"<<endl;
		}
		else
			cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
from numpy import array
a,b,c=array([list(map(int,input().split()))for i in range(3)])
e,f,g=[array(i)for i in zip(a,b,c)]
h=lambda x:list(x)==list(set(x))*3
print("YNeos"[1^all([h(a-b),h(b-c),h(c-a),h(e-f),h(f-g),h(g-e)])::2])

Measured memory_bytes: 12872
def main():
    N, K, Q = map(int, input().split())
    points = [0] * N
    for i in range(Q):
        points[int(input()) - 1] += 1
    for i in range(N):
        if points[i] + K - Q > 0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 50648
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
#include <bitset>
using namespace std;
#define pb push_back
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define sld(n) scanf("%lld",&n)
#define sldd(n,m) scanf("%lld%lld",&n,&m)
#define slddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define sf(n) scanf("%lf",&n)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define ss(str) scanf("%s",str)
#define ans() printf("%d",ans)
#define ansn() printf("%d\n",ans)
#define anss() printf("%d ",ans)
#define lans() printf("%lld",ans)
#define lanss() printf("%lld ",ans)
#define lansn() printf("%lld\n",ans)
#define fansn() printf("%.10f\n",ans)
#define r0(i,n) for(int i=0;i<(n);++i)
#define r1(i,e) for(int i=1;i<=e;++i)
#define rn(i,e) for(int i=e;i>=1;--i)
#define rsz(i,v) for(int i=0;i<(int)v.size();++i)
#define szz(x) ((int)x.size())
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define lowbit(a) (a&(-a))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pli pair<ll,int>
#define mp make_pair
#define lrt rt<<1
#define rrt rt<<1|1
#define X first
#define Y second
#define PI (acos(-1.0))
#define sqr(a) ((a)*(a))
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000000+7;
const double eps=1e-9;
const int inf=0x3f3f3f3f;
const ll infl = 10000000000000000;
const int maxn=  200+10;
const int maxm = maxn*21+10;
//Pretests passed
int in(int &ret)
{
    char c;
    int sgn ;
    if(c=getchar(),c==EOF)return -1;
    while(c!='-'&&(c<'0'||c>'9'))c=getchar();
    sgn = (c=='-')?-1:1;
    ret = (c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9')ret = ret*10+(c-'0');
    ret *=sgn;
    return 1;
}

int dis[maxn][maxn];
int nd[maxn];
int a[maxn];
int check(int r)
{
    int ans = 0 ;
    for(int i=1;i<r;++i)
    {
        int x = a[i],y = a[i+1];
        ans+=dis[x][y];
    }
    return ans;
}
int main()
{
#ifdef LOCAL
    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif // LOCAL
    int n,m,r;
    sddd(n,m,r);
    r1(i,r)sd(a[i]),nd[a[i]]++;
    mst(dis,0x3f);
    while(m--)
    {
        int u,v,w;
        sddd(u,v,w);
        dis[u][v] = min(dis[u][v],w);
        dis[v][u] = min(dis[v][u],w);
    }
    for(int k=1;k<=n;++k)
        for(int i=1;i<=n;++i)
            for(int j=1;j<=n;++j)
                dis[i][j] = min(dis[i][j],dis[i][k]+dis[k][j]);
    sort(a+1,a+1+r);
    int ans = inf;
    while(next_permutation(a+1,a+1+r))
    {
        ans = min(ans,check(r));
    }
    ansn();
    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rept(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.bigin(),v.end()

using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    ll h[n];
    rep(i,n){
        cin>>h[i];
    }
    ll ans=0;
    sort(h,h+n);
    
    rept(i,n-k){
        ans+=h[i];
    }
    cout<<ans<<endl;


}



Measured memory_bytes: 5168
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b;
    int x,y;
    cin >> x >>y ;
    a = 1;
    b = 1;
    if(x==2)a=3;
    if(y==2)b=3;
    if(x==4|x==6|x==9|x==11)a=2;
    if(y==4|y==6|y==9|y==11)b=2;
    if(a==b){
      cout << "Yes";
    }else{
      cout << "No";
    }
    return 0;
}


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

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

    static class CMonstersBattleRoyale {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long answer = 0;
            for (int i = 0; i < n; i++) {
                answer = NumberTheory.gcd(answer, in.nextInt());
            }

            out.println(answer);
        }

    }

    static class NumberTheory {
        public static long gcd(long a, long b) {
            long c;
            while (a != 0) {
                c = a;
                a = b % a;
                b = c;
            }
            return b;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 35676
#include <stdio.h>
#include <string.h>
int main() {
	char s[11], ans[11] = "\0";
	int pt = 0;
	scanf("%s", s);
	for (int i = 0; i < strlen(s); i++) {
		if (s[i] == '0') {
			ans[pt] = '0';
			pt++;
		} else if (s[i] == '1') {
			ans[pt] = '1';
			pt++;
		} else {
			pt--;
			if (pt < 0)
				pt = 0;
			ans[pt] = '\0';
		}
	}
	printf("%s\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A[50][50];
string S,T;

int main(){
  rep(i,3){
    rep(j,3){
      cin >> A[i][j];
    }
  }
  ll N;
  cin >> N;
  rep(k,N){
    ll X;
    cin >> X;
    rep(i,3){
      rep(j,3){
        if(X==A[i][j]){
          A[i][j]=LINF;
        }
      }
    }
  }
  rep(i,3){
    ll X=0,Y=0;
    rep(j,3){
      if(A[i][j]==LINF){
        X++;
      }
      if(A[j][i]==LINF){
        Y++;
      }
    }
    if(X==3||Y==3){
      cYes;
      return 0;
    }
  }
  if((A[1][1]==LINF)&& ((A[0][0]==LINF && A[2][2]==LINF ) || (A[0][2]==LINF && A[2][0]==LINF ) )){
    cYes;
    return 0;
  }
  cNo;
}


Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())
a_lst = [int(x) for x in stdin.readline().rstrip().split()]
b_lst = [int(x) for x in stdin.readline().rstrip().split()]
c_lst = [int(x) for x in stdin.readline().rstrip().split()]
val = 0
prev = -100

for a in a_lst:
  val += b_lst[a-1]
  if prev + 1 == a:
    val += c_lst[a-2]
  prev = a
 
print(val)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

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

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		String ss = sc.next();
		int onefirst = 0;
		for(int i = 0;i < ss.length();i++){		//1010101
			if(ss.charAt(i) == '0' && i%2 == 0){
				onefirst++;
			}else if(ss.charAt(i) == '1' && i%2 == 1 ){
				onefirst++;
			}
		}
		
		int zerofirst = 0;
		for(int i = 0;i < ss.length();i++){		//010101
			if(ss.charAt(i) == '1' && i%2 == 0){
				zerofirst++;
			}else if(ss.charAt(i) == '0' && i%2 == 1 ){
				zerofirst++;
			}
		}
		
		int ans = Math.min(onefirst, zerofirst);
		System.out.print(ans);
		
		
		
		
		
	}
	


}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




Measured memory_bytes: 24784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  string s, t;
  cin >> s >> t;
  int n = sz(s), m = sz(t);

  vector<vector<int>> dp(26, vector<int>(0));
  rep(i, n) dp[s[i]-'a'].push_back(i);
  rep(i, n) dp[s[i]-'a'].push_back(i+n);

  ll ans = 0;
  int pre_t = 0;
  bool h = 1;

  rep(i, m){
    int t_now = t[i] - 'a';
    if (dp[t_now].size() == 0){
      h = 0;
      break;
    }
    auto it = lower_bound(dp[t_now].begin(),dp[t_now].end(), pre_t);
    int index = it - dp[t_now].begin();
    int t_next = dp[t_now][index];
    ans += t_next - pre_t +1;
    pre_t = t_next % n +1;
  }

  if(h) cout << ans << endl;
  else cout << -1 << endl;

}


Measured memory_bytes: 1724
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
//#define P pair<int, int>

using namespace std;
using ll = __int64_t;

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

void solve(){
  int n;
  ll temp;
  vector<ll> x, y;

  cin >> n;
  rep(i, n) cin >> temp, x.push_back(temp);

  y = x;
  sort(y.begin(), y.end());
  ll med = n/2;
  ll medb = y[med];
  ll meds = y[med-1];

  rep(i, n){
    if(x[i] < medb){
      cout << medb << endl;
    }else{
      cout << meds << endl;
    }
  }
}

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


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

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int N,T;
	cin>>N;
	T=floor(N/2)+(N%2);
	cout<<T;
	return 0;
}

Measured memory_bytes: 256
// Osaki
// 所要時間 分
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    while(true){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        int time[86500] = {};
        rep(i, n){
            int hh1, mm1, ss1;
            int hh2, mm2, ss2;
            scanf("%d:%d:%d", &hh1, &mm1, &ss1);
            scanf("%d:%d:%d", &hh2, &mm2, &ss2);
            int t1 = hh1 * 3600 + mm1 * 60 + ss1;
            int t2 = hh2 * 3600 + mm2 * 60 + ss2;
            time[t1]++;
            time[t2]--;
        }
        int ans = 0;
        rep(i, 86450){
            time[i+1] = time[i+1] + time[i];
        }
        rep(i, 86450){
            ans = max(ans, time[i]);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3500
a=input()
b=input()
c=input()
lenA = len(a)
lenB = len(b)
lenC = len(c)

turn = a[len(a)-lenA]

while 1:
    if turn=="a":
        if(lenA==0):
            print("A")
            break
        turn=a[len(a)-lenA]
        lenA-=1
    
    elif turn == "b":
        if(lenB==0):
            print("B")
            break
        turn=b[len(b)-lenB]
        lenB-=1

    elif turn =="c":
        if(lenC==0):
            print("C")
            break
        turn=c[len(c)-lenC]
        lenC-=1


# while 1 :
#     if turn == "a":
#         if lenA!=0:    
#             lenA-=1
#             turn = a[len(a)-lenA]
#         else:
#             print("A")
#             break
#     elif turn == "b":
#         if lenB!=0:    
#             lenB-=1
#             turn=b[len(b)-lenB]
#         else:
#             print("B")
#             break
#     elif turn == "c":
#         if lenC!=0:    
#             lenC-=1
#             turn = c[len(c)-lenC]
#         else:
#             print("C")
#             break


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

int main() {
  int S;
  cin >> S;
  int S1,S2,S3;
  S3 = S%10;
  S2 = (S%100-S3)/10;
  S1 = (S-S2*10-S3)/100;
  cout << S1+S2+S3 << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
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; }

int main(){
  int n,k;
  cin>>n>>k;
  bool a[100];
  rep(i,0,n) a[i]=false;

  rep(i,0,k){
    int d;
    cin>>d;
    rep(i,0,d){
      int tmp;
      cin>>tmp;
      a[tmp-1]=true;
    }
  }

  int cnt=0;
  rep(i,0,n){
    if(!a[i]) cnt++;
  }

  cout<<cnt<<endl;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void){
  int a[10];
  int i=0,l,min=1000,sub;
  char s[10];
  scanf("%s",s);
  l = strlen(s);
  for(i=0;i<l;i++){
    a[i]=(int)s[i]-48;
  }
  for(i=2;i<l;i++){
    sub = abs(753-(100*a[i-2]+10*a[i-1]+a[i]));
    if(min>sub) min = sub;
  }
  printf("%d\n",min);
  return 0;
}

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

int main(){
    string str1, str2;
    cin >> str1;
    cin >> str2;
    if (str1.size()+1 == str2.size()){
        str2 = str2.erase(str1.size());
        if (str1 == str2){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
a=gets.chomp.to_i
b=gets.split.map(&:to_i)
c=gets.split.map(&:to_i)

for i in 0..(c.length-1)
  c[i]=(b[1]-(b[0]-(c[i]*0.006))).abs
end

puts c.index(c.min)+1


Measured memory_bytes: 1788