akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){a%=mod;b%=mod;return a*b%mod;}
inline int power(int a,int b,int MOD){a%=mod;int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     int n;
     cin>>n;
     map<int,int>m;
     for(int i=2;i<=n;i++)
     {
           int x=i;
           for(int j=2;j<=sqrt(x);j++)
           {
           	      while(x%j==0)
           	      {
           	      	    x/=j;
           	      	    m[j]++;
           	      }
           }
           if(x>=2)
           	m[x]++;
     }
     int count1=0;
     int count2=0;
     for(auto &x:m)
     	count1+=x.second>=4,count2+=x.second>=2;
     int res=(count1*(count1-1)/2)*(count2-2);
     count1=0;
     count2=0;
     for(auto &x:m)
     	count1+=x.second>=14,count2+=x.second>=4;
     res+=count1*(count2-1);
     count1=0;
     count2=0;
     for(auto &x:m)
     	count1+=x.second>=24,count2+=x.second>=2;
     res+=count1*(count2-1);
     count1=0;
     count2=0;
     for(auto &x:m)
     	count1+=x.second>=74;
     res+=count1;
     cout<<res<<endl;
     time();
     return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll INF=1LL<<60;


int main(){
  ll k,sum=0;
  cin>>k;
  auto gcd=[&](int a,int b){
    int tmp=a%b;
    while(tmp!=0){
      a=b;
      b=tmp;
      tmp=a%b;
    }
    return b;
  };
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      for(int c=1;c<=k;c++){
	int x=gcd(max(a,b),min(a,b));
	int y=gcd(max(b,c),min(b,c));
	sum+=gcd(max(x,y),min(x,y));
      }
    }
  }
  cout << sum;
}






Measured memory_bytes: 3192
import sys
INF=10**9
N,M=map(int,input().split())

graph=[]
for i in range(N+1):
  graph.append([])

for i in range(M):
  L,R,D=map(int,input().split())
  graph[L].append((R,D))
  graph[R].append((L,-D))
#print(graph)

pos_list=[-INF]*(N+1)
for i in range(1,N+1):
  if pos_list[i]!=-INF:
    continue
    
  queue={i}
  pos_list[i]=0
  while(len(queue)>0):
    new_queue=set()
    for q in queue:
      for v,d in graph[q]:
        if pos_list[v]==-INF:
          pos_list[v]=pos_list[q]+d
          new_queue.add(v)
        elif pos_list[v]!=pos_list[q]+d:
          print("No")
          sys.exit(0)
          
    queue=new_queue
          
#print(pos_list[1:])
print("Yes")

Measured memory_bytes: 70060
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;
int N;
vector<int> G[100010];
long long b[100010], w[100010];

void dfs(int u, int p) {
    b[u] = 1;
    w[u] = 1;
    for (int v : G[u]) {
        if (v == p) continue;
        dfs(v, u);
        b[u] *= w[v];
        b[u] %= MOD;
        w[u] *= w[v] + b[v];
        w[u] %= MOD; 
    } 
}

int main() {
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        int x, y; cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    dfs(0, -1);
    int ans = (b[0] + w[0]) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 14208
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder0725
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] ABC = intArray(Console.ReadLine());
            int A = ABC[0];
            int B = ABC[1];
            int C = ABC[2];
            int K = int.Parse(Console.ReadLine());

            int cnt = K;
            int ans = 0;

            for(var i = 0; i< K; i++)
            {
                if (A < B) { break; }
                B *= 2;
                cnt -= 1;
            }

            int remcnt = cnt;

            if (remcnt > 0)
            {
                for (var i = 0; i <= cnt; i++)
                {
                    if (B < C) {
                        ans++;
                        break;
                    }
                    if(remcnt == 0) { break; }
                    C *= 2;
                    remcnt -= 1;
                    continue;
                }
            }

            if (ans > 0) { Console.WriteLine("Yes"); }
            else { Console.WriteLine("No"); }
        }

        public static int[] intArray (string s)
        {
            int[] N = s.Split(' ').Select(x => int.Parse(x)).ToArray();
            return N;
        }
        public static long[] longArray(string s)
        {
            long[] N = s.Split(' ').Select(x => long.Parse(x)).ToArray();
            return N;
        }
    }
}


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

int main(){
    int n;
    cin >> n;
    string s = to_string(n);
    int cnt = 1;

    for (int i = 1; i < s.size(); ++i) {
        if (s[i] == s[i-1]) {
            ++cnt;
            if (cnt == 3) {
                printf("Yes\n");
                return 0;
            }
        } else
        {
            cnt = 1;
        }        
    } 
    printf("No\n");
}

Measured memory_bytes: 3640
(defun collatz (n)
    (if (evenp n)
        (/ n 2)
        (+ (* n 3) 1)))
(defun gen-collatz-sequence (sequence)
    (if (= (length sequence) (length (remove-duplicates sequence :test #'=)))
        (gen-collatz-sequence (cons (collatz (car sequence)) sequence))
        (length sequence)))
(let ((n (read)))
    (princ (gen-collatz-sequence (cons n nil))))

Measured memory_bytes: 13540
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
 
		Scanner scanner = new Scanner(System.in);
 
		//入力表示
		int N = scanner.nextInt();
		int B = 0;
 
		if (N % 2 == 0) {
			B = N / 2;
		
		} else {
			B = N / 2 + 1;
		}
 
	 System.out.println((double)B/N); 
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, ab, am;
  cin >> a >> b;
  ab = (a + b) / 2;
  am = (a + b) % 2;
  if (am == 0) cout << ab << endl;
  else cout << ab + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

int main() {
  int N, M;
  std::string red[101], blue[101];
  std::map<std::string, int> mpr, mpb;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> blue[i];
    mpb[blue[i]]++;
  }

  cin >> M;
  for (int i = 0; i < M; ++i) {
    cin >> red[i];
    mpr[red[i]]++;
  }

  int ans = 0;

  for (int i = 0; i < N; ++i) {
    ans = std::max(ans, mpb[blue[i]] - mpr[blue[i]]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

D = defaultdict(int)

def f(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x
    return (x+y+z)**2+(x*y+y*z+z*x)

N=int(input())
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ret = f(x,y,z)
            if ret>N:
                break
            D[f(x,y,z)]+=1

for i in range(1,N+1):
    print(D[i])


Measured memory_bytes: 10132
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 9999999;
const int MOD = 1e9 + 7;

int main() {
	string h;
	cin >> h;
	bool out = false;
	if (h[0] != 'A') {
		out = true;
	}
	int c = 0;
	for (int i = 2; i < h.length() - 1; ++i) {
		if (h[i] == 'C') { ++c; }
	}
	if (c != 1) { out = true; }
	c = 0;
	for (auto i : h) {
		if (islower(i)) { ++c; }
	}
	if (c != h.length() - 2) { out = true; }

	if (out) { cout << "WA" << endl; }
	else { cout << "AC" << endl; }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
C - Strange Bank
https://abc099.contest.atcoder.jp/tasks/abc099_c

"""
import sys
from sys import stdin
input = stdin.readline


def solve(n):
    withdrawals = []
    for i in range(1, 100):
        for j in [6, 9]:
            if j**i <= n:
                withdrawals.append(j**i)
    withdrawals.sort()

    dp = [[-1] * (n+1) for _ in range(len(withdrawals)+1)]
    for x in range(n+1):
        dp[0][x] = x
    for y in range(len(withdrawals)+1):
        dp[y][0] = 0

    for y, w in enumerate(withdrawals, start=1):
        for x in range(1, n+1):
            if dp[y][x-w] >= 0:
                dp[y][x] = min(dp[y][x-w] + 1, dp[y-1][x])
            else:
                dp[y][x] = dp[y-1][x] - dp[y-1][x-1] + dp[y][x-1]
    return dp[-1][-1]


def main(args):
    n = int(input())
    ans = solve(n)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 28660
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(1e5 + 5)], DP[int(1e5 + 5)];

int main(){
  cin >> N;
  fill(DP, DP + N + 1, 1e16);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] <= DP[0]){
      DP[0] = A[i]; continue;
    }

    int L = 0, R = N;
    while (R - L > 1){
      int Mid = (L + R) / 2;
      if (DP[Mid] < A[i]) L = Mid;
      else R = Mid;
    }
    DP[R] = A[i];
  }

  for (int i = 0; i <= N; i++){
    if (DP[i] == 1e16){
      cout << i << endl; return 0;
    }
  }

  return 0;
}



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


using namespace std;

typedef long long ll;




int main(void)
{
   // ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);

 ll n,d;
 cin>>n>>d;
 int ans=0;
 for(int i=0;i<n;i++)
 {
     ll x,y;
     double dist;
     cin>>x>>y;

     dist = sqrt(pow(x,2)+pow(y,2));
     if(d>=dist)
     {
         ans++;
     }


 }
 cout<<ans<<endl;

}





Measured memory_bytes: 3676
a = int(input())
b = input().split()
c = []
for i in range(a * 2):
  if i % 2 == 0:
    c.append(b[0][i // 2])
  else:
    c.append(b[1][(i - 1) // 2])
for f in c:
  print(f,end="")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int n;
ll fac[100010];
ll x[100010];
ll fans = 0;

ll kmi (ll x, ll t) {
	ll ans = 1;
	for (x %= mod; t; t >>= 1, x = (x * x) % mod)
		if (t % 2)
			(ans *= x) %= mod;
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	fac[0] = 1;
	for (int i = 1; i <= n; i ++)
		fac[i] = fac[i - 1] * i % mod;
	ll cnt = 0;
	for (int i = 1; i <= n; i ++) {
		cin >> x[i];
		if (i == 1)
			continue ;
		(cnt += fac[n - 1] * kmi (i - 1, mod - 2) % mod) %= mod;
		(fans += cnt * (x[i] - x[i - 1]) % mod) %= mod;
	}
	cout << fans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>Pt;
#define fr first
#define sc second
Pt st[10];
int h,w,n,dx[]={0,1,0,-1},dy[]={1,0,-1,0},used[1000][1000];
char mas[1000][1000],tmp[]="S123456789";
int bfs(Pt,Pt);
int main(){
  cin >> h >> w >> n;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> mas[i][j];
      for(int k=0;k<=n;k++){
	if(mas[i][j] == tmp[k]) st[k] = Pt(i,j);
      }
    }
  }
  int cnt = 0;
  for(int i=1;i<=n;i++){
    memset(used,-1,sizeof(used));
    cnt += bfs(st[i-1],st[i]);
  }
  cout << cnt << endl;
}

int bfs(Pt S,Pt G){
  queue<Pt> que;
  que.push(S);
  used[S.fr][S.sc] = 0;
  while(!que.empty()){
    Pt p = que.front();
    que.pop();
    if(p == G) break;
    for(int i=0;i<4;i++){
      int nx = p.fr + dx[i],ny = p.sc + dy[i];
      if(nx>=0 && nx<h && ny>=0 && ny<w && used[nx][ny]==-1 && mas[nx][ny]!='X'){
	used[nx][ny] = used[p.fr][p.sc] + 1;
	que.push(Pt(nx,ny));
      }
    }
  }
  return used[G.fr][G.sc];
}


Measured memory_bytes: 8044
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{   
	int n;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++)
	{
        cin>>a[i];
    }
    long long ans=1,odd=a[0]%2==0?2:1;
    for(int i=0;i<n;i++)
	{
		ans*=3;
	}
    for(int i=1;i<n;i++)
	{
        if(a[i]%2==0)
		{
			odd*=2;
		}
    }
    cout<<ans-odd;
}

Measured memory_bytes: 256
from sys import stdin,setrecursionlimit
setrecursionlimit(10 ** 7)
h,w = map(int,stdin.readline().rstrip().split())
li = [["" for i in range(w)]for j in range(h)]
for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        li[i][j] = s[j]
lin = []
for i in li:
    if i != ["."]*w:
        lin.append(i)
out = []
for i in range(w):
    flag = True
    for j in range(len(lin)):
        if lin[j][i] == "#":
            flag = False
    if flag:
        out.append(i)

lis = []
for i in lin:
    case = []
    for j,k in enumerate(i):
        if j in out:
            continue
        case.append(k)
    lis.append(case)

for i in lis:
    print("".join(i))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int n;
    cin>>n;
    int a;
    vector<unsigned long long>A(100000);
    ll ans;
    rep(i,n){
        cin>>a;
        A[a]++;
        ans+=a;
    }
    int q;
    cin>>q;
    vector<unsigned long long> data(q);
    unsigned long long b, c;
    rep(i,q){
        cin>>b>>c;
        if(A[b]!=0){
            ans += (c-b)*A[b];
            A[c]+=A[b];
            A[b]=0;
        }
        data[i]=ans;
    }

    rep(i,q){
        cout<<data[i]<<endl;
    }

}


Measured memory_bytes: 4764
t,s[51],a[];short*p;Q(){for(p=a;*p=='=Q';p++);}main(i,b){for(;~scanf("%[^\n]\n",s);i=0)i||puts(sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,a)-3||t-'~'|strcmp(a,b)?sscanf(s,">^%[Q=]~%c%c",a,&t,a)-2||t-'~'|(Q(),*p&7|p==a)?"NA":"B":"A");}

Measured memory_bytes: 0
#include<stdio.h>
#define MOD 1000000007
long int SUM(long int a,long int b){return (a%MOD+b%MOD+MOD)%MOD;}//a+b
long int PROD(long int a,long int b){return a%MOD*(b%MOD)%MOD;}//a*b
int main(){
  long int i,j,n,dp[100001][4]={};
  char s[100001];
  scanf("%s",s);
  dp[0][0]=1;
  for(n=0;s[n];n++);
  for(i=0;i<n;i++){
    if(s[i]=='?'){
      dp[i+1][0]=PROD(dp[i][0],3);
      for(j=1;j<4;j++)dp[i+1][j]=SUM(PROD(dp[i][j],3),dp[i][j-1]);
    }
    else {
      dp[i+1][0]=dp[i][0];
      for(j=0;j<3;j++)dp[i+1][j+1]=SUM(dp[i][j+1],dp[i][j]*(s[i]=='A'+j));
    }
  }
  printf("%ld",dp[n][3]);
}


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

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	int res = 0;
	for (int i = 1; i < n-1; ++i) {
		if ((p[i] > p[i-1] && p[i] < p[i+1])||(p[i] < p[i-1] && p[i] > p[i+1])) {
				++res;
		}
	}
	cout << res << endl;
	return 0;
}


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

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

using namespace std;

template<class T>
vector<pair<T,int>> run_length_encoding(const vector<T>& a){
	vector<pair<T,int>> res;
	int n=a.size(),pre=0;
	rep(i,n) if(i==n-1 || a[i]!=a[i+1]) res.emplace_back(a[i],i-pre+1), pre=i+1;
	return res;
}

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	int ans=0;
	for(auto p:run_length_encoding(a)) ans+=p.second/2;
	printf("%d\n",ans);

	return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	string s; cin>>s;
	int a=0,b=0;
	for(int i=0; i<3; ++i){
		if(s[i]=='A') a++;
		if(s[i]=='B') b++;	
	}
	if(a and b) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}

Measured memory_bytes: 256
import sys
s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)

#print(s, t)

length = min(len(s), len(t))

for i in range(length):
    if s[i] < t[i]:
        print('Yes')
        sys.exit()
    elif s[i] == t[i]:
        continue
    else:
        print('No')
        exit()
        
if len(s) < len(t):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll  unsigned long long int
#define pb push_back
#define sx 200007
int main()
{
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
        cout<<s<<"es"<<endl;
    else
        cout<<s<<"s"<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>

int main(){
    int n,l;
    int temp,sum=0;
    int flag;

    scanf("%d %d",&n,&l);

    temp = abs(l+1);

    for(int i = 0;i<n;i++){
        if(temp>abs(l+i)){
            temp = abs(l+i);
            if(l+i >= 0){
                flag = 1;
            }else{
                flag = -1;
            }
        }

        sum += l+i;
    }

    if(flag == 1)
        sum -= temp; 
    else
        sum += temp;

    printf("%d\n",sum);


    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    
    string ans;
    
    string que;
    char value;
    int num;
    
    cin >> ans;
    cin >> num;
    
    bool reverse = false;
    
    for(int i = 0;i < num;i ++){
        cin >> que;
        if(que[0] == '1'){
            reverse = !reverse;
        } else {
            cin >> que;
            cin >> value;
			if(que[0] == '1') {
				if(reverse) {
					ans.push_back(value);
				} else {
					ans.insert(ans.begin(), value);
				}
			} else {
				if(reverse) {
					ans.insert(ans.begin(), value);
				} else {
					ans.push_back(value);
				}
			}
		}
    }
    
    if(reverse){
        std::reverse( ans.begin(), ans.end() );
    }
    
    cout << ans << "\n";
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+10;
struct T
{
	ll a,b;
}D[N];
ll A[N];
T stk[N];int cnt=0;
ll res[N];
int main()
{
	//freopen("/home/zz7/CFInput","r",stdin);
	ll n,c;scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++)scanf("%lld%lld",&D[i].a,&D[i].b);
	ll ans=0,f=0;D[n+1].a=c;
	for(int i=n;i>=1;i--){
		A[i]=A[i+1]+D[i].b-(D[i+1].a-D[i].a);
		if(A[i]>=ans)ans=A[i],stk[cnt++]={ans,i};
		f=max(f,A[i]-(c-D[i].a));res[i]=f;
	}
	for(int i=1;i<=n;i++){
		A[i]=A[i-1]+D[i].b-(D[i].a-D[i-1].a);
		while(cnt>0&&stk[cnt-1].b<=i)cnt--;
		if(cnt>0){
			ll op=A[i]-D[i].a+stk[cnt-1].a;
			ll op1=A[i]+res[i+1];
			ans=max(ans,op);
			ans=max(ans,op1);
		}ans=max(ans,A[i]);
	}cout<<ans<<'\n';
}


Measured memory_bytes: 4992
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, m] <- getIntList
  putStrLn $ if n == m then "Yes" else "No"

Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
int main() {
    string s;
    cin >> s;
    int m;
    string temp = s.substr(0,3);
    m = abs(753 - stoi(temp));
    for(int i = 0; i < s.size() - 2; i++){
        temp = s.substr(i,3);
        if (abs(753 - stoi(temp)) < m)
            m = abs(753 - stoi(temp));
    }
    cout << m;
}

Measured memory_bytes: 384
import sys
from collections import deque

read = sys.stdin.buffer.read

N, *A = map(int, read().split())
A.sort(reverse=True)

deq = deque([A[0]])
ans = 0

for x in A[1:]:
    ans += deq.popleft()
    deq.append(x)
    deq.append(x)

print(ans)


Measured memory_bytes: 29500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct BinomialCoefficient  {
    BinomialCoefficient() {
        
    }
    
    BinomialCoefficient(int n) : fac(n + 2), finv(n + 2), inv(n + 2) {
        initialize(n, false);
    }
    
    void initialize(int n, bool resize = true) {
        if (resize) {
            fac.resize(n + 2);
            finv.resize(n + 2);
            inv.resize(n + 2);
        }
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    
    ll factorial(int n) {
        return fac[n];
    }
    
    ll combination(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
    
    ll permutation(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * finv[n - r] % mod;
    }
    
private:
    int mod = 1e9 + 7;
    vector<ll> fac, finv, inv;
};

const int mod = 1e9 + 7;
int n, k;
vector<vector<int>> g;
BinomialCoefficient bc;
ll ans = 1;

ll f(int l, int r) {
    if (l < 0) return 0;
    ll res = bc.permutation(l, r);
    return res;
}

void dfs(int v, int p = -1) {
    for (auto e : g[v]) {
        if (e == p) continue;
        dfs(e, v);
    }
    int l = ((p == -1) ? k : (k - 2));
    int r = ((p == -1) ? (sz(g[v]) + 1) : (sz(g[v]) - 1));
    ans = (ans * f(l, r)) % mod;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    g.resize(n);
    bc.initialize(max(n, k));
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11648
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if(Math.abs(a - c) <= d){
        	System.out.println("Yes");
        }else if(Math.abs(a - b) <= d && Math.abs(b - c) <= d){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 35964
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
string s;
cin>>s;
if(s.size()%2!=0){
    cout<<"No"<<endl;
    return 0;  
}
for(int i=0;i<s.size();i+=2){
    if(s[i]!='h'||s[i+1]!='i'){
        cout<<"No"<<endl;
        return 0;
    }
}
cout<<"Yes"<<endl;






return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    if (N < 10) ans = N;
    else if(10 <= N && N < 100) ans = 9;
    else if(100 <= N && N < 1000) ans = 9 + N - 100 + 1;
    else if(1000 <= N && N < 10000) ans = 909;
    else if(10000 <= N && N < 100000) ans = 909 + N - 10000 + 1;
    else if(100000 <= N) ans = 90909;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(2*n-1,0);
  for(int i=0;i<n;i++) a[n-1+i] = 1;
  for(int i=0;i<m;i++){
    int k; cin >> k;
    a[n-1+k] = 0;
  }
  int cnt = 0;
  for(int i=n-2;i>=0;i--){
    a[i] = a[2*i+1] | a[2*i+2];
    cnt += a[2*i+1] * a[2*i+2];
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3040
#include <stdio.h>
#include <stdlib.h>
 
void main() {
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  int ans = 0;
  for(int i = 0; i < N; i++) {
    int *ptr = (int *)malloc(sizeof(int *));
    scanf("%d ", ptr);
    int tmp = (K - (*ptr));
    int a = (tmp > 0 ? tmp : (-tmp))*2;
    int b = (*ptr)*2;
    ans += (a > b ? b : a);
  }
  printf("%d\n", ans);
  __asm__("mov $0x0,%rax");
}

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

int main(){
    int N, M;
    cin >> N >> M;
    bool if_start_to_island[N - 2];
    bool if_island_to_goal[N - 2];
    for(int i = 0; i < N - 2; i++){
        if_start_to_island[i] = false;
        if_island_to_goal[i] = false;
    }
    for(int i = 0; i < M; i++){
        int start, goal;
        cin >> start >> goal;
        if(start == 1){
            if_start_to_island[goal - 2] = true;
        }else if(goal == N){
            if_island_to_goal[start - 2] = true;
        }
    }
    for(int i = 0; i < N - 2; i++){
        if(if_start_to_island[i] && if_island_to_goal[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, m; cin >> n >> m;
	vl a(m); REP(i, m) cin >> a[i];
	vl odd;
	REP(i, m) if (a[i] % 2 == 1) odd.push_back(a[i]);
	if (odd.size() > 2) {
		cout << "Impossible" << endl;
		return 0;
	}

	vl n_a;
	if(!odd.empty()) n_a.push_back(odd[0]);
	REP(i, m) if (a[i] % 2 == 0) n_a.push_back(a[i]);
	if (odd.size() == 2) n_a.push_back(odd[1]);

	REP(i, m) cout << n_a[i] << endl;
	if (n_a.size() == 1 && n_a[0] == 1) {
		cout << 1 << endl;
		cout << 1 << endl;
	}else if (n_a.size() == 1) {
		cout << 2 << endl;
		cout << n_a[0] - 1 << endl;
		cout << 1 << endl;
	} else {
		if (n_a.front() - 1 != 0) {
			cout << n_a.size() << endl;
			cout << n_a.front() - 1 << endl;
		} else {
			cout << n_a.size() - 1 << endl;
		}
		REP(i, n_a.size() - 2) cout << n_a[i + 1] << endl;
		cout << n_a.back() + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 998244353LL;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void readv(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    V<V<V<ll>>> dp(n + 1, V<V<ll>>(10, V<ll>(2, -INF)));
    dp[0][0][0] = 0;
    for (int i = 1; i <= n; i++) {
        int u = i / 2 + (i % 2 > 0);
        for (int j = max(0, u - 5); j <= u; j++) {
            if (i % 2) {
                chmax(dp[i][u - j][1], dp[i - 1][u - j][0] + a[i - 1]);
                if (u - j > 0) {
                    chmax(dp[i][u - j][0], dp[i - 1][u - j - 1][1]);
                    chmax(dp[i][u - j][0], dp[i - 1][u - j - 1][0]);
                }
            } else {
                chmax(dp[i][u - j][1], dp[i - 1][u - j + 1][0] + a[i - 1]);
                chmax(dp[i][u - j][0], dp[i - 1][u - j][1]);
                chmax(dp[i][u - j][0], dp[i - 1][u - j][0]);
            }
        }
    }
    cout << max(dp[n][n % 2][0], dp[n][n % 2][1]) << '\n';
}

Measured memory_bytes: 122000
#include<iostream> 
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;

int main()
{
	int x,y;
	cin>>x>>y;
	int f=0;
	for(int i=0;i<=x;i++){
		if(i*2+(x-i)*4==y){
			f=1;cout<<"Yes";break;
		}
	}
	if(!f) cout<<"No";
	return 0;	
} 

Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,T;
  cin>>N>>T;
  VI A(N);
  rep(i,N) cin>>A[i];
  VI X(N);
  X[0]=A[0];
  rep(i,N-1) X[i+1]=min(X[i],A[i+1]);
  VI Y(N);
  rep(i,N) Y[i]=A[i]-X[i];
  sort(all(Y));
  cout<<Y.end()-lb(all(Y),Y[N-1])<<endl;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    double R;
    cin >> R;
    printf("%.5f\n", 2*R*M_PI);
    return 0;
}


Measured memory_bytes: 3784
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  ll cnt = 0;
  rep(i,s.size()) if(s[i]=='p') cnt++;
  cout<<s.size()/2-cnt<<endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;

int main() {
	int h, w;
	scanf("%d %d", &h, &w);
	rep(i, h) {
		rep(j, w) {
			char c[6];
			scanf("%s", c);
			if (strcmp(c, "snuke") == 0) {
				printf("%c%d", 'A' + j, i + 1);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 128
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(A[K-1])

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e7+10,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int dec(int x,int y){x-=y;return x<0?x+p:x;}
int mul(int x,int y){return (ll)x*y%p;}
int power(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=mul(x,x))
		if (y&1) ans=mul(ans,x);
	return ans;
}
int S,bits[N];ll sum[10];
//(10^(n-1)-1)/9*80+9+(n-1)*10^n
int calc(int p){
	if (p<=7) return 0;
	int l=S/p;
	return dec(mul(9,power(10,p-1)),l-1);
}
int calc(int L,int S){
	int ans=0;
	for (int l=L,r;l<=S;l=r+1){
		r=S/(S/l);
		ans=inc(ans,mul(r-l+1,S/l));
	}
	return ans;
}
int main()
{
	cin>>S;
	for (ll i=1,p=10;i<10;i++,p*=10) sum[i]=(8*p-80)/9+(i-1)*p+9;
	int ans=0;
	for (int i=1;i<=1e7;i++) bits[i]=bits[i/10]+1;
	//枚举l<10^7
	for (int l=0,s=0;l<9999999;l++,s+=bits[l]){		
		ll v=S+s;int p=1;
		while (v>sum[p]) p++;
		if ((v-sum[p-1])%p==0) ans++;
	}
	for (int i=1;i*i<=S;i++)
	if (S%i==0){
		ans=inc(ans,calc(i));
		if (S!=i*i) ans=inc(ans,calc(S/i));
	}
	//两段
	ans=inc(ans,calc(8,S-1));
	ans=dec(ans,calc(9,S));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 39424
def main():
    n, k = map(int, input().split())
    d, A = [], []
    for _ in range(k):
        d.append(int(input()))
        l = list(map(lambda x:int(x) - 1, input().split()))
        A.append(l)

    ans = solve(n, k, d, A)
    print(ans)


def solve(n, k, d, A):
    sunuke = [False for _ in range(n)]
    for l in A:
        for i in l:
            sunuke[i] = True
    ans = [1 for i in sunuke if i == False]
    return sum(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int flag;
  
  string S[N];
  for(int i=0; i<N; i++){
    cin >> S[i];
  }
  
  for(int i=0; i<N; i++){
    if(S[i] == "Y"){
      flag = 1;
      break;
    }
    else{
      flag = 0;
    }
  }
  
  if(flag == 1){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int r,c,table[101][101]={{0}},i,j,temp;

    scanf("%d%d",&r,&c);

    for(i=0;i<r;i++) {
        for(j=0;j<c;j++) {
            scanf("%d", &temp);
            table[i][j]=temp;
            table[i][c]+=temp;
            table[r][j]+=temp;
            table[r][c]+=temp;
        }
    }

    for(i=0;i<=r;i++) {
        for(j=0;j<c;j++) {
            printf("%d ",table[i][j]);
        }
        printf("%d\n",table[i][c]);
    }

    return 0;
}

Measured memory_bytes: 2720
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;
int main(){
  ll N, K;
  cin >> N >> K;
  vector<int> v;
  int a[100010][2];
  vector<pair<int, int>> pairs(N);
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < 2; ++j){
      cin >> a[i][j];
     }
    pairs[i] = make_pair(a[i][0], a[i][1]);
   }
  sort(pairs.begin(), pairs.end());
  ll sum = 0;
  for(int i = 0; i < N; ++i){
    sum += pairs[i].second;
    if(sum >= K){
      cout << pairs[i].first << endl;
      break;
    }
  }
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	int n , cnt=0;
	cin >>n;
	VI a(n);
	rep(i,n) cin >>a[i];
	
	rep(i,n){
		int minj=i;
		rep2(j, i, n){
			if(a[j] < a[minj]) minj = j;
		}
		if(a[i] != a[minj]){
			swap(a[i], a[minj]);
			cnt++;
		}
	}
	
	rep(i,n) cout <<a[i] << (i==n-1?"\n":" ");
	cout <<cnt <<"\n";
	return 0;
}




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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int w, h;
char t[20][20];
void dfs(int i, int j) {
	t[i][j] = '*';
	for (int di = -1; di <= 1;di++) {
			for (int dj = -1;dj <= 1;dj++) {
				int ni = i + di;
				int nj = j + dj;
				if (di!=dj && di+dj!=0 && ni >= 0 && ni < h&&nj >= 0 && nj < w&&t[ni][nj] == '.') {
					dfs(ni, nj);
				}
			}
		}
	return;
}

int main() {
	cin.sync_with_stdio(false);
	vector<int>ans;
	while (1) {

		cin >> w >> h;
		if (w == 0)break;
		rep(i, h) {
			rep(j,w) {
				cin >> t[i][j];
			}
		}
		rep(i, h) {
			rep(j, w) {
				if (t[i][j] == '@') {
					dfs(i, j);
					break;
				}
			}
		}
		int count = 0;
		rep(i, h) {
			rep(j, w) {
				if (t[i][j] == '*') {
					count++;
				}
			}
		}
		ans.push_back(count);
	}
	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}

	return 0;
}

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

#define INF 100000

using namespace std;

void chmin(int &a, int b) { if (a > b) a = b; }

int N, A, B, C;
vector<int> l(N);

int rec(int i, int a, int b, int c) {

    if (i == N) {
        if (!a || !b || !c) return INF;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }

    int res = rec(i+1, a, b, c);

    chmin(res, rec(i+1, a+l[i], b, c) + (a ? 10 : 0));
    chmin(res, rec(i+1, a, b+l[i], c) + (b ? 10 : 0));
    chmin(res, rec(i+1, a, b, c+l[i]) + (c ? 10 : 0));

    return res;

}

int main() {
    cin >> N >> A >> B >> C;
    l.resize(N);
    for (int i=0; i<N; ++i) cin >> l[i];

    int res = rec(0, 0, 0, 0);
    cout << res << endl;

    return 0;


}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
	int n;
	int t;
	int boss[200001] = { 0 };
	scanf("%d", &n);

	for (int i = 1; i < n; i++) {
		scanf("%d", &t);
		boss[t]++;
	}

	for (int i = 1; i <= n; i++) {
		printf("%d\n", boss[i]);
	}
	return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
int main () {
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    if (A % K == 0) {
      if (B / K - A / K >= 0) {
        cout << "OK" << endl;
      }
      else {
        cout << "NG" << endl;
      }
    }
    else {
      if (B / K - A / K >= 1) {
        cout << "OK" << endl;
      }
      else {
        cout << "NG" << endl;
      }
    }

}


Measured memory_bytes: 3604
def call(n)   
  for i in 1..n do
        if i%3==0
            print " ",i
        else
            x = i
            while x > 0 do
                if x%10==3
                    print " ",i
                    break
                end
                x /= 10
            end
        end
    end
    puts
end

n = gets.to_i
call(n)

Measured memory_bytes: 8752
#include <iostream>
using namespace std;
int main (void) {
    int A, B, C, D, s_in, s_out ;

    cin >> A >> B >> C >> D;

    if (A < C) s_in = C;
    else s_in = A;

    if (B < D) s_out = B;
    else s_out = D;
    if (s_in < s_out){
        cout << (s_out - s_in) << "\n";
    } else {
        cout << 0 << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
P=p[:X]+q[:Y]
P.sort(reverse=True)
Q = [0]
for sp in P:
    Q.append(Q[-1]+sp)
R = [0]
for sr in r:
    R.append(R[-1]+sr)

res = 0
for i in range(min(X+Y,C)+1):
    res = max(res,Q[X+Y-i]+R[i])
print(res)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

vpint ans;
bool used[1111][1111];

void f(int y,int x){
    if(used[y][x]||(y+x)%2==0)return;
    used[y][x]=true;
    ans.pb({y,x});
}

signed main(){
    int N;cin>>N;
    for(int i=0;i<N;i++){
        f(0,i);
        f(i,N-1);
    }
    for(int i=1;i<N;i+=6){
        rep(j,N)f(j,i);
    }

    for(int i=4;i<N;i+=6){
        rep(j,N)f(j,i);
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size())cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    return 0;
}


Measured memory_bytes: 7408
#include <bits/stdc++.h>
using namespace std;
#define reps(i,j,k) for(int i=j;i<k;++i)
#define rep(i,j) reps(i,0,j)
int main(){
	int n, m, s;
	while (true){
		cin >> n >> m >> s;
		if (n + m + s == 0)break;
		int p;
		int sum = 0;
		int g = -1;
		rep(i, n){
			scanf("%d", &p);
			if (i == m - 1){
				g = p;
			}
			sum += p;
		}
		if (g == 0){
			puts("0");
		}
		else{
			int res = sum * (100 - s) / g;
			cout << res << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1244
n = gets.to_i

def totient(n)
	t = n
	i = 2
	while i * i <= n
		if n % i == 0
			t = t / i * (i - 1)
			n /= i while n % i == 0
		end
		i += 1
	end
	t = t / n * (n - 1) if n != 1
	t
end

p totient n


Measured memory_bytes: 6876
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
		
			int n = sc.nextInt();
			
			Set<Integer> countSet = new HashSet<>();
			boolean isDuplicated = false;
			
			for(int i = 0 ; i < n ; i++ ) {
				
				int v = sc.nextInt();
				
				if (countSet.contains(v)) {
					isDuplicated = true;
				}
				countSet.add(v);
			}
			
			if ( isDuplicated ) {
				System.out.println("NO");
			}
			else {
				System.out.println("YES");
			}
		}
	}
}

Measured memory_bytes: 69588