akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

# スペース区切りの整数入力
a,b,c = map(int, input().split())

if a <= b and c <= b:
  sum = a + c
if b <= a and c <= a:
  sum = b + c
if a <= c and b <= c:
  sum = a + b






#出力
print(str(sum))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    int k,x;
    cin>>k>>x;

    if ( 500*k >= x )
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int h1,m1,h2,m2,n;
  cin>>h1>>m1>>h2>>m2>>n;
  int ret = h2 * 60 + m2 - h1 * 60 - m1 - n;
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
    string s; cin >> s;
    int f = 0;
    int n = s.size();
    for(int i = 0; i < n / 2; i++){
        if(s[i] != s[n-1-i]){
            f = 1;
        }
    }
    for(int i = 0; i < (n-1)/2; i++){
        if(s[i] != s[(n-1)/2-1 - i]){
            f = 1;
        }
    }
    for(int i = (n+3)/2-1; i < n; i++){
        if(s[i] != s[n-1 - (i - ((n+3) / 2 - 1))]){
            f = 1;
        }
    }
    if(f == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
v = int(input())
vlist = [0]*v
for num in range(v):
    temp = list(map(int,input().split()))
    if temp[1] != 0:
        vlist[num] = temp[2:]
deep = [0]+[-1]*(v-1)
waiting = [1]

while waiting:
    vertex = waiting.pop(0)
    if vlist[vertex-1]:
        for subv in vlist[vertex-1]:
            if deep[subv-1] == -1:
                deep[subv-1] = deep[vertex-1]+1
                waiting += [subv]

count = 0
for num in deep:
    count += 1
    print(count,num)



Measured memory_bytes: 5620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MAX = 200007;
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;
    int a[MAX];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long res = 0;
    map<long long, long long> mp;
    for (int i = 0; i < n; i++) {
        long long cur = i - a[i];
        res += mp[cur];
        mp[i + a[i]]++;
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve(); cout << endl;}
    solve();
}

Measured memory_bytes: 26964
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    int x=30;
    int y,w,n,m;
    int j=0;
    char c[28];
    scanf("%s",c);
    for(int i=0;i<28;i++){
        if(c[i]=='\0'&&x>i)x=i;
    }
    int a[x];
    for(int i=0;i<x;i++){
        a[i]=c[i]-'a';
    }
    if(x<26){
        sort(a,a+x);
        while(j==a[j]){
            j++;
        }
        c[x+1]=c[x];
        c[x]='a'+j;
        printf("%s\n",c);
    }
    if(x==26){
        int z=0;
        for(int i=0;i<26;i++){
            if(a[i]==25-i)z++;
        }
        if(z==26)printf("-1\n");else{
            j=0;z=-1;
            while(a[25-j]>z){
                z=a[25-j];
                j++;
            }
            y=a[25-j];w=30;m=25-j;
            for(int i=m+1;i<26;i++){
                if(a[i]-y>0&&a[i]-y<w){w=a[i]-y;n=i;}
            }
            a[25-j]=a[n];
            for(int f=0;f<=m;f++){
                c[f]='a'+a[f];
            }
            for(int f=m+1;f<26;f++){
                c[f]='\0';
            }
            printf("%s\n",c);
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int len=s.size(),ans=len;
	for(int i=0;i<len-1;i++){
		if(s[i]!=s[i+1]){
			ans=min(ans,max(i+1,len-i-1));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    
    int n,sum=0,i,j,k;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    
    sort(a,a+n);
    for(i=0;i<n;i++){
       for(j=i+2;j<n;j++){
           for(k=i+1;k<j;k++){
               if((a[i]+a[k])>a[j])
               sum++;
           }
       }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
"""
思考
N <= 10 ** 5
O(N)は通る

すでにpi != iのところは置き換えたくない
隣同士しか変えられない

隣もpi == iだったら喜んで変える
基本的に後ろのやつと変えると固定
"""

N = int(input())
P = list(map(int, input().split( )))

count = 0
for i in range(len(P) - 1):
    if i + 1 != P[i]:
        continue
    else:
        P_temp = P[i]
        P[i] = P[i + 1]
        P[i + 1] = P_temp
        count += 1

if N == P[N-1]:
    print(count + 1)
    exit()

print(count)

Measured memory_bytes: 20708
#include <stdio.h>

int main(){
  int a=0;
  scanf("%d",&a);
  a=a%10;
  
  switch(a){
    case 0:
    case 1:
    case 6:
    case 8:
      printf("pon");
      break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("hon");
      break;
    case 3:
      printf("bon");
      break;
  }
  
  return 0;
}

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

using namespace std;

int main(void) {
	int A, B, K;
	cin >> A >> B >> K;
	int counter = 0;
	for(int ans = max(A, B); ans >= 0; --ans) {
		if(A % ans == 0 && B % ans == 0) {
			++counter;
			if(counter == K) {
				cout << ans << '\n';
				break;
			}
		}
	}
	return 0;
}



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

public class Main{
	public static long calculateGCD(long x, long y){
		if( y > x ){
			long temp = x;
			x = y;
			y = temp;
		}
		if( y == 0 ){
			return x;
		} else {
			return calculateGCD(x-y, y);
		}
	}
	
	public static long calculateLCM(long x, long y){
		return x*y/calculateGCD(x, y);
	}
			
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		long[][] result = new long[100][2];
		int index = 0;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			long x = 0;
			long y = 0;
			while( stdIn.hasNext() ){
				if( stdIn.hasNextInt() ){
					x = stdIn.nextInt();
					y = stdIn.nextInt();
				} else {
					stdIn.next();
				}
				
				result[index][0] = calculateGCD(x, y);
				result[index][1] = calculateLCM(x, y);
				index++;
			}
			
			for(int i = 0; i < index; i++){
				System.out.println(result[i][0] + " " + result[i][1]);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 11000
#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,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;

vector <int> dx = { 1,-1,0,0,1,1,-1,-1 };
vector<int> dy = { 0,0,1,-1,1,-1,1,-1 };



int main() {
	
	int h, w;
	cin >> h >> w;
	priority_queue<pair<int, pair<int, int>>, vector< pair<int, pair<int, int>>>, greater< pair<int, pair<int, int>>>> q;

	
	VVC v(h, VC(w));
	REP(i, h)REP(j, w) {
		cin >> v[i][j];
		if (v[i][j] == '#')q.push({ 0,{i,j} });
	}
	int ans = 0;
	while (!q.empty()) {
		auto a = q.top();
		q.pop();
		int i = a.second.first;
		int j = a.second.second;
		ans = max(ans, a.first);
		REP(k, 4) {
			int ny = i + dy[k], nx = j + dx[k];
			if (ny < 0 || h <= ny || nx < 0 || w <= nx)continue;
			if (v[ny][nx] == '#')continue;
			v[ny][nx] = '#';
			q.push({ a.first+1,{ny,nx} });
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 14828
/*  ex4_1
    person_A  */
#include<stdio.h>
#include<math.h>

int main(void){
    double n,d;
    //NとDの値の取得
    scanf("%lf%lf",&n,&d);
    //最低限必要な監視員の数の出力
    //一人が監視できる木の最大本数で割って、余った場合は一人追加
    printf("%d\n",(int)ceil(n/(2*d+1)));
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N, Y;
	cin >> N >> Y;
	for (int i = 0; i <= N; i++)
	{
		for (int j = 0; j <= N-i; j++)
		{
			if (10000*i+5000*j+1000*(N-i-j) == Y)
			{
				printf("%d %d %d\n", i, j, N-i-j);
				return (0);
			}
		}
	}
	puts("-1 -1 -1");
}



Measured memory_bytes: 256
fun main(args: Array<String>?): Unit {
    while (true) {
        val n = readLine()!!.trim().toInt()
        if (n == 0) break
        val lines = Array(n + 1) {
            val m = readLine()!!.trim().toInt()
            val points = Array(m) {
                val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
                Point(x, y)
            }
            PolygonalLine(points)
        }
        (1..n).filter { lines.first().isSame(lines[it]) }.forEach { println(it) }
        println("+++++")
    }
}

data class Point(val x: Int, val y: Int) {
    fun rotate90(): Point = Point(-y, x)
    operator fun plus(that: Point): Point = Point(x + that.x, y + that.y)
    operator fun minus(that: Point): Point = Point(x - that.x, y - that.y)
}
class PolygonalLine(initial: Array<Point>) {
    private val points: Array<Point>
    private val reversed: Array<Point>
    init {
        points = normalize(initial)
        reversed = normalize(initial.reversedArray())
    }
    fun isSame(that: PolygonalLine): Boolean {
        if (points.size != that.points.size) return false
        return points.indices.all{points[it] == that.points[it]} ||
                points.indices.all{points[it] == that.reversed[it]} ||
                reversed.indices.all{reversed[it] == that.points[it]} ||
                reversed.indices.all{reversed[it] == that.reversed[it]}
    }
    companion object {
        private fun normalize(points: Array<Point>): Array<Point> {
            var shifted = points.map{it - points.first()}
            while (shifted[1].x <= 0 || shifted[1].y < 0) {
                shifted = shifted.map(Point::rotate90)
            }
            return shifted.toTypedArray()
        }
    }
}


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

int n, k;
vector<int> a(100005), memo(100005);
int frog( int i ){
    if ( i == n - 1 )
        return 0;
    
    if ( memo[i] != - 1)
        return memo[i];
        
    long long s = 1e9, mn = 1e9;
    for ( int j = i + 1; j <= i + k; j++ ){
          if( j < n){
            s = abs( a[i] - a[j]  ) + frog(j);
            mn = min( mn, s );
          }
    }
    
    return memo[i] = mn;
}

int main()
{
    cin >> n >> k;
    for ( int i = 0; i < n; i++ )
        cin >> a[i];
    fill_n( memo.begin(), 100005, -1 );
    cout << frog(0) << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  int ans = 0;

  auto pos = s.find("ABC");
  while (pos != string::npos) {
    ans++;
    pos = s.find("ABC", pos + 3);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

template <class T> class Factorial {
    T mod;
    vector<uint64_t> facts, factinv;

public:
    Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
        facts[0] = 1;
        for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
        factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
        for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
    }

    T fact(int k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T operator[](const int &k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T C(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
    }

    T P(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>((facts[p] * factinv[p-q]) % mod);
    }

    T H(int p, int q) const {
        if(p < 0 || q < 0) return 0;
        return static_cast<T>(q == 0 ? 1 : C(p+q-1, q));
    }
};



int main() {
    int b, w;
    cin >> b >> w;
    Factorial<int> f(b+w, MOD);
    ll ans = 500000004;
    vector<ll> inv2s(b+w+1, 500000004);
    for (int i = 0; i < b+w; ++i) {
        (inv2s[i+1] *= inv2s[i]) %= MOD;
    }
    cout << ans << "\n";
    for (int i = 1; i < b+w; ++i) {
        if(b <= i) (ans += inv2s[i]*(MOD-f.C(i-1, b-1))) %= MOD;
        if(w <= i) (ans += inv2s[i]*f.C(i-1, w-1)) %= MOD;
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 6912
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i

dp = [n-2]
dp[0] = {}
agct = ["A", "G", "C", "T"]
agct.each do |a|
  agct.each do |b|
    agct.each do |c|
      dp[0][a+b+c] = 1
    end
  end
end
dp[0]["AGC"] = 0
dp[0]["GAC"] = 0
dp[0]["ACG"] = 0

def agc?(s)
  s =~ /(AGC.)|(GAC.)|(ACG.)|(.AGC)|(.ACG)|(.GAC)|(A.GC)|(AG.C)/
end

1.upto(n-3).each do |i|
  dp[i] = {}
  dp[i].default = 0

  dp[i-1].each do |k, v|
    agct.each do |add|
      if !agc?(k + add)
        key = k.slice(1,2) + add
        dp[i][key] += v
        dp[i][key] %= MOD #=
      end
    end
  end
end

# p dp[n-3]
p dp[n-3].values.inject(&:+) % MOD



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

using namespace std;

int main()
{
      int n,d,sum=0,count=0;
      double x;
      cin>>n>>d;
      int a[n][d];
      for(int i=0; i<n; i++){
          for(int j=0; j<d; j++)
              cin>>a[i][j];
      }
      for(int i=0; i<n; i++){
          for(int j=i+1; j<n; j++){
              for(int k=0; k<d; k++){
                  sum+=pow((a[i][k]-a[j][k]),2);
              }
              x=sqrt(sum);
              sum=0;
              if(abs(x-int(x))==0){
                  count++;
              }
          }
      }
      cout<<count<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll left = a + b, right = c + d;
    if (left > right) {
        cout << "Left" << endl;
    }
    if (left == right) {
        cout << "Balanced" << endl;
    }
    if (left < right) {
        cout << "Right" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static long lcm(long a, long b) {
        long temp;
        long c = a * b;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return c / b;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        long lcm = lcm(c, d);
        long ans = b - a + 1
                - (b / c - (a - 1) / c)
                - (b / d - (a - 1) / d)
                + (b / lcm - (a - 1) / lcm);
        System.out.println(ans);
    }
    
}


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

int main() {
  int N;
  int d[110] = {};
  int c[110] = {};

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

  for(int i = 0; i < N; i++){
    c[d[i]]++;
  }

  int ans = 0;
  for(int i = 0; i < 110; i++){
    if(c[i] > 0)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

bool is_uruu(int y){
    if(y%400 == 0) return true;
    if(y%100 == 0) return false;
    if(y%4 == 0) return true;
    return false;
}

const int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    ll p = 0, d = 0;
    rep(i,400){
        for(int j=1; j<=12; ++j){
            if((d+12)%7 == 6) ++p;

            int add = m[j];
            if(j==2 && is_uruu(i)) ++add;
            d += add;
        }
    }

    ll y1,y2,m1,d1,m2,d2;
    cin >>y1 >>m1 >>d1 >>y2 >>m2 >>d2;

    ++d2;
    int lim = m[m2];
    if(is_uruu(y2) && m2==2) ++lim;
    if(d2 == lim){
        d2 = 1;
        ++m2;
        if(m2 == 13){
            m2 = 1;
            ++y2;
        }
    }

    auto F = [&](ll Y, ll M, ll D){
        ll ret = p*(Y/400);
        Y %= 400;

        ll now = 0;
        rep(i,400){
            for(int j=1; j<=12; ++j){
                if(i==Y && j==M){
                    if(13 < D){
                        if( (now+12)%7 == 6 ) ++ret;
                    }
                    return ret;
                }

                if( (now+12)%7 == 6 ) ++ret;

                int add = m[j];
                if(j==2 && is_uruu(i)) ++add;
                now += add;
            }
        }
    };

    cout << F(y2,m2,d2) - F(y1,m1,d1) << endl;
    return 0;
}



Measured memory_bytes: 3096
(* O(n^2) *)
let n = read_int () in
let c_max = n / 4
and d_max = n / 7 in
for c = 0 to c_max do
  for d = 0 to d_max do
    if c * 4 + d * 7 = n then (print_endline "Yes"; exit 0)
  done
done;
print_endline "No"

Measured memory_bytes: 384
from collections import defaultdict

n = int(input())
dd = defaultdict(int)
for i in range(2, int(n ** (1 / 2) + 2)):
    while n % i == 0:
        dd[i] += 1
        n //= i
if n != 1:
    dd[n] += 1
ans = 0
cnt = {}
for i in range(20):
    tmp = i * (i + 1) // 2
    cnt[tmp] = i
for i, j in dd.items():
    for num in cnt:
        if j >= num:
            continue
        ans += cnt[num] - 1
        break
print(ans)

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

int main()
{ 
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s == u)
    cout << a - 1 << " " << b << endl;
  else
    cout << a << " " << b - 1 << endl;
  return 0;
}

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

int main(){
   int a,b,c;
   cin>>a>>b>>c;
   
   int cnt = 0;
   for(int i= a; i <= b; i++){
      if(c%i == 0){ cnt++;}   
   }
   cout <<cnt<<endl;
   return 0;
} 


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

int main()
{
  long long int N;
  cin >> N;
  if (N % 2 != 0)
  {
    cout << 0 << endl;
    return 0;
  }
  long long int cnt = 0;
  long long int base = 10;
  while (base <= N)
  {
    cnt += N / base;
    base *= 5;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    ll ans = 0;
    for (ll i = N - 1; i >= 0; i--){
        A[i] += ans;
        if (A[i] % B[i] != 0){
            ans += (B[i] - (A[i] % B[i]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4808
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <string>

const int mod = 1e9+7;

using namespace std;

int main(void){
    string s;
    cin >> s;
    for(int i=0; i<s.length(); i++){
        if(s[i] == '9'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>

using namespace std;

void roll(int target[], int idx[], int size,  bool rev){
  if(!rev){
    int tmp = target[idx[0]];
    for(int i=0;i<size-1;i++){
      target[idx[i]] = target[idx[i+1]];
    }
    target[idx[size-1]] = tmp;
  }else{
    int tmp = target[idx[size-1]];
    for(int i=size-1;i>0;i--){
      target[idx[i]] = target[idx[i-1]];
    }
    target[idx[0]] = tmp;
  }
}

bool is_match(int x[],int y[],int size){
  for(int i=1;i<size;i++){
    if(x[i] != y[i]) return false;
  }
  return true;
}

void pri(int x[], int size){
  for(int i=1;i<size;i++){
    cout << x[i] << " "; 
  }
  cout << endl;
}

int main(){


  static int n = 0;
  cin >> n;

  int x[n][7];

  for(int i=0;i<n;i++){
    for(int j=1;j<7;j++)
      cin >> x[i][j];
  }

  int roll_n[] = {5,1,2,6};
  int roll_e[] = {3,1,4,6};
  int roll_side[] = {3,5,4,2};

  int size = sizeof(x[0])/sizeof(int);
  int size_roll = sizeof(roll_n)/sizeof(int);

  for(int k=0;k<n;k++){
    for(int l=k+1;l<n;l++){

      for(int i=0;i<4;i++){
        roll(x[k], roll_n,size_roll,false);
        ///pri(x,size);
        for(int j=0;j<4;j++){
          roll(x[k], roll_side,size_roll,false);
          if(is_match(x[k],x[l],size)){
            cout << "No" << endl;
            return 0;
          }
        }
      }

      for(int i=0;i<4;i++){
        roll(x[k], roll_e,size_roll, false);
        for(int j=0;j<4;j++){
          roll(x[k], roll_side,size_roll, false);
          if(is_match(x[k],x[l],size)){
            cout << "No" << endl;
            return 0;
          }
        }
      }

    }
  }



  cout << "Yes" << endl;
}





Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
#define MOD 1000000007
#define MSG(a) cout << #a << " " << a << endl;
#define print(a) cout << a << endl;
template <class T, class C>
void chmax(T &a, C b)
{
    if (a <= b)
        a = b;
}
template <class T, class C>
void chmin(T &a, C b)
{
    if (a >= b)
        a = b;
}

// const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
// const int dx[]{0, 1, 0, -1}, dy[]{1, 0, -1, 0};

template <class T>
T sum(const vector<T> &v)
{
    T res = 0;
    for (size_t i = 0; i < v.size(); ++i)
        res += v[i];
    return res;
}
// vector の出力
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    size_t last = v.size() - 1;
    for (size_t i = 0; i < v.size(); ++i)
    {
        out << v[i];
        if (i != last)
            out << " ";
    }
    return out;
}

int main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //////////////////////////////////////////

    // string a, b;
    // cin >> a >> b;
    int h, w, n;
    cin >> h >> w >> n;
    
    int a[n];
    rep(i, n)
    {
        cin >> a[i];
    }
    int x = 0;
    int xi = 0;
    vector<int> ans(w);

    rep(i, h)
    {
        rep(j, w)
        {
            if (i % 2 == 0)
            {
                ans[w - j - 1] = x + 1;
            }
            if (i % 2 == 1)
            {
                ans[j] = x + 1;
            }

            xi += 1;
            if (xi >= a[x])
            {
                x += 1;
                xi = 0;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n;
	cin >> n;
	cout << setprecision(7) << (double)((n + 1) / 2) / n;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

double stddev(int n, int *s) {
  int i;
  double ave, dev;

  ave = 0;
  for(i = 0;i < n;i++) {
    ave += s[i];
  }
  ave /= n;
  dev = 0;
  for(i = 0;i < n;i++) {
    dev += pow(s[i] - ave, 2);
  }
  dev /= n;
  
  return sqrt(dev);
}

			       

int main() {
  int n,i;
  while(1) {
    scanf("%d", &n);
    if(n == 0) break;
    int s[n];
    for(i = 0;i < n;i++) {
      scanf("%d", s+i);
    }
    printf("%lf\n", stddev(n, s));
  }

  return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,n) for(int i=0;i<n;i++)
#define repa(i,j,n) for(int i=j;i<n;i++)
//#define v.all() v.begin(),v.end()
#define repr(i,n) for(int i=n;i>=0;i--)
#define int long long int
#define vi vector<int>
#define vpi vector<pair<int,int>>

signed  main(){
	int test=1;
	//cin>>test;
	rep(tt,test) {
		string a,b;
		int c=0;
		cin>>a>>b;
		rep(i,a.length()){
			if(a[i]==b[i]) c++;
		}
		cout<<c<<endl;
		
	}
	return 0;
}


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

int main(void){
   int m,f,r;

   while(true){
       cin >> m >> f >> r;
       if(m == -1 && f == -1 && r == -1){
           break;
       }
       if(m == -1 || f ==-1){
           cout << "F" ;
       }
       else if(m+f >= 80){
           cout << "A" ;
       }
       else if(65 <= m+f && m+f < 80){
           cout << "B" ;
       }
       else if(50 <= m+f && m+f < 65){
           cout << "C" ;
       }
       else if(30 <= m+f && m+f < 50){
           if(r >= 50){
               cout << "C" ;
           }
           else{
               cout << "D" ;
           }
       }
       else{
           cout << "F" ;
       }
       cout << endl;
   }
}



Measured memory_bytes: 3088
from collections import deque
S = deque(input())
N = int(input())
is_inversed = False
for i in range(N):
    Q = input()
    if Q[0] == '1':
        is_inversed = not (is_inversed)
    else:
        if (Q[2] == '1' and is_inversed) or (Q[2] == '2' and not (is_inversed)):
            S.append(Q[4])
        else:
            S.appendleft(Q[4])
if is_inversed:
    print(''.join(list(S)[::-1]))
else:
    print(''.join(S))


Measured memory_bytes: 74584
#include <cstdio>

using namespace std;

int n;
int a[300];
double dp[301][301][301];

double calc(int x, int y, int z) {
    double ans = 0;
    
    if (x == 0 && y == 0 && z == 0) return 0;
    if (dp[x][y][z] > 0) return dp[x][y][z];
    
    if (x > 0) ans += (calc(x - 1, y, z) + 1) * x / n;
    if (y > 0) ans += (calc(x + 1, y - 1, z) + 1) * y / n;
    if (z > 0) ans += (calc(x, y + 1, z - 1) + 1) * z / n;
    ans += 1 - (double)(x + y + z) / n;
    
    return dp[x][y][z] = ans * n / (x + y + z);
}

int main() {
    int x = 0, y = 0, z = 0, i;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n; i++) {
        if (a[i] == 1) {
            x++;
        } else if (a[i] == 2) {
            y++;
        } else {
            z++;
        }
    }
    
    printf("%.12lf\n", calc(x, y, z));
    
    return 0;
}


Measured memory_bytes: 213248
#include<iostream>

int n;
int pw[10] = {1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};

void solve(){
	int ans = 0;
	int tmp = n;
	for(int i=0; i<10; i++){
		int temp = tmp%8;
		if(temp==4)
			temp++;
		else if(temp > 4)
			temp+=2;
		if(i==9)
			std::cout << temp;
		else{
			ans += temp*pw[i];
			tmp = tmp/8;
			if(tmp == 0)
				break;
		}
	}
	std::cout << ans << std::endl;
}

int main(){
	while(true){
		std::cin >> n;
		if(!n)
			return 0;
		solve();
	}
}

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

int main(){
    int a,b,ans;
    char op;
    while(true){
        cin >> a >> op >> b;
        if(op == '?') break;
        if(op == '+') ans = a+b;    
        if(op == '-') ans = a-b;    
        if(op == '*') ans = a*b;    
        if(op == '/') ans = a/b;
        cout << ans << endl;   
    }
    return 0;
}



Measured memory_bytes: 3092
//#pragma Gbb optimize("Ofast") 
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<time.h>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;

int a[32] = { 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 };

int main()
{
	int n;
	cin >> n;
	cout << a[n - 1];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <utility>
#include <cmath>
#include <cstdio>

using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;
LL MOD = 1000000007;


typedef vector<LL> VI;
typedef vector<VI> VVI;


VVI matrix_multi(VVI a,VVI b){
	VVI ret(a.size(),VI(b[0].size(),0));
	for(int k=0;k<a[0].size();k++)
	for(int i=0;i<a.size();i++)
	for(int j=0;j<b[0].size();j++)
	{
		ret[i][j] += a[i][k] * b[k][j];
        ret[i][j] %= MOD;
    }
	return ret;
}

VVI matrix_pow(VVI a, LL k) {
    if(k == 1) return a;
    VVI b = matrix_pow(a, k/2);
    VVI ans = matrix_multi(b, b);
    if(k%2==1) {
        ans = matrix_multi(ans, a);
    }
    return ans;
}


int main() {
    LL N, K;
    cin >> N >> K;
    VVI A(N, VI(N, 0));
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++)
            cin >> A[i][j];
    }
    A = matrix_pow(A, K); 
    LL ans = 0;
    for(auto vec: A) {

        for(auto elem: vec) {
            ans += elem;
            //cout << elem << " " ;
        }
        //cout << endl;
    }
    cout << ans % MOD << endl;

    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    using P = array<char, 8>;
    map<P, int> m; m[{0, 1, 2, 3, 4, 5, 6, 7}] = 0;
    P x = {0, 1, 2, 3, 4, 5, 6, 7};
    queue<P> Q;
    Q.emplace(x);
    while(!Q.empty()){
        P a = Q.front(); Q.pop();
        int val = m[a];
        for (int i = 0; i < 8; ++i) {
            if(!a[i]){
                swap(a[i], a[i^4]);
                if(!m.count(a)){
                    m[a] = val+1;
                    Q.emplace(a);
                }
                swap(a[i], a[i^4]);
                if(i&3){
                    swap(a[i-1], a[i]);
                    if(!m.count(a)){
                        m[a] = val+1;
                        Q.emplace(a);
                    }
                    swap(a[i-1], a[i]);
                }
                if((i&3) != 3){
                    swap(a[i], a[i+1]);
                    if(!m.count(a)){
                        m[a] = val+1;
                        Q.emplace(a);
                    }
                    swap(a[i], a[i+1]);
                }
            }
        }
    }
    while(scanf("%hhd", &x[0]) != EOF){
        for (int i = 1; i < 8; ++i) scanf("%hhd", &x[i]);
        cout << m[x] << "\n";
    }
    return 0;
}


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

int main()
 {
 	string s;
 	cin>>s;
 	int i,n,f=0,g=0;
 	n=s.length();
 	for(i=0;i<n;i++)
 		{
 			if(s[i]!=s[n-i-1])
 				f=1;
		 }
	for(i=0;i<(n-1)/2;i++)
		{
			if(s[i]!=s[(n-1)/2-i-1])
				g=1;
		}
	if(f==0&&g==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
 	return 0;
 }


Measured memory_bytes: 3556
#include<iostream>
#include <string>
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define mp make_pair
#define sz(v) (int)(v.size())
#define len(s) (int)(s.length())
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll power(ll a,ll n) 
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
int main(){
    ios;
    int n;
    cin>>n;
    vector <ll> a(n);
    inarr(a,n);
    sort(all(a));
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if((a[i] + a[j] > a[k]) && (a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k])){
                    ans+=1;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
typedef unsigned long long int ll;

ll A, B, N;

int main()
{

  ll p;
  
  cin >> A >> B >> N;
  p = min(B-1, N);
  A = floor(A*p/B);
  printf("%lld\n", A);


  return 0;
}
/*
  x = p + qB (p<B)
  Ax/B = Ap/B + Aq
  x/B = p/B + q

  floor(Ax/B)
= floor(Ap/B + Aq)
= floor(Ap/B) + Aq

  A × floor(x/B)
= A × floor(p/B + q)
= A × floor(p/B) + Aq
= Aq
  
  floor(Ax/B) - A × floor(x/B) =
  floor(Ap/B)

  floor(Ap/B)の最大値を求める
  p<Bなので p=min(B-1,N)
  p=B-1のとき
  floor(A(B-1)/B) = floor(A-1/B) = A-1
  p=Nのとき
  floor(AN/B)

  */

Measured memory_bytes: 3700
# -*- coding: utf-8 -*-
N = int(input())
# 文字列の入力
s = input()
t = s.split(" ")
#print(t)
ans = []
for i in range(N):
    ans.append(0)

#print(ans)

for i in range(len(t)):
    ans[int(t[i])-1]=ans[int(t[i])-1]+1

for i in ans:
    print(i)


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

int main() {
    int n, a, b,count = 0;
    std::cin >> n >> a >> b;

    for (int i = 1; i < n+1; i++) {
        int sum = 0;
        int tmp = i;
        while (tmp > 0) {
            sum += tmp % 10;
            tmp /= 10;
        }
        if (sum >= a && sum <= b)count+=i;
    }
    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define ck(n,a,b) ((a)<=(n)&&(n)<(b))
#define p(s) cout<<(s)<<endl
#define F first
#define S second
typedef long long ll;
using namespace std;

int main() {
	int h, w;
	while(cin>>h>>w, h||w){
		int val=h*h+w*w;
		int ans=10000000;
		int hh, ww;

		//REP(i, 1, 150){
		for(int i=149; i>0; i--){
			REP(j, i+1, 151){
				int tmp=i*i+j*j;
				if(tmp>val){
					if(tmp<=ans){
						ans=tmp;
						hh=i;
						ww=j;
					}
				}else if(tmp==val && i>h){
					ans=tmp;
					hh=i;
					ww=j;
				}
				/*
				int tmp=i*i+j*j;
				if(tmp>val){
					if(tmp==ans&&i<hh){
						hh=i;
						ww=j;
					}
					else if(tmp<ans){
						ans=tmp;
						hh=i;
						ww=j;
					}
				}else if(tmp==val && i>h){
					if(tmp==ans&&i>hh)continue;
					hh=i;
					ww=j;
				}
				*/
			}
		}

		cout<<hh<<" "<<ww<<endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int int64_t
#define fi first
#define se second
signed main(){
  int n;
  string s;
  int ac=0,wa=0,tle=0,re=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s=="AC") ac++;
    else if(s=="WA") wa++;
    else if(s=="TLE") tle++;
    else re++;
  }
  cout<<"AC x "<<ac<<"\nWA x "<<wa<<"\nTLE x "<<tle<<"\nRE x "<<re<<"\n";
}


Measured memory_bytes: 3632
// g++ -std=c++11 -O2 -Wall -Wl,--stack=268435456

#include <bits/stdc++.h>
using namespace std;

typedef vector< int >      vi;
typedef vector< vi >       vvi;
typedef pair<int, int>     pi;
typedef vector< pi >       vpi;

typedef long long          ll;
typedef vector<ll>         vl;
typedef vector< vl >      vvl;

const int LARGE_INT = 1000000007;
const ll LARGE_LONG = 1L << 62;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = (int)(a); i < (int)(b); i++)

const int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    vi a(2);
    cin >> a[0] >> a[1];
    sort(a.begin(), a.end());
    if (a[0] == 1 && a[1] == 2)  cout << 3;
    else if (a[0] == 1 && a[1] == 3) cout << 2;
    else if (a[0] == 2 && a[1] == 3) cout << 1;
    cout << endl;
    
    return 0;
}

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

int main()
{
	int n,k;cin>>n>>k;
		int mi=1001010100;
	
	int h[n+1],dp[n+1];
	
	for(int i=0;i<n;i++)
{	cin>>h[i];dp[i]=mi;}
	
	dp[0]=0;dp[1]=abs(h[1]-h[0]);
	
	
	for(int i=2;i<n;i++)
	{
	
		for(int j=1;j<=k;j++)
		{	if(i>=j)
		dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		else
		break;
		}
	}
		cout<<dp[n-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int w,h,n,i,c=0,d,e=0,f;
	int x[200],y[200],a[200];
	scanf("%d %d %d",&w,&h,&n);
	d=w;
	f=h;
	for(i=0;i<n;i++){
		scanf("%d %d %d",&x[i],&y[i],&a[i]);
		if(a[i]==1)
			if(c<x[i])
				c=x[i];
		if(a[i]==2)
			if(d>x[i])
				d=x[i];
		if(a[i]==3)
			if(e<y[i])
				e=y[i];
		if(a[i]==4)
			if(f>y[i])
				f=y[i];
	}
	if(c>=d || e>=f)
		printf("0\n");
	else
		printf("%d\n",(d-c)*(f-e));
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL


struct node{
  struct node *parent;
  struct node *left;
  struct node *right;
  int key;
};

typedef struct node * Node;

void insert(Node,int);
void PrintInorder(Node );
void PrintPreorder(Node );
Node find(Node ,int);
Node root,newnode;

main(){

  int n,i,k;
  char T[20];
  
  scanf("%d",&n);
  
  root = malloc(sizeof(struct node));
  
  for( i=0 ; i<n ; i++ ){
    scanf("%s",T);
    
    if( T[0] == 'i'){
      scanf("%d",&k);
    
      if( i != 0)
	insert(root, k);
     
      else 
	root->key = k;
    }
    else if(T[0] == 'p'){
      PrintInorder(root);
      printf("\n");
      PrintPreorder(root);
      printf("\n"); 
    }
    else{
      scanf("%d",&k);
      if(find(root,k)==NIL)printf("no\n");
      else printf("yes\n");
    }
  }
  return 0;
}

void insert(Node T, int k){
  
  Node x,y,z;
  z = malloc(sizeof(struct node));
  z->key =k;
  z->left = z->right = NIL;

  y = NIL;
  x = T;
  while(1){
    y = x;
    if( z->key < x->key )
      x = x->left;
    else 
      x = x->right;

    if( x == NIL )break;
  }
  z->parent =y;
    if( y == NIL )
      T = z;
    else if(z->key < y->key)
      y->left = z;
    else 
      y->right = z;
    
}

Node find(Node T,int k){
  if(T == NIL || k == T->key)return T;
  if(k < T->key )return find(T->left,k);
  else return find(T->right,k);
}
 
void PrintInorder(Node T)
{
  if(T != NIL){
     PrintInorder(T->left);
  
  printf(" %d",T->key);
    
   PrintInorder(T->right);
  }
  else return;
   
}
 

void PrintPreorder(Node T){
  if(T != NIL){
    printf(" %d",T->key);
 
    PrintPreorder(T->left);
    PrintPreorder(T->right);
 
  }
  else return ;
}     

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int num_thousand = N / 1000;
  int num_hundred = (N % 1000) / 100;
  int num_ten = ((N % 1000) % 100) / 10;
  int num_one =  ((N % 1000) % 100) % 10;
 
  if (num_thousand == num_hundred) {
    if (num_hundred == num_ten) {
      cout << "Yes" << endl;
    }
    
    else {
      cout << "No" << endl;
    }
  }
  
  else if (num_hundred == num_ten) {
    if (num_ten == num_one) {
      cout << "Yes" << endl;
    }
    
    else {
      cout << "No" << endl;
    }
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    println!("{}", solve(&input));
}

fn solve(input: &str) -> String {
    let mut iter = input.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let mut answered = 0;
    let mut penalty = 0;
    let mut penalties = vec![0; n + 1];
    for _ in 0..m {
        let p: usize = iter.next().unwrap().parse().unwrap();
        let r = iter.next().unwrap();
        if r == "AC" {
            if penalties[p] != -1 {
                answered += 1;
                penalty += penalties[p];
            }
            penalties[p] = -1;
        } else {
            if penalties[p] != -1 {
                penalties[p] += 1;
            }
        }
    }
    format!("{} {}\n", answered, penalty)
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, d;


int main() {
    ll n, d;
    cin >> n >> d;

    ll ans = 0;
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        if (d * d >= a * a + b * b) ans++;
    }
    cout << ans << endl;
}

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

int main()
{
  int N, K;
  std::string S;

  std::cin >> N >> S >> K;

  int wc = 0, bc = 0;
  for (int i = 0; i < S.size(); i++)
  {
    if (S[i] != S[K - 1])
    {
      S[i] = '*';
    }
  }

  std::cout << S << std::endl;
}


Measured memory_bytes: 888
#include <stdio.h>
int main(){
  int n,m,p,x,r=0;
  int t[101];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&t[i]);
    r+=t[i];
  }
  scanf("%d",&m);
  for(int i=0;i<m;i++){
    scanf("%d%d",&p,&x);
    printf("%d\n",r+x-t[p-1]);
  }
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
long long MOD = 1000000000 + 7;

int const inf = INT_MAX / 2;
enum query_type { min_query, max_query, sum_query, gcd_query};

template<typename T>
T _gcd(T a, T b){
  if(a == 0){
    return b;
  }
  if(b == 0){
    return a;
  }
  if(a%b==0){
    return b;
  } else { 
    return _gcd(b, a%b);
  }
}

template<class T> struct segtree {
  int N;
  vector<T> dat, sum;
  function<T(T, T)> func;
  T ngvalue;

  void init(int n, function<T(T, T)> const& f, T ng) {
    N = 1;
    while(N < n) N <<= 1;
    dat.assign(2 * N - 1, 0);
    sum.assign(2 * N - 1, 0);
    func = f;
    ngvalue = ng;
  }



  segtree() = default;

  segtree(int n, query_type qtype) {
    if(qtype == min_query) {
      init(n, [](T a, T b){return min(a, b);}, numeric_limits<T>::max());
    }
    else if(qtype == max_query) {
      init(n, [](T a, T b){return max(a, b);}, numeric_limits<T>::min());
    }
    else if(qtype == sum_query) {
      init(n, [](T a, T b){return a + b;}, 0);
    }
    else if(qtype == gcd_query) {
      init(n, [](T a, T b){return _gcd(a,b);}, 0);
    }
    else {
      runtime_error("no matching query type");
    }
  }

  void add(int i, T x) {
    add(i, i + 1, x);
  }

  void add(int a, int b, T x) {
    add(a, b, x, 0, 0, N);
  }

  T add(int a, int b, T x, int k, int l, int r) {
    if(b <= l || r <= a) return dat[k];
    if(a <= l && r <= b) {
      sum[k] += x;
      return dat[k] += x;
    }
    int m = (l + r) / 2;
    return dat[k] = func(add(a, b, x, 2 * k + 1, l, m), add(a, b, x, 2 * k + 2, m, r)) + sum[k];
  }

  T operator()(int a, int b) {
    return query(a, b, 0, 0, N);
  }

  T query(int a, int b, int k, int l, int r) {
    if(b <= l || r <= a) return ngvalue;
    if(a <= l && r <= b) return dat[k];
    int m = (l + r) / 2;
    return func(query(a, b, 2 * k + 1, l, m), query(a, b, 2 * k + 2, m, r)) + sum[k];
  }
};


int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  segtree<ll> s(N, gcd_query);

  for(int i = 0; i < N; i++){
    ll tmp;
    cin >> tmp;
    s.add(i, tmp);
  }

  ll max_val = 0;
  for(int i = 0; i < N; i++){
    ll tmp_ans;
    if(i == 0){
      tmp_ans = s(1, N);
    } else if(i == N-1){
      tmp_ans = s(0, N-1);
    } else { 
      tmp_ans = _gcd(s(0,i), s(i+1, N));
    }
    // cerr << tmp_ans << endl;
    max_val = max(max_val, tmp_ans);
  }
  cout << max_val << endl;


}


Measured memory_bytes: 4352