akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  ll d,t,s;
  cin>>d>>t>>s;
  if(t*s>=d){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 100005
using namespace std;
typedef long long ll;
ll n, k, v[N], w[N], dp[N][105];

ll f(ll kal, ll x){
	ll &r = dp[kal][x];
	if(r != -1)
		return r;
	if(x == n + 1)
		return 0;
	r = f(kal, x + 1);
	if(w[x] <= kal)
		r = max(r, v[x] + f(kal - w[x], x + 1));
	return r;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	memset(dp, -1, sizeof dp);
	scanf("%lld %lld",&n ,&k);
	for(ll i = 1; i <= n; i++)
		scanf("%lld %lld",w + i, v + i);
	printf("%lld\n", f(k, 1));
	return 0;
}

Measured memory_bytes: 82304
#include<stdio.h>
#define N 10

int main(){
  int i,j,x,y,size;
  int data[N][N];
  int ptnx1[]={0,0,0,1,-1},ptny1[]={0,-1,1,0,0};
  int ptnx2[]={0,0,0,-1,-1,-1,1,1,1},ptny2[]={0,-1,1,-1,0,1,-1,0,1};
  int ptnx3[]={0,0,0,-1,-1,-1,1,1,1,0,0,-2,2},ptny3[]={0,-1,1,-1,0,1,-1,0,1,2,-\
2,0,0};
  for (i=0;i<N;i++)
    for (j=0;j<N;j++)
      data[i][j]=0;

  while (scanf("%d,%d,%d",&x,&y,&size)!=EOF){
    if (size==1){
      for (i=0;i<5;i++)
        if ((0<=x+ptnx1[i]) && (0<=y+ptny1[i]) &&
            (x+ptnx1[i]<N) && (y+ptny1[i]<N)){
          data[x+ptnx1[i]][y+ptny1[i]]++;
        }
    }

    if (size==2){
      for (i=0;i<9;i++)
        if ((0<=x+ptnx2[i]) && (0<=y+ptny2[i]) &&
            (x+ptnx2[i]<N) && (y+ptny2[i]<N)){
          data[x+ptnx2[i]][y+ptny2[i]]++;
        }
    }

    if (size==3){
      for (i=0;i<13;i++)
        if ((0<=x+ptnx3[i]) && (0<=y+ptny3[i]) &&
            (x+ptnx3[i]<N) && (y+ptny3[i]<N)){
          data[x+ptnx3[i]][y+ptny3[i]]++;
        }
    }
  }

  int max=0;
  int cnt=0;
  for (i=0;i<N;i++)
    for (j=0;j<N;j++){
      if (data[i][j]==0)
        cnt++;
      if (data[i][j]>max)
        max=data[i][j];
    }
  printf("%d\n%d\n",cnt,max);
  return 0;
}

Measured memory_bytes: 600
teisuu = input().split(" ")
N = int(teisuu[0])
M = int(teisuu[1])
C = int(teisuu[2])
B_list = list(map(int, input().split(" ")))
ans = 0
for i in range(N):
    num = 0
    A_list = list(map (int, input().split(" ")))
    for j in range(M):
        num += A_list[j] * B_list[j]
    if num + C > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, m, a[100000];
int g = 1;
bool bl;

signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		g = lcm(g, a[i]);
	}
	bl = true;
	g /= 2;
	for (int i = 0; i < n; i++) {
		if ((g%a[i]) != a[i] / 2)bl = false;
	}
	if (!bl || m < g)cout << 0 << endl;
	else cout << (m - g) / (g * 2) + 1 << endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int K = sc.nextInt();
  int[] x = new int[N];
  int sum = 0;
  for(int i = 0;i < N;i++){
    x[i] = sc.nextInt();
    if(x[i] <= (K/2)) sum += x[i];
    else sum += (K - x[i]);
  }
  System.out.println(sum*2);
}}


Measured memory_bytes: 22100
import math
x,k,d = map(int,input().split())
d = abs(d)
x = abs(x)

if k*d<=x:
  print(x-k*d)
else:
  e = math.floor(x/d)
  k -= e
  x = x-e*d
  if k%2 == 0:
    print(x)
  else:
    print(abs(x-d))



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

int main(){
    int x;
    cin>>x;
    int a,b,ans;
    a=x/500;
    x=x-500*a;
    b=x/5;
    ans=a*1000+b*5;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];
  sort(a, a + n);

  ll ans = 1;
  bool flag = true;
  rep(i, n) {
    if (a[i] == 0) {
      ans = 0;
      break;
    } else {
      if (a[i] <= 1000000000000000000 / ans) {
        ans *= a[i];
      } else {
        flag = false;
        break;
      }
    }
  }
  if (flag)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 4372
#include<stdio.h>
int main(){
  int n, i; 
  int fib[45];
  scanf("%d", &n);
  fib[0]=fib[1]=1;
  for(i=2;i<=n;i++)fib[i]=fib[i-1]+fib[i-2];
  printf("%d\n",fib[n]);
  return 0;
}



Measured memory_bytes: 2112
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    bool flag=true;
    for(int n=0; n<N; n++) {
        int A;
        cin >> A;
        if(A%2==0) {
            if(A%3!=0 && A%5!=0) {
                flag = false;
            }
        }
    }
    
    if(flag) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");

		int k = Integer.parseInt(tmpArray[0]);
		int x = Integer.parseInt(tmpArray[1]);

		for(int i = x - k + 1; i <= x + k - 1; i++){
			if(i != x - k + 1){
				System.out.print(" ");
			}
			System.out.print(i);
		}
		System.out.println();
	}

}


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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    int A[N], B[N], C[N];
    rep(i, N) cin >> A[i] >> B[i] >> C[i];
    int bignum = 1000000000;
    int dim = N*10+1;
    int dp[N+1][dim][dim]; //薬の種類を1からNとすると, dp[i][j][k]はi番目までの薬の組み合わせでa = j, b = kを実現する最小コスト
    rep(i, N+1) rep(j, dim) rep(k, dim) dp[i][j][k] = bignum+1;
    dp[0][0][0] = 0;
    for(int i = 1; i <= N; i++){
        int va = A[i-1];
        int vb = B[i-1];
        rep(j, dim){
            rep(k, dim){
                if(j-va >= 0 && k-vb >= 0) dp[i][j][k] = min(dp[i-1][j][k], C[i-1]+dp[i-1][j-va][k-vb]);
                else dp[i][j][k] = dp[i-1][j][k];
            }
        }
    }
    priority_queue<int, vector<int>, greater<int>> kouho;
    for(int i = 1; i <= N; i++){
        for(int j = Ma, k = Mb; j < dim && k < dim; j+=Ma, k+=Mb){
            //if(dp[i][j][k] != bignum+1) cout << i << " " << j << " " << k << ": " << dp[i][j][k] << ", ";
            kouho.push(dp[i][j][k]);
        }
    }
    if(kouho.top() != bignum+1) cout << kouho.top() << endl;
    else cout << -1 << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 26112
#include <stdio.h>
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

struct Node  T[MAX];
int n, D[MAX],H[MAX];

void Depth(int u,int d) {
	if (u == NIL) return;
	D[u] = d;
	Depth(T[u].l,d+1);
	Depth(T[u].r,d+1);
}

int Height(int u) {
	int h1 = 0, h2 = 0;
	if (T[u].l != NIL) h1 = Height(T[u].l) + 1;
	if (T[u].r != NIL) h2 = Height(T[u].r) + 1;

	return H[u] = (h1 > h2 ? h1 : h2);
}

int getsibling(int u){
	if (T[u].p == NIL) return NIL;
	if (T[T[u].p].l != u && T[T[u].p].l != NIL) return T[T[u].p].l;
	if (T[T[u].p].r != u && T[T[u].p].r != NIL) return T[T[u].p].r;

	return NIL;
}

void print(int u) {
	int i, c;

	printf("node %d:", u);
	printf(" parent = %d,", T[u].p);
    printf(" sibling = %d,",getsibling(u));
	int deg = 0;
	if (T[u].l != NIL) deg++;
	if (T[u].r != NIL) deg++;
	printf(" degree = %d,",deg);
	printf(" depth = %d,", D[u]);
	printf(" height = %d, ",H[u]);

	if (T[u].p == NIL) printf("root\n");
	else if (T[u].l == NIL && T[u].r== NIL) printf("leaf\n");
	else printf("internal node\n");
}

int main() {

	int n, i, j, node, nodenum, c, left, right;
	int root = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) T[i].p = NIL;

	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &nodenum, &left, &right);
		T[nodenum].l = left;
		T[nodenum].r = right;
		if (left != NIL) T[left].p = nodenum;
		if (right != NIL) T[right].p = nodenum;
	}
	
	for (i = 0; i < n; i++) if (T[i].p == NIL) root = i;

	Depth(root,0);
	Height(root);

	for (i = 0; i < n; i++) print(i);
	return 0;
}



Measured memory_bytes: 2112
N = int(input())
H = list(map(int, input().split()))
base = H[-1]
cnt = 0
ans = 0
if N == 1:
    print(0)
else:
    for h in H[N-2::-1]:
        if base <= h:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
        base = h
    print(max(ans,cnt))

Measured memory_bytes: 20380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    string s;
    cin >> s;
    if (s[0] == '7' ||s[1] == '7' ||s[2] == '7') {
        cout << "Yes" << endl;
    } else {
        cout << "No" <<endl;
    }
}


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

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

vector<pair<ll,ll>> E[100005];
ll ans[100005];

void dfs(ll fro, ll to, ll dis) {
  ans[to] = dis%2;
  for (auto& e:E[to]) {
    if (e.first != fro) dfs(to, e.first, dis+e.second);
  }
}

int main() {
  int n;
  cin >> n;
  ll u,v,w;
  rep(i,n-1) {
    cin >> u >> v >> w;
    E[u-1].push_back({v-1, w%2});
    E[v-1].push_back({u-1, w%2});
  }
  dfs(-1,0,0);
  rep(i,n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 13356
N = gets.to_i

Ary = readlines.map(&:chomp!)

map = { "AC" => 0, "WA" => 0, "TLE" => 0, "RE" => 0 }
Ary.each do |re|
  map[re] += 1
end

puts "AC x #{map["AC"]}"
puts "WA x #{map["WA"]}"
puts "TLE x #{map["TLE"]}"
puts "RE x #{map["RE"]}"


Measured memory_bytes: 20576
#include<stdio.h>
int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  for(int i = 1;i < B;i++){
    if(A * i % B == C){
      printf("YES");
      return 0;
    }
  }
  printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    int a[n];
    ll ans=0;
    for (i=0;i<n;i++)
    {
        cin>>a[i];
        ans+=a[i]-1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint()
{
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//
const ull e=65436534565367;
const int maxn=600+10;
int n,res,cnt;
char s[maxn][maxn],ss[maxn][maxn];
ull val[2*maxn][maxn],oval[2*maxn][maxn];
//
bool check(int x,int y,int xx,int yy,int istep)
{	
	if(istep>=n)return true;
	if(val[x][y]!=oval[xx][yy])return false;
	return check(x+1,y,xx,yy+1,istep+1);
}
int main()
{
	srand(time(0));
	n=getint();
	rep(i,n)scanf("%s",ss[i]);
	rep(i,n)rep(j,n)s[i][j]=s[i+n][j]=s[i][j+n]=s[i+n][j+n]=ss[i][j];
	ull ee=1;
	rep(i,n)ee*=e;
	rep(i,2*n)
	{
		rep(j,n)val[i][0]=val[i][0]*e+(ull)s[i][j];
		for(int j=1;j<n;j++)val[i][j]=val[i][j-1]*e-s[i][j-1]*ee+(ull)s[i][j+n-1];
	}
	rep(j,2*n)
	{
		rep(i,n)oval[0][j]=oval[0][j]*e+(ull)s[i][j];
		for(int i=1;i<n;i++)oval[i][j]=oval[i-1][j]*e-s[i-1][j]*ee+(ull)s[i+n-1][j];
	}
	rep(i,n)rep(j,n)if(check(i,j,i,j,0))res++;
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

set<char> a[256], b[256];
string solve() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		int ss = s[i];
		int tt = t[i];
		a[s[i]].insert(t[i]);
		b[t[i]].insert(s[i]);
	}
	for (int i = 0; i < 256; i++) {
		if (a[i].size() > 1) return "No";
		if (b[i].size() > 1) return "No";
	}
	return "Yes";
}
int main() {
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 900
program hrn;
 var
  s1,s2:string;
  l1,l2,i:longint;
 begin
  readln(s1);l1:=length(s1);
  readln(s2);l2:=length(s2);
  for i:=1 to l2 do write(s1[i],s2[i]);
  if l1>l2 then write(s1[l1]);writeln;
 end.



Measured memory_bytes: 128
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in a:
    x -= i
    if x >= 0:
        ans += 1
    else:
        break
if x > 0:
    print(ans - 1)
else:
    print(ans)


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


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a;
	string s;
	cin >> a;
	cin >> s;
	if(a >= 3200)
	{
		cout << s;
	}
	else
	{
		cout << "red";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ll x,base=100,ans=0;
	cin >> x;
	while (base < x) {
		base*= 1.01;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
import math

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
countP = 0
countQ = 0

List = [i for i in range(N)]

for i in range(N-1):
    if i == 0:
        countP += (P[i]-1) * math.factorial(N-1)
    elif i == 1:
        if P[0]<P[1]:
            countP += (P[i]-2) * math.factorial(N-2)
        else:
            countP += (P[i]-1) * math.factorial(N-2)
    else:
        count = 0
        for j in range(i):
            if P[i]>P[j]:
                count+=1
        countP += (P[i]-count-1) * math.factorial(N-1-i)

for i in range(N-1):
    if i == 0:
        countQ += (Q[i]-1) * math.factorial(N-1)
    elif i == 1:
        if Q[0]<Q[1]:
            countQ += (Q[i]-2) * math.factorial(N-2)
        else:
            countQ += (Q[i]-1) * math.factorial(N-2)
    else:
        count = 0
        for j in range(i):
            if Q[i]>Q[j]:
                count+=1
        countQ += (Q[i]-count-1) * math.factorial(N-1-i)


if countP > countQ:
    print(countP-countQ)
else:
    print(countQ-countP)


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

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    int a; cin >> a; --a;
    if (a != i) ++cnt;
  }
  if (cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

import os
import sys
import math
import numpy as np
import collections
import itertools
import functools
import operator

N = int(input())
names = collections.defaultdict(list)


for i in range(N):
    name = input()
    names[name[0]].append(names)

march = ['M', 'A', 'R', 'C', 'H']

ans = 0
prod = functools.partial(functools.reduce, operator.mul)

for heads in itertools.combinations(march, 3):
    nums = [len(names[head]) for head in heads]
    ans += prod(nums)

print(ans)

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

int main(){

    while(1){
        int M,T,P,R;
        cin >> M >> T >> P >> R;
        if(M==0&&T==0&&P==0&&R==0)break;
        vector<vector<int>> wa(T,vector<int>(P,0));
        vector<vector<bool>> ac(T,vector<bool>(P,false));
        vector<int> cnt(T,0);
        vector<pair<int,int>> mt(T,{0,0});
        rep(i,T){
            mt[i].second=-(i+1);
        }
        rep(i,R){
            int m,t,p,j;
            cin >> m >> t >> p >> j;
            t--;p--;
            if(j!=0){
                wa[t][p]++;
            }else{
                mt[t].first+=m;
                ac[t][p]=true;
            }
        }
        vector<vector<pair<int,int>>> accnt(P+1);
        for(int i=T-1;i>=0;i--){
            for(int j=0;j<P;j++){
                if(ac[i][j]){
                    cnt[i]++;
                    mt[i].first+=20*wa[i][j];
                }
            }
            accnt[cnt[i]].push_back(mt[i]);
        }
        rep(i,P+1){
            stable_sort(accnt[i].begin(),accnt[i].end());
        }
        int cn=0;
        for(int i=P;i>=0;i--){
            for(int j=0;j<(int)accnt[i].size()-1;j++){
                cout << -accnt[i][j].second;
                cn++;
                if(accnt[i][j].first==accnt[i][j+1].first){
                    cout << "=";
                }else{
                    cout << ",";
                }
            }
            if(accnt[i].size()>0){
                cout << -accnt[i].back().second;
                cn++;
                if(cn!=T)cout << ",";
            }
        }
        cout<< endl;
    }

    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
 
typedef long long lli;
 
const static lli n_day[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
 
bool isleap(lli y) {
  if(y % 4 != 0) return false;
  return (y % 100 != 0 || y % 400 == 0);
}
 
struct Maya {
  lli b, ka, t ,w , ki;
};
 
struct Date {
  lli y, m, d;
  bool operator != (const Date &date) const {
    return y != date.y || m != date.m || d != date.d;
  }
 
  bool isleap() {
    if(y % 4 != 0) return false;
    return (y % 100 != 0 || y % 400 == 0);
  }
  lli numOfDays() {
    if(m == 2)
      return n_day[2] + isleap();
    else
      return n_day[m];
  }
  void next() {
    if(d == numOfDays()) {
      d = 1;
      if(m == 12) {
        m = 1;
        y += 1;
      } else {
        m += 1;
      }
    } else {
      d += 1;
    }
  }
};
 
lli mayaToDay(const Maya &maya) {
  return maya.b * 20*20*18*20
    + maya.ka * 20*18*20
    + maya.t * 18*20
    + maya.w * 20
    + maya.ki;
}
 
Maya dayToMaya(lli day) {
  Maya maya;
  day %= 20*20*18*20*13;
  maya.ki = day % 20;
  day /= 20;
  maya.w = day % 18;
  day /= 18;
  maya.t = day % 20;
  day /= 20;
  maya.ka = day % 20;
  day /= 20;
  maya.b= day;
  return maya;
}
 
Date dayToDate(lli day) {
  int remainDay = day;
  Date date = {2012, 12, 21};
  while(remainDay >= 366) {
    remainDay -= 365 + isleap(date.y+1);
    date.y += 1;
  }
  while(remainDay > 0) {
    remainDay -= 1;
    date.next();
  }
  return date;
}
 
lli dateToDay(const Date &date) {
  lli res = 0;
  Date n = {2012, 12, 21};
  while(date.y - n.y >= 2) {
    res += 365 + isleap(n.y+1);
    n.y += 1;
  }
  while(date != n) {
    res += 1;
    n.next();
  }
  return res;
}
 
int main() {
  string line;
  while(getline(cin, line) && line != "#") {
    replace(line.begin(), line.end(), '.', ' ');
    stringstream ss(line);
    vector<lli> v;
    string str;
    while(ss >> str) {
      v.push_back(atoll(str.c_str()));
    }
    if(v.size() == 3) {
      Date date = {v[0], v[1], v[2]};
      Maya maya = dayToMaya(dateToDay(date));
      cout << maya.b << "." << maya.ka << "." << maya.t
           << "." << maya.w << "." << maya.ki << endl;
    } else {
      Maya maya = {v[0], v[1], v[2], v[3], v[4]};
      Date date = dayToDate(mayaToDay(maya));
      cout << date.y << "." << date.m << "." << date.d << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d%d", &a, &b);
if(a < b) {
	printf("a < b\n");
}
if (a == b) {
	printf("a == b\n");
}
if (a > b) {
	printf("a > b\n");
}
return 0;
}


Measured memory_bytes: 2068
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
 
int main(){
  int K,N;
  cin>>K>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  int M=K+A[0]-A[N-1];
  rep(i,N-1) M=max(M,A[i+1]-A[i]);
  cout<<K-M<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int n, l;
  cin >> n >> l;
  vector<string> s;
  for(int i = 0; i < n; i++){
    string tmp;
    cin >> tmp;
    s.push_back(tmp);
  }
  sort(s.begin(), s.end());

  string output;
  for(int i = 0; i < n; i++){
    output = output + s[i];
  }

  cout << output << endl;
  return 0;
}

Measured memory_bytes: 3684
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n, k;
  while (cin >> n >> k, n) {
    vvi g(n, vi(n, INF));
    rep(i, n) g[i][i] = 0;
    while (k--) {
      int q;
      cin >> q;
      if (q) {
        int c, d, e;
        cin >> c >> d >> e;
        --c, --d;
        cmin(g[c][d], e), cmin(g[d][c], e);
        rep(i, n) rep(j, n) cmin(g[i][j], g[i][c] + g[c][j]);
        rep(i, n) rep(j, n) cmin(g[i][j], g[i][d] + g[d][j]);
      } else {
        int a, b;
        cin >> a >> b;
        --a, --b;
        cout << (g[a][b] == INF ? -1 : g[a][b]) << endl;
      }
    }
  }
}

Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <string>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main() {
    bool dp[100000] = {true};
    int lens[] = {5, 7, 5, 6};
    string words[] = {"dream", "dreamer", "erase", "eraser"};
    string S;
    cin >> S;

    REP(i, S.size()) {
        if (!dp[i]) continue;

        REP(j, 4)
            if (S.substr(i, lens[j]) == words[j])
                dp[i + lens[j]] = true;
    }

    if (dp[S.size()])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for D - Floor Function
	var A, B int
	var N int
	fmt.Scan(&A, &B, &N)

	/*
		var ans int
		var max int

		for i := 0; i <= B-1; i++ {
			ans = int(math.Ceil(float64((A * i) / B)))
			if max < ans {
				max = ans
			}
		}
	*/

	//fmt.Println(max)
	i := int(math.Min(float64(B-1), float64(N)))
	fmt.Println(int(math.Ceil(float64((A*i)/B))) - A*int(math.Ceil(float64(i/B))))
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

typedef string::const_iterator State;
class ParseError
{
};

bool iscat(State &begin, char next)
{
    if (*begin == next)
    {
        return true;
    }
    if (*begin != 'm')
    {
        return false;
    }
    begin++;
    bool ret = iscat(begin, 'e');

    if (ret = false || *begin != 'e')
    {
        return false;
    }
    begin++;
    ret = iscat(begin, 'w');
    if (ret = false || *begin != 'w')
    {
        return false;
    }
    begin++;
    return true;
}

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    State begin = s.begin();
    bool ret = iscat(begin, '@');
    if (ret && !(*begin))
    {
        cout << "Cat" << endl;
    }
    else
    {
        cout << "Rabbit" << endl;
    }

    return 0;
}



Measured memory_bytes: 3212
#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,k,q;
  cin >> N >> k >> q;
  vector<int> a(N,k-q);
  rep(i,q){
    int w;
    cin >> w;
    w--;
    a[w]++;
  }
  // rep(i,N) cout << a[i] << endl;

  rep(i,N){
    if(a[i]<=0){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    string S;
    cin >> S;
    if (S.back() == 's') {
        cout << S + "es" << endl;
    } else {
        cout << S + "s" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto A = RD;
	auto B = RD;
	auto M = RD;
	auto a = RDA;
	auto b = RDA;
	auto xyc = new long[][](M);
	foreach (i; 0..M)
	{
		xyc[i] = [RD-1, RD-1, RD];
	}

	auto pos_a = a.MIN_POS;
	auto pos_b = b.MIN_POS;
	long ans = a[pos_a] + b[pos_b];

	foreach (i; 0..M)
	{
		auto x = xyc[i][0];
		auto y = xyc[i][1];
		auto c = xyc[i][2];
		auto t = a[x]+b[y]-c;
		ans.chmin(t);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 20540
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
map<char,int>mp;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++) mp[s[i]]++;
    map<char,int>::iterator it;
    for(it=mp.begin();it!=mp.end();it++){
        if(it->second>1){
            cout<<"no\n";
            return 0;
        }
    }
    cout<<"yes\n";
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: Xor Sum 2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;

/* global variables */

ll as[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) scanf("%lld", &as[i]);

  ll cnt = 0, x = 0;
  for (int i = 0, j = 0; i < n; i++) {
    while (j < n && (x & as[j]) == 0LL) x ^= as[j++];
    cnt += j - i;
    x ^= as[i];
  }

  printf("%lld\n", cnt);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;
char maze[1001][1001];
int d[1001][1001];
bool pre[1001][1001];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;


int main() {
	ll i, j, k, l, m, n, sum, flag, cc, M, X, N, Y, Z, K;
	ll R, G, B;
	ll color[3];
	cin >> color[0]>>color[1]>>color[2]>>N;
	sort(color, color + 3);
	R=color[2];
	G = color[1];
	B = color[0];
	ll ans = 0;
	for (i = 0; i*R <= N; i++) {
		for (j = 0; i*R + j * G <= N; j++) {
			if((N-(i*R+j*G))%B==0){
            ans++;
            }
		}
	}
	
	output(ans);
	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
const int MAXN=1e5+100;;
ll n,m;
ll a[MAXN];
ll lcm(ll a,ll b){
    return a*b/__gcd(a,b);
}
int main()
{
    ios;
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) a[i]/=2;
    ll c=1,f=0;
    for(int i=1;i<=n;i++) c=lcm(c,a[i]);
    if(c>m) f=1;
    for(int i=1;i<=n;i++){
        if((c/a[i])%2==0){
            f=1;
            break;
        }
    }
    if(f){
        cout<<0<<'\n';
        return 0;
    }
    ll tmp=m/c;
    ll ans=tmp/2;
    if(tmp&1) ans++;
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 4424
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	var t string
	fmt.Scan(&t)

	s1 := strings.Split(s, "")
	s2 := strings.Split(t, "")

	length1 := len(s1)
	length2 := len(s2)

	length := length1 - length2
	var count int
	max := 0
	for i := 0; i <= length; i++ {
		count = 0
		for j := 0; j < length2; j++ {
			if s1[j+i] == s2[j]{
				count++
			}
		}
		if max < count{
			max = count
		}
	}

	ans := length2 - max
	fmt.Println(ans)
}


Measured memory_bytes: 1888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int R,G,B,N;cin >> R >> G >> B >> N;
    int ans = 0;
    for(int i=0;i<=N;i++) {
        for(int j=0;j<=N;j++) {
            int a = N - R*i - G*j;
            if(a%B == 0 && a >= 0) ans++; 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3520
str = input()
flag = 0
for i in range(len(str)):
	if i % 2 == 0:
		if str[i] == "L":
			print("No")
			flag = 1
			break
	else:
		if str[i] == "R":
			print("No")
			flag = 1
			break

if flag == 0:
	print("Yes")
	pass

Measured memory_bytes: 2940
import sys

input = sys.stdin.readline

def main():
    n = int(input())
    m = list(map(int, input().split()))
    m.sort()
    ans = (m[0] + m[1]) / 2
    for i in range(2,n):
        ans = (ans + m[i]) / 2
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::num;

fn main(){

    input!{
        n: i64,
        k: i64,
    }

    let mut r = n % k;
    if k-r < r {
        r = k-r;
    }

    println!("{}", r);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            h[i]--;
        } else {
            if (h[i - 1] < h[i]) {
                h[i]--;
            } else if (h[i - 1] > h[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    city = set()
    sp = []
    for i in range(N):
        i += 1
        s, p = input().split()
        p = -int(p)
        sp.append([s, p, i])
    sp.sort()
    for s, p, i in sp:
        print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const int Maxn = 100010 * 2;
ll md[Maxn];

int main() {
    ll n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        md[i % k]++;
    }

    ll ans = 0;
    for (int i = 0; i < k; ++i) {
        if (2 * i % k != 0) continue;
        ans += md[i] * md[i] * md[(k - i) % k];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep2(i, j, n) for (LL i = j; i <= n; ++i)
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define boost cin.tie(0);ios_base::sync_with_stdio(0);
#define vi vector <int>

using namespace std;			

const int nax = 2e5 + 111;
const LL INF = 1e9 + 100;

int n, a, b, T;
vector <pair<int, int>> gao;
vector <int> qw;

LL dp[50];

int main() {	
	scanf ("%d%d", &n, &T);
	rep(i, 1, n) {
		scanf ("%d%d", &a, &b);
		if (a == 0) qw.pb(b);
		else gao.pb({a, b});
	}
	
	sort(gao.begin(), gao.end(), [](pair<int, int> x, pair<int, int> y) {
		return (LL) x.fi * (y.se + 1) > (LL) y.fi * (x.se + 1);
	});
	
	rep(i, 0, 49) dp[i] = INF;
	dp[0] = 0;
	for (auto it : gao) {
		per(j, 0, 48) {
			if (dp[j] == INF) continue;
			dp[j + 1] = min(dp[j + 1], dp[j] + 1 + (LL) it.fi * (dp[j] + 1) + it.se);
		}
	}
	
	sort(qw.begin(), qw.end());
	
	int best = 0;
	rep(i, 0, 49) {
		if (T < dp[i]) continue;
		LL tim = dp[i];
		int res = i;
		for (auto it : qw) {
			if (tim + it + 1 <= T) {
				tim += it + 1;
				res++;
			}
		}
		best = max(best, res);
	}
	printf ("%d", best);
	
	
	
	
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

const int MOD = int(1e9) + 7;

int n;
int x[100000];

int main() {
    scanf("%d", &n);
    forn(i, n) {
        scanf("%d", x + i);
    }
    int cnt = 0;
    int ans = 1;
    forn(i, n) {
        ++cnt;
        if (x[i] < 2 * cnt - 1) {
            assert(x[i] == 2 * cnt - 2);
            ans = (LL)cnt * ans % MOD;
            --cnt;
        }
    }
    while (cnt) {
        ans = (LL)cnt * ans % MOD;
        --cnt;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	int a = -1, b;
	for (int i = 0; i < s.size(); i++) {
		if (a == -1 && s[i] == 'A') {
			a = i;
		}
		else if (s[i] == 'Z') {
			b = i;
		}
	}
	cout << b - a + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
// Problem : B - Crane and Turtle
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int x,y;cin>>x>>y;
if((y-2*x)&1)
cout<<"No";
else
{
	int b=(y-2*x)/2;
	int a=x-b;
	if(b>=0 and a>=0)
	cout<<"Yes";
	else
	cout<<"No";
}
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    int n;
    while (cin >> n) {
        int x = 0;
        rep(i, n) {
            int a;
            cin >> a;
            x = gcd(x, a);
        }
        cout << x << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
int x[1000001];
bool check(int a){

    if(x[a]==0) {
        if (a == 1){
            x[a]=2;
            return false;}

        for (int j = 2; j <= sqrt(a); j++) {
            if (a % j == 0){
                x[a]=2;
                return false;}
        }
        x[a]=1;

        return true;
    }else{
        if(x[a]==1){
            return true;
        }else{
            return false;
        }
    }


}
int main() {
    int a,b,c;
    while(true){
       scanf("%d%d%d",&a,&b,&c);
        if(a==0&b==0&&c==0)break;
        int ans=0;
        int count=0;
        while(true){

           if(check(a)){
               count++;
               if(count==c){
                   ans=a;
                   break;
               }
           }
           a+=b;
        }
        cout<<ans<<endl;




    }

    return 0;
}



Measured memory_bytes: 6960
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <ctime>
#include <set>
#include <sstream>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int i,a,b,t;int ans=0;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b;
	t=b;
	while(t>0)
	{
		i++;
		t/=10;
	}
	while(i--)
	{
		a*=10;
	}
	ans=a+b;
	i=sqrt(ans);
	if(i*i==ans)
	{
		printf("Yes\n");
	}
	else
	printf("No\n");
	return 0;
}



Measured memory_bytes: 256