akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(){
    int AA,BB,X,A,B;
    string ans;
    cin >> X >> A >> B;
    AA = A-X;
    BB = B-X;
    if (A-X<=0){
        AA = (A-X)*-1;
    }
    if (B-X<=0){
        BB = (B-X)*-1;
    }
    if (AA<=BB){
        ans = "A";
    }else {
        ans = "B";
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,a,b,c;
    t = 1;
    while(t--) {
     cin >> a >> b >> c;
     if(a <= c && a + b >= c)
      cout << "YES" << endl;
     else
      cout << "NO" << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  if(k % 2 == 0) {
    cout << a - b << endl;
  }else {
    if(a == c) cout << b - a << endl;
    else cout << b - a << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

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

int main(){
	int n , m , p, b[23][23][23];
	int turn;
	string win;
	int d[13][3] ={{1,0,-1},{1,1,-1},{0,1,-1},{-1,1,-1},
		{1,0,0},{1,1,0},{0,1,0},{-1,1,0},
		{1,0,1},{1,1,1},{0,1,1},{-1,1,1},{0,0,1}};
	
	while(1){
		int x,y,z;
		cin >> n >> m >> p;
		if(!n)break;
		REP(i,23) REP(j,23) REP(k,23) b[i][j][k]=0;
		turn = 0;
		REP(i,p){
			cin >> x >> y;
			REP(j,n){
				if(b[x+7][y+7][j+7]==0){
					if(i%2==0) b[x+7][y+7][j+7] = 1;
					else b[x+7][y+7][j+7] = -1;
					break;
				}
			}
			/*
			for(int j=8;j<8+n;j++){
				for(int k=8;k<8+n;k++){
					for(int l=7;l<7+n;l++){
						cout << b[k][l][j] << " ";
					}
					cout << endl;
				}
				cout << endl;
			}
			*/
			int flag=0, ins;
			if(!turn){
				for(int j=8;j<8+n;j++){
					for(int k=8;k<8+n;k++){
						for(int l=7;l<7+n;l++){
							if(b[j][k][l]!=0){
								REP(s,13){
									ins = b[j][k][l];
									x = j;
									y = k;
									z = l;
									REP(q,m-1){
										x += d[s][0];
										y += d[s][1];
										z += d[s][2];
										ins += b[x][y][z];
									}
									if(abs(ins)==m){
										turn = i+1;
										if(i%2==0) win = "Black";
										else win = "White";
									}
								}
							}
						}
						//cout << endl;
					}
					//cout << endl;
				}
			}
		}
		if(!turn) cout << "Draw" << endl;
		else cout << win << " " << turn << endl;
	}
	return 0;
}

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

using namespace std;

// https://atcoder.jp/contests/abc075/tasks/abc075_b
// 200点

//問題文の通りに実装するだけ

int main()
{
    long long n;
    cin >> n;
    n = sqrt(n); //整数にキャストしないとうまくいかない
    n = pow(n, 2);
    cout << n << endl;
}


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
  i32 N = input(), M = input();
  string S = input<string>();

  i32 idx = N;
  vector<i32> ans;
  while (idx) {
    // i32 st = max(0, idx - M);
    i32 st = idx - M;
    i32 nxt = -1;
    range(i, 0, M) {
      if (i + st < 0 || S[i + st] == '1')
        continue;
      nxt = i;
      break;
    }

    if (nxt == -1) {
      cout << -1 << endl;
      return;
    }

    ans.push_back(M - nxt);
    idx = st + nxt;
  }

  whole(reverse, ans);
  cout << ans << endl;
}

signed main(int argc, char *argv[]) { solver(); }

Measured memory_bytes: 1096
#include "stdio.h"
#include "limits.h"

long long int dp[2][10000];
int zikan[10000];

int main()
{
  int n;
  scanf("%d",&n);
  for(int i = 0; i < n - 1; i++)
    {
      scanf("%d",&(zikan[i]));
    }
  for(int i = 0; i < n - 1; i++)
    {
      dp[0][i] = LLONG_MAX - 10000;
      dp[1][i] = LLONG_MAX - 10000;
    }
  dp[0][0] = 0;
  dp[1][0] = 0;
  for(int i = 0; i < n - 1; i++)
    {
      for(int ii = i; ii >= 0; ii--)
	{
	  dp[0][ii + 1] = dp[0][ii];
	  dp[0][ii] = LLONG_MAX - 10000;
	}
      for(int ii = 0; ii < i + 2; ii++)
	{
	  if(dp[1][ii] > dp[0][ii] + zikan[i])
	    {
	      dp[1][ii] = dp[0][ii] + zikan[i];
	    }
	  if(dp[0][ii] > dp[1][ii] + zikan[i])
	    {
	      dp[0][ii] = dp[1][ii] + zikan[i];
	    }
	}
    }
  printf("%lld\n",dp[1][n / 2]);
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define mp make_pair
#define print(con) for(auto it=con.begin() ; it!=con.end(); it++) \
						cout << *it <<" ";
using namespace std;

int main(){
	
	int n;
	cin >> n;
	int arr[n];
	int sum = 0;
	int req = 10000;
	for(int i=0 ; i<n;i++){
		cin >> arr[i];
		sum += arr[i];
	}
	
	for(int i=1;i<n-1;i++){
		int b = 0, a = 0;
		for(int j=0;j<=i;j++){
			b += arr[j];
		}
		a = sum - b;
		req = min(req , abs(a-b));
	//	cout <<a << " "<<  b << endl;
	}
	cout << req;
	return 0;
}

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

int main(){
    int N,X,Y;
    cin >> N >> X >> Y;
    // i -> j or i -> X -> Y -> j
    int ans[N];
    for(int i=0; i<N; i++){
        ans[i]=0;
    }

    X=X-1;
    Y=Y-1;

    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            long distance = min( j-i, abs(X-i)+1+abs(Y-j) );

            //cout << "i j distance " << i << " " << j << " " << distance << endl;
            ans[distance]++;
        }
    }

    for(int i=1; i<=N-1; i++){
        cout << ans[i] << endl;
    }


    return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S, T; cin >> S >> T;
  ll A, B; cin >> A >> B;
  string U; cin >> U;
  if (S == U) A--;
  else B--;
  cout << A << " " << B << endl;

  return 0;
}



Measured memory_bytes: 3580
dice = gets.split.map(&:to_i)
cross = []

gets.to_i.times do
	tate = [dice[1], dice[5], dice[4], dice[0]]
	yoko = [dice[1], dice[2], dice[4], dice[3]]

	q1, q2 = gets.split.map(&:to_i)
	
	if q1 == dice[5] or q1 == dice[0]
		tate.rotate!(tate.index(q1))
	else
		yoko.rotate!(yoko.index(q1))
	end
	
	# [cross] 北, 東, 南, 西
	cross = [tate[-1], yoko[1], tate[1], yoko[-1]]
	
	p cross[cross.index(q2)-1]
end


Measured memory_bytes: 6872
class UnionFind(object):

    def __init__(self, N):
        self.N = N
        self.parent = list(range(self.N))
        self.rank = [0] * self.N
        self.size = [1] * self.N

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            x, y = y, x

        self.size[x] += self.size[y]
        self.parent[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def count(self, x):
        return self.size[self.find(x)]

from collections import Counter
fn = lambda: map(int, input().split())
N, K, L = fn()
roads = UnionFind(N)
for i in range(K):
    pi, qi = fn()
    roads.union(pi-1, qi-1)
rails = UnionFind(N)
for i in range(L):
    ri, si = fn()
    rails.union(ri-1, si-1)
groups = []
for i in range(N):
    groups.append(str(roads.find(i)) + '-' + str(rails.find(i)))
c = Counter(groups)
print(*(c[g] for g in groups))

Measured memory_bytes: 56284
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;

using ll = long long;
using namespace std;

int find_palindrome(int n){
    int dist[6], i;
    i = 0;
    while (n>0){
        dist[i] = n%10;
        n /= 10;
        i++;
    }
    if (dist[0]==dist[4] && dist[1]==dist[3]) return 1;
    else return 0;
}

int main(){
int a, b;
cin >> a >> b;
int count=0;

for(int i=a; i<=b; i++) count += find_palindrome(i);

cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int a[200051],sum[200051];
int n;
struct Node
{
	int l,r,sum;
};
Node tree[1600401];
int push_up(int p)
{
	tree[p].sum=tree[p<<1].sum+tree[p<<1|1].sum;
}
void build(int p,int l,int r)
{
	if(l==r)
	{
		tree[p].sum=0;
		tree[p].l=l;
		tree[p].r=r;
		return;
	}
	tree[p].l=l;
	tree[p].r=r;
	int mid=(l+r)>>1;
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	push_up(p);
}
int update(int p,int pos)
{
	if(pos==tree[p].l&&pos==tree[p].r)
	{
		tree[p].sum++;
		return 0;
	}
	int mid=(tree[p].l+tree[p].r)>>1;
	if(pos<=mid) update(p<<1,pos);
	else update(p<<1|1,pos);
	push_up(p);
}
int query(int p,int l,int r)
{
	if(l>r) return 0;
	if(l<=tree[p].l&&tree[p].r<=r) return tree[p].sum;
	int mid=(tree[p].l+tree[p].r)>>1;
	if(r<=mid) return query(p<<1,l,r);
	else
	{
		if(l>mid) return query(p<<1|1,l,r);
		else return query(p<<1,l,mid)+query(p<<1|1,mid+1,r);
	}
}
int check(int x)
{
	long long ans=0;
	memset(sum,0,sizeof(sum));
	for(int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+(a[i]<=x?1:-1);
	}
	for(int i=0;i<=n;i++)
	sum[i]+=n+1;
	build(1,1,200051);
	for(int i=0;i<=n;i++)
	{
		ans+=query(1,1,sum[i]-1);
		update(1,sum[i]);
	}
	return ans>=1ll*n*(n+1)/4+1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int l=1,r=1e9,mid;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
		if(r-l<=1)
		{
			mid=check(l)?l:r; break;
		}
	}
	printf("%d\n",mid);
	return 0;
}

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

int n,count=0;
int input[10];
bool res;

bool dfs(int x,int ltop,int rtop){
//  cout<<x<<","<<ltop<<","<<rtop<<endl;
    if(x==10) return true;
    if(ltop<input[x]){
        if(dfs(x+1,input[x],rtop)) return true;}
    if(rtop<input[x]){
        if(dfs(x+1,ltop,input[x])) return true;}

    return false;
}

int main(){ 
    cin>>n; 
    while(count<n){
        res=false;
        for(int i=0;i<10;i++){
            cin>>input[i];
        }       
        if(dfs(0,0,0)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        count++;
    }
    return 0;
}       

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <set>
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	string s; cin >> s;
	int K; cin >> K;
	set<string> substring;

	rep(i, 1, K + 1) {
		rep(j, 0, s.length()) {
			string tmp = s.substr(j, i);
			substring.insert(tmp);
		}
	}
	set<string>::iterator it = substring.begin();
	rep(i, 1, K)it++;
	cout << *it << endl;

	return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

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

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N*A,B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb push_back

using namespace std;

int main() {
	//freopen("0158.inp", "r", stdin);
	int n = 1;
	while (n != 0) {
		cin >> n;
		if (!n) break;
		int count = 0;
		while (n != 1) {
			if (n % 2 == 0) n /= 2;
			else n = 3 * n + 1;
			count++;
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _dbg(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_dbg(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int N=55;
int a[N],w[N];pii f[N];
void no(){cout<<"-1\n";exit(0);}
int32_t main(){
    int n,k;
    cin>>n>>k;
    if(n==1){
        cout<<"1\n1\n";
        return 0;
    }
    int s=0;
    memset(w,-1,sizeof w);
    forn(i,n){
        cin>>a[i];
        f[i].f=max(0ll,k+1-a[i]);
        f[i].s=i;
        s+=f[i].f;
        if(f[i].f>(k+1)/2)no();
    }
    if(s>k)no();
    sort(f,f+n,std::greater<pii>());
    int pos=1;
    forn(v,n){
        int i=f[v].s;
        while(f[v].f--){
            w[pos]=i;
            pos+=2;
            if(pos>k)pos=2;
        }
    }
    for(int j=1;j<=k;++j){
        if(w[j]==-1){
            forn(x,n){
                if(w[j-1]!=x&&w[j+1]!=x){
                    w[j]=x;
                    break;
                }
            }
        }
    }
    cout<<n+k*(n-1)<<'\n';
    forn(i,k+1){
        if(w[i]!=-1)cout<<w[i]+1<<' ';
        forn(j,n)if(j!=w[i]&&j!=w[i+1])cout<<j+1<<' ';
    }
    cout<<'\n';



    return 0;
}


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

signed main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1')cout<<9;
		else cout<<1;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 11 15:18:17 2018
ABC081C
@author: maezawa
"""
import collections as col
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

kinds = col.Counter(a)
commonk = kinds.most_common(k)

ans = n - sum([elem[1] for elem in commonk])
print(ans)


Measured memory_bytes: 32564
#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;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n, m;
    ll k;
    cin >> n >> m >> k;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    ll b[m];
    rep(i, m) {
        cin >> b[i];
    }
    vector<ll> sum(m + 1, 0);
    rep(i, m) {
        sum[i + 1] += sum[i] + b[i];
    }
    ll now = 0;
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        if(k - now >= 0){
            auto itr = upper_bound(ALL(sum), k - now);
            itr--;
            ans = max(ans, (int)(itr - sum.begin()) + i);
        }
        now += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

const string YES = "YES";
const string NO = "NO";


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    vector<string> inp(2);
    for(long long i = 0; i < 2; i++){
      cin >> inp[i];
    }

    for(long long i = 0; i < 2; i++) {
      for(long long j = 0; j < 3; j++) {
        if(inp[i][j] != inp[1-i][2-j]) goto err;
      }
    }

    cout << YES << endl;
    return 0;
    err:

    cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  ll N, K; cin >> N >> K;
  vector<ll> a(N); rep(i, N) cin >> a[i];

  vector<ll> s(N + 1, 0);
  rep(i, N){
    s[i + 1] = s[i] + a[i];
    s[i + 1] %= K;
  }

  map<ll, ll> mp;
  ll ans = 0;
  queue<ll> que;
  rep(r, N + 1){
    ll x = (s[r] - r) % K;
    if (x < 0) x += K;
    ans += mp[x];
    mp[x]++;

    que.push(x);
    if (que.size() >= K){
      mp[que.front()]--;
      que.pop();
    }
  }
  cout << ans << endl;
}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	int N;
  cin >> N;
  if(N >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 3620
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[] mm = new int[m];
        for (int i = 0; i < n; i++) {
            int kk = sc.nextInt();
            for (int j = 0; j < kk; j++) {
                mm[sc.nextInt() - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (mm[i] == n)
                ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 38468
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
    ll A,B;
    cin >> A >> B;
    cout << (A*B/__gcd(A,B)) << endl;
}

Measured memory_bytes: 3632
N = int(input())
h = list(map(int, input().split()))
dp = [0]*N
ans = int(0)
dp[1] = abs(h[1]-h[0])


for i in range(2,N):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),dp[i-2] + abs(h[i]-h[i-2]))

ans = dp[N-1]

print(ans)

Measured memory_bytes: 13928
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int N, a[109];
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a, a + N, greater<int>());
	int ret = 0;
	for (int i = 0; i < N; i++) ret += a[i] * (i & 1 ? -1 : 1);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 768
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

a, b, c = map(int, input().split())
k = int(input())

for _ in range(k):
    if a >= b:
        b = b * 2
    else:
        c  = c * 2

if a < b and b < c:
    print('Yes')
else:
    print('No')

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

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

	ll res = 0;
	if(n>1) rep(i,n-1) res += (ll)i+1;
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;

bool not31(ll x){
    if(x == 4 || x == 6 || x == 9 || x == 11){
        return true;
    }else{
        return false;
    }
}

int main(){
    ll x, y;
    cin >> x >> y;

    ll ifSame;
    if(x == 2 || y == 2){
        ifSame = 0;
    }else if(not31(x) && not31(y)){
        ifSame = 1;
    }else if(!not31(x) && !not31(y)){
        ifSame = 1;
    }else{
        ifSame = 0;
    }

    if(ifSame == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
        

    return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);

    int c = 0;
    for (int i = 1; i <= n; i+=2) {
        int y = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) { 
                y++;
            }
        }
        if (y== 8) {
            c++;
        }
    }

    printf("%d\n", c);
}



Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  bitset<30> v;
  rep(i, 30) if(k >> i & 1) v.set(i, 1);
  vl b(n);
  vector<bitset<30>> bs(n);
  rep(i, n) {
    ll a;
    cin >> a >> b[i];
    rep(j, 30) if(a >> j & 1) bs[i].set(j, 1);
  }
  ll ans = 0;
  for(ll x = 29; x >= 0; x--) {
    if(!v.test(x) && x > 0) continue;
    ll now = 0;
    rep(i, n) {
      bool ok = true;
      for(ll j = 29; j >= x; j--)
        if(!v.test(j) && bs[i].test(j)) ok = false;
      if(bs[i].test(x) && x > 0) ok = false;
      if(ok) now += b[i];
    }
    ans = max(ans, now);
    // cout << x << ' ' << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4716
n,m=map(int, input().split())
li=[]
for i in range(n):
    a,b=map(int,input().split())
    li.append((a,b))
li.sort()
pp=0
cj=0
while m>0:
    cj+= min(li[pp][1],m)*li[pp][0]
    m-=min(li[pp][1],m)
    pp+=1
print(cj)

Measured memory_bytes: 54104
n, x, m = map(int, input().split())
# init = x
# 二乗してあまりが x となる個数
amari = [0] * (m + 1)
for i in range(m + 1):
    y = pow(i, 2, m)
    amari[y] += 1 

visited = [0] * (m + 1)
now = x
loop = 1
while True:
    y = pow(now, 2, m)
    if visited[y] == 1:
        last = y
        break
    visited[y] += 1
    now = pow(now, 2, m)
    loop += 1

# print(visited)
# print(loop)
# print(last, 'last')

res = x

# 循環する手前まで
cnt_init = 1
now = x
while True:
    y = pow(now, 2, m)
    # print(y)
    if y == last:
        break
    res += pow(now, 2, m)
    now = pow(now, 2, m)
    cnt_init += 1

# print(loop)
loop = loop - cnt_init
# print(cnt_init)
# print(loop)

# 循環
cnt = (n - cnt_init) // loop
tmp = last # 最初足し込む
now = last
while True:
    y = pow(now, 2, m)
    if y == last:
        break
    tmp += pow(now, 2, m)
    # print('y', y)
    now = pow(now, 2, m)

res += tmp * cnt

# 残り
nokori = (n - cnt_init) % loop

if nokori == 0:
    print(res)
    exit()

now = last
res += last
for _ in range(nokori-1):
    res += pow(now, 2, m)
    now = pow(now, 2, m)

print(res)

Measured memory_bytes: 69236
#include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #define LL long long
    using namespace std;
    const LL p=924844033,yg=5;
    LL n;
    struct node{
    	LL y,next;
    }a[400010];LL len=0,last[200010];
    LL f[200010],inv[200010],A[800010],B[800010],bin[800010];
    void ins(LL x,LL y)
    {
    	a[++len].y=y;
    	a[len].next=last[x];last[x]=len;
    }
    void pre()
    {
        f[0]=f[1]=inv[0]=inv[1]=1;
        for(LL i=2;i<=200000;i++) f[i]=f[i-1]*i%p,inv[i]=(p-p/i)*inv[p%i]%p;
        for(LL i=2;i<=200000;i++) inv[i]=inv[i-1]*inv[i]%p;
    }
    LL pow(LL a,LL b)
    {
    	LL ans=1;
    	while(b)
    	{
    		if(b&1) ans=ans*a%p;
    		a=a*a%p;b>>=1;
    	}
    	return ans;
    }
    LL size[200010];
    void ntt(LL *a,LL n,LL op)
    {
        for(LL i=0;i<n;i++) bin[i]=(bin[i>>1]>>1)|((i&1)*(n>>1));
        for(LL i=0;i<n;i++) if(i<bin[i]) swap(a[i],a[bin[i]]);
        for(LL i=1;i<n;i<<=1)
        {
            LL wn=pow(yg,op==1?(p-1)/(2*i):(p-1)-(p-1)/(2*i)),w,t;
            for(LL j=0;j<n;j+=i<<1)
            {
                w=1;
                for(LL k=0;k<i;k++)
                {
                    t=a[i+j+k]*w%p;w=w*wn%p;
                    a[i+j+k]=(a[j+k]-t+p)%p;a[j+k]=(a[j+k]+t)%p;
                }
            }
        }
        if(op==-1)
        {
            LL Inv=pow(n,p-2);
            for(LL i=0;i<n;i++) a[i]=a[i]*Inv%p;
        }
    }
    void dfs(LL x,LL fa)
    {
    	size[x]=1;A[n]++;
    	for(LL i=last[x];i;i=a[i].next)
    	{
    		LL y=a[i].y;
    		if(y==fa) continue;
    		dfs(y,x);size[x]+=size[y];
    		A[size[y]]--;
    	}
    	if(n-size[x]) A[n-size[x]]--;
    }
    //LL C(LL m,LL n) {return f[m]*inv[m-n]%p*inv[n]%p;}
    int main()
    {
    	scanf("%lld",&n);
    	for(LL i=1;i<n;i++)
    	{
    		LL x,y;scanf("%lld %lld",&x,&y);
    		ins(x,y);ins(y,x);
    	}
    	pre();dfs(1,0);
    	for(LL i=0;i<=n;i++) B[i]=inv[i],A[i]+=A[i]<0?p:0,A[i]=A[i]*f[i]%p;
    	reverse(B,B+n+1);
    	LL N=1;while(N<(n+1)<<1) N<<=1;
    	ntt(A,N,1);ntt(B,N,1);
    	for(LL i=0;i<N;i++) A[i]=A[i]*B[i]%p;
    	ntt(A,N,-1);
    	for(LL i=1;i<=n;i++) printf("%lld\n",inv[i]*A[n+i]%p);
    }

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

const int N = 100233, mod = 1000000007;
int n, m, p, x[N], y[N], uni[N];
pair<int, int> q[N];
int tr[N];
void add(int x, int y) {
  for (; x <= m; x += x & -x) {
    tr[x] = (tr[x] + y) % mod;
  }
}
int ask(int x) {
  int r = 1;
  for (; x; x -= x & -x) {
    r = (r + tr[x]) % mod;
  }
  return r;
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &y[i]);
  }
  sort(x + 1, x + 1 + n);
  sort(y + 1, y + 1 + m);
  for (int i = 1; i <= n; i++) {
    int t = (int) (upper_bound(y + 1, y + 1 + m, x[i]) - y);
    if (t == 1 || t == m + 1) continue;
    ++p;
    q[p].first = x[i] - y[t - 1];
    q[p].second = uni[p] = y[t] - x[i];
  }
  sort(uni + 1, uni + 1 + p);
  m = (int) (unique(uni + 1, uni + 1 + p) - uni - 1);
  sort(q + 1, q + 1 + p, [&](pair<int, int> &a, pair<int, int> &b){return a.first == b.first ? a.second > b.second : a.first < b.first;});
  n = (int) (unique(q + 1, q + 1 + p) - q - 1);
  for (int i = 1; i <= n; i++) {
    int t = (int) (lower_bound(uni + 1, uni + 1 + m, q[i].second) - uni);
    add(t, ask(t - 1));
  }
  printf("%d\n", ask(m));
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}



int fac[2110000];

int inv(int x){
  if(x==1) return 1;
  return (M-M/x)*inv(M%x)%M;
}


int comb(int n,int k){
  int x=(fac[k]*fac[n-k])%M;
  return (fac[n]*inv(x))%M;
}

int fac_init(int n){
  fac[0]=1;
  FOR(i,1,n+1){
    fac[i]=fac[i-1]*i;
    fac[i]%=M;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int x,y;
  cin>>x>>y;

  if((x+y)%3){
    cout<<0<<endl;
    return 0;
  }
  fac_init(2100000);

  int m=(x+y)/3;
  int ans=0;
  rep(i,m+1){
    int j=m-i;
    if(i*2+j==x&&i+j*2==y){
      ans+=comb(m,i);
      ans%=M;
    }
  }

  cout<<ans<<endl;



}

Measured memory_bytes: 16768
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int N;
    cin>>N;
    vector<int> B(N);

    for(int i=0; i<N-1; i++){
        cin >> B[i];
    }

    int answer=0;
    answer+=B[0];
    answer+=B[N-2];

    int last=B[0];
    for(int i=1; i<N-1; i++){
        answer+=min(B[i], B[i-1]);
    }

    cout<<answer<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
double area_3point(double x1,double y1,double x2,double y2,double x3,double y3);
int main(){
        while(1){               
                double x1,y1,x2,y2,x3,y3,xp,yp;
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp;
                if(cin.eof()) break;
		double s,s1,s2,s3;  
                s=area_3point(x1,y1,x2,y2,x3,y3);
 		s1= area_3point(x1,y1,x2,y2,xp,yp);
		s2=area_3point(x1,y1,xp,yp,x3,y3);               
  		s3=area_3point(xp,yp,x2,y2,x3,y3);  
                if(s<(s1+s2+s3-0.0000001)){ 
                       cout<<"NO"<<endl;
                }else {     
                        cout<<"YES"<<endl; }        
        }
        return 0;
}

double area_3point(double x1,double y1,double x2,double y2,double x3,double y3){
     double s,a,b,c,area;
     a = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
     b = sqrt((x2-x3)*(x2-x3) + (y2-y3)*(y2-y3));
     c = sqrt((x3-x1)*(x3-x1) + (y3-y1)*(y3-y1));
     s=(a+b+c)/2.0;
     area=sqrt(s*(s-a)*(s-b)*(s-c));

     return area;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> vec(n);
  
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  int prev, count = 0;
  
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      prev = vec.at(i);
    } else {
      prev = vec.at(prev - 1);
    }
    if (prev == 2) {
      count = i + 1;
      break;
    }
  }
  
  if (prev == 2) {
    cout << count << endl;
  } else {
    cout << -1 << endl;
    return 0;
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

void sort2vectors(vector<int> &av, vector<int> &bv){
   int n = av.size();
   vector<int> p(n), av2(n), bv2(n);
   iota(p.begin(), p.end(), 0);
   sort(p.begin(), p.end(), [&](int a, int b) { return av[a] < av[b]; });
   for (int i = 0; i < n; i++) {
       av2[i] = av[p[i]];
       bv2[i] = bv[p[i]];
   }
   av = av2;
   bv = bv2;
}

int main(){
    int n,d,a;
    cin >> n >> d >> a;
    vector<int> x(n),h(n),acc(n);
    rep(i,0,n-1)cin >> x[i] >> h[i];
    sort2vectors(x,h);
    // vector<vector<int>> to(n);
    ll ans = 0LL;

    queue<P> q;
    ll total = 0;
 
    rep(i,0,n-1){
        while(sz(q) && (ll)q.front().first+2*d < x[i]){
            total -= (ll)q.front().second * a;
            q.pop();
        }
        h[i] -= total;
        if(h[i] <= 0)continue;
        int count = (h[i]+a-1)/a;
        ans += (ll)count;
        total += (ll)count * a;
        q.push(P(x[i],count));
    }
 
    cout << ans << endl;
//  printf("%.10f\n",ans);
 
    return 0;
}


Measured memory_bytes: 4992
while true
    a, b = gets.split.map(&:to_i)
    if a == 0 and b == 0
        break
    end

    for i in 1..a
        if i == 1 or i == a
            puts "#" * b
        else
            puts "#" + ("." * (b-2)) + "#"
        end
    end
    puts ""
end


Measured memory_bytes: 6944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF (ll)1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};

class CompareDist
{
public:
	bool operator()(pair<int, int> n1, pair<int, int> n2) {
		return (n1.fs != n2.fs ? n1.fs < n2.fs : n1.sc < n2.sc);
	}
};

int main() {
	int n;
	ll ans=0;
	cin >> n;
	vi v(n);
	rep(i, n) {
		cin >> v[i];
	}
	rep(i, n) {
		ans += v[i] / 2;
		if (i != n - 1 && v[i] % 2 == 1 && v[i+1]) {
			ans += 1;
			v[i + 1]--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int i, j, k, x, y, z, a, b;
    String str;
    char[] ch;

    a = 0; b = 0;
    for(;sc.hasNext();){
      str = sc.next();
      ch = new char[str.length()];
      for(j = 0;j < str.length();j++)ch[j] = str.charAt(j);
      x = 0; y = 0; z = 0; k = 0;

      for(j = 0;j < str.length();j++){
        if(ch[j] == ','){
          x = readint(ch, 0, j);
          k = ++j; break;
        }
      }
      for(;j < str.length();j++){
        if(ch[j] == ','){
          y = readint(ch, k, j);
          j++; break;
        }
      }
      z = readint(ch, j, str.length());

      if(x * x + y * y == z * z)a++;
      if(x == y)b++;
    }
    out.println(a);
    out.println(b);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int readint(char[] ch, int l, int r){
    int i, d, res;
    d = 1; res = 0;
    for(i = r - 1;i >= l;i--){
      res += d * (int)(ch[i] - '0');
      d *= 10;
    }
    return res;
  }
}

Measured memory_bytes: 17132
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, C;
    std::cin >> N >> C;

    struct Prog {
        int64_t s;
        int64_t t;
        int64_t c;
    };

    struct RecStat {
        int64_t c;
        int64_t t;
    };

    std::vector<RecStat> recs;

    std::vector<Prog> P;
    for (decltype(N) i = 0; i < N; ++i) {
        Prog t;
        std::cin >> t.s >> t.t >> t.c;
        P.push_back(t);
    }

    std::sort(std::begin(P), std::end(P),
              [](const auto& a, const auto& b) {
                  return a.s < b.s;
              });

    for (auto p: P) {
        // おなじチャンネル（なら空いているはず）
        auto pos = std::find_if(std::begin(recs), std::end(recs), [&p](auto& r) {
                if (r.c == p.c) {
                    return true;
                }
                return false;
            });

        if (pos != std::end(recs)) {
            pos->t = p.t;
            continue;
        }

        // 違うチャンネルのチューナ空き
        pos = std::find_if(std::begin(recs), std::end(recs), [&p](auto& r) {
                if (r.t + 1 <= p.s) {
                    return true;
                }
                return false;
            });
        if (pos != std::end(recs)) {
            pos->c = p.c;
            pos->t = p.t;
        }

        else {
            recs.push_back({p.c, p.t});
        }
    }

    std::cout << recs.size() << std::endl;

    return 0;
}


Measured memory_bytes: 4980
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

ll LCM(ll a,ll b){
    ll A=a;
    ll B=b;
    while(a%b!=0){
        ll t=a%b;
        a=b;
        b=t;
    }
    return A*(B/b);
}

ll GCD(ll a,ll b){
    while(a%b!=0){
        ll t=a%b;
        a=b;
        b=t;
    }
    return b;
}

signed main(){
    ll a,b;
    cin>>a>>b;
    cout<<GCD(a,b)<<endl;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main()
{
	int N, X;
	cin >> N >> X;

	vector<int> m(N);
	int i, min_ = inf, all = 0;
	rep(i, N) {
		cin >> m[i];
		all += m[i];
		min_ = min(min_, m[i]);
	}

	cout << N + ((X - all) / min_) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const int MOD2 = 1e9 + 9;
const int INF = 5e18;
 
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = result*a;
 
        b >>= 1;
        a = a*a;
    }
    return result;
}

void solve(){
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
}
signed main(){
    fastio; 
    // int x=0;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

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

using namespace std;

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if (a == 0) {
    cout << 1 << endl;
  }
  else if (b == 0) {
    cout << 2 << endl;
  }
  else if (c == 0) {
    cout << 3 << endl;
  }
  else if (d == 0) {
    cout << 4 << endl;
  }
  else {
    cout << 5 << endl;
  }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
ll mx(ll a,ll b){if(a>=b) return a;return b;}
ll mn(ll a,ll b){if(a<b) return a;return b;}
#define pb push_back
#define mp make_pair
#define M (1e9+7)
#define INF (3e18)
int main(){
	ll a;string s;
  cin>>a>>s;
  if(a>=3200)
    cout<<s<<endl;
  else
    cout<<"red"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int prime(long long int n)
{
    int i;
    for(i=2; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            return 0;
            break;
        }
    }
    return 1;
}
int main()
{
    long long int a,b,k,i;

    cin>>a;
    for(i=a;; i++)
    {
        if(prime(i)==1)
        {
            cout<<i<<endl;
            break;
        }

    }



}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;



public class Main {
    static Scanner s = new Scanner(System.in);
    static int num;
    static int[][] map = new int[200][200];
    static Deque<Integer> queue = new ArrayDeque<Integer>();


    static void move(int x, int y, int turn) {
        if (map[x][y] == -2) return;
        if (map[x][y] == -1) {
            num++;
            map[x][y] = -2;
        }
        if (turn == 0) return;
        queue.offer((turn - 1) * 1000000 + (x + 1) * 1000 + (y + 1));
        queue.offer((turn - 1) * 1000000 + (x + 1) * 1000 + (y));
        queue.offer((turn - 1) * 1000000 + (x) * 1000 + (y + 1));
        queue.offer((turn - 1) * 1000000 + (x) * 1000 + (y - 1));
        queue.offer((turn - 1) * 1000000 + (x - 1) * 1000 + (y));
        queue.offer((turn - 1) * 1000000 + (x - 1) * 1000 + (y - 1));
    }

    public static void main(String[] args) {
        int turn, object;
        int x, y,xx,yy,tt,p;
        int i,j;

        while (true) {
            turn = s.nextInt();
            object = s.nextInt();

            if (turn == 0 && object == 0) break;

            for (i = 0; i < 200; i++) {
                for (j = 0; j < 200; j++)
                    map[i][j] = -1;
            }
            num = 0;

            for (i = 0; i < object; i++) {
                x = s.nextInt() + 100;
                y = s.nextInt() + 100;

                map[x][y] = -2;
            }

            x = s.nextInt() + 100;
            y = s.nextInt() + 100;

            queue.offer(turn * 1000000 + x * 1000 + y);

            while (!queue.isEmpty()) {
                p = queue.poll();
                tt = p / 1000000;
                xx = (p / 1000) % 1000;
                yy = p % 1000;

                move(xx, yy, tt);
            }
            System.out.println(num);
        }
    }
}

Measured memory_bytes: 60860
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define N 50
#define EPS 1e-9

using namespace std;

int Q[N][4];
vector<vector<int>> S;
vector<int> s;
int m, n;

void backtrack(int k) {
	if (s.size() == n) {
		S.push_back(s);
		return;
	}

	for (int i = k; i <= m; ++i) {
		s.push_back(i);
		backtrack(i);
		s.pop_back();
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int q;
	long long ans, best;

	cin >> n >> m >> q;
	
	backtrack(1);

	// cout << S.size() << '\n';

	for (int i = 0; i < q; ++i) {
		cin>>Q[i][0]>>Q[i][1]>>Q[i][2]>>Q[i][3];
	}

	ans = 0;
	for (int i = 0; i < S.size(); ++i) {
//		for (int k = 0; k < S[i].size(); ++k)
//			cout << S[i][k] << ' ';
//		cout << '\n';
		best = 0;
		for (int j = 0; j < q; ++j) {
			if (S[i][Q[j][1] - 1] - S[i][Q[j][0] - 1] == Q[j][2])
				best += Q[j][3];
		}
		ans = max(ans, best);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 9744