akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

//https://www.slideshare.net/hcpc_hokudai/topological-sort-69581002
//コード例は24ページ


vector<int> tsort_kahn(const vector<vector<int>>& g) {
	const int V = g.size();
	vector<int> indeg(V, 0);
	stack<int> S;

	for (auto& u_out_edges : g) {
		for (auto& v : u_out_edges) {
			indeg[v]++;
		}
	}

	for (int i = 0; i < V; i++) {
		if (indeg[i] == 0) {
			S.push(i);
		}
	}

	vector <int>ans;
	while (S.size() > 0) {
		int u = S.top(); S.pop();
		ans.emplace_back(u);
		for (auto& v : g[u]) {
			indeg[v]--;
			if (indeg[v] == 0)S.push(v);
		}
	}
	return ans;
}

int main() {
	int v, e;
	cin >> v >> e;
	vector<vector<int>>vv(v);
	REP(i, e) {
		int s, t;
		cin >> s >> t;
		vv[s].emplace_back(t);
	}
	vector<int> ans = tsort_kahn(vv);
	REP(i, v) {
		cout << ans[i] << endl;
	}
	//system("pause");
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {

    static final int MOD=1000000007;


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n%2==1) System.out.println(n/2+1);
        else System.out.println(n/2);

    }
}




Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    ll ans = 0;
    int n = s.size();
    reverse(whole(s));
    rep(i, n) {
        ll x = s[i] - '0';
        ll t = 1;
        rep(j, i+1) {
            ll num = 1LL<<(n-1-j);
            if (j!=i) num = 1LL<<(n-2-j);
            ans += x*t*num;
            t *= 10LL;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  alias T=long;
  const inf=1e9.to!(T);
  struct Edge{int to; T cost;}
  int n; rd(n);
  auto g=new Edge[][](n);
  foreach(i; 0..n){
    auto args=readln.split.to!(int[]);
    foreach(j; 0..args[1]){
      g[i]~=Edge(args[j*2+2], args[j*2+3]);
    }
  }

  T[] dijkstra(Edge[][] g, int s){
    auto d=new T[](n);
    fill(d, inf);
    struct P{int v; T d;}
    import std.container;
    auto Q=new RedBlackTree!(P, "a.d<b.d", true);
    Q.insert(P(s, 0)); d[s]=0;
    while(Q.empty==false){
      auto cur=Q.front; Q.removeFront;
      foreach(e; g[cur.v]){
        if(d[e.to]<=d[cur.v]+e.cost) continue;
        d[e.to]=d[cur.v]+e.cost;
        Q.insert(P(e.to, d[e.to]));
      }
    }
    return d;
  }

  auto d=dijkstra(g, 0);
  foreach(i; 0..n) writeln(i, " ", d[i]);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}



Measured memory_bytes: 21392
using System;


namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine(); 
            int count = 0;
            
          for(int i=0; i<S.Length; i++)
          {
             if(S[i]!=T[i])
                count++;
          }
          
          Console.Write(count);
        }
    }
}


Measured memory_bytes: 18152
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, K = mi()

flag = [0]*N

for i in range(K):
    n = ii()
    A = li()
    for num in A:
        flag[num-1] += 1

cnt = 0
for i in flag:
    if not i:
        cnt += 1

print(cnt)

Measured memory_bytes: 9232
n=int(input())
s=input()

#末尾と1番目を羊または狼と仮定して貪欲。4パターン
import itertools
for x,y in itertools.product(["S","W"], repeat=2):
  ans=[None]*n
  ans[-1]=x
  ans[0]=y
  flag=1
  for i in range(n): #各発言から次の動物を特定する。末尾らへんにきたら矛盾を検証
    if 0<=i<=n-3: #このifに関して間違ってないはず…
      if ans[i]=="S":
        if s[i]=="o":
          ans[i+1]=ans[i-1] #同じと言ってる場合は同じのため、次の番号は2つ前と同じ動物。
        else: #そうじゃない場合は、次の番号は2つ前と違う動物。
          if ans[i-1]=="W":
            ans[i+1]="S"
          else:
            ans[i+1]="W"
      #今の番号が狼の場合は上の全部逆にする
      if ans[i]=="W": 
        if s[i]=="x":
          ans[i+1]=ans[i-1]
        else:
          if ans[i-1]=="W":
            ans[i+1]="S" 
          else:
            ans[i+1]="W"
    else: #iがn-2とn-1の場合は、先頭と末尾の羊を指定するため、矛盾を確認しないといけない。こっからが肝だよ
      if ans[i]=="S":
        if s[i]=="o":
          if ans[(i+1)%n]!=ans[i-1]:
            flag=0
        else:
          if ans[(i+1)%n]==ans[i-1]:
            flag=0
      #今の番号が狼の場合は上の全部逆にする
      if ans[i]=="W":
        if s[i]=="x":
          if ans[(i+1)%n]!=ans[i-1]:
            flag=0
        else:
          if ans[(i+1)%n]==ans[i-1]:
            flag=0
  if flag==1:
    print("".join(ans))
    exit()

#どんなケースでも矛盾するとループを抜けてしまう
print(-1)

Measured memory_bytes: 5076
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int H,W;cin>>H>>W;
    int Ch,Cw;cin>>Ch>>Cw;Ch--;Cw--;
    int Dh,Dw;cin>>Dh>>Dw;Dh--;Dw--;
    vector<vector<bool>> S(H,vector<bool>(W));
    vector<vector<int>> dist(H,vector<int>(W));
    for(int i=0;i<H;i++) for(int j=0;j<W;j++) dist[i][j] = 1e9;
    dist[Ch][Cw] = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            char c;cin>>c;
            if(c=='.') S[i][j] = true;
        }
    }
    const int di[] = {0,0,-1,1};
    const int dj[] = {-1,1,0,0};
    const int magic_di[] = {-2,-1,0,1,2};
    const int magic_dj[] = {-2,-1,0,1,2};
    deque<pair<int,int>> que;
    que.push_back({Ch,Cw});
    while(que.size()){
        auto p = que.front();que.pop_front();
        int i = p.first, j = p.second;
        for(int k=0;k<4;k++){
            int i2 = i + di[k],j2 = j + dj[k];
            if(i2<0||i2>=H||j2<0||j2>=W) continue;
            if(!S[i2][j2]) continue;
            if(dist[i2][j2]>dist[i][j]){
                dist[i2][j2] = dist[i][j];
                que.push_front({i2,j2});
            }
        }
        for(int k=0;k<5;k++){
            for(int l=0;l<5;l++){
                int i2 = i + magic_di[k],j2 = j + magic_dj[l];
                bool skip = 0; 
                for(int m=0;m<4;m++) if(magic_di[k]==di[m]&&magic_dj[l]==dj[m]) skip = true;
                if(skip||i2<0||i2>=H||j2<0||j2>=W) continue;
                if(!S[i2][j2]) continue;
                int d2 = dist[i][j] + 1;
                if(dist[i2][j2]>d2){
                    dist[i2][j2] = d2;
                    que.push_back({i2,j2});
                }
            }
        }
    }
    if(dist[Dh][Dw]!=1e9) cout << dist[Dh][Dw] << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 7840
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	vector<int> a;
	a.resize(n + 1);
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	map<int, int> mp;
	long long ans = 0;
	++mp[0];
	for(int i = 1; i <= n; ++i) {
		a[i] = (a[i] + a[i - 1]) % k;
		int t = ((a[i] - i) % k + k) % k;
		if(i - k >= 0) {
			--mp[((a[i - k] - (i - k)) % k + k) % k];
		}
		ans += mp[t];
		++mp[t];
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 10368
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define N 3010
#define mo 1000000007
using namespace std;
int n,m,f[N][N][2],ans=0;
int main()
{
	scanf("%d%d",&n,&m);
	fo(i,1,n) f[0][i][0]=1;
	f[0][0][1]=1;
	fo(i,0,m-1)
	{
		fo(j,0,n)
		{
			fo(k,0,1)
			{
				if(j>0) (f[i+1][j-1][k|(j==1)]+=f[i][j][k])%=mo;
				if(j>0) (f[i+1][j][k|(j==1)]+=f[i][j][k])%=mo;
				if(j<n) (f[i+1][j][k]+=f[i][j][k])%=mo;
				if(j<n) (f[i+1][j+1][k]+=f[i][j][k])%=mo;
			}
		}
	}
	fo(i,0,n) (ans+=f[m][i][1])%=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 70784
#include <cstdio>
#include <algorithm>

long long dp[100000][3];
int main()
{
  int n, k;
  long long R, S, P;
  char t[100001];
  scanf("%d%d %lld%lld%lld %s", &n, &k, &R, &S, &P, t);

  const char hand[3] = {'r', 's', 'p'};
  const long long point[3] = {R, S, P};
  long long ans = 0;
  for (int i = 0; i < k; ++i)
  {
    for (int a = 0; a < 3; ++a)
    {
      dp[i][a] = t[i] == hand[(a + 1) % 3] ? point[a] : 0;
    }
    int j;
    for (j = i + k; j < n; j += k)
    {
      for (int a = 0; a < 3; ++a)for (int last = 0; last < 3; ++last)
      {
        if (a == last) continue;
        dp[j][a] = std::max(dp[j][a], dp[j - k][last] + (t[j] == hand[(a + 1) % 3] ? point[a] : 0));
      }
    }
    ans += std::max(std::max(dp[j - k][0], dp[j - k][1]), dp[j - k][2]);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
    int n,t;
    cin >> n >> t;
    int ans = 1001;
    for (int i =0; i<n; i++)
    {
        int x,y;
        cin >> x >> y;
        if (y<=t && x<ans) ans = x;
    }
    if (ans == 1001)
    {
        cout << "TLE";
        return 0;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, i;
    char s[100];

    scanf("%d", &n);

    for(i=0; i<n; i++)
        scanf("%c", &s[i]);
    

    for(i=0; i<n; i++){
        if(s[i] == 'Y'){
            printf("Four\n");
            return 0;
        }
    }

    printf("Three\n");

    return 0;
}

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

using namespace std;
using namespace std::chrono;
#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

ll big = 1000000007ll;
ll big2 = 1000000009ll;

ll n,m,T,k,q;


ll fac(ll i){
ll t = 1;
for(ll c1 = 0; c1 < i; c1++){
    t *= (c1+1); t %= big;
}
return t;
}


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e;

    cin >> n >> m;

    if(abs(n-m) >= 2){
        cout << "0\n";
    }
    else{
        cout << ((1+(n==m))*fac(n)*fac(m))%big << "\n";
    }

    return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

S = input()
N = len(S)

if S[0] != 'A':
	print('WA')
else:
	S = S.replace('A','a')
	if not 'C' in S[2:N-1]:
		print('WA')
	else:
		S = S.replace('C','c',1)
		for s in S:
			if s in AtoZ:
				print('WA')
				sys.exit()
		print('AC')

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

int main(){
    long long int n,num;
    long long int cont = 1;
    long long int ladrillos_rotos = 0;
    cin >> n;
    long long int limit = n-1;
    for (int i=1;i<=n;i++){
        cin >> num;
        if(num==cont){
            cont++;
        }else{
            ladrillos_rotos++;
        }
    }
    if(ladrillos_rotos<=limit){
        cout << ladrillos_rotos << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

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

{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    int f = sizeof(a)/sizeof(a[0]);

    sort(a, a+f);

    for(int i=0;i<n;i++)
    {
        if(a[n-1]==b[i])
            cout<<a[n-2]<<endl;
        else
            cout<<a[n-1]<<endl;
    }



    return 0;
}


Measured memory_bytes: 3200
import math
# K = int(input())
A, B, H, M = [int(_) for _ in input().split()]
a_rad = ((H * 60 + M) / 720) * 2 * math.pi
b_rad = (M / 60) * 2 * math.pi
a_x = A * math.cos(a_rad)
a_y = A * math.sin(a_rad)
b_x = B * math.cos(b_rad)
b_y = B * math.sin(b_rad)
print(math.sqrt((a_x-b_x)**2 + (a_y - b_y)**2))


Measured memory_bytes: 9508
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>A>>B;
    ll l = A, r = B;
    rep(i, N - 1){
        cin>>A>>B;
        ll mul = 1 + max((l - 1) / A, (r - 1) / B);
        l = A * mul;
        r = B * mul;
    }
    cout<<l + r<<endl;
}

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

class Main {

    public static void main( String[] args ) {
        try {
	      	BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
			int n = Integer.parseInt( kb.readLine( ) );        
			ArrayDeque<Integer> dq = new ArrayDeque<Integer>( );
            String[] str;
            for( int i=0; i<n; i++ ) {
                str = kb.readLine().split( " " );
                if( "insert".equals( str[0] ) ) {
                    dq.addFirst( Integer.parseInt( str[1] ) );
                } else if( "deleteFirst".equals( str[0] ) ) {
                    dq.removeFirst( );
                } else if( "deleteLast".equals( str[0] ) ) {
                    dq.removeLast(  );
                } else if( "delete".equals( str[0] ) ) {
                    dq.removeFirstOccurrence( Integer.parseInt( str[1] ) );
                }
            }
        	
			StringBuilder output = new  StringBuilder( );
            for( Iterator itr = dq.iterator( ); itr.hasNext( ); ) {
                output.append( itr.next( ) ).append( " " );
            }
            output.deleteCharAt( output.lastIndexOf( " " ) );
            System.out.println( output );
            
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}

Measured memory_bytes: 560888
a, b, x = map(int, input().split())

p = 0
y = int(b//x) + 1

i = 1
#for i in range(1,y):
while x*i <= b:
    if a <= x*i:
        p = x*i
        break
    i += 1

if p != 0:
    t = b-p
    s = t//x
    ans = s + 1
    if a == 0:
        ans += 1
    print(ans)
elif a == 0:
    print(1)
else:
    print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  long a,b;
  cin>>a>>b;
  for(long i=a>b?b:a;i<(a>b?a:b);i++)
  {
    if(abs(a-i)==abs(b-i))
    {
      cout<<i;
      return 0;
    }
  }
  cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int num[3];
    for(int i=0;i<3;i++){
        scanf("%d",&num[i]);
    }
    if(num[0]<=num[2]&&num[2]<=num[1]){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
S = str(input())

flg = False

if S=="keyence":
    print("YES")
else:
    for i in range(len(S)+1):
        
        for j in range(i,len(S)+1):
            
            temp = S[0:i]+S[j:]
            
            if temp =="keyence":
                flg = True
                break
                
        if flg == True:
            break
        
    if flg == True:
        print("YES")
    else:
        print("NO")
            

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define ll long long
#define ii pair<string,int>ii;

string IntToStr(int tmp){
    ostringstream out;
    out << tmp;
    return out.str();
}

int main()
{

    int n,k;
    cin>>n>>k;
    int a[n+7];
    for(int i=0; i<n; i++)
        cin>>a[i];
    sort(a,a+n);
    int x=n-k;
    int sum=0;
    for(int i=n-1; i>=x; i--)
        sum+=a[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    if (N == 1) {
        if (A != B)
            cout << "0\n";
        else
            cout << "1\n";
        return 0;
    }

    if (A > B) {
        cout << "0\n";
        return 0;
    }

    cout << 1LL * (N - 2) * (B - A) + 1 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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


	long long n, i, j, k;
	string ans = "";

	cin >> n;

	do {
		n--;
		ans = (char)('a' + (n % 26)) + ans;
		n = n / 26;
	} while (n > 0);

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3104
/**
 * Created By: Anonyman637
 * Created On: 2/10/2020 1:56:43 AM
 */

/* =============================================================================
   ================================== HEADERS ==================================
   ========================================================================== */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

typedef char i8;
typedef short i16;
typedef int i32;
typedef long long i64;

typedef unsigned char ui8;
typedef unsigned short ui16;
typedef unsigned int ui32;
typedef unsigned long long ui64;

using namespace std;

/* =============================================================================
   ================================== MACROS ===================================
   ========================================================================== */


/* =============================================================================
   ================================== GLOBALS ==================================
   ========================================================================== */


/* =============================================================================
   ================================= FUNCTIONS =================================
   ========================================================================== */


int main() {
        
        i32 h, a;
        scanf("%d %d", &h, &a);
        h = (h + a - 1) / a;

        printf("%d", h);
                
        return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

int dp[101][4][4][4];

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

    int N;
    cin >> N;

    dp[0][3][3][3] = 1;
    REP(s, N) {
        REP(i, 4) {
            REP(j, 4) {
                REP(k, 4) {
                    if (dp[s][i][j][k] == 0)
                        continue;
                    REP(a, 4) {
                        if (a == 2 && i == 1 && j == 0)
                            continue;
                        if (a == 2 && i == 0 && j == 1)
                            continue;
                        if (a == 1 && i == 2 && j == 0)
                            continue;
                        if (a == 2 && i == 1 && k == 0)
                            continue;
                        if (a == 2 && j == 1 && k == 0)
                            continue;

                        dp[s + 1][a][i][j] += dp[s][i][j][k];
                        MOD(dp[s + 1][a][i][j]);
                    }
                }
            }
        }
    }

    int ans = 0;
    REP(i, 4) {
        REP(j, 4) {
            REP(k, 4) {
                ans += dp[N][i][j][k];
                MOD(ans);
            }
        }
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int cnt = 1, max = h[0];
	for (int i = 1; i < n; i++) {
		if (max <= h[i]) {
			cnt++;
		}
		if (h[i] > max) {
			max = h[i];
		}
	}
	cout << cnt << '\n';
	
	return 0;
}


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

using namespace std;

int main(){
    int N;
    cin>>N;
    std::vector<string>W(N);
    for (int i = 0 ; i < N ; i++) {
        cin>>W[i];
    }
    
    bool ans = true;
    std::vector<string>map;
    map.push_back(W[0]);
    for (int i = 1 ; i < N ; i++) {
        if (W[i].substr(0, 1) != W[i-1].substr(W[i-1].size()-1, 1)) {
            ans = false;
            break;
        }
        for (int j = 0 ; j < map.size() ; j++) {
            if (map[j] == W[i]) {
                ans = false;
                break;
            }
        }
        map.push_back(W[i]);
        if (! ans) break;
    }

    cout<<(ans ? "Yes" : "No" )<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef tuple<int, int, int> T;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n;

map<ll, int> prime_factor(ll n) {
    map<ll, int> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int solve() {
    if (n == 1) return 0;
    map<ll, int> m = prime_factor(n);
    int res = 0;
    for (auto v : m) {
        int i = 1;
        int k = v.second;
        while (i <= k) {
            k -= i;
            i++;
            res++;
        }
    }
    return res;
}

void input() {
    cin >> n;
}

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

    input();
    cout << solve() << endl;
}


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

using namespace std;
const int MAX = 200000 + 1;

int v[MAX] = {0};
vector<int> g[MAX];

void dfs(int c,int p = -1)
{
    for (int u :g[c])
    {
        if(u==p)
            continue;
        v[u] += v[c];
        dfs(u, c);
    }
}

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

    vector<bool> visited(n,false);

    int a, b;
    for (int i = 0; i < n - 1; i++)
    {
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int p, x;
    for (int i = 0; i < q; i++)
    {
        cin >> p >> x;
        p--;
        v[p] += x;
    }
    dfs(0);
    for (int i = 0; i < n; i++)
    {
        cout << v[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 23552
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int a, b, c;
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();

		if (b - a == c - b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

		scan.close();
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27108
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt

    var i = 0
    while (4 * i <= N) {
      if ((N - 4 * i) % 7 == 0) {
        return "Yes"
      }
      i += 1
    }
    "No"
  }
}


Measured memory_bytes: 25420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;


int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = min(b, d) - max(a, c);
  if (ans < 0) ans = 0;
  cout << ans << endl;
} 

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

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, int> pli;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int l[100010], r[100010];

int main() {
	cin >> N;
	rep(i, N) {
		cin >> l[i] >> r[i];
	}
	++N;
	sort(l, l + N);
	sort(r, r + N);
	reverse(l, l + N);

	ll s = 0, ret;
	rep(i, N) {
		s += (l[i] - r[i]) * 2;
		ret = max(ret, s);
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;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(x) push_back(x)
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
#define MOD (int)(1e9)+7
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};
    
int32_t main(){
    int n, i;
    cin >> n >> i;
    cout << n-i+1 << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int M, T, P, R;

int main()
{
	cin.sync_with_stdio(false);
	while (cin >> M >> T >> P >> R, M)
	{
		vi ac(T); vi team_penalty(T);
		vector<vi> penalty(T, vi(P));
		REP(i, R)
		{
			int m, t, p, j;
			cin >> m >> t >> p >> j;
			t--; p--;
			if (j == 0)
			{
				ac[t]++;
				penalty[t][p] += m;
				team_penalty[t] += penalty[t][p];
			}
			else
			{
				penalty[t][p] += 20;
			}
		}
		vector<tuple<int, int, int>> order; //ac, penalty, team
		REP(i, T)
		{
			order.emplace_back(-ac[i], team_penalty[i], -i-1);
		}
		sort(ALL(order));
		cout << -get<2>(order[0]);
		FOR(i, 1, T)
		{
			if (get<0>(order[i - 1]) == get<0>(order[i]) && get<1>(order[i - 1]) == get<1>(order[i]))
			{
				cout << '=';
			}
			else cout << ',';
			cout << -get<2>(order[i]);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    vector<vector<vector<vector<ll> > > >dp(n,vector<vector<vector<ll> > >(4,vector<vector<ll> >(4,vector<ll>(4))));
    rep(j,4){
        rep(k,4){
            rep(l,4){
                if(j==0&&k==3&&l==2)continue;
                if(j==3&&k==0&&l==2)continue;
                if(j==0&&k==2&&l==3)continue;
                dp[2][j][k][l]=1;
            }
        }
    }
    REP(i,3,n){
        rep(j,4){
            rep(k,4){
                rep(l,4){
                    if(l==0||l==1){
                        ll sum=0;
                        rep(x,4){
                            sum+=dp[i-1][x][j][k];
                            sum%=inf;
                        }
                        dp[i][j][k][l]=sum;
                    }else if(l==2){
                        if(j==0&&k==3)continue;
                        else if(j==3&&k==0)continue;
                        else{
                            ll sum=0;
                            rep(x,4){
                                if(j==3&&x==0)continue;
                                if(k==3&&x==0)continue;
                                sum+=dp[i-1][x][j][k];
                                sum%=inf;
                            }
                            dp[i][j][k][l]=sum;
                        }
                    }else if(l==3){
                        if(j==0&&k==2)continue;
                        ll sum=0;
                        rep(x,4){
                            sum+=dp[i-1][x][j][k];
                            sum%=inf;
                        }
                        dp[i][j][k][l]=sum;
                    }
                }
            }
        }
    }
    ll ans=0;
    rep(j,4){
        rep(k,4){
            rep(l,4){
                ans+=dp[n-1][j][k][l];
                ans%=inf;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

class UnionFind {
    public:
    vector<int> rank, p;

    UnionFind() {}

    UnionFind(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        rep(i, size) {
            makeSet(i);
        }
    }

    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }

    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
        if(rank[x] > rank[y]) {
            p[y] = x;
        }
        else {
            p[x] = y;
            if(rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }

    int findSet(int x) {
        if(x != p[x]) {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};
 
int main() {
    int n, a, b, q;
    int t;

    cin >> n >> q;

    UnionFind Uni = UnionFind(n);

    rep(i, q) {
        cin >> t >> a >> b;
        if(t == 0) {
            Uni.unite(a, b);
        }
        else if(t == 1) {
            if(Uni.same(a, b)) {
                cout << 1 << endl;
            }
            else {
                cout << 0 << endl;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3196
#include <stdio.h>

int main(void) {
	int N,i;
	unsigned char message[200];
	int swap_a[100];
	int swap_b[100];
	int sabun;
	char temp;
	while(1) {
		scanf("%d",&N);
		if(N==0)break;
		scanf("%s",message);
		for(i=0;i<N;i++) {
			scanf("%d%d",&swap_a[i],&swap_b[i]);
			swap_a[i]--;swap_b[i]--;
		}
		for(i=N-1;i>=0;i--) {
			sabun=(swap_b[i]-swap_a[i])%26;
			message[swap_a[i]]+=sabun;
			message[swap_b[i]]+=sabun;
			if(message[swap_a[i]]>'z')message[swap_a[i]]-=26;
			if(message[swap_b[i]]>'z')message[swap_b[i]]-=26;
			temp=message[swap_a[i]];
			message[swap_a[i]]=message[swap_b[i]];
			message[swap_b[i]]=temp;
		}
		puts(message);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)


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

    string s;
    cin >> s;
    int n = s.length();
    int m = 2019;
    
    vector<ll> dp(m, 0);
    dp[0] = 1;
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        int num = s[i] - '0';
        vector<ll> nextdp(m, 0);
        for(int j = 0; j < m; ++j){
            if(!dp[j])  continue;
            int nj = (j * 10 + num) % m;
            nextdp[nj] += dp[j];
        }
        swap(dp, nextdp);
        ans += dp[0]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3744
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  input()
  string = input().strip()

  count = [0] * 26

  for c in string:
    count[ord(c) - 97] += 1

  table = count[:]
  value = sum(count)

  for _ in range(len(count) - 1):
    for i in range(len(count)):
      table[i] = count[i] * sum(table[i + 1:])

    value = (value + sum(table)) % int(1.0e+9 + 7)

  print(value, flush=True)


if __name__ == '__main__':
  main()



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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    unordered_map<int, int> b;
    int a;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        ++b[a];
    }
    int ans = 0;
    for(auto x:b) {
        if(x.first == x.second) continue;
        else if(x.first - x.second < 0) ans += x.second - x.first;
        else ans += x.second;
    }
    cout << ans << endl;
    
}


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

int64_t f(int64_t n){
    return n*(n-1)/2;
}

int main(){
    int n;
    cin>>n;
    
    vector<int64_t> a(n);
    rep(i,n)cin>>a[i], a[i]--;
    
    vector<int64_t> m(n,0);
    rep(i,n)m[a[i]]++;
    
    int64_t ans = 0;
    rep(i,n)ans += f(m[i]);
    
    for(int i=0; i<n; i++){
        cout << ans - m[a[i]] + 1  << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5760
n,k,q=map(int,input().split())
a=[]

for i in range(q):
    a.append(int(input()))

kai=[0]*n
for i in range(q):
    kai[a[i]-1]+=1

go=q-k+1

for i in range(n):
    if(kai[i]>=go):
        print("Yes")
    else:
        print("No")

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    long n;

    cin >> n;

    vector<pair<ll, ll> > v;
    pair<ll, ll> prev, cur;
    ll ans;
    ll a, b;

    long i;

    for (i = 0; i < n; i++) {
        cin >> a >> b;

        v.pb(mp(a, b));
    }

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

    prev = v[0];

    ans = prev.first;

    for (i = 1; i < n; i++) {
        cur = v[i];

        ans += min(cur.first - prev.first, prev.second - cur.second);

        prev = cur;
    }

    if (prev.second != 0) ans += prev.second;

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 2420
interface ITenbodai {
  id: number;
  height: number;
  otherPlaceHeight: number[];
}
const mainCalc = (input: string) => {
  inputParser(input)
}

const inputParser = (input: string) => {
  const tmp = input.split('\n');
  const [nStr, mStr] = tmp[0].split(' ')
  tmp.shift();
  const tenbodai = tmp[0].split(' ').map((v, i) => {
    return {
      h: +v,
      th: [0],
      num: 0,
    }
  });
  tmp.shift();
  tmp.forEach(value => {
    const [a, b] = value.split(' ')
    if (a == null || b == null) return;
    const p = tenbodai[+a - 1]
    const n = tenbodai[+b - 1]
    if (p == null || n == null) return;
    p.th.push(n.h);
    n.th.push(p.h);
  });
  let count = 0;

  tenbodai.forEach((tb) => {
    const list = tb.th.filter(h => h >= tb.h);
    if (list.length == 0) {
      count ++;
    }
  })
  console.log(count);
}
// tenbodaiList.forEach((tenbodai) => {
//   const otherHightList = tenbodai.otherPlaceHeight
//     .filter(value => {
//       if (tenbodai.height <= value) {
//         return true;
//       }
//       return false;
//     });
//   if (otherHightList.length <= 0) {
//     count ++;
//   }
// });
// test
//const Q1 = `4 3
//1 2 3 4
//1 3
//2 3
//2 4
//`;
//
//const Q2 = `6 5
//8 6 9 1 2 1
//1 3
//4 2
//4 3
//4 6
//4 6
//`;
//
//mainCalc(Q1);
//mainCalc(Q2);
mainCalc(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 99964
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;

int main()
{
	string s;
	cin>>s;
	int t=1;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='C')
		{
			t=0;
		}
		if(s[i]=='F'&&t==0)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
n,k,q=map(int,input().split())

d=[0 for i in range(n)]
for i in range(1,q+1):
    a=int(input())
    d[a-1] +=1

for j in d:
    if k-(q-j) > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4708
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

// #define DEBUG 100

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7,maxn = 100010;
const double PI = acos(-1);

string solve (int n){
	if (n >= 30 ) return "Yes";
	return "No";
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;

	cout << solve(n) << endl;
}	



Measured memory_bytes: 3628
package main

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

var sc = bufio.NewScanner(os.Stdin)

func contains(target string, list []string) bool {
	for _, r := range list {
		if target == r {
			return true
		}
	}
	return false
}

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

func nextInt() int {
	sc.Scan()

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

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

func Ave(s []int) int {
	val := 0
	for _, i := range s {
		val += i
	}
	return int(val / len(s))
}
func cal(i int) (sum int) {
	for i != 0 {
		sum += i % 10
		i /= 10
	}
	return
}
func max(a []int) (idx int, val int) {
	max := a[0]
	idx = 0
	for j, i := range a {
		if max < i {
			max = i
			idx = j
		}
	}
	return idx, max
}

func draw(i int, a []int) (l []int) {
	// p = a[i]
	for j := i; j < len(a); j++ {
		if j != len(a)-1 {
			a[j] = a[j+1]
		} else if j == len(a)-1 {
			a = a[:len(a)-1]
		}
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer([]byte{}, math.MaxInt64)
	a := make([][]int, 3)
	for i := 0; i < 3; i++ {
		a[i] = make([]int, 3)
	}
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			a[i][j] = nextInt()
		}
	}

	n := nextInt()
	var b []int

	for i := 0; i < n; i++ {
		b = append(b, nextInt())
	}

	for _, v := range b {
		for i := 0; i < 3; i++ {
			for j := 0; j < 3; j++ {
				if v == a[i][j] {
					a[i][j] = -1
				}
			}
		}
	}

	for i := 0; i < 3; i++ {
		if (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1) ||
			(a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1) ||
			(a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) ||
			(a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1) {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")

}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N,K;
	cin>>N>>K;
	if((N+1)/2 >= K) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 764
a,b,c,r,K;gcd(n,m){return m?gcd(m,n%m):n;}main(){scanf("%d",&K);for(a=1;a<=K;++a)for(b=1;b<=K;++b)for(c=1;c<=K;++c)r+=gcd(a,gcd(b,c));printf("%d",r);}

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

using namespace std;

bool match(char a,char b)
{
	return (a^32)==b;
}

int solve(string ps[],int perm[],int pos)
{
	if(pos==9)
		return 1;
	int res=0;
	for(int k=pos;k<9;k++){
		swap(perm[pos],perm[k]);
		string& cur=ps[perm[pos]];
		for(int l=0;l<4;l++){
			if((pos/3==0 || match(cur[0],ps[perm[pos-3]][2]))
			&& (pos%3==0 || match(cur[3],ps[perm[pos-1]][1])))
				res+=solve(ps,perm,pos+1);
			rotate(cur.begin(),cur.begin()+1,cur.end());
		}
		swap(perm[pos],perm[k]);
	}
	return res;
}

int main()
{
	int tc; cin>>tc;
	while(tc--){
		string ps[9];
		for(int i=0;i<9;i++)
			cin>>ps[i];
		int perm[9]; iota(perm,perm+9,0);
		cout<<solve(ps,perm,0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1224
a = int(input())
if 400<=a and a<=599:
  print(8)
elif 600<=a and a<=799:
  print(7)
elif 800<=a and a<=999:
  print(6)
elif 1000<=a and a<=1199:
  print(5)
elif 1200<=a and a<=1399:
  print(4)
elif 1400<=a and a<=1599:
  print(3)
elif 1600<=a and a<=1799:
  print(2)
elif 1800<=a and a<=1999:
  print(1)

Measured memory_bytes: 9184