akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int		main(void)
{
	int		n;
	cin >> n;
	int		ans = 0;
	int		tmp;
	int		i = 0;
	while (i < n)
	{
		cin >> tmp;
		if (!(tmp % 2) && (tmp % 3) && (tmp % 5))
		{
			ans = 1;
			break ;
		}
		i++;
	}
	if (ans == 1)
		cout << "DENIED";
	else
		cout << "APPROVED";
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n,m,i,j,cnt=0;
  scanf("%d",&n);
  int a[n];
  for(i=0; i<n; i++) scanf("%d",&a[i]);
  scanf("%d",&m);
  for(i=0; i<m; i++) {
    int x;
    scanf("%d",&x);
    for(j=0; j<n; j++) {
      if(a[j]==x) {
	cnt++;
	break;
      }
    }
  }
  printf("%d\n",cnt);
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int a, b;
  cin >> a >> b;
  int ans = (a-1) * (b-1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

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

Measured memory_bytes: 256
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    x, n = map(int, readline().split())
    p = list(map(int, readline().split()))
    check = float('inf')
    ans = 0
    for i in range(1000):
        if i not in p:
            if check > abs(x - i):
                ans = i
                check = abs(x - i)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61896
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

struct tip {
	int a,b,c;
};

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,ma,mb;
	cin >> n >> ma >> mb;
	const int N = 200 + 5;
	int cst[N][N], cst2[N][N];
	const int inf = 1e9;
	rep(i,0,N)rep(j,0,N)cst[i][j] = cst2[i][j] = inf;
	vector<tip> v;
	rep(i,0,n){
		int a,b,c;
		cin >> a >> b >> c;
		v.emplace_back((tip){a,b,c});
	}
	rep(i,0,1 << (n/2)){
		int a=0,b=0,c=0;
		rep(j,0,n/2){
			if((i >> j) & 1){
				a += v[j].a;
				b += v[j].b;
				c += v[j].c;
			}
		}
		gmin(cst[a][b], c);
	}
	int ans = inf;
	rep(i,0,1 << (n-(n/2))){
		int a=0,b=0,c=0;
		rep(j,n/2,n){
			if((i >> (j - n/2)) & 1){
				a += v[j].a;
				b += v[j].b;
				c += v[j].c;
			}
		}
		gmin(cst2[a][b], c);
	}
	rep(a,0,N){
		rep(r,0,N){
			int ax = a + r;
			rep(b,0,N){
				int s = max(min((ax * mb - b * ma) / ma, N-1), 0);
				int bx = s + b;
				if(ax * bx != 0 && ax * mb == bx * ma){
					gmin(ans, cst2[a][b] + cst[r][s]);
				}
			}
		}
	}
	if(ans >= inf)ans = -1;
	cout << ans << '\n';
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

#define DEBUG 0
#define REP(i, n) for (int i = 0; i < (n); i++) 
typedef long long ll;
typedef pair<int,int> pint;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;



//?は基本aとしたいが
//Tは後ろのほうに追いやりたい
int main() { 

    string s;
    cin >> s;
    string t;
    cin >> t;



    string res = "";
    for(int i = 0 ; i < s.size(); ++i)
    {
        bool find_F = true;
        string tmp = s;
        for(int j = 0; j < t.size(); ++j)
        {
            if(i + j >= s.size())
            {
                find_F = false;
                break;
            }
            if(s[i + j] != '?' && s[i + j] != t[j])
            {
                find_F = false;
                break;
            }
            tmp[i + j] = t[j];
        }
        if(find_F)
        {
            //aに変換
            REP(i,tmp.size())
            {
                if(tmp[i] == '?')tmp[i] = 'a';
            }
            if(res == "")res = tmp;
            else res = min(res,tmp);
        }
    }

    
    if(res == "")
    {
        res = "UNRESTORABLE";
    }

    cout << res << endl;

    return 0;

} 

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

int main() {
	vector<int> a(3);
	for (int i = 0; i < 3;i++) cin >> a.at(i);

	sort(a.begin(), a.end());
	int ans = 0;

	ans += abs(a.at(1) - a.at(0));
	ans += abs(a.at(2) - a.at(1));

	cout << ans << endl;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    int n; cin >> n;
    vector<pair<int, int> > Act;
    rep(i,n){
        int ft, st; cin >> st >> ft;
        Act.push_back(make_pair(ft, st));
    }
    sort(Act.begin(), Act.end());
    queue<pair<int, int> > qAct;
    rep(i,n) qAct.push(Act[i]);

    int sum = 0;
    pair<int, int> act = qAct.front(); qAct.pop(); sum += 1;
    int ori_ft = act.first;
    while(!qAct.empty()){
        pair<int,int> action = qAct.front(); qAct.pop();
        if(action.second > ori_ft){
            sum += 1;
            ori_ft = action.first;
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 4460
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    string s;
    cin >> s;
    string t = "keyence";
    int n = s.size();
    int p = 0;
    rep(i,n){
        if (s[i] == t[p]) p++;
        else break;
    }
    cout << (s.substr(n-(7-p)) == t.substr(p) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		double sum = 0;
		for (int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
			sum += X[i];
		}

		double average = Math.round(sum / N);

		int answer = 0;
		for (int i = 0; i < N; i++) {
			answer += Math.pow(X[i] - average, 2);
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;
typedef pair<Pii, int> PPi;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int dist(int &x, int L, int R){
    if(L <= x && x <= R){
        return 0;
    }else if(x < L){
        int d = L - x;
        x = L;
        return d;
    }else{
        int d = x - R;
        x = R;
        return d;
    }
}

signed main(){

    int N; cin >> N;
    int L, R, n;
    vector<PPi> l(N), r(N);
    REP(i, N){
        cin >> L >> R;
        l[i] = PPi(Pii(L, R), i);
        r[i] = PPi(Pii(R, L), i);
    }

    SORT(l);
    REVERSE(l);
    SORT(r);

    vector<bool> is_used(N, false);
    
    int ans1 = 0, x = 0;
    REP(i, N){
        L = l[i].first.first;
        R = l[i].first.second;
        n = l[i].second;
        if(is_used[n]) break;
        is_used[n] = true;
        ans1 += dist(x, L, R);

        R = r[i].first.first;
        L = r[i].first.second;
        n = r[i].second;

        if(is_used[n]) break;
        is_used[n] = true;
        ans1 += dist(x, L, R);
    }
    ans1 += llabs(x);

    int ans2 = 0;
    x = 0;
    fill(is_used.begin(), is_used.end(), false);
    REP(i, N){
        R = r[i].first.first;
        L = r[i].first.second;
        n = r[i].second;
        if(is_used[n]) break;
        is_used[n] = true;
        ans2 += dist(x, L, R);

        L = l[i].first.first;
        R = l[i].first.second;
        n = l[i].second;
        if(is_used[n]) break;
        is_used[n] = true;
        ans2 += dist(x, L, R);
    }
    ans2 += llabs(x); 

    cout << max(ans1, ans2);
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> solve(int n, const vector<int> &a){
	const int m = a.size();
	vector<int> b(n);
	for(int i = 0; i < n; ++i){ b[i] = i; }
	for(int i = 0; i < m; ++i){ swap(b[a[i] - 1], b[a[i]]); }
	return b;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	for(int i = 0; i < m; ++i){ cin >> a[i]; }
	vector<int> ref = solve(n, a);
	sort(a.begin(), a.end());
	int answer = m;
	do {
		if(solve(n, a) == ref){
			vector<int> h(m);
			int total = 0;
			for(int i = 0; i < m; ++i){
				int ch = 0;
				for(int j = 0; j < i; ++j){
					if(a[i] - 1 <= a[j] && a[j] <= a[i] + 1){
						ch = max(ch, h[j] + 1);
					}
				}
				h[i] = ch;
				total = max(total, ch);
			}
			answer = min(answer, total + 1);
		}
	} while(next_permutation(a.begin(), a.end()));
	cout << answer << endl;
	return 0;
}

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


int main(){
	int n,m,p=0;
	cin>>n;m=n;
	while(n!=0){
		p+=n%10;
		n/=10;
		}
	if(m%p!=0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
	
	}

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

int main() {
    int N; cin >> N;
    string C; cin >> C;
    vector<int> rcount(N, 0);
    int cou = 0;
    for (int i = 0; i < N; i++) {
        if (C[i] == 'R') cou++;
        rcount[i] = cou;
    }
    int ans = 0;
    for (int i = N-1; 0 <= i; i--) {
        if (rcount[i] + ans > i) break;
        else if (C[i] == 'R') ans++;
    }
    cout << ans << endl;
}

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

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

int main(){

    int n, k;
    cin >> n >> k;
    ll ans = k;
    for(int i = 0; i < n-1; i++){
        ans *= (k-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
import itertools as it

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

a = 0
b = 0
n = it.permutations(range(1, N + 1), N)
for i, e in enumerate(n):
    if P == e:
        a = i
    if Q == e:
        b = i

print(abs(a - b))


Measured memory_bytes: 39024
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int n;
	int i;
	int s = 0;
	
	while (scanf("%d %d %d", &a, &b, &n) != EOF){
		for ( i = 0; i < n; i++){
			a *= 10;
			s += (a / b) % 10;
			a %= b;
		}
		
		printf("%d\n", s);
		s = 0;
	}
	
	return (0);
}

Measured memory_bytes: 592
n = int(input())

s = list(input())

ans = s.count("R")*s.count("G")*s.count("B")

for i in range(n):
    for j in range(i+1,n):
        k = 2*j-i
        if k < n :
            if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
                ans -= 1

print(ans)


Measured memory_bytes: 9108
n = int(input())
a = list(map(int, input().split()))
b = []
for i in a:
    if i % 2 == 0:
        b.append(i)
for j in b:
    if j % 3 != 0 and j % 5 != 0:
        print('DENIED')
        break
else:
    print('APPROVED')

Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))

ans = []
mx = max(A)
mi = min(A)

if mx * mi < 0:
    if abs(mi) > abs(mx):
        x = A.index(mi)
        for y in range(N):
            if y == x:
                continue
            A[y] += mi
            ans.append((x, y))
    else:
        x = A.index(mx)
        for y in range(N):
            if x == y:
                continue
            A[y] += mx
            ans.append((x, y))

for i in range(N - 1)[::(-1)**(min(A) < 0)]:
    l, r = A[i], A[i + 1]

    if l > r:
        if r >= 0:
            A[i + 1] += l
            ans.append((i, i + 1))
        elif l <= 0:
            A[i] += r
            ans.append((i + 1, i))

print(len(ans))
for x, y in ans:
    print(x + 1, y + 1)

if list(sorted(A)) != A:
    print(A)
    1 / 0


Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 2000000
#define left(i) 2*i
#define right(i) 2*i+1
int A[MAX+1],H;

void maxHeapify(int i){
  int tmp,largest,l,r;
  l=left(i);
  r=right(i);

  if (l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;
  if(largest != i){
    tmp = A[largest];
    A[largest] = A[i];
    A[i] = tmp;
    maxHeapify(largest);
  }
}

int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--)maxHeapify(i);
  for(i=1;i<=H;i++)printf(" %d",A[i]);
  printf("\n");
  return 0;
}

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

int main()
{
    long long n, b, r;
    long long br, total = 0;
    scanf("%lld%lld%lld", &n, &b, &r);
    
    br = b+r;
    
    total += ( n/br ) * b;
    
    if ( n%br <= b ){
        total += n%br;
    } else if ( n%br > b ){
        total += b;
    }
    
    printf("%lld\n", total );
}


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

#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)

using namespace std;

void mySortDesc(long a[],int n);
void appendArray(long a[],int n1, long b[], int n2, long ret[]);
void arraycpy(long a[],int f,int l, long ret[]);
long sumOfArray(long a[],int n);
void solver1(){
	int X,Y,A,B,C,i,j,k;
	long p[100000],q[100000],r[100000],p2[100000],q2[100000],umami[300000],ans;
	cin >> X >> Y >> A >> B >> C;
	myfor(i,A)cin >> p[i];
	myfor(i,B)cin >> q[i];
	myfor(i,C)cin >> r[i];
	mySortDesc(p,A);
	mySortDesc(q,B);
	mySortDesc(r,C);
	arraycpy(p,0,X,p2);
	arraycpy(q,0,Y,q2);

	appendArray(p2,X,q2,Y,umami);
	appendArray(umami,X+Y,r,C,umami);
	mySortDesc(umami,X+Y+C);

	ans = sumOfArray(umami,X+Y);

	cout << ans << endl;
}

int main(void){
	int X,Y,A,B,C,i,j,k;
	vector <long> p,q,r,umami;
	long ans,tmp;

	cin >> X >> Y >> A >> B >> C;
	myfor(i,A){
		cin >> tmp;
		p.push_back(tmp);
	}
	myfor(i,B){
		cin >> tmp;
		q.push_back(tmp);
	}
	myfor(i,C){
		cin >> tmp;
		r.push_back(tmp);
	}
	sort(p.begin(),p.end(),greater<long>());
	sort(q.begin(),q.end(),greater<long>());

	q.resize(X+Y);

	copy(p.begin(),p.begin() + X,q.begin() + Y);
	copy(q.begin(),q.end(),back_inserter(r));
	sort(r.begin(),r.end(),greater<long>());
	ans = accumulate(r.begin(),r.begin() + X+Y,0L);
	cout << ans << endl;


	return 0;
}

void mySortDesc(long a[],int n){
	int i,j;
	long tmp;
	myfor(i,n)myforFL(j,i,n){
		if(a[i] < a[j]){
			tmp = a[i];
			a[i] = a[j];
			a[j] = tmp;
		}
	}
}

void appendArray(long a[],int n1, long b[], int n2, long ret[]){
	int i;
	myfor(i,n1)ret[i] = a[i];
	myfor(i,n2)ret[i+n1] = b[i];
}

void arraycpy(long a[],int f,int l, long ret[]){
	int i;
	myforFL(i,f,l)ret[i-f] = a[i];
}

long sumOfArray(long a[],int n){
	int i;
	long ans=0;
	myfor(i,n)ans += a[i];
	return ans;
}

Measured memory_bytes: 8288
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int H;
    int W;
    int h;
    int w;
    int ans;

    cin >> H >> W;
    cin >> h >> w;
    ans = H*W - h*W - H*w + h*w;
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<stdio.h>
int n[5],i,I,v[5]={0,10,50,100,500},t,u[5];
int main()
{
	for(;scanf("%d",&n[I++%5]),n[0];)
	if(I%5==0)
	{
		I==5?0:puts("");
		for(i=1,t=-n[0];i<5;t+=n[i]*v[i],i++);
		for(i=5;--i;u[i]=t/v[i],t-=v[i]*u[i]);
		for(i=1;i<5;i++)
			n[i]>u[i]?printf("%d %d\n",v[i],n[i]-u[i]):0;
	}
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,l,x[200005],ans,s[200005],p[200005],y[200005];
int main(void){
    scanf("%lld%lld",&l,&n);
    for(int i=1;i<=n;i++)scanf("%lld",x+i);
    x[n+1]=l;
    for(int i=0;i<n;i++){
        s[n-i-1]+=x[n-(i/2)];
        s[n-i-1]+=s[n-i];
        p[n-i-1]+=x[n-i-1]+x[n-i];
        p[n-i-1]-=x[n-((i+1)/2)];
        p[n-i-1]+=p[n-i];
    }
    for(ll i=0;i<=n;i++){
        ans=max(ans,x[i]+(n-i)*l-(s[i]-p[i]));
    }
    for(int i=0;i<=n;i++){
        p[i]=0;
        s[i]=0;
        y[i]=x[i];
    }
    for(int i=1;i<=n;i++)x[i]=l-y[n-i+1];
    for(int i=0;i<n;i++){
        s[n-i-1]+=x[n-(i/2)];
        s[n-i-1]+=s[n-i];
        p[n-i-1]+=x[n-i-1]+x[n-i];
        p[n-i-1]-=x[n-((i+1)/2)];
        p[n-i-1]+=p[n-i];
    }
    for(ll i=0;i<=n;i++){
        ans=max(ans,x[i]+(n-i)*l-(s[i]-p[i]));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6528
from collections import Counter

N = int(input())
P = []
for _ in range(N):
    P.append(int(input()))

G = [0] * (N+1)
id = 1

for i in range(N):
    if G[P[i]-1] != 0:
        G[P[i]] = G[P[i]-1]
    else:
        G[P[i]] = id
        id+=1

C = Counter(G)

m = max(C.values())

print(N - m)




Measured memory_bytes: 37616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

inline int get_dice(){
    int ret;
    scanf(" %d", &ret);
    return ret-1;
}

inline void query(int move){
    printf("%d\n", move);
    fflush(stdout);
}

struct edge{
    int to;
    double cost;
};

const int N = 300;
vector<edge> G[N],rG[N];

void solve(){
    int m;
    scanf(" %d", &m);

    int a[6];
    rep(i,6) scanf(" %d", &a[i]);

    int s,g;
    scanf(" %d %d", &s, &g);
    --s;
    --g;

    vector<int> x(m);
    rep(i,m) scanf(" %d", &x[i]);

    auto IN = [&](int pos){
        return 0<=pos && pos<m;
    };

    auto move = [&](int pos, int aidx, int mul){
        if(mul==0) return pos;

        int nx = pos + mul*a[aidx];
        if(!IN(nx)) return -1;
        nx += x[nx];
        if(!IN(nx)) return -1;
        return nx;
    };

    rep(i,m){
        vector<int> ct(m);

        rep(j,6){
            vector<int> ttt(m);
            for(int k=-1; k<=1; ++k){
                int nx = move(i,j,k);
                if(nx!=-1) ttt[nx]=1;
            }

            rep(k,m) ct[k] += ttt[k];
        }

        rep(j,m){
            if(ct[j]>0){
                double COST = 1.0*ct[j]/6;
                G[i].pb({j, COST});
                rG[j].pb({i, COST});
            }
        }
    }

    const double INF = 19191919;
    vector<double> E(m,INF);
    vector<double> pp(m,1);
    vector<double> qq(m,0);

    E[g] = 0;

    using P = pair<double,int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0,g});
    while(!pq.empty()){
        P cur = pq.top();
        pq.pop();
        int v = cur.se;
        if(cur.fi > E[v]) continue;

        // dbg(v);
        for(const auto &e:rG[v]){
            double tp = pp[e.to] + e.cost*E[v];
            double tq = qq[e.to] + e.cost;
            double ne = tp/tq;
            // dbg(e.to);dbg(ne);
            if(E[e.to] > ne){
                pp[e.to] = tp;
                qq[e.to] = tq;
                E[e.to] = ne;
                pq.push({E[e.to], e.to});
            }
        }
    }

    // rep(i,m) printf(" %d: %.5f\n",i,E[i]);

    int now = s;
    rep(loop,3000){
        // printf(" now %d \n", now);
        int idx = get_dice();

        double tmpE = E[now];
        int ans = 0;
        for(int i=-1; i<=1; ++i){
            int nxt = move(now, idx, i);
            // dbg(i);dbg(nxt);
            if(nxt!=-1){
                if(tmpE > E[nxt]){
                    ans = i;
                    tmpE = E[nxt];
                }
            }
        }

        now = move(now,idx,ans);
        query(ans);
        if(now == g) return;
    }

    while(1){}
}

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



Measured memory_bytes: 3400
//STANLEGENDS_STANEXO
//EXO_WEAREONE
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	long long a[200000];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	a[0]=a[0]-1;
	 for(int i=1;i<n;i++)
     {
      if(a[i]<a[i-1])
      	{ cout<<"No";
            return 0;
          }
       else if(a[i]>a[i-1])
       { a[i]=a[i]-1;
       }
      } 
       cout<<"Yes";
     


}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if((A==5&&B==5)||(A==5&&C==5)||(B==5&&C==5)){
      printf("YES\n");
    }
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<cmath>
using namespace std;
#define int long long

signed main() {
    int D , T , S;
    cin>>D>>T>>S;
    int temp;
    if(D%S == 0)
    temp = D/S;
    else
    temp = D/S + 1;
    
 //   cout<<temp<<"\n";
    if(T >= temp)
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";
    
    
}	

Measured memory_bytes: 3632
package main

import (
	"bufio"
			"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

const (
	LAST_MONTH = 4280
	BASE = 1150
)

func main() {
	for scanner.Scan() {
		w, _ := strconv.Atoi(scanner.Text())
		if w < 0 {
			break
		}
		s := BASE
		if  10 < w {
			if w <= 20 {
				s+= (w-10)*125
			} else {
				s+= 1250
			}
		}
		if 20 < w {
			if w <= 30 {
				s += (w-20)*140
			} else {
				s += 1400
			}
		}
		if 30 < w {
			s += (w-30)*160
		}
		fmt.Println(LAST_MONTH-s)
	}
}


Measured memory_bytes: 1060
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second
 
using namespace std;
 
int main(){
 
    int n;
    cin >> n;

    vector<ll> a(3*n);
    for(int i=0;i<3*n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans += a[3*n-2-2*i];
    }
  	cout << ans;

    return 0;
}

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

bool isPrime(ll n) 
{ 
    // Corner case 
    if (n <= 1) 
        return false; 
  
    // Check from 2 to n-1 
    for (ll i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
} 

int main(){

	// #ifndef ONLINE_JUDGE
 //    	freopen("input", "r", stdin);
 //    	freopen("output", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);

   	ll s;
   	cin>>s;

   	cout<<0<<" "<<0<<" ";

   	ll sq = sqrt(s);

   	ll bx,cy,cx,by;

   	bx = cy = sq;

   	bool done=false;

   	if(bx*cy==s){
   		cx=by=0;
   		done=true;
   	}

   	if(!done){
   		bx++;
   		cy++;
   		cx=1;
   		by=(bx*cy-s)/1;
   	}

   	cout<<bx<<" "<<by<<" "<<cx<<" "<<cy<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long
using namespace std;

int main(){
  int N; int H;cin>>N>>H;
  int ans =0;
  int huru=0;
  vector <int> b(0);
  for(int i=0;i<N;i++){
    int ain,bin;
    cin>>ain>>bin;
    huru = max(huru,ain);
    b.push_back(bin);
  }

  b.push_back(huru);
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());

  vector <int> B(0);
  ll lastAttack=0;

  for(int i=0;i<b.size();i++){
    if(b[i] == huru){

      break;
    }

    B.push_back(b[i]);
    lastAttack += b[i];

  }

  int dif = H - lastAttack;
  //cout<<dif<<endl;
  if(dif<=0){
    
    for(int i=0;i<B.size();i++){
    H = H-b[i];
    //cout<<H<<endl;
    ans++;
    if(H<=0){
    //  cout<<76767<<endl;
      break;
    }
    }

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

  
  ans += dif / huru;
  if(dif % huru > 0) ans++;
  H = H - huru * ans;
  if(B.size() == 0) {
    cout<<ans<<endl;
    return 0;
  }

  for(int i=0;i<B.size();i++){
    H = H-b[i];
    ans++;
    if(H<=0){
      break;
    }
  }

  cout<<ans<<endl;

  



  return 0;
}
  


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

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

int main(){
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    
    if(a[0] != 0){ cout << -1 << endl; return 0; }

    ll ans = 0;
    ll save = 0;
    bool check = true;
    loop(i,1,n){
        if(a[i] == 0){ ans += save; save = 0; }
        else if(a[i] == save + 1){ save++; }
        else if(a[i] < save + 1){ ans += save; save = a[i]; }
        else if(a[i] > save + 1){ check = false; break; }
    }
    ans += save;
    if(check) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){

  int n;
  cin >> n;
  vector<int> k(n);
  vector<int> s(31,0);
  rep(i,n){
    cin >> k[i];
    int x = k[i];
    rep(j,31){
      s[j] += x%2;
      x /= 2;
    }
  }
  vector<ll> res(n,0);
  rep(j,31){
    if(s[j] & 1){
      rep(i,n){
        if(k[i] >> j & 1)k[i] -= 1 << j;
        else k[i] += 1 << j;
      }
    }
  }
  rep(i,n)cout << k[i] << " ";
  cout << endl;
  




  return 0;
}

Measured memory_bytes: 5548
#include<stdio.h>
int main(){
  int N;
scanf("%d",&N);
  int a,b,c,d;
  int count = 0;
  d = N % 10;
  c = (N % 100 - d)/10;
  b = (N % 1000 - (10 * c + d))/100;
  a = (N - (100 * b + 10 * c + d))/1000;
  if(a == b && b == c)
    {
        count = 1;
    }
  else if(b == c && c == d)
    {
        count = 1;
    }
  if(count == 1){
    printf("Yes");
  }
  else{
    printf("No");
}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

struct LCA {
    int n, h;
    vector<vector<int>> G, par;
    vector<int> depth;

    LCA(int n) : n(n), G(n), depth(n) {
        h = 1;
        while ((1 << h) <= n) h++;
        par.assign(h, vector<int>(n, -1));
    }

    void add_edge(int u, int v) {
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    void dfs(int v, int p, int d) {
        par[0][v] = p;
        depth[v] = d;
        for (int u : G[v]) {
            if (u != p) dfs(u, v, d + 1);
        }
    }

    void build(int r = 0) {
        dfs(r, -1, 0);
        for (int k = 0; k + 1 < h; k++) {
            for (int v = 0; v < n; v++) {
                if (par[k][v] != -1) par[k + 1][v] = par[k][par[k][v]];
            }
        }
    }

    int query(int u, int v) {
        if (depth[u] > depth[v]) swap(u, v);
        for (int k = 0; k < h; k++) {
            if ((depth[v] - depth[u]) >> k & 1) v = par[k][v];
        }
        if (u == v) return u;
        for (int k = h - 1; k >= 0; k--) {
            if (par[k][u] != par[k][v]) {
                u = par[k][u];
                v = par[k][v];
            }
        }
        return par[0][u];
    }

    int dist(int u, int v) {
        return depth[u] + depth[v] - depth[query(u, v)] * 2;
    }
};

#define MAX 100000

vector<tuple<int, int, int>> G[MAX];
int dist[MAX];
vector<int> colors[MAX];
int nowcnt[MAX], nowsum[MAX];
map<int, int> cnt[MAX];
map<int, int> sum[MAX];

void dfs(int cur) {
    for (int c : colors[cur]) {
        cnt[cur][c] = nowcnt[c];
        sum[cur][c] = nowsum[c];
    }
    for (auto t : G[cur]) {
        int to = get<0>(t), c = get<1>(t), d = get<2>(t);
        if (dist[to] != -1) continue;
        nowcnt[c]++;
        nowsum[c] += d;
        dist[to] = dist[cur] + d;
        dfs(to);
        nowcnt[c]--;
        nowsum[c] -= d;
    }
}

signed main() {
    int n, q;
    cin >> n >> q;
    LCA lca(n);
    rep(i, n - 1) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        lca.add_edge(a, b);
        G[a].emplace_back(b, c, d);
        G[b].emplace_back(a, c, d);
    }
    lca.build();
    int x[q], y[q], u[q], v[q];
    int a[q];
    rep(i, q) {
        cin >> x[i] >> y[i] >> u[i] >> v[i];
        u[i]--;
        v[i]--;
        a[i] = lca.query(u[i], v[i]);
        colors[u[i]].emplace_back(x[i]);
        colors[v[i]].emplace_back(x[i]);
        colors[a[i]].emplace_back(x[i]);
    }
    fill(dist, dist + n, -1);
    dist[0] = 0;
    dfs(0);
    rep(i, q) {
        int distu, distv, dista;
        distu = dist[u[i]] + y[i] * cnt[u[i]][x[i]] - sum[u[i]][x[i]];
        distv = dist[v[i]] + y[i] * cnt[v[i]][x[i]] - sum[v[i]][x[i]];
        dista = dist[a[i]] + y[i] * cnt[a[i]][x[i]] - sum[a[i]][x[i]];
        cout << distu + distv - 2 * dista << endl;
    }
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e15;

struct Edge{
  int to, cost;

  Edge(LL t, LL c): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
  bool operator<(const Edge& rhs) const{
	return cost < rhs.cost;
  }

};
typedef vector< vector<Edge> > Graph;

void add_edge(Graph& graph, int u, int v, LL cost){
  graph[u].push_back(Edge(v,cost));
  graph[v].push_back(Edge(u,cost));
}

int N, M, X;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> N >> M >> X;
  VI ty(N);
  REP(i,N) cin >> ty[i];
  Graph G(N);
  REP(i,M){
	int u, v, d;
	cin >> u >> v >> d;
	add_edge(G, u-1, v-1, d);
  }

  // 0 - X : cold, X - 2X: hot
  VVL dp(N, VL(2*X+1, INF));
  using Type = pair<LL,PII>;
  priority_queue<Type, vector<Type>, greater<Type> > pq;
  dp[0][0] = 0;
  pq.push(MP(0,MP(0,0)));

  while(!pq.empty()){
	Type pii = pq.top(); pq.pop();
	LL d = pii.FF;
	PII s = pii.second;
	if(dp[s.FF][s.SS] < d) continue;
	for(auto&& e: G[s.FF]){
	  int nxt_tmp = (s.SS <= X? min(X, s.SS+e.cost): max(X, s.SS-e.cost));
	  LL nxt_d = dp[s.FF][s.SS] + e.cost;
	  if(ty[e.to] == 0){
		if(nxt_tmp <= X){
		  if(dp[e.to][0] > nxt_d){
			dp[e.to][0] = nxt_d;
			pq.push(MP(nxt_d, MP(e.to, 0)));
		  }
		}
	  }
	  else if(ty[e.to] == 1){
		if(dp[e.to][nxt_tmp] > nxt_d){
		  dp[e.to][nxt_tmp] = nxt_d;
		  pq.push(MP(nxt_d, MP(e.to, nxt_tmp)));
		}
	  }
	  else{
		if(nxt_tmp >= X){
		  if(dp[e.to][2*X] > nxt_d){
			dp[e.to][2*X] = nxt_d;
			pq.push(MP(nxt_d, MP(e.to, 2*X)));
		  }
		}
	  }
	}
  }

  LL ans = INF;
  REP(i,2*X+1) mini(ans, dp[N-1][i]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 35636
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.IO;
 
class Program
{
    static void Main()
    {
        var input = ReadLine().Split();
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int[] a = Array.ConvertAll(ReadLine().Split(), int.Parse);
 
        Dictionary<long,long> dic = new Dictionary<long,long>();
        long[] sum = new long[n+1];
 
        foreach(int i in EnumerableCommon.Range(n))
        {
            sum[i + 1] = (sum[i] + a[i]) % m;
        }
 
        long ans = 0;
        foreach(int i in EnumerableCommon.Range(sum.Length))
        {
            if (dic.ContainsKey(sum[i]))
            {
                ans += dic[sum[i]];
            }
            else dic.Add(sum[i], 0);
            dic[sum[i]]++;
        }
 
        WriteLine(ans);
    }
    public static partial class EnumerableCommon
    {
        public static IEnumerable<int> Range(int count)
        {
            return Enumerable.Range(0, count);
        }
    }
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int H, W;
string S[22];
int dist[440][440];

signed main() {
    cin >> H >> W;
    rep(i, H) {
        cin >> S[i];
    }
    int v = H * W;
    rep(i, v)rep(j, v)dist[i][j] = INF;

    rep(i, v) {
        rep(j, v) {
            int y1 = i / W;
            int x1 = i % W;
            int y2 = j / W;
            int x2 = j % W;
            if (y1 == y2) {
                if (x1 == x2 + 1 || x2 == x1 + 1) {
                    if (S[y1][x1] == '.' && S[y2][x2] == '.') {
                        dist[i][j] = 1;
                    }
                }
            } else if (x1 == x2) {
                if (y1 == y2 + 1 || y2 == y1 + 1) {
                    if (S[y1][x1] == '.' && S[y2][x2] == '.') {
                        dist[i][j] = 1;
                    }
                }
            }
        }
    }
    rep(i, v)dist[i][i] = 0;

    rep(k, v) {
        rep(i, v) {
            rep(j, v) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = 0;
    rep(i, v) {
        rep(j, v) {
            if (dist[i][j] != INF) {
                //cerr << i << " " << j << " " << dist[i][j]<<endl;
                ans = max(ans, dist[i][j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll n,m,k,l,h,g,i;
    	ll a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    	cin>>k;
    	cout<<a[k-1];
	}
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define REP(i,n) for(i=0;i<n;i++)

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);
double to_deg(double rad);
double distance(int xi, int yi, int xj, int yj);

//main function
int main() {
    int M1 = iin(), D1 = iin(), M2 = iin(), D2 = iin();
    if (M1 != M2) iout(1);
    else iout(0);
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

/*
    弧度法を度数法に
*/

double to_deg(double rad) {
    return rad * 180.0 / (atan(1.0) * 4.0);
}

double distance(int xi, int yi, int xj, int yj) {
    return hypot(xj - xi, yj - yi);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
#include <assert.h>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 100000000
#define MAX_N 150005
#define EPS 0.000000001
using namespace std;

int main(){
    int cnt=0;
    int a[26]={};
    string s;
    cin>>s;
    rep(i,0,s.size()){
        a[int (s[i]-'a')]++;
    }
    rep(i,0,26){
        if(a[i]%2==1)cnt++;
    }
    cout<<cnt/2<<endl;
    
    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, d, x;
	cin >> n >> d >> x;
	int cnt=x;
	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		int day=1;
		while(day<=d){
			cnt++;
			day+=a;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// E - Knapsack 2
/*  States: i - index of item to be considered, j - value that can be obtained.
    Stores: minimum weight needed to achieve this value.*/

using namespace std;

int dp[101][100001];

int main() {
    int N,W,i,j,w,v,ans;

    scanf("%d%d",&N,&W);

    memset(dp,0x3f,sizeof(dp));
    dp[0][0] = 0;

    for (i = 1;i <= N;i++) {
        scanf("%d%d",&w,&v);
        for (j = v;j <= 100000;j++)
            dp[i][j] = min(dp[i][j],dp[i - 1][j - v] + w);
        for (j = 0;j <= 100000;j++)
            dp[i][j] = min(dp[i][j],dp[i - 1][j]);
    }

    ans = 0;
    for (i = 0;i <= 100000;i++) {
        if (dp[N][i] <= W)
            ans = max(ans,i);
    }

    printf("%d\n",ans);

    return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  string o,e; cin>>o>>e;
  int ol=o.size();
  int el=e.size();
  for (int i=0; i<ol; i++) {
    cout<<o[i];
    if (i<el) cout<<e[i];
  }
  cout<<endl;
}

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


Measured memory_bytes: 256
/*
	0511:Who Are The StudentYet To Submit
*/
#include	<iostream>

using namespace std;

int main(void) {
	int student[30] = { 0 };
	
	for(int i = 0; i < 28; i++) {
		int num;
		
		cin >> num;
		student[num - 1]++;
	}
	for(int i = 0; i < 30; i++) {
		if(student[i] == 0) {
			cout << i+1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<long,long>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}

map<ll,ll> prime_factor(ll n){ //素因数分解
	map<ll,ll> ret;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			ret[i]++;
			n /=i;
		}
	}
	if(n!=1) ret[n] =1;
	return ret;
} 

int main(){
	ll n;
	cin >> n;
	map<ll,ll> pf = prime_factor(n);
	ll ans =0;
	for(auto &e:pf){
		ll tmp = e.S;
		for(ll i=1;i<=tmp;i++){
			ans++;
			tmp-=i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

double PI = acos((double)-1);
const ld eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
//const ll mod = 1e9 + 9;
const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

void solve() {
	ll a, b;
	cin >> a >> b;
	if (a > 0) cout << "Positive\n";
	else if (a <= 0 && b >= 0) cout << "Zero\n";
	else if (b - a + 1 & 1) cout << "Negative\n";
	else cout << "Positive\n";
	return;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 5;
char s[maxn];
int sum[maxn];
int k[maxn];
vector<int> D;
vector<int> C;
int n;
ll slove(int k) {
    if (C.empty() || D.empty())
        return 0;
    ll ans=0;
    int j = 0;
    queue<int> q;
    int a, b;
    ll temp=0;
    for (int i = 0; i < D.size(); i++) {
        //将所有C的贡献调整
        if(i>0)
            temp-=(ll)q.size()*(sum[D[i]]-sum[D[i-1]]);
        //将跳过的C贡献调整
        if(!q.empty()) {
            int ft=q.front();
            while(ft<=D[i]) {
                temp+=sum[D[i]]-sum[D[i-1]];
                temp-=sum[ft]-sum[D[i-1]];
                q.pop();
                if(q.empty())
                    break;
                ft=q.front();
            }
        }
        //将无用的C排除
        while(j < C.size() &&C[j]<D[i]){
            j++;
        }
        //增加新的C
        while (j < C.size() && C[j] - D[i] < k) {
            q.push(C[j]);
            temp+=sum[C[j]]-sum[D[i]];
            j++;
        }
        ans+=temp;
    }
    return ans;
}
int main() {
    scanf("%d", &n);
    scanf("%s", s + 1);
    int q;
    scanf("%d", &q);
    for (int i = 1; i <= q; i++)
        scanf("%d", &k[i]);
    for (int i = 1; i <= n; i++) {
        if (s[i] == 'D')
            D.push_back(i);
        if (s[i] == 'C')
            C.push_back(i);
        if (s[i] == 'M')
            sum[i] = sum[i - 1] + 1;
        else
            sum[i] = sum[i - 1];
    }
//    cout<<"D";
//    for(auto x:D)cout<<x<<" ";cout<<endl;
//    cout<<"C";
//    for(auto x:C)cout<<x<<" ";cout<<endl;
    for (int i = 1; i <= q; i++) {
        printf("%lld\n", slove(k[i]));
    }
}


Measured memory_bytes: 16680
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main()
{
    int N, M;
    cin >> N >> M;
    priority_queue<P, vector<P>, function<bool(P, P)>> 
    IN (
        [](P x, P y) { return x.first > y.first; }
    );

    priority_queue<P, vector<P>, function<bool(P, P)>>
    OUT (
        [](P x, P y) { return x.second < y.second; }
    );

    for(int i = 0; i < N; ++i) {
        int atmp, btmp;
        cin >> atmp >> btmp;
        IN.push(make_pair(atmp, btmp));
    }

    ll cnt = 0;
    for(int i = 1; i <= M; ++i) {
        while(IN.top().first <= i && IN.size() > 0) {
            int atmp = IN.top().first,
                btmp = IN.top().second;
            OUT.push(make_pair(atmp, btmp));
            IN.pop();
        }

        if(OUT.size() > 0) { 
            cnt += OUT.top().second;
            OUT.pop();
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 2548
#include <stdio.h>


int main(){

	int X;

	scanf("%d",&X);

	if(X<0){X=-X;}

	int t=0;
	int sum=0;

	while(1){
		if(sum>=X){break;}
		t++;
		sum+=t;
	}
	printf("%d\n",t);

	return 0;
}

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

std::priority_queue<double> q;
int n;
int main()
{
	std::cin >> n;
	for(int i = 1;i <= n;i++) {
		double a; std::cin >> a;
		q.push(-a);
	}

	while(q.size() > 1) {
		double a1 = q.top(); q.pop();
		double a2 = q.top(); q.pop();
		q.push((a1 + a2) / 2);
	}

	double a1 = q.top(); q.pop();
	double a2 = q.top(); q.pop();
	std::cout << - (a1 + a2) / 2;

	return 0;
}




Measured memory_bytes: 256