akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>a;
      while(1){
        if(a<=9){
          ans+=a-1;
          cnt+=a;
          break;
        }
        cnt+=a%10;
        ans+=9;
        a/=10;
      }
      Cout(max(ans,cnt));
     

       
return 0;
}


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

const int maxn=2e5+5;

int n,q;
int p[maxn];
vector<int>g[maxn];

void dfs(int x,int f,int ad)
{
	for(int i=0;i<(int)g[x].size();i++)
	{
		int to=g[x][i];if(to==f)continue;
		dfs(to,x,ad+p[x]);
	}
	p[x]+=ad;
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	cin>>n>>q;
	for(int i=1;i<n;i++)
	{
		int a,b;cin>>a>>b;
		g[a].push_back(b);g[b].push_back(a);
	}
	for(int i=1;i<=q;i++)
	{
		int pp,xx;cin>>pp>>xx;
		p[pp]+=xx;
	}
	
	dfs(1,1,0);
	for(int i=1;i<=n;i++)
		cout<<p[i]<<' ';
	cout<<'\n';
	
	return 0;
}

Measured memory_bytes: 29824
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep(i,n)    for(ll i=0; i<n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll i,j,x,y,a,b,ans;
    cin>>x>>y>>a>>b;
        ans=min(x,y)+min(a,b);
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 3620
#include<cstdio>
#define MAXN 200005
#define LL long long
int n,a[MAXN],pos[MAXN],pr[MAXN],ne[MAXN];
LL ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        pos[a[i]]=i;
    }
    for(int i=0;i<=n+1;i++)
        pr[i]=i-1,ne[i]=i+1;//pr是i的影响区间的左端点(不含) ne是右端点(不含) 注意是不含！！！
    for(int i=n;i>=1;i--)//n的排列 倒着来
    {
        int j=pos[i];
        ans+=1LL*i*(j-pr[j])*(ne[j]-j);//统计区间个数时要注意端点时不含的
        pr[ne[j]]=pr[j];
        ne[pr[j]]=ne[j];
        //核心 用当前这个值依次更新其它数的影响区间 很巧妙
        //由于是倒着来的，那么如果被更新的值要大于当前数，则没有影响，因为被更新的贡献已经算完了
        //所以就假设这些数都小于当前数 而当前数的影响区间内的所有数都要大于它自己，也大于被更新数，所以可以更新区间
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define INF 10000
#define ppp pair<pair<int,int>,pair<int,int>>
#define mp(a,b,c,d) make_pair(make_pair(a,b),make_pair(c,d))
#define x first
#define y second
int main(){
  int h,w,b=0;
  cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;++i)cin>>s[i];
  for(auto str:s)for(auto c:str)if(c=='#')b++;
  vector<vector<int>> cost(h,vector<int>(w,INF));
  vector<vector<int>> heur(h,vector<int>(w));
  for(int i=0;i<h;++i)for(int j=0;j<w;++j)heur[i][j]=(h-1-i)+(w-1-j);
  auto comp=[](ppp a,ppp b){return a.first.first>b.first.first;};
  priority_queue<ppp,vector<ppp>,decltype(comp)> que(comp);
  que.push(mp(1,1,0,0));
  while(!que.empty()){
    ppp p = que.top();
    que.pop();
    if(p.second.x==w-1&&p.second.y==h-1){
      cout<<h*w-b-p.first.second;
      return 0;
    }
    if(0<p.second.x&&s[p.second.y][p.second.x-1]!='#'&&p.first.second+1<cost[p.second.y][p.second.x-1]){
      que.push(mp(p.first.first+heur[p.second.y][p.second.x]+1,p.first.second+1,p.second.x-1,p.second.y));
      cost[p.second.y][p.second.x-1]=p.first.second+1;
    }
    if(p.second.x<w-1&&s[p.second.y][p.second.x+1]!='#'&&p.first.second+1<cost[p.second.y][p.second.x+1]){
      que.push(mp(p.first.first+heur[p.second.y][p.second.x]+1,p.first.second+1,p.second.x+1,p.second.y));
      cost[p.second.y][p.second.x+1]=p.first.second+1;
    }
    if(0<p.second.y&&s[p.second.y-1][p.second.x]!='#'&&p.first.second+1<cost[p.second.y-1][p.second.x]){
      que.push(mp(p.first.first+heur[p.second.y][p.second.x]+1,p.first.second+1,p.second.x,p.second.y-1));
      cost[p.second.y-1][p.second.x]=p.first.second+1;
    }
    if(p.second.y<h-1&&s[p.second.y+1][p.second.x]!='#'&&p.first.second+1<cost[p.second.y+1][p.second.x]){
      que.push(mp(p.first.first+heur[p.second.y][p.second.x]+1,p.first.second+1,p.second.x,p.second.y+1));
      cost[p.second.y+1][p.second.x]=p.first.second+1;
    }
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main ()
{
	int a,b,x;
	cin >> a >> b >> x;

	if (a > x)
	{
		cout << "NO" << endl;
	}
	else if ((x - a) <= b)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
  int N;
  cin >> N;
  string s1,s2;
  cin >> s1 >> s2;

  mint ans=1;
  int flag = 0;
  if(s1.at(0)!=s2.at(0)){
    ans*=6;
    flag=1;
    FOR(i,2,N){
      if(s1.at(i)==s2.at(i)&&flag==0){
        flag=0;
        ans*=2;
      }else if(s1.at(i)==s2.at(i)&&flag==1){
        flag=0;
        ans*=1;
      }else if(s1.at(i)!=s2.at(i)&&flag==0){
        flag=1;
        ans*=2;
        i++;
      }else if(s1.at(i)!=s2.at(i)&&flag==1){
        flag=1;
        ans*=3;
        i++;
      }
    }
  }else{
    ans*=3;
    flag=0;
    FOR(i,1,N){
      if(s1.at(i)==s2.at(i)&&flag==0){
        flag=0;
        ans*=2;
      }else if(s1.at(i)==s2.at(i)&&flag==1){
        flag=0;
        ans*=1;
      }else if(s1.at(i)!=s2.at(i)&&flag==0){
        flag=1;
        ans*=2;
        i++;
      }else if(s1.at(i)!=s2.at(i)&&flag==1){
        flag=1;
        ans*=3;
        i++;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double d = sc.nextDouble();
        int t = sc.nextInt();
        double s = sc.nextDouble();
        if (d / s <= t) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 37484
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 無限大の値
const ll  LINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = 3;
  if(a == b)ans--;
  if(b == c)ans--;
  if(c == a)ans--;
  if((a == b) && (c == b) && (a == c))ans++;
   
  cout << ans << endl;
  return 0;
}

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a == b)
		cout << c << endl;
	else{
		if(a == c)
			cout << b << endl;
		else 
			cout << a << endl;
	}

  return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
constexpr int MAX = 200001;
lint fact[MAX], finv[MAX], inv[MAX];
void cominit() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR(i, 2, MAX){
    fact[i] = fact[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
lint ncr(lint n, lint r, lint mod) {
  if(n < 0 || r < 0 || n-r < 0) return 0;
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint H, W, A, B;
  cin >> H >> W >> A >> B;
  cominit();
  lint ans = 0;
  REP(i, H-A) ans = (ans + ncr(B-1+i, i, MOD) * ncr(H-i+W-B-2, H-1-i, MOD) % MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int now = 1;
  bool triger = false;
  vector<int> button(N,0);
  for(int i=0;i<N;i++){
    cin >> button[i];
  }
  for(int i=0;i<N;i++){
    if(now==2){
      cout << i << endl;
      triger = true;
      break;
    }
    now = button[now-1];
  }
  if(triger == false){
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 640
#include <stdio.h>
#define REP(i, a, b) for(int i = a; i < b; i++)

int main(void)
{
    int n,m;
    char a[100][100];
    char b[100][100];
    int s=0,q=0;
    
    scanf("%d %d",&n,&m);
    
    REP(i, 0, n) {
        scanf("%s",a[i]);
    }
    REP(i, 0, m) {
        scanf("%s",b[i]);
    }
    for(int i = 0; i <= n - m; i++){
        for(int l = 0; l <= n - m; l++){
            s = 0;
            for(int j = 0; j < m; j++){
                for(int k = 0; k < m; k++){
                    if (a[k + i][j + l] == b[k][j]) {
                        s++;
                    }
                }
            }
            if (s == m * m) {
                q=1; break;
            }
        }
    }
    if (q == 1) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
$N=<>;
++$a{$_}for glob<>;
if(%a>2){
	print"No\n"
}else{
	($y,$x)=sort{$b-$a}keys%a;
	if($x&&$y-$x>1){
		print"No\n"
	}else{
		if($N-$a{$x}>=($y-$a{$x})*2 && $a{$x}<=$x){
			print"Yes\n"
		}elsif(!$x&&$y+1==$N){
			print"Yes\n"
		}else{
			print"No\n"
		}
	}
}


Measured memory_bytes: 30208
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
#include<iomanip>
#include<numeric>
using namespace std;

int main(){
  int N,K;cin>>N>>K;
  int ans=K;
  for(int i=0;i<N-1;i++)ans*=K-1;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
import sys
h,w=sys.stdin.readline().split()
h=int(h)
w=int(w)
field=[[] for i in range(h)]
ans=[[0 for i in range(w)]for j in range(h)]
for i in range(h):
    field[i]=sys.stdin.readline()
    for j in range(w):
        if field[i][j]=='#':
            ans[i][j]=-1

for i in range(h):
    for j in range(w):
        if ans[i][j] == -1:
            continue
        if i != 0:
            if ans[i-1][j]==-1:
                ans[i][j]=ans[i][j]+1
            if j != 0:
                if ans[i-1][j-1] == -1:
                    ans[i][j]=ans[i][j]+1
            if j != (w-1):
                if ans[i-1][j+1] == -1:
                    ans[i][j]=ans[i][j]+1
        if j != 0:
            if ans[i][j-1]==-1:
                ans[i][j]=ans[i][j]+1
        if j != (w-1):
            if ans[i][j+1]==-1:
                ans[i][j]=ans[i][j]+1
        if i != (h-1):
            if ans[i+1][j]==-1:
                ans[i][j]=ans[i][j]+1
            if j != 0:
                if ans[i+1][j-1]==-1:
                    ans[i][j]=ans[i][j]+1
            if j!=(w-1):
                if ans[i+1][j+1]==-1:
                    ans[i][j]=ans[i][j]+1

for i in range(h):
    for j in range(w):
        if ans[i][j]==-1:
            print('#',end='')
        else:
            print(ans[i][j],end='')
    print('')



Measured memory_bytes: 3572
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double r = scanner.nextDouble();
        double area = Math.PI * r * r;
        double around = 2 * Math.PI * r;
        System.out.println("" + String.format("%f", area) + " " + around);
    }
}


Measured memory_bytes: 28308
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n, m, a;
    while(cin >> n >> m >> a, n|m|a){
        vector<vector<int> > amida(1001, vector<int>(n+1));
        while(m--){
            int h, p, q;
            cin >> h >> p >> q;
            amida[h][p] = q;
            amida[h][q] = p;
        }
        for(int h=1000; h>0; --h)if(amida[h][a])a = amida[h][a];
        cout << a << '\n';
    }
    return 0;
}

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

using namespace std;


#include <math.h> 


int main() {


	int N;
	cin>> N;

	if (N % 1000 != 0) {
		cout << 1000 - N % 1000;
	}
	else {
		cout << 0;
	}

	

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    const int mod = 1000000007;
    
    vector<vector<long long>> dp(64, vector<long long>(n, 0));
    
    for (int i = 0; i < 64; ++i)
    {
        if (i == 0b001001 || i == 0b100001 || i == 0b000110)
        {
            continue;
        }
        dp[i][0] = 1;
    }
    
    
    for (int i = 1; i < n - 1; ++i)
    {
        for (int j = 0; j < 64; ++j)
        {
            int first = (j >> 4) & 0x3;
            int second = (j >> 2) & 0x3;
            int third = j & 0x3;
            
            for (int k = 0; k < 4; ++k)
            {
                if (k == 1)
                {
                    if ((second == 0 && third == 2) || (second == 2 && third == 0) || (first == 0 && second == 2) || (first == 0 && third == 2))
                    {
                        continue;
                    }
                }
                else if (k == 2)
                {
                    if (second == 0 && third == 1)
                    {
                        continue;
                    }
                }
                int next = ((j & 0xF) << 2) | k;
                dp[next][i] += dp[j][i - 1];
                dp[next][i] %= mod;
            }
        }
    }
    
    long long ret = 0;
    
    for (int i = 0; i < 64; ++i)
    {
        ret += dp[i][n - 3];
        ret %= mod;
    }
    
    cout << ret << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
	long long n;
	cin >> n;
	long long ans = 1;
	while(ans != 0){
		if(ans > n){
			cout << ans/2<< endl;
			return 0;
		}
		ans *= 2;
	}
}            

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

int main() {
  
  int N; cin >> N; int A[N], B[N], C[N - 1]; int sum = 0;
  
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N - 1; i++) cin >> C[i];
  
  for (int i = 0; i < N; i++) {
    sum += B[A[i] - 1];
    if (i != 0 && A[i - 1] + 1 == A[i]) {
      sum += C[A[i - 1] - 1];
    }
  }
  
  cout << sum << endl;
  
}

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

int main()
{
  string a, b;
  int c;
  cin >> a >> b;
  c = atoi((a + b).c_str());

  for (int i = 1; i * i <= c; i++)
  {
    if (i * i == c)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
H,W=map(int, input().split())
S = []

S.append(['.']*(W+2))
for _ in range(H):
    S.append(['.']+list(input())+['.'])
S.append(['.']*(W+2))

for i in range(1,H-1):
    for j in range(1,W-1):
        if S[i][j] == "#" and S[i-1][j] == "." and S[i+1][j] == "." and  S[i][j-1] == "." and  S[i][j+1]== ".":
            print("No")
            sys.exit()

print("Yes")

Measured memory_bytes: 77312
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;

const int maxn=200000+10;

double a[maxn],sum[maxn];

int main()
{
//	freopen("std.in","r",stdin);
	int n,k;cin>>n>>k;
	rep(i,1,n){
		cin>>a[i];
		a[i]=(a[i]+1)/2;
	}
	rep(i,1,n) sum[i]=sum[i-1]+a[i];
	double ans=0;
	rep(i,1,n-k+1){
		ans=max(ans,sum[i+k-1]-sum[i-1]);		
	}
	printf("%.12f\n",ans);
	return 0;
}


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 *
 */
public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerMain1 sc = new FastScannerMain1(System.in);

		try {
			String S = sc.nextLine().trim();
			boolean a = false;

			S = S.replace("hi", "");

			if (S.length() == 0) {
				a = true;
			}

			if (a) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

//高速なScanner
class FastScannerMain1 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain1(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 28884
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  int N,A[100000];
  int ans=0;
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  sort(A,A+N);
  int i=0;
  int cnt=0;
  while(1){
    cnt=0;
    int p=A[i];
    i++;
    cnt++;
    while(A[i]==p){
      i++;
      cnt++;
    }
    if(cnt>p){
      ans+=cnt-p;
    }else if(cnt<p){
      ans+=cnt;
    }
    if(i==N){
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b;
int x, y;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

cin>> a >> b;
pr(a-b+1);  
}

Measured memory_bytes: 3576
A, B, C, D = map(int, input().split())
P = [0 for _ in range(102)]
for p in range(A, B): P[p] += 1
for p in range(C, D): P[p] += 1
count = 0
for p in P:
  if p == 2: count += 1
print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    t = 1;
    for(int i=0;i<t;i++)
    {
        int n,m;
        cin>>n>>m;
        unordered_map <int,int> mp;
        int penalties = 0,correct = 0;;
        for(int i=0;i<m;i++)
        {
            string s;
            int x;
            cin>>x>>s;
            if(s=="WA")
            {
                if(mp[x]!=1000000)
                {
                    mp[x]++;
                }
            }
            if(s=="AC")
            {
                if(mp[x]!=1000000)
                {
                    penalties+=mp[x];
                    correct ++;
                    mp[x] = 1000000;
                }
            }
        }
        cout<<correct<<" "<<penalties;
    }
    return 0;
}


Measured memory_bytes: 7232
#include <bits/stdc++.h>
 using namespace std;
 int main() { 
   string s,t;
   cin>>s>>t;
   if(s.size()+1==t.size()){
     int x=0;
     for(int i=0;i<s.size();i++){
       if(s[i]==t[i]){
         x++;
       }
     }
     if(s.size()==x){
       cout<<"Yes"<<endl;
     }
     else{
       cout<<"No"<<endl;
     }
   }
   else{
     cout<<"No"<<endl; 
   }
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#pragma GCC optimize("02")
#define ll long long
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
class complex{
public:
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline complex & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
int n,k;
double a[200005];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]=(double)(1+a[i])*a[i]/2.0/a[i];
	}
	double sum=0;
	for(int i=1;i<=k;i++) sum+=a[i];
	double ans=sum;
	for(int i=k+1;i<=n;i++){
		sum=sum+a[i]-a[i-k];
		ans=max(ans,sum);
	}
	printf("%.8lf",ans);
	return 0;
}


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

int main() {
    int n, d1, d2, counter = 0;
    bool ans = false;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d1 >> d2;
        if (d1 == d2) counter++;
        else counter = 0;
        if (counter == 3) {
            ans = true;
            break;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#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 VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 10 || b >= 10) {
		cout << -1 << endl;
	}
	else {
		cout << a * b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define cps CLOCKS_PER_SEC
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

const int MAXN = 2005;
pair<int,int> x[MAXN];
int dp[MAXN][MAXN];
int n; 

int rec(int s,int e){
    if(s > e) return 0;
    int &ans = dp[s][e];
    if(ans != -1) return ans;

    int idx = s - 1 + n - (e - 1); 
    ans = max(rec(s+1,e) + abs(x[idx].s - s)*x[idx].f,rec(s,e-1) + abs(x[idx].s - e)*x[idx].f);

    return ans;
}

void solve(){

    cin>>n;
    FOR(i,1,n) {cin>>x[i].f; x[i].s = i;}
    
    sort(x+1,x+n+1); reverse(x+1,x+n+1);

    MINUS(dp);
    cout<<rec(1,n)<<endl;
}
 
signed main(){
 
    FastRead; 

    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 35192
using System;
using System.Linq;

namespace ITP1_3_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] data = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            int num_factor = 0;
            for (int i = data[0]; i <= data[1]; i++)
                if (data[2] % i == 0) num_factor++;
            Console.WriteLine(num_factor);           
        }
    }
}

Measured memory_bytes: 9660
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>=10||b>=10)
	{
		printf("-1\n");
	}
	else
	{
		printf("%d\n",a*b);
	}
	
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

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

func tmp(t []int, N int, M int) [][]int {
	if len(t) == N {
		o := [][]int{}
		return append(o, t)
	}
	o := [][]int{}
	for j := t[len(t)-1]; j <= M; j++ {
		x := tmp(append(t, j), N, M)
		o = append(o, x...)
	}
	return o
}

func main() {
	defer w.Flush()

	sc.Split(bufio.ScanWords)
	N := nextInt()
	M := nextInt()
	Q := nextInt()

	o := [][]int{}
	p := [][]int{}

	for i := 1; i <= M; i++ {
		t := make([]int, 1)
		t[0] = i
		o = append(o, tmp(t, N, M)...)
	}

	u := make([]int, 4)
	for i := 0; i < Q; i++ {
		q := make([]int, 4)
		for j := range q {
			q[j] = nextInt()
		}
		u = make([]int, 4)
		copy(u, q)
		p = append(p, u)
	}

	max := 0
	total := 0

	for oi := range o {
		total = 0
		for pi := range p {
			if (o[oi][p[pi][1]-1] - o[oi][p[pi][0]-1]) == p[pi][2] {
				total = total + p[pi][3]
			}
		}
		if total > max {
			max = total
		}
	}
	fmt.Fprintln(w, max)
}


Measured memory_bytes: 19812
use std::io;

fn main() {
    let inputs = read_line();
    let num = inputs[0];
    let yen = inputs[1];

    let mut done = false;

    let mut x_max = yen / 10000;
    if x_max > num {
        x_max = num
    }

    'top: for i in 0..(x_max+1) {
        let x = x_max - i;
        let y_max = num - x;

        for j in 0..(y_max+1) {
            let y = y_max - j;
            let z = num - x - y;

            let sum_yen = x*10000 + y*5000 + z*1000;
            if yen == sum_yen {
                println!("{} {} {}", x, y, z);
                done = true;
                break 'top;
            }
        }
    }

    if done == false { println!("-1 -1 -1"); }
}

fn read_line() -> Vec<i32> {

    let input_str = get_input();
    let vec: Vec<&str> = input_str.trim().split_whitespace().collect();

    let mut int_vec: Vec<i32> = Vec::new();
    for v in vec {
        int_vec.push(to_i(v));
    }

    int_vec
}

fn to_i(s: &str) -> i32 {
    let input_num: i32 = match s.trim().parse() {
        Ok(num) => num ,
        Err(_)  => panic!("input wrong number."),
    };
    input_num
}

fn get_input() -> String {
    let mut input_str = String::new();
    io::stdin().read_line(&mut input_str)
        .expect("Failed to read line")
        ;
    input_str
}


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

using namespace std;

int main() {
    int t;
    cin>>t;
   if(t==0)
   cout<<1<<endl;
   else if(t==1)
   cout<<0<<endl;
}
// 0 0 1 3 5
// 0 0 2 4 6 

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define all(x) x.begin(),x.end()
#define pb push_back
#define setp(x) setprecision(x)

int main() {
	int n; cin >> n;
	vector<pair<int,int>> xy(n);
	rep(i, 0, n) {
		int x, y; cin >> x >> y;
		xy[i] = make_pair(x, y);
	}

	vector<double> ans;
	vector<int> num(n); rep(i, 0, n) num[i] = i;
	do {
		double sum = 0;
		rep(i, 0, n - 1) {
			int x = xy[num[i]].first - xy[num[i + 1]].first, y = xy[num[i]].second - xy[num[i + 1]].second;
			sum += (double)sqrt(x * x + y * y);
		}
		ans.pb(sum);
	} while (next_permutation(all(num)));

	cout << fixed << setp(10);
  	cout<< accumulate(all(ans), 0.0) / ans.size() << endl;

	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int a[10];
int main()
{
	scanf("%d%d%d%d",&a[1],&a[2],&a[3],&a[4]);
	sort(a+1,a+5);
	if ((a[1]==1) && (a[2]==4) && (a[3]==7) && (a[4]==9)) printf("YES");
		else printf("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint x;

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

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x;
	llint l = x*360/gcd(x, 360);
	cout << l/x << endl;
	
	return 0;
}

Measured memory_bytes: 3632
fn main(){
    let mut x = String::new();
    std::io::stdin().read_line(&mut x).ok();
    let n : usize = x.trim().parse().ok().unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let mut v : Vec<i32> = s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
    let mut ans : i32 = 0;
    loop {
        let mut dividable = true;
        for i in 0..n {
            if v[i] % 2 != 0 {
                dividable = false;
                break;
            }
            v[i] /= 2;
        }
        if !dividable {
            break;
        }
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<ll,ll>
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  ll k,ans;cin>>k;
  ll pos=0, lim=min(k,(ll)s.length());
  while(pos<lim) {
    ans=s[pos]-'0'; pos++;
    if(ans>1) break;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
	int R = stdIn.nextInt();
	int r=0;
	int i=0;
	if(N<10){
	    r=100*(10-N);
	    i=R+r;
	}else{
	    i=R;
	}
	System.out.println(i);
    }
}


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

int main(){
    int n = 0;
    int a = 0;
    int b = 0;
    std::string s;
    int pass = 0;
    int passb = 1;

    std::cin >> n >> a >> b;
    std::cin >> s;

    for(int i = 0; i < n; i++){
        if(s[i] == 'a' && pass < a + b){
            std::cout << "Yes" << std::endl;
            pass++;
        }
        else if(s[i] == 'b' && pass < a + b && passb <= b){
            std::cout << "Yes" << std::endl;
            pass++;
            passb++;
        }
        else{
            std::cout << "No" << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin>>s;
    mp[s]++;
  }
  cout<<"AC x "<<mp["AC"]<<endl;
  cout<<"WA x "<<mp["WA"]<<endl;
  cout<<"TLE x "<<mp["TLE"]<<endl;
  cout<<"RE x "<<mp["RE"]<<endl;
  


  return 0;
}


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

int main(){
	const int dx[4] = {-1, 0, 1, 0};
	const int dy[4] = {0, 1, 0, -1};
	int c[500][500], N;
	while( cin >> N , N ){
		int min_x = 250, max_x = 250, min_y = 250, max_y = 250;
		for(int y = 0 ; y < 500 ; y++ ){
			for(int x = 0 ; x < 500 ; x++ ){
				c[y][x] = ( x == 250 && y == 250 )? 0 : -1;
			}
		}
		for(int i = 0 ; i < N - 1 ; i++ ){
			int n, d;
			cin >> n >> d;
			for(int y = min_y ; y <= max_y ; y++ ){
				for(int x = min_x ; x <= max_x ; x++ ){
					if( c[y][x] == n ){
						int mx = x + dx[d], my = y + dy[d];
						c[my][mx] = i + 1;
						max_x = max(max_x, mx);
						max_y = max(max_y, my);
						min_x = min(min_x, mx);
						min_y = min(min_y, my);
						break;
					}
				}
			}
		}
		cout << (max_x - min_x + 1) << " " << (max_y - min_y + 1) << endl;
	}
}

Measured memory_bytes: 2132
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
#include <unordered_map>

int main(void){
	int64_t l, r;
	std::cin >> l >> r;
	int64_t ans = 2018;
	for(int64_t i=l;i<r && i < l + 2019;i++){
		for(int64_t j=i+1;j<=r && j <= i + 2019;j++){
			ans = std::min<int64_t>(((i % 2019) * (j % 2019)) % 2019, ans);
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cmath>
#define N 200005
using namespace std;
int Rank,n,l,t;
int x[N],w[N],e[N];
int main()
{
	scanf("%d%d%d",&n,&l,&t);
	Rank=0;
	for (int i=0;i<n;i++)
	{
		scanf("%d%d",&x[i],&w[i]);
		e[i]=x[i]+((w[i]==1)?1:-1)*t;
		e[i]%=l;
		e[i]=(e[i]+l)%l;
		if (w[i]==1)
			Rank+=(x[i]+t)/l; else
			Rank-=(l-x[i]-1+t)/l;
		Rank=(Rank%n+n)%n;
	}
	sort(e,e+n);
	for (int i=Rank;i<n;i++)
		printf("%d\n",e[i]);
	for (int i=0;i<Rank;i++)
		printf("%d\n",e[i]);
	return 0;
}

Measured memory_bytes: 4908
/*
ID: amagica1
TASK: ariprog
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define NINF -INF
#define mp make_pair
#define boost() cin.tie(0); cin.sync_with_stdio(0)
#define For(i, a, b) for(int i=a; i<b; i++)
#define FOR(i, a, b) for(int i=a; i<=b; i++)
#define Rev(i, a, b) for(int i=a; i>b; i--)
#define REV(i, a, b) for(int i=a; i>=b; i--)
typedef long long ll;
typedef long double ld;
typedef int64_t l;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int MAXN = 100005;
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
int a, b, c;
int main() {
    //-----------FILE------------//
    // freopen("ariprog.in", "r", stdin);
    // freopen("ariprog.out", "w", stdout);
    //----------------------------//
    int N, K; string s;
    cin >> N >> s >> K;
    char key = s[K-1];
    string res="";
    for(int i=0; i<N; i++) {
        if(s[i] != key) res += "*";
        else res += s[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
        int jun[114514],n,ans=0,i;
        scanf("%d",&n);
        for(i=0;i<n;i++){
            scanf("%d",&jun[i]);
        }
        for(i=0;i<n;i++){
            if(jun[i]==(i+1) && i!=n-1){
                swap(jun[i],jun[i+1]);
                ans ++;
            }
            if(jun[i]==(i+1) && i==n-1){
                ans ++;
            }
        }
        printf("%d\n",ans);
    }

Measured memory_bytes: 640
def main():
    n = int(input())
    ans = 1
    arr = list(map(int, input().split()))
    for i in range(1, n):
        for j in range(i):
            if arr[j] > arr[i]:
                break
            if j == i - 1:
                ans += 1
    print(ans)
    return 0
main()

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int N, M, X, Y;
	int x[100], y[100];
	scanf("%d%d%d%d", &N, &M,&X,&Y);
	int max = X, min = Y;
	for (int i = 0; i < N; i++) {
		scanf("%d", &x[i]);
		if (x[i] >= max) {
			max = x[i];
		}
	}
	for (int i = 0; i < M; i++) {
		scanf("%d", &y[i]);
		if (y[i] <= min) {
			min = y[i];
		}
	}
	//printf("max=%d min=%d ", max, min);
	if (max < min) {
		printf("No War");
	}
	else if (max >= min) {
		printf("War");
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	map<char, int> mp;
	rep(i,s.size()){
		mp[s[i]]++;
	}
	for(auto p : mp){
		if(p.second%2 == 1){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1<<29)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

class Edge{
public:
  int from, to, rev;
  Int cost, lim;
  Edge(int from, int to, Int cost, int lim = -1, Int rev = -1):
    from(from),to(to),cost(cost),lim(lim),rev(rev){}
};


class Graph{
public:
  int n;
  int m;
  vector<vector<Edge>> edge;
  Graph(int n = 0):n(n),m(0){
    edge = vector<vector<Edge>>(n);
  }
  void add_edge(int from, int to, int cost = 1, int lim = -1)
  {
    if(lim == -1){
      edge[from].push_back(Edge(from, to, cost));
      return;
    }
    edge[from].push_back(Edge(from, to, cost, lim, edge[to].size()));
    edge[to].push_back(Edge(to, from, -cost, 0, edge[from].size() - 1));
  }
};

int n, m, s, t;
Graph g;
vector<int> come(108000);
vector<int> ongo(108000);
vector<int> cnt(108000);
vector<P> ans;
void dfs(int x, int last = - 1){
  come[x] = true;
  ongo[x] = true;
  for(auto e:g.edge[x]){
    if(e.to == last)continue;
    if(ongo[e.to]){
      cnt[x]++;
      cnt[e.to]--;
    }
    if(!come[e.to]){
      dfs(e.to, x);
      cnt[x] += cnt[e.to];
    }
  }
  ongo[x] = false;
  if(last != -1 && cnt[x] == 0){
    ans.push_back(P(min(x, last), max(x, last)));
  }
}

int main(){
  cin >> n >> m;
  g = Graph(n);
  for(int i = 0;i < m;i++){
    cin >> s >> t;
    g.add_edge(s, t);
    g.add_edge(t, s);
  }
  dfs(0);
  sort(ans.begin(), ans.end());
  for(auto p:ans)cout << p.first << " " << p.second << endl;
  return 0;
}


Measured memory_bytes: 9880
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a<c&&b>c||a>c&&b<c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	set<int> nums;
	REP( i, 0, 28 )
	{
		int tmp;
		cin >> tmp;
		nums.insert( tmp );
	}
	REP( i, 1, 31 )
	{
		if ( !EXIST( nums, i ) )
		{
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
const int maxn = 251005;

int a[maxn],x[maxn],ord[maxn],pos,n;
bool comp(int u,int v) {return x[u]<x[v];}
int main()
{
	#ifdef Amberframe
		freopen("agc008d.in","r",stdin);
		freopen("agc008d.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&x[i]),a[x[i]]=i,ord[i]=i;
	sort(ord+1,ord+n+1,comp);pos=1;
	for (int i=1;i<=n;i++) {
		int t=ord[i];
		for (int j=1;j<t;j++) {
			while (a[pos]) ++pos;
			a[pos]=t;++pos;
		}
		if (pos>x[t]) {puts("No");return 0;}
	}
	for (int i=1;i<=n;i++) {
		int t=ord[i];
		for (int j=n;j>t;j--) {
			while (a[pos]) ++pos;
			if (pos<x[t]) {puts("No");return 0;}
			a[pos]=t;++pos;
		}
	}
	puts("Yes");
	for (int i=1;i<=n*n;i++)
		printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int a[200005],c[200005],n,ans1,ans2,k,maxx=0;
bool cheak(int x)
{
	int ans1=1e8,ans0=1e8;
	for(int i=1;i<=n*2-1;i++) 
	 if(a[i]<x) c[i]=0;else c[i]=1;
    for(int i=1;i<=n*2-2;i++) 
    if(c[i]==c[i+1])
	{
     	 if(c[i])ans1=min(ans1,min(abs(n-i),abs(n-(i+1))));
     	 else ans0=min(ans0,min(abs(n-i),abs(n-(i+1))));
    }
    if(ans1==1e8&&ans0==1e8) return (n&1)==c[n];
	else return ans1<ans0; 
}
int main()
{
	//freopen("pyramid.in","r",stdin);
	//freopen("pyramid.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n*2-1;i++)cin>>a[i];
   int l=-1,r=1e8;
   while(r-l>1)
   {
   	int mid=l+r>>1;
   	if(cheak(mid)) l=mid;
   	else r=mid;
   }
   cout<<l;
}

Measured memory_bytes: 1792