akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string t;
int a,b,c;
int main(){
	while(1){
		cin>>t;
		if(t=="#")break;
		cin>>a>>b>>c;
		int q=c+b*100+a*10000;
		if(q>=310501)printf("? %d %d %d\n",a-30,b,c);
		else printf("HEISEI %d %d %d\n",a,b,c);
	}
	return 0;
}


Measured memory_bytes: 3276
#include <iostream>

int main(int argc, char **argv)
{
    int N, X;
    std::cin >> N >> X;

    int sum = 0;
    int min = 100001; // < 10^5
    for(int i = 0; i < N; i++){
        int m;
        std::cin >> m;
        sum += m;
        if(m < min) min = m;
    }

    std::cout << (((X - sum) / min) + N) << std::endl;

    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <iterator>
#include <limits>
#include <numeric>
#include <type_traits>
#include <cmath>
#include <cstdlib>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

#define ALL(v) (v).begin(), (v).end()
#define endl "\n"
typedef long long int ll;

template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

int SumDigitValues(int x)
{
	int sum = 0;
	while (x)
	{
		sum += x % 10;
		x = x / 10;
	}

	return sum;
}

int Factorial(int n)
{
	if (n < 0) return 0;
	if (n == 0) return 1;
	return n * Factorial(n - 1);
}

int factorial(int n)
{
	if (n > 1)
	{
		return n * factorial(n - 1);
	}
	else
	{
		return 1;
	}
}


int gcd(int a, int b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

vector<int> Divisors(int x)
{
	vector<int> divisors;
	divisors.push_back(1);
	for (int a = 2; a <= x; a++)
	{
		if (x % a == 0) divisors.push_back(a);
	}
	return divisors;
}

vector<int> CommonDivisors(int a, int b)
{
	vector<int> divisorsA = Divisors(a);
	vector<int> divisorsB = Divisors(b);
	vector<int> commonDivisors;
	set_intersection(divisorsA.begin(), divisorsA.end(), divisorsB.begin(), divisorsB.end(), std::back_inserter(commonDivisors));
	return commonDivisors;
}

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

	int a, b;
	cin >> a >> b;

	int smaller, larger;
	if (a < b)
	{
		smaller = a;
		larger = b;
	}
	else
	{
		smaller = b;
		larger = a;
	}

	for (int k = smaller; k <= larger; k++)
	{
		int l = abs(a - k);
		int r = abs(b - k);
		if (l == r)
		{
			cout << k << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;
}

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

ll count_range(ll l,ll u,vector<ll> &v){
    return lower_bound(v.begin(),v.end(),u)-lower_bound(v.begin(),v.end(),l);
}

ll solve(vector<ll> &a,vector<ll> &b,ll n){
    ll res = 0;

    for(int i = 0;i <= 28;i ++){
        vector<ll> amod,bmod;
        ll mod = pow(2,i+1),cnt = 0,T = pow(2,i);

        for(int i = 0;i < n;i ++){
            amod.push_back(a[i]%mod);
            bmod.push_back(b[i]%mod);
        }
        sort(bmod.begin(),bmod.end());

        for(int j = 0;j < n;j ++){
            cnt += count_range(T-amod[j],2*T-amod[j],bmod) +
                   count_range(3*T-amod[j],4*T-amod[j],bmod);
        }

        if(cnt%2) res += pow(2,i);
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),b(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
    }
    for(int i = 0;i < n;i ++){
        cin >> b[i];
    }
    cout << solve(a,b,n) << endl;
    return 0;
}

Measured memory_bytes: 8408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.PriorityQueue;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Comparator;

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int[] a = new int[n];
            int cnt = 0;
            Map<Integer, Integer> num = new TreeMap<>(new Comparator<Integer>() {

                public int compare(Integer integer, Integer t1) {
                    if (t1.compareTo(integer) == 0) {
                        return 0;
                    } else if (t1.compareTo(integer) > 0) {
                        return -1;
                    } else {
                        return 1;
                    }
//                return t1.compareTo(integer);
                }
            });
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
                if (num.containsKey(a[i])) {
                    int tmp = num.get(a[i]) + 1;
                    num.put(a[i], tmp);
                } else {
                    num.put(a[i], 1);
                    cnt++;
                }
            }
            int ans = 0;
            PriorityQueue<Integer> pq = new PriorityQueue<>();
            for (Map.Entry<Integer, Integer> e : num.entrySet()) {
                pq.add(e.getValue());
            }
            while (pq.size() > k) {
                ans += pq.poll();
            }

            out.println(ans);

        }

    }
}



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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  int flag=0;
  for(int i=0; i<N; i++){
    cin >> p.at(i);
    if(p.at(i)!=i+1) flag++;
  }
  if(flag==0 || flag==2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
int x[50],y[50];
 
signed main(){
	int K,n;cin>>n>>K;
	vector<int>X,Y;
	rep(i,n){
		cin>>x[i]>>y[i];
		X.push_back(x[i]);
		Y.push_back(y[i]);
	}
	ll Min=LLONG_MAX;
	rep(i,X.size())rep(j,X.size()){
		rep(k,Y.size())rep(t,Y.size()){
			int cnt=0;
			rep(l,n){
				if(X[i]<=x[l]&&x[l]<=X[j]&&Y[k]<=y[l]&&y[l]<=Y[t])cnt++;
			}
			if(cnt>=K){
				Min=min(Min,(ll)(X[j]-X[i])*(ll)(Y[t]-Y[k]));
			}
		}
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    num_int = int(input())
    numbers = list(map(lambda x: int(x), input().split()))
    num_query = int(input())

    for _ in range(num_query):
        op, begin, end = map(lambda x: int(x), input().split())
        sub_numbers = numbers[begin: end]
        if (0 == op):
            min_num = min(sub_numbers)
            print(min_num)
        elif (1 == op):
            max_num = max(sub_numbers)
            print(max_num)



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

d = {'AC':0, 'TLE':0, 'WA':0, 'RE':0}
for i in range(n):
  s = input()
  d[s] += 1
  
print('AC x',d['AC'])
print('WA x',d['WA'])
print('TLE x',d['TLE'])
print('RE x',d['RE'])

Measured memory_bytes: 9196
import sys

x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()
else:
    p = list(map(int, input().split()))

a = []
b = []

for i in range(0, 102):
    if i not in p:
        a.append((x - i)**2)
        b.append(i)
ans = min(a)
bb = a.index(ans)
print(b[bb])


Measured memory_bytes: 61864
#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() {
    ll h,w;
    cin >> h >> w;
    if(h==1 || w==1){
        cout << 1 << endl;
        return 0;
    }
    if(h%2==0 && w%2==0){
        cout << (h*w)/2 << endl;
        return 0;
    }else{
        cout << (h*w+1)/2 << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char initial;
  string s;
  getline(cin, s);
  
  int i = 0;
 
  for(; i < s.size(); i++){
    if(s.at(i) == ' ')
       break;
  }
  
  cout << 'A' << s.at(i+1) << 'C' << endl;
  
  // ここにプログラムを追記
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi pair<ll,int> 
#define pii pair<int,ll>
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
/*ll maxvolume(ll s) 
{ 
    ll l= s / 3; 
    s -= l; 
  
    // finding breadth 
    ll b = s / 2; 
  
    // finding height 
    ll h = s - breadth; 
  
    return l * b * h; 
} */
int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    map<ll,ll> m;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    map<ll,ll>::iterator itr; 
    ll i=0,ans=0;
    for(itr=m.begin();itr!=m.end();itr++)
    {
        ans+=((itr->second)*(itr->second-1))/2;
    }
    for(ll i=0;i<n;i++)
    {
        ll ans1;
        ans1=ans;
        ans1-=((m[arr[i]])*(m[arr[i]]-1))/2;
        ans1+=((m[arr[i]]-1)*(m[arr[i]]-2))/2;
        cout<<ans1<<endl;
    }
    return(0);
}


Measured memory_bytes: 11792
#include <bits/stdc++.h>
using namespace std;
int main(){

int N, M, X, Y;
  cin >> N >> M >> X >> Y;
int xmax = -100;
int ymin = 99;  
  
  for(int i = 0;i < N;i++){
    int x;
  cin >> x;
    xmax = max(xmax, x);
  }
  
  for(int i = 0;i < M;i++){
    int y;
  cin >> y;
    ymin = min(ymin, y);
  }
  
  if((ymin > xmax) && (ymin > X) && (ymin <= Y)) cout << "No War" << endl;
  else cout << "War" << endl;
  
return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
struct node{
	int l, r, m, cnt; ll sum;
	node *lch, *rch;
	node(){}
	node(int L, int R):l(L), r(R){
		m=(l+r)>>1; cnt=sum=0;
		lch=rch=NULL;
	}
}pn[200010], *root;
int n, m, nT, cnt[100010];
inline int rd(){
	int a=0; char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) (a*=10)+=c-'0', c=getchar();
	return a;
}
void build(node *p){
	if(p->r-p->l==1) return;
	p->lch=&(pn[nT++]=node(p->l, p->m)); build(p->lch);
	p->rch=&(pn[nT++]=node(p->m, p->r)); build(p->rch);
}
void modify(node *p, int l, int r, int v){
	if(r<=p->l||p->r<=l) return;
	if(l<=p->l&&p->r<=r){
		p->cnt++; p->sum+=v;
		return;
	}
	modify(p->lch, l, r, v); modify(p->rch, l, r, v);
}
ll query(node *p, int k){
	ll ret=(ll)p->cnt*k-p->sum;
	if(p->r-p->l==1) return ret;
	return ret+query(k<p->m?p->lch:p->rch, k);
}
int query2(node *p, int k){
	if(p->r-p->l==1) return p->cnt;
	return p->cnt+query2(k<p->m?p->lch:p->rch, k);
}
int main(){
	n=rd(), m=rd(); ll tot=0;
	root=&(pn[nT++]=node(1, m+1)); build(root);
	int a=rd(), b;
	for(int i=1;i<n;i++){
		b=rd(); cnt[a]++;
		if(a<b) modify(root, a, b+1, a), tot+=b-a;
		else{
			modify(root, a, m+1, a);
			modify(root, 1, b+1, a-m);
			tot+=m-a+b;
		}
		a=b;
	}
	ll ma=0;
	for(int i=1;i<=m;i++)
		ma=max(ma, query(root, i)-query2(root, i)+cnt[i]);
	printf("%lld\n", tot-ma);
	return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
int N,M;
int res = 0;
set<int>Set;
void dfs(int now,vector<bool> &ok,vector<vector<int>> &vec) {
    for(int i = 0; i < vec[now].size(); i++) {
        if(ok[vec[now][i]] == false) {
            ok[vec[now][i]] = true;
            Set.insert(vec[now][i]);
            dfs(vec[now][i],ok,vec);
        }
    }
}
int main(){
    cin >> N >> M;
    vector<int>a(M);
    vector<int>b(M);
    for(int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    for(int i = 0; i < M; i++) {
        vector<vector<int>>vec(N,vector<int>(0,{}));
        for(int j = 0; j < M; j++) {
            if(i == j) {
                continue;
            }
            vec[a[j]].push_back(b[j]);
            vec[b[j]].push_back(a[j]);
        }
        vector<bool>ok(N,false);
        ok[0] = true;
        Set.clear();
        dfs(0,ok,vec);
        Set.insert(0);
        if(Set.size() == N) {
            res++;
        }
    }
    cout << M-res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s; cin >> s;
    int N = s.size();
    ll ans = 0, now = 0;
    rep(i, N) {
        if(s[i] == 'W') ans += now;
        else now++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string str[] = {"maerd", "remaerd", "esare", "resare"};
    string S;
    cin >> S;

    reverse(all(S));
    int index = 0;
    while (index != (int)S.size()) {
        bool flag;
        rep(j, 4) {
            flag = true;
            rep(k, str[j].size()) {
                if (S[index + k] != str[j][k]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                index += (int)str[j].size();
                break;
            }
        }
        if (!flag) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

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

int main(){
    int n,k;
    ll a;
    cin >> n >> k;
    vector<ll>V;
    for (int i=0;i<n;i++) {
        cin >> a;
        V.push_back(a);
    }
    for (int i=0;i<n-k;i++) {
        if (V[i+k]>V[i]) {cout << "Yes" << endl;}
        else {cout << "No" << endl;}
    }
}


Measured memory_bytes: 5388
import numpy as np

n, m = map(int, input().split())

h = list(map(int, input().split()))

good_peak = np.zeros(n, dtype = np.int)

for i in range(m):
  a, b = map(int, input().split())
  if h[a-1] > h[b-1]:
    good_peak[b-1] += 1
  elif h[a-1] < h[b-1]:
    good_peak[a-1] += 1
  else:
    good_peak[a-1] += 1
    good_peak[b-1] += 1

# print(good_peak)
print(np.count_nonzero(good_peak == 0))

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

int main()
{
  int ans=0;
  string s;
  
  cin >> s;
  
  if(s[0]=='1') ans++;
  if(s[1]=='1') ans++;
  if(s[2]=='1') ans++;
  
  cout << ans << endl;
}
  

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

using namespace std;

typedef pair<int,int> pii;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n, m;
    while(cin>>m, m){
        set<pii> p;
        for(int i=0; i<m; i++){
            pii t;
            cin >> t.first >> t.second;
            p.insert(t);
        }
        cin >> n;
        set<pii> q;
        for(int i=0; i<n; i++){
            pii t;
            cin >> t.first >> t.second;
            q.insert(t);
        }

        int ax=-1, ay=-1;
        for(auto const& e: q){
            int dx = e.first - p.begin()->first;
            int dy = e.second - p.begin()->second;
            bool ok = true;
            for(auto const& f: p){
                pii t(f.first + dx, f.second + dy);
                if(q.count(t)==0){
                    ok = false;
                    break;
                }
            }
            if(ok){
                ax = dx;
                ay = dy;
                break;
            }
        }

        cout << ax << " " << ay << endl;
    }
}

Measured memory_bytes: 1252
#include<cstdio>
#include<vector>
using namespace std;
int n,two[18],used[200000],a,b,cnt=0,bit[18];
vector<int> ans,jun,jun2;
bool dfs(int x,int y){
    int z;
    bool res=false;
    used[x]=1;
    ans.push_back(x);
    z=0;
    for(int i=0;i<n;i++){
        if(ans.size()+two[i]>=two[n]){
            z=n-i;
            break;
        }
    }
    for(int i=0;i<n;i++){
        if(z!=n&&ans.size()!=two[n]-1&&(x^two[i])!=y&&used[(x^two[i])]==0&&((y&two[jun[z]])^((x^two[i])&two[jun[z]]))){
            res= dfs((x^two[i]),y);
        }
        if(ans.size()==two[n]-1&&(x^two[i])==y){
            ans.push_back(y);
            return true;
        }
        if(res==true){
            return res;
        }
    }
    ans.pop_back();
    used[x]=0;
    return false;
}
int main(){
    scanf("%d %d %d",&n,&a,&b);
    two[0]=1;
    for(int i=1;i<=n;i++){
        two[i]=two[i-1]*2;
    }
    for(int i=0;i<n;i++){
        if(a&two[i]){
            cnt++;
        }
        if(b&two[i]){
            cnt++;
            bit[i]=1;
        }
        if((a&two[i])^(b&two[i])){
            jun.push_back(i);
        }
        else{
            jun2.push_back(i);
        }
    }
    if(cnt%2==0){
        printf("NO\n");
        return 0;
    }
    for(int i=0;i<jun2.size();i++){
        jun.push_back(jun2[i]);
    }
    if(dfs(a,b)){
        printf("YES\n");
        for(int i=0;i<ans.size();i++){
            printf("%d ",ans[i]);
        }
        printf("\n");
    }
    else{
        printf("NO\n");
    }
}

Measured memory_bytes: 10360
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)
const int MAX = INT_MAX;
using namespace std;
typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



int main() {

    int N = in();
    
    vector<int> A1;
    vector<int> A2;
    
    for(auto i = 0; i <N; i++){
        A1.push_back(in());
    }
    for(auto i = 0; i <N; i++){
        A2.push_back(in());
    }
    
    int sum;
    int ans = -1;
    for(auto j = 0; j<N; j++){
        sum = 0;
        
        for(auto k = 0; k<=j; k++){
            sum +=A1[k];
        }
        for(auto k = j; k<N; k++){
            sum +=A2[k];
        }
        
        if (ans < sum) ans = sum;
        
    }
    
    cout << ans << endl;
    
    return 0;
}




                          




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i=(a); i<(b); i++)

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  if (((g*10 + b) % 4) == 0) cout << "YES" << endl;
  else cout << "NO" << endl;

return 0;
}

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

type robot struct {
	x, y int
}

type robots []robot

func (p robots) Len() int {
	return len(p)
}

func (p robots) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p robots) Less(i, j int) bool {
	return p[i].x < p[j].x
}

// Priority Queue
// Item :
type Item struct {
	priority, x, index int
}

// PQ :
type PQ []*Item

func (pq PQ) Len() int {
	return len(pq)
}

func (pq PQ) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}

func (pq PQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

// Push :
func (pq *PQ) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

// Pop :
func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1
	*pq = old[0 : n-1]
	return item
}

// End Priority Queue
const mod = 998244353

type pair struct {
	first, second int
}

var to [][]int

func dfs(v int) int {
	res := 1
	for _, u := range to[v] {
		res *= dfs(u)
		res %= mod
	}
	return (res + 1) % mod
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	p := make(robots, N)
	for i := 0; i < N; i++ {
		x, d := getInt(), getInt()
		p[i] = robot{x, d}
	}
	sort.Sort(p)

	to = make([][]int, N)
	pq := make(PQ, 0)
	heap.Init(&pq)
	for i := N - 1; i >= 0; i-- {
		x := p[i].x
		d := p[i].y
		for pq.Len() > 0 {
			item := heap.Pop(&pq).(*Item)
			if item.priority < x+d {
				to[i] = append(to[i], item.x)
			} else {
				heap.Push(&pq, item)
				break
			}
		}
		heap.Push(&pq, &Item{x, i, 0})
	}

	ans := 1
	for pq.Len() > 0 {
		item := heap.Pop(&pq).(*Item)
		ans *= dfs(item.x)
		ans %= mod
	}
	out(ans)
}


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

bool chk(long long n, long long div) {
    if(div == 1) return false;
    while(n % div == 0) n /= div;
    return n % div == 1;
}

int main() {
    long long n, ans = 0;
    scanf("%lld", &n);
    for(long long i = 1; i * i <= (n - 1); i++) {
        if((n - 1) % i == 0) {
            ans += 2;
            if(i * i == (n - 1)) ans--;
        }
    }
    for(long long i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            if(chk(n, i)) ans++;
            if(i * i != n) chk(n, n / i);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int K;
	scanf("%d",&K);
	int cnt=0,i,j;
	for(i=1;i<=K;i+=2){
		for(j=2;j<=K;j+=2){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

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

typedef long long ll;
ll MOD = 1000000007;

int main()
{
    int N;
    ll now = 0;
    cin >> N;
    vector < pair<ll, ll> >  X(N);

    for (int i = 0; i < N; i++) {
        cin >> X[i].second >> X[i].first;
    }
    sort(X.begin(), X.end());
    /*
    for (int i = 0; i < N; i++) {
        cout << X[i].second << X[i].first << endl;
    }*/   
    for (int i = 0; i < N; i++) {
        now += X[i].second;
        if (now > X[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3328
#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; cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    vector<int> y(n);
    y = x; sort(y.begin(), y.end());
    int it1 = y[n/2 - 1], it2 = y[n/2];
    rep(i, n) {
        int ans;
        if(x[i]<=it1) ans = it2;
        else ans = it1;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3712
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d %d\n",&a,&b);
    int A[a][b];
    int B[b];
    int C[a];
    for(int i=0;i<a;i++){
        C[i]=0;
    }

    for(int i=0;i<a;i++){
        for(int f=0;f<b;f++){
            scanf("%d",&A[i][f]);
        }
    }
    for(int i=0;i<b;i++){
        scanf("%d",&B[i]);
    }

    for(int i=0;i<a;i++){
        for(int f=0;f<b;f++){
            C[i] += A[i][f]*B[f];
        }
    }

    for(int i=0;i<a;i++){
        printf("%d\n",C[i]);
    }
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
int n,idx;
int a[300009];
int s[300009];

bool judge(ll mid,ll k){
  while(idx>0&&a[idx-1]>mid)idx--;
  ll sum=s[idx]+mid*(n-idx);
  if(sum>=mid*k)return 1;
  else return 0;
}

int main(){
  cin>>n;
  rep(i,n){
    int x;
    cin>>x;
    a[x-1]++;
  }
  sort(a,a+n);
  for(int i=0;i<n;i++){
    s[i+1]=s[i]+a[i];
  }

  int ans=n;
  idx=n;
  for(int i=1;i<=n;i++){
    while(1){
      if(judge(ans,i))break;
      else ans--;
    }
    cout<<ans<<endl;
  }

  return(0);

}


Measured memory_bytes: 3200
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())
 
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
 
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
 
INF = float('inf')
 
def solve():
    S = list(map(int, list(input())))
 
    S = S[::-1]
    # print(S)
    n = len(S)
    mod = 2019
 
    #
    A = [0] * (n)
    a = 1
    for i in range(n):
        A[i] = S[i] * a
        a = a * 10 % mod
    # print(A)
 
    # 累積和
    R = [0] * (n+1)
    for j in range(n):
        R[j+1] = (R[j] + A[j]) % mod
    # print(R)
 
    # 個数を数える
    cnt = {}
    ans = 0
    for l in range(0, n+1):
        r = R[l]
        ans = ans + cnt.get(r, 0)
        cnt[r] = cnt.setdefault(r, 0) + 1
    print(ans)
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 91704
#include"bits/stdc++.h"
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF= 1e20;

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);

int main() {
	int a, b;
	cin >> a >> b;
	COUT(max({ a + b,a - b,a * b }));
	return 0;
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)  (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL moduloMultiplication(LL x, LL y) {
	return (x%mod * 1LL * y%mod) %

		mod;
}
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}
inline LL inv(LL a) { return power(a, mod - 2) % mod; }
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
}

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

	int mx = INT_MIN;
	map<string, int>M;
	rep(i, n) {
		string s;
		cin >> s;
		M[s]++;
		mx = max(mx, M[s]);
	}

	for (auto i : M) {
		if (i.second == mx) {
			cout << i.first << endl;
		}
	}

}







Measured memory_bytes: 23808
H, W = map(int,input().split())
A = [["#"] + [s for s in input()] + ["#"] for k in range(H)]
A = [["#"]*(W+2)] + A + [["#"]*(W+2)]


que = []
for k in range(1,H+1):
    for l in range(1,W+1):
        if A[k][l] == "#":
            que.append([k,l])
if len(que) == H*W:
    print(0)
    exit(0)
ans = 0
while True:
    t = []
    while len(que) > 0:
        s = que.pop()
        k, l = s[0], s[1]
        if A[k][l-1] == ".":
            A[k][l-1] = "#"
            t.append([k,l-1])
        if A[k][l+1] == ".":
            A[k][l+1] = "#"
            t.append([k,l+1])
        if A[k-1][l] == ".":
            A[k-1][l] = "#"
            t.append([k-1,l])
        if  A[k+1][l] == ".":
            A[k+1][l] = "#"
            t.append([k+1,l])
    if len(t) > 0:
        ans += 1
        que = t
    else:
        break
print(ans)


Measured memory_bytes: 180604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int N = 100000 + 5;
const int INF = 0x3f3f3f3f;
vector<int> a[N];
int vis[N],v[N];

int main()
{	
	ios::sync_with_stdio(false);
	cin.tie(0); 
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == '?')
			cout << 'D';
		else
			cout << s[i]; 
	}
	cout << endl;
	return 0;
} 

Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a,b,c,x,y,z;
  cin >> a >> b >> c >> z >> y >> x;
  if(a==x&&b==y&&c==z){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

count = 0
for i, p_i in enumerate(p):
  if i == 0 or i == n-1:
    continue
  if p[i-1] < p_i < p[i+1] or p[i-1] > p_i > p[i+1]:
    count += 1

print(count)

Measured memory_bytes: 3060
N = gets.to_i
a_list = gets.split.map(&:to_i)

sum = a_list.reduce(&:+)
x1 = sum
1.step(by: 2, to: N - 2) do |i|
  x1 -= a_list[i] * 2
end
ans = Array.new(N)
ans[0] = x1
(0...(N - 1)).each do |i|
  ans[i + 1] = a_list[i] * 2 - ans[i]
end
puts ans.join(' ')


Measured memory_bytes: 14212
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, stamina = 0;
    cin >> n;
    vector<int> coordinates(n);
    int sum = 0;
    for(int i =0; i < n; i++){
        cin >> coordinates[i];
        sum += coordinates[i];
    }
    double ans = sum / (double)n;
    double temp = (int) ans;
    int final;
    temp += 0.5;
    if(ans <= temp)
        final = (int) ans;
    else
        final = ceil(ans);    
    for(int i = 0; i < n; i++){
        stamina += pow(abs(coordinates[i] - final), 2);
    }    
    cout<<stamina<<endl;
    return 0;
}

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

int x[200001] = {};

signed main() {
	int N, T;
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	int num = 0, sum = 0;
	for (int i = 0; i < N; i++) {
		if (x[i] < num) {
			sum -= (num - x[i]);
			sum += T;
			num = x[i] + T;
		}
		else {
			num = x[i] + T;
			sum += T;
		}
	}
	cout << sum << endl;
	
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#define MAX 20000

typedef struct Data{
  int area,pos;
}Data;

void D_push();
Data D_pop();
void push(int );
int pop();
void init();

Data makeData(int x, int y){
  Data res;
  res.area = x;
  res.pos = y;
  return res;
}

Data t[MAX];
int u[MAX];
int n,i;
char str[MAX+1];
int ans,A,T,U;
Data B,X;

int main(){
  init();
  scanf("%s",str);
  n = strlen(str);
  for(i = 0;i<n;i++){
    if(str[i] == '/'){
      if( U == 0)continue;
      A = pop();
      X = makeData(i-A,A);
      ans = ans +i -A;
      while(T > 0){
	B = D_pop();
	if(B.pos <A){
	  D_push(B);
	  break;
	}
	X.area += B.area;
	if(B.pos<X.pos){
	  X.pos = B.pos;
	}
      }
	D_push(X);
      }
      else if(str[i] == '\\'){
	push(i);
      }
    }
    printf("%d\n%d",ans,T);
    
    for(i = 0; i<T; i++){
      printf(" %d",t[i].area);
    }
    printf("\n");
    return 0;
  }

void D_push(Data data){
  t[T++] = data;
}

Data D_pop(){
  return t[--T];
}

void push(int x){
  u[U++] = x;
}

int pop(){
  return u[--U];
}

void init(){
  ans = T = U = 0;
}



Measured memory_bytes: 2096
// C++ program to find the longest 
// path in the DAG 

#include <bits/stdc++.h> 
using namespace std; 

// Function to traverse the DAG 
// and apply Dynamic Programming 
// to find the longest path 
void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
	// Mark as visited 
	vis[node] = true; 

	// Traverse for all its children 
	for (int i = 0; i < adj[node].size(); i++) { 

		// If not visited 
		if (!vis[adj[node][i]]) 
			dfs(adj[node][i], adj, dp, vis); 

		// Store the max of the paths 
		dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
	} 
} 

// Function to add an edge 
void addEdge(vector<int> adj[], int u, int v) 
{ 
	adj[u].push_back(v); 
} 

// Function that returns the longest path 
int findLongestPath(vector<int> adj[], int n) 
{ 
	// Dp array 
	int dp[n + 1]; 
	memset(dp, 0, sizeof dp); 

	// Visited array to know if the node 
	// has been visited previously or not 
	bool vis[n + 1]; 
	memset(vis, false, sizeof vis); 

	// Call DFS for every unvisited vertex 
	for (int i = 1; i <= n; i++) { 
		if (!vis[i]) 
			dfs(i, adj, dp, vis); 
	} 

	int ans = 0; 

	// Traverse and find the maximum of all dp[i] 
	for (int i = 1; i <= n; i++) { 
		ans = max(ans, dp[i]); 
	} 
	return ans; 
} 

// Driver Code 
int main() 
{ 
	int n,m,a,b;
     cin>>n;
	 cin>>m;
	  
	vector<int> adj[n + 1]; 

	 for(int i=1;i<=m;i++)
	{  cin>>a;
	cin>>b;
	addEdge(adj, a, b); } 

	cout << findLongestPath(adj, n); 
	return 0; 
} 


Measured memory_bytes: 9600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int i,n,t;
    char s[4];
    while(gets(s))
    {
        t=0;
        n=strlen(s);
        for(i=0;i<n;i++)
        {
            if(s[i]=='+')
                t++;
            else
                t--;
        }
        printf("%d\n",t);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main(){
	fastIO
  int n,k;
  cin>>n>>k;
  int arr[n],ans=0;
  for(int i=0;i<n;i++){
  	cin>>arr[i];
  }
  sort(arr,arr+n);
  for(int i=0;i<k;i++){
  	ans+=arr[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    string s; cin>>s;
    regex bc_to_d("BC");
    s = regex_replace(s,bc_to_d,"d");
    ll ans = 0, x = 0;
    rep(i,(int)s.size()){
        if(s.at(i) == 'A') x++;
        else if(s.at(i) == 'd') ans+= x;
        else x = 0;
    }
    cout << ans << endl;
}


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

int main(){
  int N,D;
  int ans;
  cin >> N >> D;
  
  int n = 2*D + 1;
  if(N%n == 0){
    ans = N/n;
  }
  else{
    ans = N/n+1;
  }
  
  
  cout << ans << endl;
}

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

int memo[100006] = {0};
int n, ans;

int main() {
  int i, a, b;
  cin >> n;
  for(i = 0; i < n; ++i) {
    cin >> a >> b;
    ++memo[a];
    --memo[b + 1];
  }
  for(i = 1; i <= 100002; ++i) {
    memo[i] += memo[i - 1];
    if(i <= memo[i] + 1) ans = i - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3464
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2000 + 10;
const int mod = 1e9 + 7;

long long n, k, a[maxn];

long long ans = 0;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			if (a[i] == a[j])
				continue;
			else if (a[i] > a[j])
				ans = (ans + (k * (k + 1)) / 2) % mod;
			else
				ans = (ans + (k * (k - 1)) / 2) % mod;
	cout << ans << '\n';
	return 0;
}


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

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if (a > x) {
    cout << "NO" << endl;
  } else if (a + b >= x) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
ll a,b,c;
void input(){
    cin>>a>>b>>c;
}
void src(){
    cout<<b+min(c,a+b+1);
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
/* 17D8102015F 岩男悠生 */
/* 10/24 ALDS1_5_C*/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793
double radian = 60 * PI / 180.0;

void fk(double s[], double t[], int n, int i);
double dis(double x[], double y[]);

int main()
{
    int n,m,i,con;
    double p1[2] = {0,0};
    double p2[2] = {100,0};

    scanf("%d",&n);

    printf("%f %f\n",p1[0], p1[1]);
    if (n > 0) {
        fk(p1,p2,n-1,1);
    }
    printf("%f %f\n",p2[0], p2[1]);

    return 0;
}

void fk(double s[], double t[], int n, int i) {
    double a[2],b[2],c[2];

    a[0] = s[0] + (t[0]-s[0])/3;
    a[1] = s[1] + (t[1]-s[1])/3;
    c[0] = s[0] + ((t[0]-s[0])/3)*2;
    c[1] = s[1] + ((t[1]-s[1])/3)*2;
    b[0] = a[0] + dis(a,c)*cos(radian*i);
    b[1] = a[1] + dis(a,c)*sin(radian*i);

    if (n > 0) {
        fk(s, a, n-1,i);
    }
    printf("%f %f\n",a[0], a[1]);
    if (n > 0) {
        fk(a, b, n-1,i+1);
    }
    printf("%f %f\n",b[0], b[1]);
    if (n > 0) {
        fk(b, c, n-1,i-1);
    }
    printf("%f %f\n",c[0], c[1]);
    if (n > 0) {
        fk(c, t, n-1,i);
    }
}

double dis(double x[], double y[]) {
    return sqrt(pow(y[0]-x[0],2)+pow(y[1]-x[1],2));
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	int n;
	cin>>n;
	int a=100,b=105;
	bool ok=false;
	while(n>=a){
		if(a<=n && n<=b)ok=true;
		a+=100; b+=105;
	}
	cout<<ok<<endl;
	return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int result = 0;
    if (N >= 2) result += N * (N - 1) / 2;
    if (M >= 2) result += M * (M - 1) / 2;
    cout << result << endl;
    return 0;
}

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

int main()
{
	while (1)
	{
		char ch ;
		int num = 0 ;
		scanf ( "%c", &ch ) ;
		num = ch ;
		if ( 65 <= num && num <= 90 ) printf ( "%c" , num + 32 ) ;
		else if ( 97 <= num && num <= 122 ) printf ( "%c" , num - 32 ) ;
		else printf ( "%c" , ch ) ;
		if ( ch == '\n' ) break ;

	}
	return 0;
}



Measured memory_bytes: 2592
from collections import deque

def mapinput():
    return map(int,input().split())

n,m = mapinput()
rootlist = [[] for i in range(n)]
flag = [False for i in range(n)]

for i in range(m):
    a,b= mapinput()
    rootlist[a-1].append(b)
    rootlist[b-1].append(a)

que = deque()
que.append(1)
while len(que) !=0:
    now = que.popleft()
    for room in rootlist[now-1]:
        if flag[room-1] == False:
            flag[room-1] = now
            que.append(room)

print('Yes')
for root in flag[1:]:
    print(root)


Measured memory_bytes: 34684
#include <iostream>

using namespace std;

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

int main()
{
    int H, W;
    char grid[50][50];
    
    cin >> H >> W;
    REP(i, H) scanf("%s", grid[i]);
    
    bool done = false;
    REP(h, H) {
        REP(w, W) {
            if (grid[h][w] == '#') {
                bool enable = false;
                if (h != 0 && grid[h-1][w] == '#') enable = true;
                if (!enable && h != H-1 && grid[h+1][w] == '#') enable = true;
                if (!enable && w != 0 && grid[h][w-1] == '#') enable = true;
                if (!enable && w != W-1 && grid[h][w+1] == '#') enable = true;
                
                if (!enable) { done = true; break;}
            }
        }
        if (done) break;
    }
    if (!done) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


int main(){
  
  long long n, p;
  cin>>n>>p;
  
  vector<int> primes;
  REPP(i,1'000'000){
    if(prime_(i)){
      primes.push_back(i);
    }
  }
  
  int num_primes = primes.size();
  long long cnt[num_primes]={};
  long long flag = false;//pが1'000'000以上の素数で割り切れるか否か
  long long temp = p;
  long long d;
  REP(i, num_primes){
    if(temp==1)break;
    d = (long long)primes[i];
    while(temp%d==0){
      temp /= d;
      cnt[i]++;
    }
  }
  if(temp != 1){
    flag = true;
  }
  
  long long ans=1;
  long long power;
  REP(i, num_primes){
    if(cnt[i]==0)continue;
    power = cnt[i]/n;
    REP(j, power){
      ans *= (long long)primes[i];
    }
  }
  if(flag && n==1){
    ans *= temp;
  }
  
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
string str;
int main(){
    cin >> str;
    for(int i=0;i<str.size()+1;i++){
            if(str[i]-3<65)str[i]=str[i]+26;
    str[i]=str[i]-3;
    }
cout << str << endl;;
return 0;
}

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

typedef long long ll;

int main() {
    int N, K;
    string S, ans= "";
    cin >> N >> K;
    cin >> S;
    for (int i = 0; i < N; i++)
    {
        if (i + 1 == K){
            ans += (S[i] + 0x20);
        } else {
            ans += S[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 1000010
#define test(a,n) REP(i,n) cout << a[i] << " ";
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> s(m),c(m);
  REP(i,m) cin >> s[i] >> c[i];
  vector<int> ans(n+1,-1);
  
  REP(i,m){
    if(ans[s[i]] != -1 && ans[s[i]] != c[i]){
      cout << -1;
      return 0;
    }
    else{
      ans[s[i]] = c[i];
    }
  }
  
  int flag = false;
  FOR(i,1,n+1){
    if(ans[i] != -1 && ans[i] != 0) flag = true;
  }
  
  if(n == 1){
    if(ans[1] == -1) cout << 0;
    else cout << ans[1];
    return 0;
  }

  else if(ans[1] == 0){
    cout << -1;
    return 0;
  }

  FOR(i,1,n+1){
    if(i==1 && ans[1] == -1) cout << 1;
    //else if(ans[1] == -1) cout << 0;
    else if(ans[i] == -1) cout << 0;
    else cout << ans[i];
  }
  return 0;
}

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

using namespace std;

bool Check(deque<int>& deq)
{
  int cnt = deq.size();
  for(int i=deq.size()-1;i>=0;i--)
    {
      if(deq[i] != cnt)
	return false;
      cnt--;
    }
  return true;
}

bool Do(deque<int>& deq)
{

 for(int i=1;i<=10000;i++)
   {

     for(int iu=0;iu<deq.size();iu++)
       	 deq[iu]--;
      
     int next = deq.size();
     deq.erase(remove(deq.begin(),deq.end(),0),deq.end());     
     deq.push_back(next);


     if(Check(deq))
       {
	 cout << i << endl;
	 return true;
       }
   }
 return false;
}

int main()
{
  int N;
  while(cin >> N,N)
    {
      deque<int> deq;
      for(int i=0;i<N;i++)
	{
	  int in;
	  cin >> in;
	  deq.push_back(in);
	}

      if(Check(deq))
	{
	  cout << 0 << endl;
	  continue;
	}

      if(!Do(deq))
	cout << -1 << endl;  

    }
  return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;

int main(void){
    int N;
    cin >> N;
    long long A, B;
    cin >> A >> B;
    vector<int> c(3, 0);
    for(int i = 0; i < N; i++){
        int P;
        cin >> P;
        if(P <= A) c[0]++;
        else if(P <= B) c[1]++;
        else c[2]++;
    }
    cout << *min_element(c.begin(), c.end()) << endl;
    return 0;
}

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

#define N_MAX 100

int X; // 1~100
int N; // 0~100
int p[N_MAX]; //1~100

void input(){
    cin >> X >> N;
    for (int i=0;i<N;i++){
        cin >> p[i];
    }
}

void solve(){
    // pに含まれない整数のうち、最もXに近いものを答えよ。
    // 複数存在する場合は小さい方を答えよ。
    int ans = X;
    int deff = 100;
    for (int i=0;i<102;i++){
        for (int j=0;j<N;j++){
            if (p[j]==i) break;
            if (j==N-1) {
                if (deff>abs(X-i)){
                    deff = abs(X-i);
                    ans = i;
                }
            }
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3140