akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;
int main() {
	cin>>N;

	if(N==1 || N==8 || N==15 || N==22 || N==29)cout<<"fri"<<endl;
	if(N==2 || N==9 || N==16 || N==23 || N==30)cout<<"sat"<<endl;
	if(N==3 || N==10 || N==17 || N==24 || N==31)cout<<"sun"<<endl;
	if(N==4 || N==11 || N==18 || N==25)cout<<"mon"<<endl;
	if(N==5 || N==12 || N==19 || N==26)cout<<"tue"<<endl;
	if(N==6 || N==13 || N==20 || N==27)cout<<"wed"<<endl;
	if(N==7 || N==14 || N==21 || N==28)cout<<"thu"<<endl;

	return 0;
}

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

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

    long A, B;
    cin >> A >> B;

    if ((A + B) % 2 == 0) {
        cout << (A + B) / 2 << '\n';
    } else {
        cout << "IMPOSSIBLE" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int n;
    cin >> n;
    ll sum = 0;
    for(ll i=1; i<=n; i++)
    {
        if(!(i%3 == 0) && !(i%5 == 0)) sum += i;
    }
    cout << sum << endl;
    return 0;
}


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

using namespace std;

int contains(string s){
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == '#'){
            return 1;
        }
    }
    return 0;
}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int H , W , K;
cin >> H >> W >> K;
    vector<vector<int> > res(H , vector<int> (W));
    vector<string> s(H);
    int y = 0;
    for(int i = 0; i < H; ++i){
        cin >> s[i];
        if(contains(s[i])){
            ++y;
        }
        bool flag = 0;
        for(int j = 0; j < W; ++j){
            if(s[i][j] == '#'){
                if(flag){
                    ++y;
                }
                flag = true;
            }
            res[i][j] = y;
        }
    }
    for(int i = 1; i < H; ++i){
        if(!contains(s[i])){
            res[i] = res[i - 1];
        }
    }
    for(int i = H - 2; i >= 0; --i){
        if(!contains(s[i])){
            res[i] = res[i + 1];
        }
    }
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
return 0;
}


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

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static List<string> cons = new List<string>();
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] elm = new int[n];
            for (int i=0; i<n; i++)
            {
                elm[i] = int.Parse(str[i]);
            }
            Array.Sort(elm);

            double result = elm[0];
            for (int i = 1; i < n; i++)
            {
                result = (elm[i] + result) / 2.0;
            }
            Console.WriteLine(result);
        }
    }
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int get_digit(ll n){
    int digit = 0;
    if(n == 0){
        return 1;
    }
    while(n != 0){
        digit++;
        n /= 10;
    }
    return digit;
}
bool is_junretu(ll n){
    int digit = get_digit(n);
    string s;
    s = to_string(n);
    bool flg= true;
    for(int i = 1; i <= digit; i++){
        if(s.find(i) == string::npos){
            flg = false;
            break;
        }
    }
    return flg;
}

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

    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef pair<int,int> P;

string S;
size_t cur;
int f;

int digit(){
    assert(isdigit(S[cur]));
    int n=S[cur]-'0';
    cur++;
    return n;
}

P number(){
    int n=digit();
	while(cur<S.size()&&isdigit(S[cur])){
	n=n*10+digit();
	if(n>10000||n<-10000)f=1;
	}
    P p;
    p.second=n;
    return p;
}

P expression();
P factor(){
    P p;
    if(S[cur]=='i'){p.first=1;p.second=0;cur++;return p;}
	if(S[cur]!='(')return number();
	cur++;
	p=expression();
	assert(S[cur]==')');
	cur++;
	return p;
}

P term(){
    P p=factor();
    while(cur<S.size()&&(S[cur]=='*'||S[cur]=='/')){
		char op=S[cur++];
		P q=factor();
    	if(op=='*'){
    		double p1=p.first,p2=p.second,q1=q.first,q2=q.second;
    		p.first=p1*q2+p2*q1;p.second=p2*q2-p1*q1;
    	}
    	else {p.first/=q.second;p.second/=q.second;}
    	if(p.first>10000||p.first<-10000||p.second>10000||p.second<-10000)f=1;
    }
    return p;
}

P expression(){
    P p=term();
    while(cur<S.size()&&(S[cur]=='+'||S[cur]=='-')){
	char op=S[cur++];
	P q=term();
	if(op=='+'){p.first+=q.first;p.second+=q.second;}
	else {p.first-=q.first; p.second-=q.second;}
    if(p.first>10000||p.first<-10000||p.second>10000||p.second<-10000)f=1;
    }
    return p;
}

int main() {
	while(cin>>S){
		cur=0;f=0;
		P e=expression();
		if(f)cout<<"overflow"<<endl;
		else{
			int im=e.first,re=e.second;
			if(!im&&!re)cout<<"0"<<endl;
			else if(!im)cout<<re<<endl;
			else if(!re)cout<<im<<"i"<<endl;
			else if(im>0)cout<<re<<"+"<<im<<"i"<<endl;
			else cout<<re<<im<<"i"<<endl;
		}
	}
} 

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    ll A;
    ll b1, b2;
    scanf("%lld %lld.%lld", &A, &b1, &b2);
    cout << A * b1 + (A * b2) / (ll)100 << endl;
}


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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

void solve(ll N, std::vector<std::vector<ll>> D) {
  ll cnt = 0;
  bool result = false;

  rep(i, N) {
    if (D.at(i).at(0) == D.at(i).at(1)) {
      cnt++;
      if (cnt >= 3) {
        result = true;
        break;
      }
    } else {
      cnt = 0;
    }
  }

  yesOrNo(result);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<std::vector<ll>> D(N, std::vector<ll>(2));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      scanf("%lld", &D[i][j]);
    }
  }
  solve(N, std::move(D));
  return 0;
}


Measured memory_bytes: 3724
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();

    if( a<b && b<c ) System.out.println("Yes");
    else System.out.println("No");

  }
}

Measured memory_bytes: 26312
#include <stdio.h>
#include <stdlib.h>

typedef struct _n {
  int id;              /* ?????? */
  int num;             /* ??? */
  struct _n *left;     /* ??? -- ?????±?????§ */
  struct _n *right;    /* ??? -- ?????±?????§ */
} _node;

/* ????????¢?´¢??¨????????? -- ?????°????????¨*/
void insert(_node *p1, int id, int num)
{
  _node *p2;

  if (p1->num == 0){
  	p1->num = num;
  }else if (p1->num <= num) {    /* ????????????????????§????????¨??? */
    /* ??????NULL?????????????????°????????????????????¶???????????? */
    if (p1->right == NULL) {
      p2 = malloc(sizeof(_node));
      p2->id = id;
      p2->num = num;
      p2->left = NULL;
      p2->right = NULL;
      p1->right = p2;
    } else {  /* NULL??§???????????°?????´????????????????§???? */
      insert(p1->right, id, num);
    }
  } else {
    /* ??????NULL?????????????????°????????????????????¶???????????? */
    if (p1->left == NULL) {
      p2 = malloc(sizeof(_node));
      p2->id = id;
      p2->num = num;
      p2->left = NULL;
      p2->right = NULL;
      p1->left = p2;
    } else {  /* NULL??§???????????°?????´????????????????§???? */
      insert(p1->left, id, num);
    }
  }
}

//?????????????????¢?????´?????????
void middleprint(_node *p){
	if (p != NULL)
	{
		middleprint(p->left);
		printf(" %d", p->num);
		middleprint(p->right);
	}else{
		return;
	}
}

//?????????????????¢?????´?????????
void preprint(_node *p){
	if (p != NULL)
	{
		printf(" %d", p->num);
		preprint(p->left);
		preprint(p->right);
	}else{
		return;
	}

}

int main(void)
{
	_node *start, *p1;
	int i, nx, key;
	int *x;

	//??¢?´¢??¨???????????°??\???
	scanf("%d", &nx);
	x = calloc(nx-1, sizeof(int));

	/* ?????????????????????????????? */
	start = malloc(sizeof(_node));
	start->id = 0;
	start->num = 0;
	start->left = NULL;
	start->right = NULL;
	p1 = start;

	while(nx--){
		char str[100];
    	scanf("%s", str);
    	if(!strcmp(str, "insert")){
      		scanf("%d", &x[i]);
			insert(p1, i, x[i]);
    	}else{
			middleprint(p1);
			printf("\n");
			preprint(p1);
			printf("\n");
    	}
  	}
/*
	//S?????´??°??????
	for (i = 1; i < nx-1; i++)
	{
		printf("insert ");
		scanf("%d", &x[i]);
		insert(p1, i, x[i]);
	}

	puts("print");
	middleprint(p1);
	printf("\n");
	preprint(p1);
*/
	free(x);
	free(p1);

	return 0;
}

Measured memory_bytes: 16232
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int n;
	cin >> n;
	int a = 1;
	int ans = 1;
	while (1) {
		if (a * a > n) {
			cout << ans << endl;
			return 0;
		}
		ans = a * a;
		a++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	x -= z;
	cout << x / (y + z) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
	char *dic[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	int len[]={-1,5,3,3,3,3,3,4,3,4};
	int n;	scanf("%d",&n);
	while(n--){
		char s[1025];	scanf("%s",s);
		char bef='@';
		int cnt=0;
		for(int i=0;s[i];i++){
			if(s[i]=='0'){
				if(cnt>0)	putchar(dic[bef-'0'][(cnt-1)%len[bef-'0']]);
				cnt=0;
				bef='@';
			}
			else{
				cnt++;
				bef=s[i];
			}
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
A = list(map(int, input().split()))

ans = 1
up = dn = False
pre = A[0]
for a in A[1:]:
    if pre < a:
        up = True
    elif pre > a:
        dn = True
    if up and dn:
        ans += 1
        up = dn = False
    pre = a

print(ans)


Measured memory_bytes: 20096
#include <stdio.h>


int main(void){

    int a, b, c;
    int count_five,count_seven;
    scanf("%d %d %d", &a,&b,&c);

    count_five = 0;
    count_seven = 0;

    if(a == 5) count_five++;
    if(a == 7) count_seven++;
    if(b == 5) count_five++;
    if(b == 7) count_seven++;
    if(c == 5) count_five++;
    if(c == 7) count_seven++;

    if(count_five ==2 && count_seven == 1){
       printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
import heapq

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

pq = []
for val in a:
    heapq.heappush(pq, val)

while len(pq) > 1:
    val1 = heapq.heappop(pq)
    val2 = heapq.heappop(pq)
    heapq.heappush(pq, (val1 + val2) / 2)

print(heapq.heappop(pq))

Measured memory_bytes: 38384
'use strict';

const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const N = parseInt(input[0]);
const s = input[1];

function constructorAnswer(t1, t2, N, s) {
    let t = [t1, t2];

    let tNow = t2,
        tPrev = t1,
        tOdd = t1 == 'S' ? 'W' : 'S';

    for (let i = 1; i < N - 1; i++) {
        tNow = t[i];

        t.push(
            tNow == 'S' ?
            (s[i] == 'o' ? tPrev : tOdd) :
            (s[i] == 'o' ? tOdd : tPrev)
        );

        tPrev = tNow;
        tOdd = tPrev == 'S' ? 'W' : 'S';
    }

    return t;
}

function judge(t, N, s) {
    let s1 = s[0],
        sn = s[N-1],
        t1 = t[0],
        t2 = t[1],
        tn = t[N - 1],
        tn1 = t[N - 2];

    return (t1 == 'S' ?
        ((s1 == 'o') == (tn == t2)) :
        ((s1 == 'o') == (tn != t2)))
        &&
        (tn == 'S' ?
        ((sn == 'o') == (tn1 == t1)) :
        ((sn == 'o') == (tn1 != t1)));
}

let answerList = [
    ['S', 'S'],
    ['S', 'W'],
    ['W', 'S'],
    ['W', 'W'],
];

for (let i = 0; i < answerList.length; i++) {
    let t1 = answerList[i][0],
        t2 = answerList[i][1];

    let t = constructorAnswer(t1, t2, N, s);
    if (judge(t, N, s)) {
        console.log(t.join(''));
        process.exit(0);
    }
}

console.log('-1');

Measured memory_bytes: 20936
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,a;
    cin>>n;
    std::deque<long long int> deq;
    long long int tmp;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
        if (i==0) {
            tmp=deq[i];
        } else {
            tmp=tmp^deq[i];
        }
    }
    for (int i=0;i<n;i++) {
        long long int hoge=tmp^deq[i];
        if (i<n-1) {
            cout<<hoge<<" ";
        } else {
            cout<<hoge<<endl;
        }
    }
}

Measured memory_bytes: 5252
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x,y;
    cin>>x>>y;
    int m=(x+y)%2;
    if (m)
        cout<<"IMPOSSIBLE";
    else
        cout<<(x+y)/2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int N;  cin>>N;
  vector<int> a(N);
  rep(i,0,N) cin>>a[i];
  int c4 = 0;
  int c2=0;
  int other=0;
  rep(i,0,N){
    if(a[i]%4==0) c4++;
    else if(a[i]%2==0) c2++;
    else other++;
  }
  c2 %= 2;
  other += c2;
  if(other-1<=c4){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  bool Y;
  Y = false;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      Y = true;
      cout << "Four" << endl;
      break;
    }
    else
      continue;
  }
  if (Y == true)
    return 0;
  else
    cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define all(x) x.begin(), x.end()
using namespace std;

int n, k;
int a[100010], b[100010], c[100010];
string s;

int get_comp (int l, int r) {
  return b[r] - b[c[l]];
}

int check (int md) {
  for (int i = 1; i <= n - md + 1; i++) {
    int le = i, ri = i + md - 1;
    if (k >= get_comp(le, ri)) return 1;
  }
  return 0;
}

signed main () {
  cin >> n >> k >> s;
  a[0] = 1; b[0] = 0; c[0] = 0;
  for (int i = 0; i < n; i++) {
    a[i + 1] = (s[i] == '1');
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1) {
      b[i] = b[i - 1];
      c[i] = i;
    } else { // a[i] == 0
      b[i] = b[i - 1] + a[i - 1];
      c[i] = c[i - 1];
    }
  }
  
  int lo = 0, hi = n + 1;
  while (lo + 1 < hi) {
    int md = (lo + hi) >> 1;
    if (check (md)) lo = md;
    else hi = md;
  }
  cout << lo << endl;
  return 0;
}



Measured memory_bytes: 2816
#include <stdio.h>

int main(void) {
	// your code goes here
	int r,d,x,i;
	scanf("%d",&r);
	scanf("%d",&d);
	scanf("%d",&x);
	for(i=1;i<=10;i++)
	{
		x=r*x-d;
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e5;
int n;
pii a[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    cin >> a[i].fi;
    a[i].se = i;
  }
  sort(a, a+n);
  reverse(a, a+n);
  FOR(i, 0, n) cout << (i==a[0].se ? a[1].fi : a[0].fi) << endl;
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int D, G; cin >> D >> G;
	vector<int> p(10);
	vector<int> c(10);
	rep(i, 0, D - 1)cin >> p[i] >> c[i];
	int ans = 20101010;
	rep(i, 0, pow(2, D) - 1)
	{
		int score = 0;
		int cnt = 0;
		string s = "";
		rep(j, 0, D - 1)
		{
			if (i >> j & 1)
			{
				s = "0" + s;//使った点数
				score += 100 * (j + 1) * p[j] + c[j];
				cnt += p[j];
			}
			else s = "1" + s;//使ってない点数
		}
		rep(j, 0, D - 1)
		{
			if (s[j] == '1')
			{
				rep(k, 0, p[D - 1 - j])
				{
					if (score >= G)break;
					score += 100 * (D - j);
					++cnt;
				}
			}
			if (score >= G)break;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = [int(input())-1 for _ in range(Q)]
points = [0]*N

for a in A:
  points[a] += 1

for i in range(N):

  if points[i] + K - Q  > 0:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 8592
import Data.Bool
import qualified Data.Set as S
import Control.Monad

main = do
 [n,m] <- map read . words <$> getLine
 ta <- concat <$> replicateM n getLine
 tb <- concat <$> replicateM m getLine
 let pa = map fst $ filter ((=='#') . snd) $ zip [(h,w) | h<-[0..n-1], w<-[0..n-1]] ta
 let pb = map fst $ filter ((=='#') . snd) $ zip [(h,w) | h<-[0..m-1], w<-[0..m-1]] tb
 let sa = S.fromDistinctAscList pa
 let sb = S.fromDistinctAscList pb
 let d = n - m
 putStrLn $ bool "No" "Yes" (templateMatch d sa sb)

templateMatch d sa sb = any (match sa sb) [(dh,dw) | dh<-[0..d], dw<-[0..d]]

match sa sb (dh,dw) = S.map (move dh dw) sb `S.isSubsetOf` sa

move dh dw (h,w) = (h+dh, w+dw)

Measured memory_bytes: 1404
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=3005;
int s[N][N];
int n,k;
int S(int x1,int y1,int x2,int y2){
    return s[x2][y2]-s[x2][y1]-s[x1][y2]+s[x1][y1];
}
int main()
{
    scanf("%d%d",&n,&k);
    k<<=1;
    int a,b;
    char c;
    for(int i=1;i<=n;i++){
        scanf("%d%d %c",&a,&b,&c);
        a%=k,b%=k;
        if(c=='W')
            b+=(k>>1);
        s[a%k+1][b%k+1]++;
    }
    for(int i=1;i<=k;i++)
        for(int j=1;j<=k;j++)
            s[i][j]=s[i][j]+(s[i-1][j]+s[i][j-1]-s[i-1][j-1]);
    int ans=0,sum;
    for(int i=1;i<=(k>>1);i++)
        for(int j=1;j<=(k>>1);j++){
            sum=S(0,0,i,j);
            sum+=S(i,j,(k>>1)+i,(k>>1)+j);
            sum+=S((k>>1)+i,(k>>1)+j,k,k);
            sum+=S((k>>1)+i,0,k,j);
            sum+=S(0,(k>>1)+j,i,k);
            sum=max(n-sum,sum);
            ans=max(ans,sum);
        }
    printf("%d\n",ans);
}

Measured memory_bytes: 25168
#include <bits/stdc++.h>
using namespace std;
long long d[100000];
long long bor = 1000000000000000000;


int main() {
  long long res =1;
  int n;
  cin >> n;
  
  for(int i = 0;i<n;i++){
    cin >> d[i];
    if(d[i] == 0){ 
      res = 0;
    }
  }
  
  if(res != 0){
    for(int i = 0;i<n;i++){
      if(d[i] > bor/res){
        res = -1;
        break;
      }else{
        res = res*d[i]; 
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 4412
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n;  cin >> n;
    int ans = 0;
    for(int i = n; i > 0; i--){
	int tmp = i;
	int count = 0;  //割れる回数
	int countmax;
	for(; tmp%2 == 0; count++){
	    tmp /= 2;
	}
	if(countmax <= count){
	    countmax = count;
	    ans = i;
	}
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
  var a, b, c, d, e int
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&c)
  fmt.Scan(&d)
  fmt.Scan(&e)
  if a == 0 {
    fmt.Print("1")
  } else if b == 0 {
    fmt.Print("2")
  } else if c == 0 {
    fmt.Print("3")
  } else if d == 0 {
    fmt.Print("4")
  } else if e == 0 {
    fmt.Print("5")
  }
}

Measured memory_bytes: 1832
using System;
using System.Collections.Generic;
using System.Linq;

public static class Test
{
    public static void Main()
    {
        Console.ReadLine();
        var directions = Console.ReadLine();
        
        int s = 0;
        for(int i = 0; i < directions.Length; ++i)
        {
            s += (directions[i] == 'E' ? 1 : 0);
        }
        
        int min = int.MaxValue;
        char prev = 'E';
        for(int i = 0; i < directions.Length; ++i)
        {
            s += (prev == 'E' ? 0 : 1);
            s -= (directions[i] == 'E' ? 1 : 0);
            prev = directions[i];
            min = min < s ? min : s;
        }
                
        Console.WriteLine(min);
    }
}


Measured memory_bytes: 13212
while(1):
	box = []
	num = int(input())
	if num == 0: break
	[box.append(list(map(int,input().split()))) for i in range(num)]
	[box[i].append(sum(box[i])) for i in range(num)]
	box_replace = list(map(list, zip(*box)))
	temp = [[]]
	[temp[0].append(sum(box_replace[i])) for i in range(num+1)]
	box += temp
	box = [list(map(str, box[i])) for i in range(num+1)]
	box = ([[ box[i][j].rjust(5," ") for j in range(num+1)] for i in range(num+1)] )
	
	[print("".join(box[i])) for i in range(num+1)]

Measured memory_bytes: 7696
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int s = 15;
    for (int i = 0; i < 5; i++) {
        int a;
        cin >> a;
        s -= a;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3592
X, Y=list(map(int,(input().split())))
m=10**9+7
N=(X+Y)//3
bikkuri=[1 for i in range(N+2)]
gyaku=[1 for i in range(N+2)]
for i in range(1, N+1):
    bikkuri[i+1] =((i+1)*bikkuri[i])%m
    gyaku[i+1] = pow(bikkuri[i+1], m-2, m)
def comb(n, r):
    return (bikkuri[n]*gyaku[r]*gyaku[n-r])%m
if (X+Y)%3==1 or (X+Y)%3==2:
    print(0)
else:
    if X<N or Y<N:
        print(0)
    else:
        print(comb((X-N)+(Y-N), Y-N))

Measured memory_bytes: 91024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define hh   puts("");
#define db double
#define ull unsigned long long
#define maxn 1000010

int main(){
    int a,b;
    cin>>a>>b;
    int m[b],sum=0;
    for (int i = 0; i <b ; ++i) {
        cin>>m[i];
        sum+=m[i];
    }
    if(sum<a)cout<<"No";
    else cout<<"Yes";
    return 0;
}

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

int main() {
    int N;
    string syurui = "Three";
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        string arare;
        cin >> arare;
        
        if (arare == "Y") {
            syurui = "Four";
            break;
        }
    }
    
    cout << syurui << endl;
}


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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    lint N;
    cin >> N;

    string ans;
    if(1 <= N and N <= 999) {
        ans = "ABC";
    } else {
        ans = "ABD";
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3620
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	string s; cin >> s;
	map<pair<string, string>, ll> mp;
	string x = s.substr(0, n);
	string y = s.substr(n, 2 * n);
	reverse(all(y));
	rep(i, pow(2, n))
	{
		string r = "", b = "";
		rep(j, n)
		{
			if (i&(1 << j))r += x[j];
			else b += x[j];
		}
		++mp[make_pair(r, b)];
	}
	ll res = 0;
	rep(i, pow(2, n))
	{
		string r = "", b = "";
		rep(j, n)
		{
			if (i&(1 << j))b += y[j];
			else r += y[j];
		}
		res += mp[make_pair(b, r)];
	}
	cout << res << endl;
}

Measured memory_bytes: 91904
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  Int ans=10000;
  for(Int i=0;i+2<(Int)s.size();i++){
    Int tmp=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0')*1;
    chmin(ans,abs(tmp-753));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int N = 0;
	long long Apre = 0, Apost = 0, answer = 0;

	std::cin >> N;

	for (int number = 0; number < N; ++number)
	{
		if (number == 0)
		{
			std::cin >> Apre;
			continue;
		}

		std::cin >> Apost;

		if (Apost < Apre)
		{
			answer += Apre - Apost;
		}
		else
		{
			Apre = Apost;
		}
	}
	std::cout << answer << std::endl;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,d[101],a[101][101],h[101],sum=0;
  cin >> n >> k;
  for(int i=0;i<k;i++){
    cin >> d[i];
    for(int j=0;j<d[i];j++){
      cin >> a[i][j];
      h[a[i][j]-1]+=1;
    }
  }
  for(int i=0;i<n;i++){
   
    if(h[i]==0){
      sum+=1;
    }
    
    }
  cout << sum << endl;
  }
  



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

int main() {
  int N,Y,a,b,c;
  cin >> N >> Y;
  bool ok = true;
  for (int x = 0;x <= N;x++) {
    for (int y = 0;y<=N-x;y++) {
      if (Y == 10000*x + 5000*y + 1000*(N-x-y)) {
 
        a = x;
        b = y;
        c = N-x-y;
        ok = false;
      }
    }
  }
  if (ok) cout << "-1 -1 -1" << endl;
  else cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
const ll p=1000000007;
int main(){
  ll n;
  cin >> n;
  ll bb=0;
  ll k[n];
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    bb+=b;
    k[i]=a+b;
  }
  sort(k,k+n);
  ll ans=0;
  rep(i,n-n/2){
    ans+=k[n-1-2*i];
  }
  cout << ans-bb << endl;
}


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


int main() {
	char s[100];		int n, x = 0, ans = 0;
	cin >> n >> s;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') x++;
		else if (s[i] == 'D') x--;

		if (ans < x) ans = x;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
#define MAX 100000
 
struct TRAMP{
    char mark;
    int number,inputed_order;
};
 
TRAMP cards[MAX];
 
int n;
 
int Partition(int left,int right){
    int i = left-1,pivot = cards[right].number;
    for(int start = left; start < right; start++){
        if(cards[start].number <= pivot){
                i++;
                std::swap(cards[i],cards[start]);
        }
    }
 
    std::swap(cards[i+1],cards[right]);
 
    return i+1;
}
 
void quickSort(int left,int right){
    if(left < right){
        int q = Partition(left,right);
        quickSort(left,q-1);
        quickSort(q+1,right);
    }
}
 
 
int main(){
 
    bool stableFLG = true;
    scanf("%d",&n);
 
    for(int i = 0; i < n; i++){
        scanf("%s %d",&cards[i].mark,&cards[i].number);
        cards[i].inputed_order = i;
    }
 
    quickSort(0,n-1);
 
    for(int i = 1; i < n; i++){
        if(cards[i].number == cards[i-1].number && cards[i].inputed_order < cards[i-1].inputed_order){
            stableFLG = false;
            break;
        }
    }
 
    if(stableFLG){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
 
    for(int i = 0; i < n; i++)   printf("%c %d\n",cards[i].mark,cards[i].number);
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	ll a, b, c = 0;
	cin >> a >> b;
	c = min(a, b / 2);
	a -= c;
	b -= 2 * c;
	if (b > 0){
		c += b / 4;
	}
	cout << c << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,m,d;
  long long int sum;
  double ans;
  cin>>n>>m>>d;
  if(d==0) sum=n;
  else sum=(n-d)*2;
  /*cout<<sum;*/
  ans=(double)(sum*(m-1))/double(n*n);
  cout<<setprecision(10)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

const ll mod = 998244353;

int main() {

    int n;
    cin >> n;
    
    ll ans = 1;
    vector<int> D(n);

// 個数を数える
    vector<int> tmp(n);
    for(int i = 0; i < n; i++) {        
        tmp[i] = 0;
    }

    cin >> D[0];
    if (D[0] != 0) {
        cout << 0 << endl;
        return 0;
    }

    RREP(i, 1, n) {
        cin >> D[i];
        if (D[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
        tmp[D[i]] ++;
        // ans = ans * D[i] % mod;
    }

    RREP(i, 2, n) {
        // cout << tmp[i] << " " << tmp[i-1] << endl;
        for(int j = 0; j < tmp[i]; j++) {
            ans = ans * tmp[i-1] % mod;
        }
    }

    cout << ans << endl;

    return 0;
}

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

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

  vector<long long> a(n), b(n), c(n);
  rep (i, n) cin >> a[i];
  rep (i, n) cin >> b[i];
  rep (i, n) cin >> c[i];

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  long long ans = 0;
  rep (i, n) {
    long long s = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    long long e = c.end() - upper_bound(c.begin(), c.end(), b[i]);
    ans += s*e;
  }

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


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;


int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b,c; cin >> a >> b >> c;

    if(a==b && b != c){
        cout << "Yes" << endl;
    } else if (a==c && b!=c){
        cout << "Yes" << endl;
    } else if (c==b && a!=b){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }

    


    return 0;
}

Measured memory_bytes: 256
#解答を見た後


x,y,z,N =(int(i) for i in input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]

sa=sorted(a,reverse=True)
sb=sorted(b,reverse=True)
sc=sorted(c,reverse=True)
answer=[]

for i in range(len(sa)):
  for j in range(len(sb)):
    if (i+1)*(j+1)>N:break
    for k in range(len(sb)):
      if (i+1)*(j+1)*(k+1)>N:break 
      answer.append(sa[i]+sb[j]+sc[k])
answer=sorted(answer,reverse=True)
for i in range(0,N):
  print(answer[i])



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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
constexpr int inf = 1 << 30;
constexpr int mx = 100000;

int X, K, Q, pos;
int T[mx + 2];
int lx[mx + 1];
int ly[mx + 1];
int rx[mx + 1];
int ry[mx + 1];

// solve
int main(){

    cin >> X >> K;
    rep(i, 1, K)cin >> T[i];
    T[K + 1] = inf;

    rx[0] = ry[0] = X;
    rep(i, 1, K){
        lx[i] = lx[i - 1];
        rx[i] = rx[i - 1];
        if(i & 1){
            ly[i] = ly[i - 1] + T[i - 1] - T[i];
            ry[i] = ry[i - 1] + T[i - 1] - T[i];
            if(ly[i] < 0 && ry[i] < 0){
                lx[i] = ly[i] = rx[i] = ry[i] = 0;
            } else if(ly[i] < 0){
                lx[i] -= ly[i];
                ly[i] = 0;
            }   
        } else {
            ly[i] = ly[i - 1] + T[i] - T[i - 1];
            ry[i] = ry[i - 1] + T[i] - T[i - 1];
            if(ly[i] > X && ry[i] > X){
                lx[i] = ly[i] = rx[i] = ry[i] = X;
            } else if(ry[i] > X){
                rx[i] -= ry[i] - X;
                ry[i] = X;
            }
        }
    }

    cin >> Q;
    while(Q--){
        int t, a;
        cin >> t >> a;
        while(T[pos + 1] <= t)pos++;
        int ans, dif = t - T[pos];
        if(a <= lx[pos])ans = ly[pos];
        else if(a >= rx[pos])ans = ry[pos];
        else ans = ly[pos] + (a - lx[pos]);
        if(pos & 1)cout << min(ans + dif, X) << '\n';
        else cout << max(ans - dif, 0) << '\n';
    }

}


Measured memory_bytes: 3200
#include <stdio.h>
int main(void)
{
	int h,w,i,j,a=0;
	char s[51][51];
	scanf("%d%d",&h,&w);
	for(i=0; i<h; i++){
		scanf("%s",&s[i]);
	}
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			if(s[i][j]=='#'){
				if(s[i+1][j]!='#' && s[i-1][j]!='#' && s[i][j+1]!='#' && s[i][j-1]!='#'){
					a=1; break;
				}
			}
		}
	}
	
	if(a==1)	printf("No\n");
	if(a==0)	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);

    int n,i,t,min,s1,s2;
    int w[];

    n = sc.nextInt();

    w = new int[n];

    for(i=0;i<n;i++){
      w[i] = sc.nextInt();
    }
    min = 99999;
    for(t=1;t<n;t++){
      s1=0;
      s2=0;
      for(i=0;i<t;i++){
        s1 += w[i];
      }
      for(;i<n;i++){
        s2 += w[i];
      }
      if(s1>s2){
        if(min>s1-s2){
          min = s1-s2;
        }
        
      }else{
        if(min>s2-s1){
          min = s2-s1;
        }
      }

    }
    System.out.println(min);
  }
}


Measured memory_bytes: 21716
from collections import deque
N, M = map(int, input().split())


G = dict()
edge_dict = dict()
count_list = [0] * (N + 1)

for i in range(1, N + 1):
    G[i] = dict()
    edge_dict[i] = dict()

for _ in range(M):
    A, B = map(int, input().split())
    if A > B:
        A, B = B, A
    G[A][B] = 1
    G[B][A] = 1
    edge_dict[A][B] = 1
    edge_dict[B][A] = -1
    count_list[A] += 1

if M % 2 == 1:
    print(-1)
else:
    # minimum spanning tree
    parent = [0] * (N + 1)
    node_list = []
    queue = deque([1])
    visited = [0] * (N + 1)
    # BFS
    while len(queue) > 0:
        p = queue.popleft()
        for q in G[p].keys():
            if visited[q]:
                continue
            else:
                parent[q] = p
                visited[q] = 1
                queue.append(q)
                node_list.append(q)

    while len(node_list) > 0:
        q = node_list.pop()
        p = parent[q]
        if count_list[q] % 2 == 1:
            edge_dict[p][q] *= -1
            edge_dict[q][p] *= -1
            count_list[p] += 1
            count_list[q] += 1

    for i in range(1, N + 1):
        for j in edge_dict[i].keys():
            if edge_dict[i][j] == 1:
                print(i, j)


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

int main() {
  int S = 0;
  for (int i = 0; i < 4; i++) {
    int score;
    cin >> score;
    S += score;
  }
  int T = 0;
  for (int i = 0; i < 4; i++) {
    int score;
    cin >> score;
    T += score;
  }

  if (S > T || S == T) {
    cout << S << endl;
  } else {
    cout << T << endl;
  }

  return 0;
}


Measured memory_bytes: 3084
import java.util.*;

public class Main {
	public static long[] size = new long[51];
	public static long[] point = new long[51];
	
	public static void main(String[] args){
		size[0] = 1;
		point[0] = 1;
		for (int i = 1; i < 51; i++) {
			size[i] = size[i - 1] * 2 + 3;
			point[i] = point[i - 1] * 2 + 1;
		}
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); //整数の入力
		long x = sc.nextLong();
		System.out.println(count(n, x));
		
	}
	
	public static long count(int level, long end) {
		if (level == 0) {
			return 1;
		}
		if (end > size[level]) {
			return point[level];
		}
		long total = 0;
		end--;
		if (end <= 0) {
			return total;
		}
		total += count(level - 1, end);
		end -= size[level - 1];
		if (end <= 0) {
			return total;
		}
		end--;
		total++;
		if (end <= 0) {
			return total;
		}
		total += count(level - 1, end);
		return total;
	}
	
}

Measured memory_bytes: 23764