akhauriyash/Code-Regression huggingface dataset:
n,m=list(map(int,input().split()))
hs=list(map(int,input().split()))

check=[0]*n
for _ in range(m):
    a,b=list(map(int,input().split()))
    if hs[a-1]>hs[b-1]:
        check[b-1]+=1
    elif hs[a-1]<hs[b-1]:
        check[a-1]+=1
    elif hs[a-1]==hs[b-1]:
        check[a-1]+=1
        check[b-1]+=1
print(check.count(0))



Measured memory_bytes: 20112
#include <cstdio>

constexpr long long mod = 1000000007;

int main()
{
  long long n, m;
  scanf("%lld%lld", &n, &m);
  long long x[100000];
  long long y[100000];
  for (long long i = 0; i < n; ++i)
  {
    scanf("%lld", x + i);
  }
  for (long long i = 0; i < m; ++i)
  {
    scanf("%lld", y + i);
  }
  long long tape = 0;
  for (long long i = 0; i < n - 1; ++i)
  {
    (tape += ((i + 1) * (n - (i + 1)) % mod) * (x[i + 1] - x[i]) % mod) %= mod;
  }
  long long ans = 0;
  for (long long i = 0; i < m - 1; ++i)
  {
    (ans += ((i + 1) * (m - (i + 1)) % mod) * (y[i + 1] - y[i]) % mod * tape % mod) %= mod;
  }
  printf("%lld\n", ans);
  return 0;
}

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

int main() {
	int s; cin >> s;
	map<int, int> mp;

	for (int i = 1;; i++) {
		if (mp.count(s) > 0) {
			cout << i << endl;
			return 0;
		}
		mp[s]++;

		if (s % 2 == 0) s /= 2;
		else s = 3 * s + 1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 7 // 10000 + \n + \0
#define N_MOUNTAINS 10

int desc(const void *p, const void *q) {
    return *(int *)q - *(int *)p;
}

int main() {
    char line[SIZE];
    int results[N_MOUNTAINS];
    int max = 0;
    int i = 0;
    while (fgets(line, SIZE, stdin) != NULL) {
        size_t len = strlen(line);
        line[len - 1] = '\0';
        results[i] = atoi(line);
        i++;
    }
    qsort(results, i, sizeof(int), desc);
    printf("%d\n%d\n%d\n", results[0], results[1], results[2]);
    return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <tuple>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for (int i=0;i<n;i++)

ll mod = 1e9+7;

// 階乗
ll factorial(ll a){
    if (a==1){
        return 1;
    }
    return a * (factorial(a-1));
}

//組み合わせの数
ll nCr(ll n,ll r){
    return factorial(n)/factorial(r);
}

//重複する組み合わせの数
ll nHr(ll n,ll r){
    return factorial(n+r-1)/factorial(r);
}

int main(){
    int k,x;
    cin >> k >> x;
    int l = x - (k - 1),r = x + (k - 1);
    for (int i=l;i<=r;i++){
        cout << i << endl;
    }
}

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

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

struct UnionFind{
	vector<int> par;

	UnionFind(int N) : par(N,-1){ }

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

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

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

	int size(int x){
		return -par[root(x)];
	}

	int relations(){
		set<int> s;
		for(int i=0; i<(int)par.size(); i++) s.insert(root(i));
		return s.size();
	}
};

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> X(M),Y(M);
	vector<int> Z(M);
	rep(i,M){ 
		cin >> X[i] >> Y[i] >> Z[i];
		X[i]--; Y[i]--;
	}

	UnionFind uf(N);
	rep(i,M){
		uf.unite(X[i],Y[i]);
	}

	cout << uf.relations() << endl;

	return 0; 
}

Measured memory_bytes: 6400
#include <stdio.h>

int main() {
        long a, b, d, r;
        double f;

        scanf("%ld %ld", &a, &b);

        d = a / b;
        r = a % b;
        f = (double)a / b;

        printf("%ld %ld %lf\n", d, r, f);

}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

using namespace std;

union
{
	double f;
	long long int i;
} a;

union
{
	double f;
	long long int i;
} b;

union
{
	double f;
	long long int i;
} c;

int main()
{
	/*cin >> a.f >> b.f >> c.f;
	
	if (sqrt(a.f) + sqrt(b.f) < sqrt(c.f))
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
	*/

	
	uint64_t w = 1, h = 1;
	cin >> w >> h;
	uint64_t w_max = w / 2 + (w % 2);
	uint64_t h_max = h / 2 + (h % 2);
	uint64_t w_min = w / 2;
	uint64_t h_min = h / 2;
	uint64_t counter = 0;

	counter += w_max * h_max;
	counter += w_min * h_min;

	if (w == 1 || h == 1)
	{
		counter = 1;
	}
	
	cout << counter << endl;
	return 0;

}

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

int main(){
    int x;
    cin >> x;
    
    int tot = 0;
    
    int i = 1;
    while(1) {
        tot += i;
        if(tot >= x) {
            cout << i << endl;
            break;
        }
        i++;
    }
}


Measured memory_bytes: 3592
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        mut a: Chars,
        b: Chars,
    }

    a.extend(b);
    let a1: String = a.iter().collect();
    let num = a1.parse().unwrap();

    for i in 1..10000+1 {
        if i*i==num {
            println!("Yes");
            return;
        }
    }

    println!("No");

}


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

int main(){
	int A, B, K;
	cin >> A >> B >> K;
	vector<int> w;

	for(int i = 1; i <= max(A, B); ++i){
		if(A % i == 0 && B % i == 0){
			w.push_back(i);
		}
	}

	sort(w.begin(), w.end(), greater<int>());

	cout << w[K-1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n;
	cin>>n;
	int a[10001]={0};
	for(int i=1;i*i<=10050;i++){
	  for(int j=1;j*j<=10050;j++){
	  	for(int k=1;k*k<=10050;k++){
	  		ll x=i*i+j*j+k*k+i*j+j*k+k*i;
	  		if(x<=10000){
	  			a[x]++;
	  		}
	  	}
	  }
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<endl;
	}
}

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

int main(){
	int A[9];
	
	for (int i = 0; i < 9; i++) {
		cin >> A[i];
	}
	
	int N;
	cin >> N;
	
	for (int i = 0; i < N; i++) {
		int b;
		cin >> b;

		for (int i = 0; i < 9; i++){
			if(A[i] == b){
              A[i] = 0;
            }
		}

	}
		if(
		A[0]+A[1]+A[2] == 0 || 
		A[3]+A[4]+A[5] == 0 || 
		A[6]+A[7]+A[8] == 0 || 
		A[0]+A[3]+A[6] == 0 || 
		A[1]+A[4]+A[7] == 0 || 
		A[2]+A[5]+A[8] == 0 || 
		A[0]+A[4]+A[8] == 0 || 
		A[2]+A[4]+A[6] == 0){
		cout << "Yes" <<endl;
	}else{
		cout << "No" <<endl;
	}
}

Measured memory_bytes: 256
import math
def kosu(n):
    l=[]
    sosu = [True] * (n + 1)
    sosu[0]= False
    sosu[1]= False
    for i in range(2,math.floor(math.sqrt(n))+1):
        if not sosu[i]:
            continue
        for j in range(i*2,n+1,i):
            sosu[j] = False
    for i in range(len(sosu)):
        if sosu[i]:
            l.append(i)
    return(l)
    
while True:
    try:
        n = int(input())
    except EOFError:
        break
    print(len(kosu(n)))


Measured memory_bytes: 16816
import bisect
N = int(input())
S = input()
pairs = []
for i in range(len(S)):
    pairs.append([int(S[i]),i])

pairs = sorted(pairs)
cnt = 0

numlists = [[] for i in range(10)]

for i in range(N):
    numlists[pairs[i][0]].append(pairs[i][1])

ans = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            if(len(numlists[i]) == 0):
                continue
            indi = min(numlists[i])


            if(len(numlists[j]) == 0):
                continue
            if(max(numlists[j]) <= indi):
                continue
            
            
            indj = bisect.bisect_right(numlists[j],indi)
            indj = numlists[j][indj]
            if(len(numlists[k]) == 0):
                continue
            if(max(numlists[k]) <= indj):
                continue

            #indk = bisect.bisect_right(numlists[k],indj)

            cnt += 1
            #ans.append("{}{}{}:{}{}{}".format(i,j,k,indi,indj,indk))

print(cnt)

    

Measured memory_bytes: 12988
#include <stdio.h>
#include <queue>
#include <vector>
#include <functional>
#include <math.h>

using namespace std;
using P = pair<int, int>;

struct edge { int to, cost; };

const int MAX_N = 3000;

int dist[MAX_N + 1];
vector<edge>graph[MAX_N + 1];

int n, m, k;

void dijkstra()
{
	for (int i = 0; i <= n; ++i)dist[i] = 123456789;
	dist[0] = 0;
	priority_queue<P, vector<P>, greater<P>>que;
	que.push(make_pair(0, 0));
	while (!que.empty())
	{
		P u = que.top(); que.pop();
		if (dist[u.second] < u.first)continue;
		for (edge e : graph[u.second])
		{
			int alt = u.first + e.cost;
			if (dist[e.to] > alt)
			{
				dist[e.to] = alt;
				que.push(make_pair(alt, e.to));
			}
		}
	}
}

int main()
{
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 0; i < m; ++i)
	{
		int a, b, l;
		scanf("%d %d %d", &a, &b, &l);
		graph[a].push_back({ b,l });
		graph[b].push_back({ a,l });
	}
	for (int i = 0; i < k; ++i)
	{
		int s;
		scanf("%d", &s);
		graph[0].push_back({ s,0 });
	}
	dijkstra();
	int ans = 0;
	for (int v = 1; v <= n; ++v)
	{
		for (edge e : graph[v])
		{
			int u = e.to;
			int cost = e.cost;
			int a = min(dist[u], dist[v]);
			int b = max(dist[u], dist[v]);
			ans = max(ans, (int)round((b - a + cost) / 2.0) + a);
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> h(N);
    rep(i,N) cin >> h[i];

    vector<ll> dp(N,1e18);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

class ModCalc
{
    LLONG m_mod = MOD;
    vector<LLONG> m_fac;
    vector<LLONG> m_ifac;

public:
    ModCalc(const LLONG mod)
    {
        m_mod = mod;
    }

    // Combinationを計算したいときの前処理：O(max)
    ModCalc(const int max, const LLONG mod)
    {
        m_mod = mod;
        m_fac = vector<LLONG>(max + 1);
        m_ifac = vector<LLONG>(max + 1);
        m_fac[0] = m_ifac[0] = 1;
        for (int i = 0; i < max; ++i)
        {
            m_fac[i + 1] = m_fac[i] * (i + 1) % mod;    // n! (mod M)
            m_ifac[i + 1] = m_ifac[i] * ModPow(i + 1, mod - 2) % mod;   // k!^(M-2) (mod M)
        }
    }

    const LLONG ModAdd(LLONG a, LLONG b) const
    {
        return (a + b) % m_mod;
    }

    const LLONG ModSubtract(LLONG a, LLONG b) const
    {
        LLONG diff = a - b;
        return diff >= 0 ? diff : diff + m_mod;
    }

    const LLONG ModMulti(LLONG a, LLONG b) const
    {
        LLONG prod = a * b % m_mod;
        return prod >= 0 ? prod : prod + m_mod;
    }

    const LLONG ModDiv(LLONG a, LLONG b) const
    {
        LLONG c = m_mod, u = 1, v = 0;
        while (c)
        {
            LLONG t = b / c;
            b -= t * c; swap(b, c);
            u -= t * v; swap(u, v);
        }
        u %= m_mod;
        if (u < 0) u += m_mod;
        return (a % m_mod) * u % m_mod;
    }

    const LLONG ModPow(LLONG x, LLONG n) const
    {
        LLONG ret = 1;
        while (n != 0)
        {
            if (n & 1) ret = ret * x % m_mod;
            x = x * x % m_mod;
            n = n >> 1;
        }
        return ret;
    }

    const LLONG ModComb(LLONG n, LLONG r) const
    {
        if (n == 0 && r == 0) return 1;
        if (n < r || n < 0) return 0;
        LLONG tmp = m_ifac[n - r] * m_ifac[r] % m_mod;
        return tmp * m_fac[n] % m_mod;
    }
};

int main()
{
    int N; string S; cin >> N >> S;
    map<char, LLONG> char2NumMap;
    for (int i = 0; i < N; ++i)
    {
        ++char2NumMap[S[i]];
    }
    LLONG ans = 1;
    ModCalc mod(MOD);
    for (const auto &kvp : char2NumMap)
    {
        LLONG tmp = kvp.second + 1;
        ans = mod.ModMulti(ans, tmp);
    }
    ans = mod.ModSubtract(ans, 1);
    cout << ans << endl;
}


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

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

  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[i] = a;
    B[i] = a;
  }

  sort(B.begin(), B.end(), greater<int>());

  for (int i = 0; i < N; i++) {
    if (A[i] == B[0]) {
      cout << B[1] << endl;
      continue;
    }

    cout << B[0] << endl;
  }
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 5e3+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int k,q;
int d[MAXN],dd[MAXN];
LL s[MAXN],szero[MAXN];

void work(){
    scanf("%d%d",&k,&q);
    for(int i=1;i<=k;i++){
        scanf("%d",&d[i]);
    }
    while(q--){
        int n,x,m;
        LL ans=0,a0,an;
        scanf("%d%d%d",&n,&x,&m);
        for(int i=1;i<=k;i++){
            dd[i]=d[i]%m;
            s[i]=s[i-1]+dd[i];
            szero[i]=szero[i-1]+(dd[i]==0);
        }
//        for(int i=1;i<=k;i++) printf("%lld ",szero[i]);
//        printf("\n");
        a0=x;
        LL p=(n-1)/k;
        int q=(n-1)%k;
        an=(LL)x+(p*s[k]+s[q]);
//        printf("q = %lld\n",n-1-p*k);
//        printf("p = %lld , q = %d\n",p,q);
//        printf("an = %lld , a0 = %lld\n",an,a0);
        ans+=(p*szero[k]+szero[q]);
        ans+=an/m-a0/m;
//        printf("%lld %lld\n",p*szero[k]+szero[q],an/m-a0/m);
        printf("%lld\n",(LL)n-1-ans);
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}






Measured memory_bytes: 384
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討

#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3 * 1e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const ld INF = 1e18;
const long double EPS = 1e-7;
const int X = 1;
const int Y = 0;
typedef pair<ld, ut> pld;
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL A[SIZE], B[SIZE];

LL solve() {
	int N;
	cin >> N;
	REP(i, N) {
		cin >> A[i];
		if (A[i] % 2) return 1;
	}
	return 0;
}
signed main() {
	if (solve()) {
		cout << "first" << endl;
	}
	else {
		cout << "second" << endl;
	}
	cin >> N;
	return 0;

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 9856
import bisect
N, K = map(int,input().split())
x = list(map(int,input().split()))
ans = float("inf")
if x[0]*x[-1] >= 0:
    if x[0] >= 0:
        ans = x[K-1]
    else:
        ans = -x[-K]
    print(ans)
else:
    M = []
    P = []
    for e in x:
        if e > 0:
            P.append(e)
        else:
            M.append(-e)
    M.sort()
    M = [0] + M
    P = [0] + P
    for k in range(max(len(P),len(M))):
        if k < len(P) and 0 <= K-k < len(M):
#            print(M[K-k],P[k])
            ans = min(ans,2*M[K-k]+P[k],M[K-k]+2*P[k])
    print(ans)


Measured memory_bytes: 14480
#include <iostream>
#include <cctype>
#include <string>
using namespace std;
int main(){
    string s;
    while(getline(cin, s)){
        for(int i = 0; i < s.size(); i++){
            if(islower(s[i])){
                s[i] = toupper(s[i]);
            } else if(isupper(s[i])) {
                s[i] = tolower(s[i]);
            }
        }
        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 3140
n=int(input())
a=list(map(int,input().split()))
f=0
for i in range(n):
    if(a[i]%2==0):
        if(a[i]%3==0 or a[i]%5==0):
            f=0
        else:
            f=1
            break
if(f==0):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B,V,W,T;
    cin>>A>>V>>B>>W>>T;

    int x=abs(A-B);
    int d=V-W;
    if(x<=d*T){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    

    



}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int>A(N);
  for(int i=0; i<N; i++)cin >> A.at(i);
  
  for(int i=K; i<N; i++){
    if(A.at(i)>A.at(i-K))cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}



Measured memory_bytes: 4048
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

N = ii()
m = 0
k = N
while k > 0:
    m += k%10
    k //= 10
print(max(m, int(str(N)[0])-1+9*(len(str(N))-1)))

Measured memory_bytes: 9412
#include<bits/stdc++.h>
using namespace std;
#define double long double
int l[10],b[10],n,C;
double dp[400][1<<7],ans;
double dfs(int a[],int L){
	memset(dp,0,sizeof dp);
	dp[a[n]][0]=1;
	for (int i=0;i<L;i++)
		for (int k=0;k<n;k++)
			for (int j=0;j<1<<n;j++)
				if (!((1<<k)&j)){
					int to=min(i+a[k],L);
					for (int l=to;l<=L;l++)dp[l][j|(1<<k)]+=dp[l][j];
					for (int l=i;l<to;l++)dp[to][j|(1<<k)]+=dp[l][j];
				}
	return dp[L][(1<<n)-1];
}
int main(){
	scanf("%d%d",&n,&C);
	for (int i=0;i<n;i++)scanf("%d",&l[i]);
	sort(l,l+n);
	n--;
	for (int i=1;i<=n+1;i++){
		for (int j=0;j<=n;j++)b[j]=l[j]*i;
		double now=dfs(b,C*i);
		for (int j=1;j<=n+1;j++)
			if (j!=i)now/=i-j;
		ans+=now;
	}
	for (int i=0;i<n;i++)ans/=C;
	printf("%.15Lf\n",ans);
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_S = 100005;

string S, T;
bool used[50];
int first[50][MAX_S];

signed main()
{
  cin >> S;
  cin >> T;

  REP(n,S.size()) {
    used[S[n] - 'a'] = true;
  }
  REP(n, T.size()) {
    char t = T[n];
    if(!used[t - 'a']) {
      cout << -1 << endl;
      return 0;
    }
  }

  memset(first, -1, sizeof(first));
  for(int s = S.size()-1; 0 <= s; s--) {
    REP(n,50) {
      if(first[n][s+1] != -1) first[n][s] = first[n][s+1]+1;
      else first[n][s] = -1;
    }
    first[S[s]-'a'][s] = 1;
  }

  int ans = 0;
  int pos = 0;
  REP(n, T.size()) {
    char t = T[n];
    if(first[t-'a'][pos] == -1) {
      ans += ((int)S.size() - pos);
      pos = 0;
    }
    ans += first[t-'a'][pos];
    pos += first[t-'a'][pos];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 39680
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    while(cin >> n){
        vector<vi> d(n, vi(n));
        REP(i, n) {
            REP(j, n) {
                cin >> d[i][j];
            }
        }
        vector<ll> costs(1 << n);
        REP(b, 1 << n) {
            REP(i, n) {
                REP(j, i) {
                    if ((b & (1 << i)) && (b & (1 << j))) {
                        costs[b] += d[i][j];
                    }
                }
            }
        }
        vector<ll> dp(1 << n, - (1ll << 60));
        dp[0] = 0;
        REP(b, 1 << n) {
            int mask = ((1<<n) - 1) ^ b;
            for(int i=mask; i>0; i=(i-1)&mask) {
                chmax(dp[b | i], dp[b] + costs[i]);
            }
        }
        cout << dp[(1 << n) - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
N, L = map( int, input().split())

# 本来作りたかったアップルパイの味
assumed_apple_pie = ( L - 1 ) * N + sum( range( 1, N + 1 ) )

# 食べるりんごの味
## 食べるりんごは0に近い方が良い
edible_apple = 0
if L > 0:
  edible_apple = L
elif ( L + N - 1 ) < 0:
  edible_apple = L + N - 1
# 実際のアップルパイ
real_apple_pie = assumed_apple_pie - edible_apple

print( real_apple_pie )

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
 
int main()
{
    string s;
    cin>>s;
    ll sum=0;
    for(ll i=0;i<s.length();i++)
    {
        sum=sum+s[i]-'0';
        sum=sum%9;
    }
    if(sum==0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	map<char,int>m;
	m['A']= a;
	m['B'] = b;
	m['C'] = c;
	vector<char>v;
	vector<string>v2(n);
	int flag = 1;
	string s;
	for(int i = 0;i<n; i++)
		cin>>v2[i];
	for(int i = 0; i<n; i++)
	{
		s = v2[i];
		if(m[s[0]]>m[s[1]])
		{
			m[s[0]]--;
			if(m['A']<0 || m['B']<0 || m['C']<0) flag = 0;
			m[s[1]]++;
			v.pb(s[1]);
		}
		else
		{
			string t="";
			if(m[s[0]]==m[s[1]] && m[s[0]]==1)
				if(i!=n-1)
					t = v2[i+1];
			if(t.size()==0 || t[0]==s[0] || t[1]==s[0])
			{
				m[s[1]]--;
				if(m['A']<0 || m['B']<0 || m['C']<0) flag = 0;
				m[s[0]]++;
				v.pb(s[0]);
			}
			else
			{
				m[s[0]]--;
				if(m['A']<0 || m['B']<0 || m['C']<0) flag = 0;
				m[s[1]]++;
				v.pb(s[1]);
			}
		}
	}
	if(flag)
	{
		cout<<"Yes"<<endl;
		for(char i:v)
			cout<<i<<endl;
	}
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 6580
a,b=map(int,input().split())
cntA,cntB=0,0
print(100,100)
flag=False
if a>=b:
  arr=[['#']*100 for i in range(100)]
  l=[]
  cntB=1
  for i in range(2,99,4):
    if flag:break
    for j in range(2,99,4):
      l.append((i,j))
      for y in range(i-1,i+2):
        for x in range(j-1,j+2):
          arr[y][x]='.'
      cntA+=1
      if cntA==a:
        flag=True
        break
  while cntB<b:
    cntB+=1
    s,t=l.pop()
    arr[s][t]='#'
  for i in range(100):
    print(''.join(arr[i]))
else:
  arr=[['.']*100 for i in range(100)]
  l=[]
  cntA=1
  for i in range(2,99,4):
    if flag:break
    for j in range(2,99,4):
      l.append((i,j))
      for y in range(i-1,i+2):
        for x in range(j-1,j+2):
          arr[y][x]='#'
      cntB+=1
      if cntB==b:
        flag=True
        break
  while cntA<a:
    cntA+=1
    s,t=l.pop()
    arr[s][t]='.'
  for i in range(100):
    print(''.join(arr[i]))

Measured memory_bytes: 3188
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <array>

using namespace std;

#define fi first	
#define se second
#define long long long
typedef pair<int,int> ii;

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	long n, k;
	scanf("%lld %lld", &n, &k);

	long res = 0;
	res += (n/k)*(n/k)*(n/k);
	for(long i = 1; i < k; i++)
	{
		long j = k-i;
		long vi = n/k + (n%k >= i);
		long vj = n/k + (n%k >= j);
		if(i == j)
		{
			res += vi*vi*vi;
		}
	}
	printf("%lld\n", res);
}












Measured memory_bytes: 256
//coins problem

#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<iomanip>
#define ll long double
using namespace std;
void printmat(vector< vector<ll> > &dp,ll n)
{
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=n;j++)
		{
			cout<<setw(6)<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
}
int main()
{
	ll n;
	cin>>n;
	vector<ll> ph(n+1,0);
	vector< vector<ll> > dp(n+1);
	for(ll i=1;i<=n;i++)
	cin>>ph[i];
	
	for(ll i=0;i<=n;i++)
	{
		dp[i].resize(n+1,0);
	}
	
	//initializing dp
	dp[1][1]=ph[1];
	dp[0][1]=(1-ph[1]);
	for(ll i=2;i<=n;i++)
	{
		dp[i][i]=dp[i-1][i-1]*ph[i];
	}
	//filling 0th row
	for(ll i=2;i<=n;i++)
	{
		dp[0][i]=dp[0][i-1]*(1-ph[i]);
	}
	
	//bottom up approach
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=n;j++)
		{
			if(i==j)
			continue;
			
			dp[i][j]=ph[j]*dp[i-1][j-1]+(1-ph[j])*dp[i][j-1];
		}
	}
	
	ll st=ceil(n/2);
	ll tp=0;
	for(ll i=st;i<=n;i++)
	{
		tp+=dp[i][n];
	}
	cout<<setprecision(9)<<tp<<endl;
	
//	printmat(dp,n);
	return 0;
}


Measured memory_bytes: 143104
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long gt[200005];
long long POW(long long a, long long b){
	long long ans=1;
	while(b){
		if(b%2==1){
			ans=(ans*a)%mod;
		}
		b/=2;
		a=(a*a)%mod;
	}
	return ans;
}
long long C(long long x, long long y){
	long long up=gt[y]%mod;
	long long down=(POW(gt[x],mod-2))%mod;
	down = (down*POW(gt[y-x],mod-2))%mod;
	long long ans= (up*down)%mod;
	return ans;
}
signed main(){
	long long h,w,a,b;
	gt[0]=1;
	for(int i=1;i<=200000;i++){
		gt[i]=(gt[i-1]*i)%mod;
	}
	cin >> h >> w >> a >> b;
	long long dapan=0;
	for(int i=1;i<=h-a;i++){
		long long left=C(b-1,b+i-2);
		long long right=C(w-b-1,w-b-1+h-i);
		//cout << i << " " << left<< " " << right<<endl;
		dapan=dapan+(left*right)%mod;
		dapan=dapan%mod;
	}
	cout << dapan;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
ll a[N];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	sort(a,a+n);
	int l=0,r=n-1,w=1; 
	ll ans=1;
	if(k&1) ans=a[r--],k--,w=(ans<0?-1:1);
	while(k){
		ll x=a[l]*a[l+1],y=a[r]*a[r-1];
		if(x*w>y*w) ans=(ans*(x%mod))%mod,l+=2;
		else ans=(ans*(y%mod))%mod,r-=2;
		k-=2;
	}
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 5304
package main

import "fmt"

func main() {
	// Code for B - Postal Code
	var A, B int
	fmt.Scanf("%d %d", &A, &B)

	var S string
	fmt.Scanf("%s", &S)

	var flag int = 0
	for i := 0; i < len(S); i++ {
		if i < A {
			if S[i] == '-' {
				flag = 1
			}
		} else if i == A {
			if S[i] != '-' {
				flag = 1
			}
		} else {
			if S[i] == '-' {
				flag = 1
			}
		}
	}

	if flag == 1 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 1832
#! env/bin/local python3
import sys

x, n = map(int, input().split())
try:
    p = list(map(int, input().split()))
except EOFError:
    print(x)
    sys.exit()

sorted_p = sorted(p, reverse=True)
except_p = [i for i in range(0, 102) if i not in sorted_p]

memory_min = 10000
memory_index = 0

for k, ep in enumerate(except_p):
    if abs(ep - x) < memory_min:
        memory_min = abs(ep - x)
        memory_index = k

print(except_p[memory_index])


Measured memory_bytes: 61940
Sd = input()
T = input()
 
def check(A, B):
    for a, b in zip(A, B):
        if a != '?' and a != b:
            return False
 
    return True
 
for i in range(len(Sd) - len(T) + 1)[::-1]:
    if check(Sd[i:i + len(T)], T):
        print((Sd[:i] + T + Sd[i + len(T):]).replace('?', 'a'))
        break
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
    cin>>a>>b;
    if((a+b)%2==0)
    {
        cout<<(a+b)/2;
    }
    else
    {
        cout<<"IMPOSSIBLE";
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////



//////////////////////////////////////

int main() {
    
    int N;
    cin >> N;
    
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<int> x(N);
    int sign = 1;
    for (int i = 0; i < N; i++) {
        x[0] += A[i] * sign;
        sign *= -1;
    }
    x[0] /= 2;
    x[N-1] = A[N-1] - x[0];
    for (int i = N-1; i > 0; i--) {
        x[i-1] = A[i-1] - x[i];
    }
    for (int i = 0; i < N; i++) {
        cout << 2*x[i] << " ";
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	#define PI 				acos(-1)
	#define mp				make_pair
	#define pb				push_back
	#define all(a)			(a).begin(), (a).end()
	#define sz(a)			a.size()
	#define srt(a)			sort(all(a))
	#define mem(a, h)		memset(a, (h), sizeof(a))
	#define f 				first
	#define s 				second
	#define MOD1			998244353
	#define fore(i, b, e)	for(int i = b; i < e; i++)
	#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
	int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

	using namespace std;
	using namespace __gnu_pbds;

	typedef long long 		ll;
	typedef unsigned long long 		ull;
	typedef pair<int, int>  ii;
	typedef vector<int>     vi;
	typedef vector<ii>      vii;
	typedef vector<ll>      vll;
	typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
	const int tam = 100010;
	const int MOD = 1e9+7;
	const double EPS = 1e-9;

	int main()
	{
		ios::sync_with_stdio(0); cin.tie(0);
		//freopen("qwe.txt", "r", stdin);
		//freopen("asd.txt", "w", stdout);
		int n, a, b, c, x = 0, y = 0, d, lc = 0;
		cin>>n;
		while(n--)
		{
			cin>>c>>a>>b;
			lc = c - lc;
			d = abs(x - a) + abs(y - b);
			bool bo = false;
			if(lc >= d && (d & 1) == (lc & 1))
				bo = true;
			lc = c;
			x = a;
			y = b;
			if(!bo)
			{
				cout<<"No\n";
				return 0;
			}

		}
		cout<<"Yes\n";
		return 0;
	}

	// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2			

Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>

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

int main() {
  string s, t;
  cin >> s >> t;

  int ans = 0;
  if(s[0]==t[0]) ans++;
  if(s[1]==t[1]) ans++;
  if(s[2]==t[2]) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 


int main() {
  int n; cin >> n;
  vi a(n);
  rep(i,n ) cin >> a[i];
  set<int> tani, yama;
  if (a[0] < a[1]) tani.insert(0);
  yama.insert(n-1);
  for (int i=1; i<n-1; i++) {
    if (a[i] <= a[1+i] && a[i] <= a[i-1] && (a[i+1] != a[i] || a[i] != a[i-1])) tani.insert(i);
    if (a[i] >= a[i+1] && a[i] >= a[i-1]&& (a[i+1] != a[i] || a[i] != a[i-1])) yama.insert(i);
  }
  ll ans = 1000;
  ll rest = 1000;
  ll stock = 0;
  rep(i,n) {
    if (tani.find(i) != tani.end()) {
      ll maxBuy = rest / a[i];
      rest -= maxBuy * a[i];
      stock += maxBuy;
    } 
    else if (yama.find(i) != yama.end()) {
      rest += stock * a[i];
      stock = 0;
      chmax(ans, rest);
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	int s = 0;
	REP(i, n) {
		cin >> a[i];
		s += a[i];
	}
	int cnt = 0;
	REP(i, n) {
		if (4 * m * a[i] >= s) {
			cnt++;
		}
	}
	if (cnt >= m) {
		put("Yes");
	} else {
		put("No");
	}
	return 0;
}

Measured memory_bytes: 256
// 13B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle {
    int f[N2];
    int space;
    string path;

    bool operator < (const Puzzle& p) const {
        for (int i = 0; i < N2; i++) {
            if (f[i] == p.f[i])continue;
            return f[i] > p.f[i];
        }
        return false;
    }

};

static const int dx[4] = { -1,0,1,0 };
static const int dy[4] = { 0,-1,0,1 };
static const char dir[4] = { 'u','l','d','r' };

bool isTarget(Puzzle p) {
    for (int i = 0; i < N2; i++) {
        if (p.f[i] != (i + 1))return false;
    }
    return true;
}

string bfs(Puzzle s) {

    queue<Puzzle> Q;
    map<Puzzle, bool>V;
    Puzzle u, v;
    s.path = "";
    Q.push(s);
    V[s] = true;

    while (!Q.empty()) {
        u = Q.front(); Q.pop();
        if (isTarget(u))return u.path;
        int sx = u.space / N;
        int sy = u.space % N;
        for (int r = 0; r < 4; r++) {
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if (tx < 0 || ty < 0 || tx >= N || ty >= N) {
                continue;
            }
            v = u;
            swap(v.f[u.space], v.f[tx * N + ty]);
            v.space = tx * N + ty;
            if (!V[v]) {
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }




    return "unsolvable";
}

int main()
{
    Puzzle in;
    for (int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            in.f[i] = N2;
            in.space = i;
        }
    }

    string ans = bfs(in);
    cout << ans.size() << endl;

    return 0;
}




Measured memory_bytes: 30560
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int bySearch(int nm, vector<int> t) {

	int mid, st, ed, ans;
	st = 0;
	ed = t.size();

	while (true)
	{
		mid = min((ed - st) / 2 + st, (int)t.size() - 1);
		if (nm == t[mid]) {
			ans = mid;
			break;
		}
		else if (nm > t[mid]) {
			st = mid + 1;
		}
		else
		{
			ed = mid;
		}
		if (ed <= st) {
			ans = -1;
			break;
		}
	}

	return ans;
}

int main() {

	int sn, tn, ttl;
	sn = tn = ttl = 0;

	cin >> sn;
	vector<int> s(sn);
	for (int i = 0;i < sn;i++) {
		cin >> s[i];
	}

	cin >> tn;
	vector<int> t(sn);
	for (int i = 0;i < tn;i++) {
		cin >> t[i];
	}

	sort(s.begin(), s.end());

	for (int k = 0; k < tn;k++) {
		int tp = bySearch(t[k], s);
		if (tp > -1) ttl++;
	}

	cout << ttl << endl;

	return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
int main(){
  int i,n,m=0;
  std::string s;
  std::map<std::string,int> poll;
  std::cin >> n;
  for(i=0;i<n;i++){
    std::cin >> s;
    poll[s]++;
    if(m<poll[s]) m=poll[s];//m: 最多得票数
  }
  for(const auto& [key, value] : poll){//map: 辞書順で処理される
    if(value==m) std::cout << key << std::endl;
  }
  return 0;
}

Measured memory_bytes: 19100
#include <stdio.h>

main(){
  int data[102];
  int count1, count2, sum, a, b,i,t=0;

  while(1){
    for(i=0;i<102;i++){
      data[i]=0;
    }
    
    while(1){
      if(scanf("%d %d", &a, &b)==EOF){
	t=1;
	break;
      }
      if(a==0 && b==0) break;

      if(data[a]>=0){
	data[a]--;
	data[b]++;
      }
      else{
	data[a]++;
	data[b]--;
      }
    }

    if(t==1) break;

    count1=count2=0;
    for(i=0;i<102;i++){
      if(data[i]==1) count1++;
      else if(data[i]==-1) count2++;
    }

    if(count1==1 && count2==1) printf("OK\n");
    else printf("NG\n");
  }
  return 0;
}

Measured memory_bytes: 0