akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
string s;
int idx=0;
int f(){
    if(s[idx]>='0'&&s[idx]<='9'){
        int num=0;
        while(s[idx]>='0'&&s[idx]<='9')num*=10,num+=s[idx++]-'0';
        return num/2+1;
    }

    vector<int>v;
    while(s[idx]=='['){
        idx++;
        v.push_back(f());
        idx++;
    }
    sort(v.begin(),v.end());
    int res=0;
    REP(i,v.size()/2+1)res+=v[i];
    return res;
}

void solve()
{
    int n;cin>>n;
    while(n--){
        idx=0;
        cin>>s;
        cout<<f()<<endl;
    }
}

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


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

signed main(){
  string S;
  cin >> S;
  if(S == "ARC")cout << "ABC";
  else cout << "ARC";
}


Measured memory_bytes: 3624
// g++ -std=gnu++1y -O2 main.cpp

#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

int gcd(unordered_map<int, int> table, int a, int b, int c) {
	// if (table[(a << 16) | (b << 8) | c]) {
		// return table[(a << 16) | (b << 8) | c];
	// }

	int ret = 1;
	int minVal = min(a, min(b, c));

	for (int i = minVal; i >= 2; i--)
	{
		if (((a % i) == 0) && ((b % i) == 0) && ((c % i) == 0)) {
			// table[(a << 16) | (b << 8) | c] = i;
			return i;
		}
	}
	// table[(a << 16) | (b << 8) | c] = 1;
	return 1;
}

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

	unordered_map<int, int> table;

	long long sum = 0;
	// sum = gcd(112, 244, 52);
	
	for (int a = 1; a <= K; a++)
	{
		for (int b = 1; b <= K; b++) {
			for (int c = 1; c <= K; c++) {
				sum += gcd(table, a, b, c);
			}
		}
	}

	cout << sum << endl;
	return 0;
}

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

using namespace std;

int a[105];

int main() {
	int n;
	scanf("%d", &n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		sum += a[i];
	}
	int m;
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		int p, v;
		scanf("%d %d", &p, &v);
		printf("%d\n", sum - a[p - 1] + v);	
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
        	System.out.println("Yes");
        else
        	System.out.println("No");
    }	
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep (i,n) cin >> a[i];
  vector<int> ans(n);
  
  rep (i,k){
    vector<int> b(n,0);
    rep(j,n){
      int l = max(0,j-a[j]);
      int r = min(n-1,j+a[j]);
      b[l]++;
      if (r+1<n) b[r+1]--;
    }
    for (int j=1;j<(n);j++) b[j]+=b[j-1];
    a = b;
    if (count(a.begin(),a.end(),n) == n) break;
  }
  ans = a;

  rep(i,n) cout << ans[i] << " ";
  return 0;
}


Measured memory_bytes: 5572
#include <stdio.h>
#include <string.h>

int game(char s1[], char s2[]) {
  int i;
  int l1 = strlen(s1), l2 = strlen(s2);
  int len = l1 > l2 ? l1 : l2;

  for (i = 0; i < len; i++) {
    if (s1[i] > s2[i]) {
      return 1;
    } else if (s2[i] > s1[i]) {
      return 2;
    }
  }
  return 3;
}

int main() {
  int n, ptaro = 0, phanako = 0, result;
  char taro[101], hanako[101];
  int i;
  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s %s", taro, hanako);
    result = game(taro, hanako);
    if (result == 1) {
      ptaro += 3;
    } else if (result == 2) {
      phanako += 3;
    } else {
      ptaro += 1;
      phanako += 1;
    }
  }

  printf("%d %d\n", ptaro, phanako);

  return 0;
}



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

using namespace std;

int main(){
	int d,e;
	while(cin >> d >> e,d){
		double ans=100.0;
		for(int i=0;i<=d;i++){
			ans = min(ans, abs(sqrt(i*i+(d-i)*(d-i))-e));
		}
		cout << setprecision(12);
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3240
a=[list(map(int,input().split()))for _ in range(3)]
N = int(input())
for i in range(N):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:
          a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:
      ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:
      ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:
    ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:
    ans="Yes"
print(ans)


Measured memory_bytes: 3064
a,b=map(int,input().split())
stra = format(a,'b').zfill(50)
strb = format(b,'b').zfill(50)
#print(stra)
#print(strb)

summ = 0
numa = int(stra[-1])
numb = int(strb[-1])
if numa == numb:
    if numa==1:
        if (b-a)%4==0:
            summ+=1
    else:
        if (b-a)%4!=0:
            summ+=1
else:
    if (b-a)%4==1:
        summ+=1


for i in range(1,len(stra)):
    numa = int(stra[-1*i -1])
    numb = int(strb[-1*i -1])
    
    rem = 0
    cha = 0
    
    if numa==1:
        rem = a%(2**(i+1))
    if numb == 1:
        cha = b%(2**(i+1)) + 1 - 2**i
    
    if (cha+rem)%2==1:
        summ += 2**i

print(summ)

Measured memory_bytes: 3064
// Problem : D - Leaping Tak
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)
#define int long long

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
    T f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1, mod = 998244353;

int n, k;
int l[N], r[N];
int tr[N << 2];
int dp[N];

inline int ls(int p) {return p << 1;}
inline int rs(int p) {return p << 1 | 1;}

inline void pushup(int p) {tr[p] = (tr[ls(p)] + tr[rs(p)]) % mod;}

void modify(int x, int val, int l, int r, int p)
{
	if (l == r) {tr[p] += val; return;}
	int mid = (l + r) >> 1;
	if (x <= mid) modify(x, val, l, mid, ls(p));
	else modify(x, val, mid + 1, r, rs(p));
	pushup(p);
}

int getans(int ql, int qr, int l, int r, int p)
{
	if (ql <= l && r <= qr) return tr[p];
	int mid = (l + r) >> 1, ans = 0;
	if (ql <= mid) ans = getans(ql, qr, l, mid, ls(p));
	if (qr > mid) ans = (ans + getans(ql, qr, mid + 1, r, rs(p))) % mod;
	return ans;
}

signed main()
{
    //File("");
    n = gi <int> (), k = gi <int> ();
    for (int i = 1; i <= k; i+=1) l[i] = gi <int> (), r[i] = gi <int> ();
    dp[1] = 1;
    modify(1, 1, 1, n, 1);
    for (int i = 2; i <= n; i+=1)
    {
    	for (int j = 1; j <= k; j+=1)
    	{
    		if (i > l[j])
    		{
    			//cout << i << ' ' << max(1ll, i - r[j]) << ' ' << max(1ll, i - l[j]) << endl;
    			dp[i] = (dp[i] + getans(max(1ll, i - r[j]), max(1ll, i - l[j]), 1, n, 1)) % mod;
    		}
    	}
    	//cout << i << ' ' << dp[i] << endl;
    	modify(i, dp[i], 1, n, 1);
    }
    printf("%lld\n", dp[n]);
    return 0;
}

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T="";
  cin >> S;
  reverse(S.begin(),S.end());//逆から見たら場合分けを考える必要がない
  string a,b,c,d;
  a="maerd";
  b="remaerd";
  c="esare";
  d="resare";
  int t=0;
  int s=S.size();
  while (t+2<s){
    if (S[t+2]=='e'){
      T+=a;
      t+=5;
    }
    else if (S[t+2]=='m'){
      T+=b;
      t+=7;
    }
    else if (S[t+2]=='a'){
      T+=c;
      t+=5;
    }
    else if (S[t+2]=='s'){
      T+=d;
      t+=6;
    }
    else {
      break;
    }
  }
  if (T==S){
    cout << "YES" << endl;//前後だけの判断で代入してたがここで一致不一致を確認するからオッケー
  }
  else {
    cout << "NO" << endl;
  }
} 

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


int main(){

    int N;
    cin >> N;

    if(N/100%10==7 || N/10%10==7 || N/1%10==7){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

counts = defaultdict(int)
for a in A:
    counts[a + 1] += 1
    counts[a] += 1
    counts[a - 1] += 1

print(max(counts.values()))


Measured memory_bytes: 29616
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]
cnt_cons=0

for i in range(0, N-2, 1):
  if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
    print("Yes")
    cnt_cons += 1
    exit()
if cnt_cons == 0:
  print("No")

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

int split_sum(int i){
    string s=to_string(i);
    int sum=0;
    for(auto item:s){
        sum+=item-'0';
    }
    return sum;
}

int main(){
    CIN(A,B,C);
    bool flag=false;
    RepS(i,1,B){
        int n=A*i;
        if(n%B==C){
            flag=true;
            break;
        }
    }
    printf(flag?"YES\n":"NO\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main (void) {
    int i ,j ,h ,w;

    while(1) {
        cin >> h >> w;
        if (h == 0 | w == 0) break;
        for (i = 0 ; i < h ; i++ ) {
            for(j = 0 ; j < w ; j++ ) {
                if(i % 2 == 0) {
                    if(j % 2 == 0) cout << '#';
                    else cout << '.';
                } else {
                    if(j % 2 == 0) cout << '.';
                    else cout << '#';
                }
                
            }
            cout << '\n';
        }
        cout << '\n';
    }
}

Measured memory_bytes: 3092
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b;
    scanf("%d%d",&a ,&b);
    if(a<b){
        printf("a < b\n");
    }
    else if(a==b){
        printf("a == b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }

    return 0;
}



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

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

long long MOD = 10000000000 + 7;

vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i = 1; i * i <= n; i++){
    if(n % i == 0){
      res.push_back(i);
      if(i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

int main(){
  cout << setprecision(10);
  ll N; cin >> N;
  
  ll ans = 0;
  for(ll A = 1; A < N; A++){
    ll B = N / A;
    ans += B;
  }
  auto tmp = divisor(N);
  cout << ans - tmp.size() + 1 << endl;
  // cout << ans << endl;
  // cout << tmp.size() << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

int N;


int main() {
  cin >> N;
  int ans = 0;
  rep(i, N) {
    ans += i+1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
s = list(map(int,input().split()))
q = int(input())
t = list(map(int,input().split()))
# tをソートしてしたから見て行ってもいいが、二分探索でとく
def binary_search(search,list_):
  # search がlist_ の中にあるかを判定する
  l = 0
  r = len(list_)
  while r-l > 1:
    m = (l+r)//2
    if list_[m] > search: r = m
    elif list_[m] < search: l = m
    else:return m
  if r-l == 1:
    if search == list_[l]: return 0
    else: return -1
ans = 0
for i in t:
  if binary_search(i,s) >= 0: 
    ans += 1
    #print(i,s)
print(ans)



Measured memory_bytes: 16712
from itertools import groupby

n, m = map(int, input().split(" "))
py = [list(map(int, input().split(" "))) for _ in range(m)]

py = [py_i + [i] for i, py_i in enumerate(py)]
py_ = []
for key, group in groupby(sorted(py, key=lambda x: x[0]), lambda x: x[0]):
	for i, city in enumerate(sorted(group, key=lambda x: x[1])):
		py_.append(city + [i+1])

py = sorted(py_, key=lambda x: x[2])

for py_i in py:
	print(str(py_i[0]).zfill(6) + str(py_i[3]).zfill(6))

Measured memory_bytes: 45644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000000000000000

int main(){
	int n;cin>>n;
	vector<int> h(n+1);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	h[n]=0;//番兵

	int ans=0;
	bool allzero=false;

	while(!allzero){//hが全部0になるまで
		int num=0;
		for(int i=0;i<=n;i++){//0探す
			int MIN=10000000;

			if(h[i]==0){
				for(int j=num;j<i;j++){
					MIN=min(MIN,h[j]);
				}
				if(MIN!=10000000) ans+=MIN;
				for(int j=num;j<i;j++){
					h[j]-=MIN;
				}
				num=i+1;
			}
		}

		for(int i=0;i<=n;i++){//全部0になったか
			if(h[i]==0){allzero=true;}
			else{allzero=false;break;}
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
s = list(input())

acgt = ['']
while len(s) != 0:
	if s[0] == 'A' or s[0] == 'C' or s[0] == 'G' or s[0] == 'T':
		acgt[-1] += s.pop(0)
	else:
		s.pop(0)
		acgt.append('')

print(max([len(e) for e in acgt]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int a, b;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> a >> b;
	if(b == 1) {
		cout << 0;
		return 0;
	}
	for(int i = 1; i <= 40; i++) {
		int val = (i - 1) * (a - 1) + a;
		if(val >= b) {
			cout << i;
			return 0;
		}
	}
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

vector<vector<int>> to, cost;
int n;
vector<int> ans;

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

  cin >> n;
  to = vector<vector<int>> (n);
  cost = vector<vector<int>> (n);
  ans = vector<int>(n, -1);
  queue<int> q;
  for (int i = 0; i < n-1; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    a--;
    b--;
    to[a].push_back(b);
    cost[a].push_back(w);
    to[b].push_back(a);
    cost[b].push_back(w);
  }
  ans[0] = 0;
  q.push(0);

  while(!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < int(to[v].size()); i++) {
      int u = to[v][i];
      int w = cost[v][i];
      if(ans[u] != -1) continue;
      ans[u] = (ans[v] + w) % 2;
      q.push(u);
    }
  }

  for(auto a : ans) cout << a << endl;

}


Measured memory_bytes: 11904
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

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

	public Main() {
		Scanner sc = new Scanner(System.in);
		while(true){
			h = sc.nextInt();
			w = sc.nextInt();
			c = sc.nextInt();
			if(h==0 && w==0 && c==0)
				break;
			
			field =new int[h][w];
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++)
					field[i][j] = sc.nextInt();
			}
			solve();
		}
		
	}

	int h;
	int w;
	int c;
	int[][] field;
	public void solve() {
		visited = new boolean[7][h*w];
		int res = 0;
		for(int i=1;i<=6;i++){
			res =Math.max(res, rec(1, field[0][0], i));
		}
		System.out.println(res);
	}

	int[] dx = { -1, 0, 1, 0 };
	int[] dy = { 0, -1, 0, 1 };
	boolean[][] visited;
	Queue<Integer> queue = new LinkedList<Integer>();
	private int rec(int cur, int cc, int nc) {
		if(cur == 6)
			return count();
		
		int mask = (1<<3)-1;
		
		queue.add(0);
		Arrays.fill(visited[cur], false);
		while(!queue.isEmpty()){
			int p = queue.poll();
			int x = p&(0x07);
			int y = p>>3;
			if(visited[cur][y*w+x])
				continue;
			
			visited[cur][y*w+x] = true;
			field[y][x] = (field[y][x] << 3) + nc;  
			
			for(int i=0;i<4;i++){
				int nx = x+dx[i];
				int ny = y+dy[i];
				if(nx<0 || w<=nx || ny<0 || h<=ny)
					continue;
				
				if((field[ny][nx]&mask)==cc)
					queue.add((ny<<3)+nx);
			}
		}
		
		int ret = 0;
		for(int i=1;i<=6;i++)
			ret = Math.max(ret, rec(cur+1, field[0][0]&mask, i));
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(visited[cur][i*w+j]){
					field[i][j] >>=3;
				}
			}
		}
		
		
		return ret;
	}

	private int count() {
		int res = 0;
		int mask = (1<<3)-1;
		
		queue.add(0);
		Arrays.fill(visited[6], false);
		while(!queue.isEmpty()){
			int p = queue.poll();
			int x = p&0x07;
			int y = p>>3;
			if(visited[6][y*w+x])
				continue;
			
			visited[6][y*w+x] = true;  
			res++;
			for(int i=0;i<4;i++){
				int nx = x+dx[i];
				int ny = y+dy[i];
				if(nx<0 || w<=nx || ny<0 || h<=ny)
					continue;
				
				if((field[ny][nx]&mask)==c)
					queue.add((ny<<3)+nx);
			}
		}
//		System.out.println(res);
		return res;
	}

}

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

typedef long long ll;
const ll MOD = 1000000000 + 7;
string p[1002];
ll dp[1003][1003];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int h, w;
	cin >> h >> w;
	++h; ++w;
	
	for (int i = 1; i < h; ++i) {
		cin >> p[i];
	}
	
	p[0].append(w - 1, '#');
	for (int i = 0; i < h; ++i) {
		p[i] = '#' + p[i];
	}
	
	//
	/*for (int i = 0; i < h; ++i) {
		cout << p[i] << endl;
	}*/
	//
	
	dp[0][1] = 1;
	for (int i = 1; i < h; ++i) {
		for (int j = 1; j < w; ++j) {
			if (p[i][j] == '#') continue;
			dp[i][j] = (dp[i - 1][j] % MOD + dp[i][j - 1] % MOD) % MOD;
			// cout << "DP[" << i << "][" << j << "] = " << dp[i][j] <<"\n";
		}
	}
	cout << dp[h - 1][w - 1] << "\n";
	return 0;
}


Measured memory_bytes: 9216
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;



int main() {
	string st;cin>>st;
	cout<<st.substr(0,st.size()-8)<<endl;

	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int ans[1010][1010];

int main(){
  int H,W,A,B;
  cin>>H>>W>>A>>B;

  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(i<=B){
        if(j<=A) ans[i][j]=1;
        else ans[i][j]=0;
      }else{
        if(j<=A) ans[i][j]=0;
        else ans[i][j]=1;
      }
    }
  }

  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cout<<ans[i][j];
    }
    cout<<endl;
  }


  return 0;
}


Measured memory_bytes: 5120
def merge(a, left, mid, right)
	n1 = mid - left
	n2 = right - mid
	
	l = Array.new(n1+1)
	r = Array.new(n2+1)
	
	for i in 0..n1-1 do
		l[i] = a[left + i]
	end
	for i in 0..n2-1 do
		r[i] = a[mid + i]
	end
	
	l[n1] = 10 ** 9
	r[n2] = 10 ** 9
	
	i = 0
	j = 0
	for k in left..right-1 do
		if l[i] <= r[j]
			a[k] = l[i]
			i = i + 1
		else 
			a[k] = r[j]
			j = j + 1
		end
		$cnt += 1
	end
end

def merge_sort(a, left, right)
	if left + 1 < right
		mid = (left + right) / 2
		merge_sort(a, left, mid)
		merge_sort(a, mid, right)
		merge(a, left, mid, right)
	end
end

n = gets.chomp.to_i
s = gets.chomp.split(" ").map(&:to_i)

$cnt = 0
merge_sort(s, 0, n)

puts s.join(" "),$cnt

Measured memory_bytes: 65420
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(u==s)a--;
  else b--;
  cout << a << ' ' << b << endl;
return 0;}

Measured memory_bytes: 256
n = gets.to_i
ctn_500 = 0
while n >= 500
  n -= 500
  ctn_500 += 1
end

ctn_5 = 0
while n >= 5
  n -= 5
  ctn_5 += 1
end
puts ctn_500 * 1000 + ctn_5 * 5

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

using namespace std;

int main(){
    long long n, m;
    scanf("%lld%lld", &n, &m);
    long long tempAns = 0;
    tempAns += min(n, m / 2);
    m -= tempAns * 2;
    tempAns += m / 4;
    printf("%lld\n", tempAns);
    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;
  cin >> a >> b;
  if((a+b)%2==0) cout << (a+b)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,A[50];

  int solve(int,int);

int main(){
  int b,m,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&b);
  for(i=0;i<b;i++)
    {
      scanf("%d",&m);
      if(solve(0,m)==1)printf("yes\n");
      else printf("no\n");
    }
  return 0;
}
int solve(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  int b=a%10;
  if(b==3){
    cout<<"bon"<<endl;
  }else if(b==0||b==1||b==6||b==8){
    cout<<"pon"<<endl;
  }else{
    cout<<"hon"<<endl;
  }
}

Measured memory_bytes: 3652
n = int(input())
r = [int(input()) for _ in range(n)]

def get_max_ret(n, r):
    max_ret = r[1] - r[0]
    min_val = r[0]
    for i in range(1, n):
        ret = r[i] - min_val
        max_ret = max(max_ret, ret)
        min_val = min(r[i], min_val)
    return max_ret
    
max_return = get_max_ret(n, r)
print(max_return)



Measured memory_bytes: 13596
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<cmath>
#define eps 1e-9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<ll,ll> LLP;
const int MAXN=2e5+10;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const int MOD=1e9+7;
const int LOGN=20;
int arr[MAXN];
signed main()
{
    int n,k;
    scanf("%d",&n);
    scanf("%d",&k);
    int ans=0;
    for(int i=0;i<n;++i)
    {
        int tmp;
        scanf("%d",&tmp);
        if(tmp>=k)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter

n, m = map(int, input().split())
store = [] 
cart, price = 0, 0

for _ in range(n):
    temporary_dict = {}
    a, b = map(int, input().split())
    temporary_dict["value"] = a
    temporary_dict["stock"] = b
    store.append(temporary_dict)

store.sort(key=itemgetter("value", "stock"))

for i in range(n):
    test_value = store[i]["value"]
    test_stock = store[i]["stock"]
    if test_stock < m:
        m -= test_stock
        price += test_value*test_stock
    else:
        price += test_value*m
        break

print(price)

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

int main() {
  int maney = 100000;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    maney *= 1.05;
    if ( maney % 1000 != 0) {
      maney = (maney / 1000) * 1000 + 1000;
    }
  }
  cout << maney << endl;
  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b = 0, c = 0, d = 0;
  cin >> a;
  b = a / 100;
  c = (a % 100) / 10;
  d = (a % 100) % 10;
  cout << b + c + d << endl;
}

Measured memory_bytes: 256
n = int(input())
A = [int(input()) for i in range(n)]

Q = [-float("inf"), A[0]] + [float("inf")] * (n+1)
le = 2
for i in range(1, n):
    if Q[le-1] >= A[i]:
        Q[le] = A[i]
        le += 1
    else:
        l = 0
        r = le
        m = (l+r)//2
        while r-l > 1:
            if Q[m] >= A[i]:
                l = m
            else:
                r = m
            m = (l+r)//2
        Q[l+1] = A[i]
    # print(Q[:10])

print(le-1)

Measured memory_bytes: 54360
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	int N,pre_left_or_right;
	bool isBroken;
	char left,right,pre;
	char* buf = new char[100001];

	scanf("%d",&N);

	for(int loop = 0; loop < N; loop++){
		scanf("%s",buf);

		pre_left_or_right = -1;
		isBroken = false;
		left = 0,right = 0;

		pre = buf[0];
		if(pre == 'L'){
			pre_left_or_right = 0;
		}else if(pre == 'R'){
			pre_left_or_right = 1;
		}

		for(int i = 1; buf[i] != '\0'; i++){
			if(pre == buf[i]){
				isBroken = true;
				break;
			}

			switch(buf[i]){
			case 'U':
				if(pre_left_or_right  == 0){
					right = 'U';
					pre_left_or_right = 1;
				}else if(pre_left_or_right == 1){
					left = 'U';
					pre_left_or_right = 0;
				}
				break;
			case 'D':
				if(pre_left_or_right  == 0){
					right = 'D';
					pre_left_or_right = 1;
				}else if(pre_left_or_right == 1){
					left = 'D';
					pre_left_or_right = 0;
				}
				break;
			case 'L':
				if(pre_left_or_right == -1){
					right = pre;
				}else{
					if(pre_left_or_right == 0){
						isBroken = true;
						break;
					}
				}
				left = buf[i];
				pre_left_or_right = 0;
				break;
			case 'R':
				if(pre_left_or_right == -1){
					left = pre;
				}else{
					if(pre_left_or_right == 1){
						isBroken = true;
						break;
					}
				}

				right = buf[i];
				pre_left_or_right = 1;
				break;
			}
			pre = buf[i];
		}

		if(!isBroken)printf("Yes\n");
		else{
			printf("No\n");
		}

	}


	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int cnt=0;
    for(int i=1; i<=n; i++){
        if(i!=p[i-1]){
            cnt++;
            //cout << i << " " << p[i-1] << endl;
        }
    }
    if(cnt==2||cnt==0)cout << "YES";
    else cout << "NO";
    cout << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<LL> ans(100);
    ans[0] = 2;
    ans[1] = 1;
    inc(i, 2, 100) ans[i] = ans[i-2] + ans[i-1];
    cout << ans[n] << endl;
    return 0;
}


Measured memory_bytes: 256
-- Your code here!
import Control.Monad
import Data.Bits

calc :: [[Int]] -> [Int] -> [Int] -> Int
calc ks ps ns = length . filter (==True) $ map allOk ns 
  where
    allOk n = all (\(k,p) -> calc' k p n) (zip ks ps)


calc' :: [Int] -> Int -> Int -> Bool
calc' k p n = jdg
  where 
    ct = length . filter (==1) $ map (\e -> (shift n (1-e)) `mod` 2) k
    jdg = if ct`mod`2 == p then True else False
    

main = do
  [n,m] <- map read . words <$> getLine
  k <- replicateM m $ tail . map read . words <$> getLine :: IO [[Int]]
  p <- map read . words <$> getLine :: IO [Int]
  let ans = calc k p [0..2^n-1]
  print ans


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1e+9 + 7;
// constexpr int mod = 998244353;

struct edge{
    int from, to, cost;
    edge() = default;
    edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int L;
    cin >> L;
    vector<edge> res;
    vector<int> pow2(21);
    pow2[0] = 1;
    for(int i = 1; i < 21; ++i) pow2[i] = pow2[i - 1] * 2;
    int ub = 0;
    while(pow2[ub + 1] <= L)    ++ub;
    int n = ub;
    for(int i = 0; i < n; ++i)  res.emplace_back(edge(i, i + 1, 0));
    int pos = ub;
    for(int i = 0; i < ub; ++i){
        res.emplace_back(edge(pos - 1, pos, pow2[i]));
        --pos;
    }
    int rest = L - pow2[ub];
    int now = pow2[ub];
    for(int i = 20; i >= 0; --i){
        if((rest >> i) & 1){
            res.emplace_back(edge(0, ub - i, now));
            now += pow2[i];
        }
    }
    cerr << bitset<20>(rest) << endl;
    int m = res.size();
    cout << n + 1 << " " << m << "\n";
    for(int i = 0; i < m; ++i){
        int from = res[i].from + 1, to = res[i].to + 1, cost = res[i].cost;
        cout << from << " " << to << " " << cost << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    cout << (k == 1 ? 0 : n - k) << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : D - Worst Case
// Contest : AtCoder - AtCoder Regular Contest 094
// URL : https://atcoder.jp/contests/arc094/tasks/arc094_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()

const int N = 1e6 + 1;

ll a, b;

void solve() {
	cin >> a >> b;
	if (a > b) swap(a, b);
	ll c = sqrt(a * b);
	if (c * c == a * b) c--;
	if (a == b) cout << 2 * (a - 1);
	else if (a + 1 == b) cout << 2 * (a - 1);
	else if (c * (c + 1) >= a * b) cout << 2 * (c - 1);
	else cout << 2 * c - 1;
	cout << '\n';
}

int main() { cin.tie(0)->sync_with_stdio(0);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 256
s = input()
d = len(s)
n = int(s)
cand = []
def produce(text):
  if len(text) == d + 1:
    if '3' in text and '5' in text and '7' in text:
      cand.append(int(text))
    return
  if text[-1] == '0':
    for item in ['0', '3', '5', '7']:
      produce(text + item)
  else:
    for item in ['3', '5', '7']:
      produce(text + item)
produce('0')
print(sum(n >= item for item in cand))

Measured memory_bytes: 4084
#include <iostream>
#include <string>

using namespace std;

int main(){
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i]){
            ans++;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvl G;
vl visited;
vl ans;

void dfs(ll v) {
    // 行きの処理はこのへんに書く
    visited[v] = 1;
    for(auto u : G[v]) { 
        if(visited[u]) {
            continue;
        }
        ans.pb(u);
        dfs(u);
        // 帰りの処理はこのへんに書く
        return;
    }
}

int main() {
    ll n, m;
    cin >> n >> m;    
    
    G.resize(n);
    visited.resize(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    ans.pb(0);
    dfs(0);
    reverse(all(ans));
    dfs(0);
    
    out(ans.size());
    for(auto p :ans) {
        cout << p+1 << " ";
    }

    cout << endl;
    re0;
}

Measured memory_bytes: 10868
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 N;
    cin>>N;
    vector<int64> a(N);
    vector<int64> num;
    int64 num0=0,num1=0,num2=0;
    for(int64 i=0;i<N;i++){
        cin>>a[i];
    }

    num.push_back(a[0]);

    if(N%3!=0){
        for(int64 i=0;i<N;i++){
            if(a[i]!=0){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
        return 0;
    }else{
        for(int64 i=0;i<N;i++){
            if(a[i]==num[0]){
                num0++;
            }else{
                if(num.size()<=1){
                    num.push_back(a[i]);
                }
                if(a[i]==num[1]){
                    num1++;
                }else{
                    if(num.size()<=2){
                        num.push_back(a[i]);
                    }
                    if(a[i]==num[2]){
                        num2++;
                    }
                }
            }
        }
        if(num0==N/3&&num1==N/3&&num2==N/3){
            if((num[0]^num[1])==num[2]){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else if(num0==2*N/3&&num1==N/3){
            if(num[1]==0){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else if(num0==N/3&&num1==2*N/3){
            if(num[0]==0){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else if(num0==N){
            if(num[0]==0){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,t,p,m,a,b,f,e;
    cin>>a>>b;
    n=a-b;
    p=a+b;
    m=a*b;
   // cout<<n<<p<<m;
    e=max(n,p);
   // cout<<f;
    f=max(e,m);
    cout<<f<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

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

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}


  int main(){
      lint N,A,B;
      cin>>N>>A>>B;
    if((B-A)%2==0)cout<<(B-A)/2;
    else {
        if(A-1>N-B)cout<<N-B+(B-A+1)/2;
        else cout<<A-1+(B-A+1)/2;
  }
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int i,j,a,b,c;
  cin>>a>>b>>c;
  vector<int>v(a,b-c);
  for(i=0;i<c;i++)
  {
     cin>>j;
    v[j-1]=v[j-1]+1;
  }
  for(i=0;i<a;i++)
    if(v[i]>0)
      cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}
  

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

int main() {
  long long N, M;
  cin >> N >> M;
  
  vector<long long> items(N);
  for (int i = 0; i < N; i++) {
    cin >> items.at(i);
  }
  
  sort(items.begin(), items.end());
  
  if (N == 1) {
    for (int i = 0; i < M; i++) {
      items.at(0) /= 2;
      if (items.at(0) == 0)
        break;
    }
  }
  else {
    int next = 0;
    while (next < M) {
      if (items.at(N-1) == 0)
        break;
      int next_start = next;
      for (int i = 0; i < M - next_start; i++) {
        if (items.at(N-2) > items.at(N-1))
          break;
        else {
          items.at(N-1) /= 2;
          next++;
        }
      }
      next_start = next;
      for (int i = 2; i < M - next_start; i++) {
        if (N < i)
          break;
        else if (items.at(N-i) < items.at(N-1))
          break;
        else if (items.at(N-i) >= items.at(N-1)) {
          items.at(N-i) /= 2;
          next++;
        }
      }
      sort(items.begin(), items.end());
    }
  }

  long long sum = 0;
  for (int i = 0; i < N; i++) {
    sum += items.at(i);
  }  
  
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    REP(i, M) {
        cin >> A[i];
    }
    int tmp1 = 0, i = 0;
    while (A[i] < X) {
        tmp1++;
        i++;
    }
    int tmp2 = M - tmp1;
    if (tmp1 < tmp2) {
        cout << tmp1 << endl;
    } else {
        cout << tmp2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;

int ceil(int x,int y){
	if(x%y==0){
		return x/y;
	}
	else{
		return x/y+1;
	}
}

int main(){
	int n,d;
	cin >> n >> d;
	cout << ceil(n,2*d+1);


}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
    int i,n;
    char c[101];
    int cnt[10],num;

    while(1){
	scanf("%d%s",&n,c);
	if(n==0) break;

	num=0;
	for(i=0;i<n;i++) cnt[i]=0;

	for(i=0;i<100;i++){
	    if(c[i]=='M'){
		cnt[i%n]++;
	    }else if(c[i]=='S'){
		num=num+cnt[i%n]+1;
		cnt[i%n]=0;
	    }else{
		cnt[i%n]=cnt[i%n]+num+1;
		num=0;
	    }
	}

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

    return 0;
}

Measured memory_bytes: 2800
#include <stdio.h>
#define N 100000
#define M 50000

int binarySearch(int);
int S[N],n;
 
main(){
  int i,j,q,T[M],C=0;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
 
  for(i=0;i<q;i++){
    C+=binarySearch(T[i]);
  }
 
  printf("%d\n",C);
  return 0;
}
 
int binarySearch(int key){
  int left,right,mid;
 
  left=0;
  right=n;
  while(left < right){
    mid=(left + right)/2;
  if(key == S[mid]) return 1;
  if( key > S[mid]) left = mid + 1;
  else if(key < S[mid]) right = mid; 
  }
  return 0;
}
  

Measured memory_bytes: 1184
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int Z = sc.nextInt();
        
        for (int i = 1; i <= 1_000_000_0; i++) {
        	if (X < Y*i+(i+1)*Z) {
        		System.out.println(i-1);
        		return;
        	}
        }
        
        System.out.println(Y);
    }
    
}

Measured memory_bytes: 22868
z=list(map(int,input().split()))
X=list(map(int,input().split()))
N,A,B=z[0],z[1],z[2]
a=1
p=0
while True:
    p+=min((X[a]-X[a-1])*A,B)
    a+=1
    if a==N:
        break
print(p)

Measured memory_bytes: 14252
#include<iostream>
#include<list>
#include<cstring>
#include<algorithm>
#include <utility>
#include<stdio.h>
#include<climits>
#include <vector>
#include <queue>

using namespace std;

int main(){
    int i,j,k,l;
    int m,y,n,f,t,max;
    double s,r;
    cin >> m;
    for(i = 0;i < m;i++){
        cin >> s;
        cin >> y;
        cin >> n;
        max = s;
        for(j = 0;j < n;j++){
            cin >> f >> r >> t;
            if(f){
                l = s;
                for(k = 0;k < y;k++){
                    l += ((int)(l*r))-t;
                }
            }
            else{
                l = 0;
                for(k = 0;k < y;k++){
                    l += ((int)((s-t*k)*r));
                }
                l += s-t*k;
            }
            if(max < l) max = l;
        }
        cout << max << endl;
    }
}

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var cin = GetIntArray();
            var ans = 0;
            for(int i = 1; i < cin[1] - cin[0]; i++)
            {
                ans += i;
            }
            ans -= cin[0];
            Console.WriteLine(ans); 
        }


        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13396