akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;



int main(){
    int n;
    cin>>n;
    map<string,int> mp;
    int count=0;
    rep(i,n){
        string s;
        cin>>s;
        auto it =mp.find(s);
        if(it != mp.end()){
            mp[s]=1;
        }else{
            count++;
            mp[s]=1;
        }
        
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 19136
#include <stdio.h>

int main(){
	int n, a, max, min, i;
    long long int sum = 0;
    
    scanf("%d", &n);
    
	for(i = 0; i < n; i++){
		scanf("%d", &a);
		if(i == 0){
			max = a;
			min = a;
		}
		if(a > max){
			max = a;
		}else if(a < min){
			min = a;
		}
		sum += a;
	}
   printf("%d %d %lld\n", min, max, sum);
   
}


Measured memory_bytes: 2104
/*
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1295
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main() {
  int w, d;
  while(cin >> w >> d, w) {
    vi hx(w);
    vi hy(d);
    REP(i, w) cin >> hx[i];
    REP(i, d) cin >> hy[i];
    SORT(hx);
    SORT(hy);

    auto xit = hx.begin();
    for(auto it = hy.begin(); it != hy.end(); ) {
      while(*it > *xit) {
        xit++;
      }
      if (xit == hx.end()) break;
      if (*it == *xit) {
        it = hy.erase(it);
        if (++xit == hx.end()) break;
      }else{
        it++;
      }
    }

    int res = 0;
    for(auto h : hx) {
      res += h;
    }
    for(auto h : hy) {
      res += h;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;

int main() {
	ll n,m;
	cin>>n>>m;
	if(n==1||m==1){
		if(n==1&&m==1)cout<<1<<endl;
		else cout<<n+m-3<<endl;
	}
	else cout<<(n-2)*(m-2)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>

using namespace std;

typedef pair<double, double> P;
const double PI = acos(-1);

double A, B, C, D, E, F;

bool isin(double x, double y) {
	if ((x * (D / C) <= y) && (x * (E / F) >= y) && (x * ((D - F) / (C - E) + (D - C * (D - F) / (C - E))) <= y))
		return true;
	else return false;
}

bool hantei(double r) {
	double x1, y1, x2, y2, x3, y3;
	x1 = cos((atan2(C, D) + atan2(E, F)) / 2.0) * r / sin((atan2(C, D) - atan2(E, F)) / 2.0);
	y1 = sin((atan2(C, D) + atan2(E, F)) / 2.0) * r / sin((atan2(C, D) + atan2(E, F)) / 2.0);
	x2 = cos((atan2(-C, -D) + atan2(E - C, F - D)) / 2.0) * r / sin((atan2(-C, -D) - atan2(E - C, F - D)) / 2.0);
	y2 = sin((atan2(-C, -D) + atan2(E - C, F - D)) / 2.0) * r / sin((atan2(-C, -D) - atan2(E - C, F - D)) / 2.0);
	x3 = cos((atan2(C - E, D - F) + atan2(-E, -F)) / 2.0) * r / sin((atan2(C - E, D - F) - atan2(-E, -F)) / 2.0);
	y3 = sin((atan2(C - E, D - F) + atan2(-E, -F)) / 2.0) * r / sin((atan2(C - E, D - F) - atan2(-E, -F)) / 2.0);

	if (isin(x1, y1) || isin(x2, y2) || isin(x3, y3))return false;

	if (((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2) >= 4.0 * r) ||
		((x1 - x3)*(x1 - x3) + (y1 - y3)*(y1 - y3) >= 4.0 * r) ||
		((x3 - x2)*(x3 - x2) + (y3 - y2)*(y3 - y2) >= 4.0 * r))return true;
	return false;

}

int main() {

	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	cin >> E;
	cin >> F;

	C -= A, D -= B, E -= A, F -= B;
	A = 0, B = 0;

	double h, longest;
	longest = max(sqrt(C*C + D*D), max(sqrt(E*E + F*F), sqrt((E - C)*(E - C) + (F - D)*(F - D))));
	h = abs(C * F - D * E) / longest;

	cout << setprecision(12) << abs(C*F - D*E) / (sqrt(C*C + D*D) + sqrt(E*E + F*F) + sqrt((C - E)*(C - E) + (D - F)*(D - F)) + 2 * h) << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
n,m = map(int,readline().rstrip().split())
s = readline().rstrip().split()
total = 0
for i in s:
  total+=int(i)
cnt =0
for i in s:
  if int(i) >= total/(4*m):
    cnt+=1
if cnt >= m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**8)
(n,m),*xy = [list(map(int,r.split())) for r in open(0)]
g = [[] for _ in range(n)]
dp = [0 for _ in range(n)]

for i in xy:
    x,y = i[0],i[1]
    x -= 1
    y -= 1
    g[y].append(x)

def rec(node):
    if dp[node] > 0:
        return dp[node]
    
    if not g[node]:
        dp[node] = 0
        return 0

    for child in g[node]:
        dp[node] = max(dp[node], rec(child) + 1)

    return dp[node]

ans = 0
for i in range(n):
    ans = max(ans, rec(i))
print(ans)


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N, K;
  cin >> N >> K;
  int a[N];
  for (int i = 0; i < N; i++) scanf("%d", a + i);

  cout << (N - 1 + (K - 2)) / (K - 1) << endl;
  return 0;
}


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

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(){
    string n;
    cin >> n;
    ll t=0;
    rep(i, n.size()){
        int c;
        c = ctoi(n.at(i));
        //cout << c << endl;
        t+=c;
    }
    //cout << t<< endl;
    if(t%9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3752
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
map<int,int>a[2];
vector<P>vec[2];
int main(){
	cin >> n;
	rep(i,n){
		int x; cin >> x; a[i%2][x]++;
	}
	int ans = INF;
	rep(i,2){
		int mx = 0;
		vec[i].pb(mp(0,INF+i));
		for(auto x:a[i]){
			vec[i].pb(mp(x.sc,x.fi));
		}
		sort(vec[i].begin(),vec[i].end(),greater<P>());
	}
	rep(x,3) rep(y,3){
	    if(x < vec[0].size() && y < vec[1].size() && vec[0][x].sc != vec[1][y].sc){
	        ans = min(ans,n-vec[0][x].fi-vec[1][y].fi);
	    }
	}
	cout << ans << endl;
}

Measured memory_bytes: 6136
from collections import deque

inf = float('inf')
H,W = (int(x) for x in input().split())
maze = [['#'] for _ in range(H+2)]
white = 0
for i in range(1,H+1):
    line = input()
    white += line.count('.')
    maze[i] = '#' + line + '#'

dh,dw = [0,1,0,-1],[1,0,-1,0]
sh,sw = (1,1)
ans = -1

def bfs(sh,sw):
    seen = deque()
    dist = [[inf]*(W+2) for _ in range(H+2)]
    seen.append((sh,sw))
    dist[sh][sw] = 0
    while seen:
        h,w = seen.popleft()
        if (h,w) == (H,W):
            break
        for i in range(4):
            nh,nw = h+dh[i], w+dw[i]
            if nh < 1 or H < nh: continue
            if nw < 1 or W < nw: continue
            if maze[nh][nw] == '#': continue
            if dist[nh][nw] != inf: continue
            dist[nh][nw] = dist[h][w] + 1
            seen.append((nh,nw))
    return dist[H][W]

if bfs(sh,sw) != inf:
    ans = white - (bfs(sh,sw) + 1)
print(ans)

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

vector<pii> mat;
vvi dp;
int rec(int l, int r){
    if(dp[l][r] != INF) return dp[l][r];
    if(l == r) return dp[l][r] = 0;
    int res = INF;
    REP(i,l,r){
        int x = mat[l].fi * mat[i].se * mat[r].se;
        res = min(res, x + rec(l,i) + rec(i+1,r));
    }
    return dp[l][r] = res;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    mat = vector<pii>(n);
    rep(i,n){
        int r, c; cin >> r >> c;
        mat[i] = pii(r, c);
    }
    dp = vvi(n, vi(n, INF));
    if(n == 1) cout << 0 << endl;
    else cout << rec(0, n-1) << endl;
    return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
    string S;
    cin>>S;
    vector<int> v(3,0);
    for(ll i=0;i<S.size();i++){
        if(S[i]=='a') v[0]++;
        else if(S[i]=='b') v[1]++;
        else v[2]++;
    }
    sort(v.begin(),v.end(),greater<ll>());
    if((v[0]==1&&v[1]==1&&v[2]==0)||(v[0]==1&&v[1]==0&&v[2]==0)){
        cout<<"YES"<<endl;
        return 0;
    }
    if(v[0]==0||v[1]==0||v[2]==0||v[0]-1>v[1]||v[0]-1>v[2]){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 512
/* ex 9_1
   offNaria */

#include <stdio.h>
#include <stdlib.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node
{
    char elem;
    struct node *next;
} node;

void push(node **first, char elem); //スタックにデータを追加
char pop(node **first);             //スタックからデータを取り出す

int main(void)
{
    char input[11], output[11];
    //最初のノードの指す先
    node *first = NULL;
    //スタックにノードを追加
    scanf("%s", input);
    for (int i = 0; i < 11; i++)
    {
        //'0'か'1'ならスタックに挿入
        if (input[i] == '0' || input[i] == '1')
        {
            push(&first, input[i]);
        }
        //'B'ならスタックの一番上のものを取り出す
        else if (input[i] == 'B')
        {
            pop(&first);
        }
        else
        {
            break;
        }
    }
    //スタックの逆順に出力
    for (int i = 0; i < 11; i++)
    {
        output[10 - i] = pop(&first);
    }
    for (int i = 0; i < 11; i++)
    {
        if (output[i] != 'x')
        {
            printf("%c", output[i]);
        }
    }
    printf("\n");
    return 0;
}

void push(node **first, char elem)
{
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if (new == NULL)
        exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

char pop(node **first)
{
    char elem;
    node *tmp = *first;
    if (tmp != NULL)
    {
        elem = tmp->elem;
        *first = tmp->next;
        //取り出したノードのメモリを解放
        free(tmp);
        return elem;
    }
    //スタックの一番下またはスタックが空であれば目印記号'x'を返す
    else
    {
        return 'x';
    }
}


Measured memory_bytes: 1596
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	a := getNextInt(scanner)
	b := getNextInt(scanner)

	max := a * b
	m := a - b
	if max < m {
		max = m
	}
	p := a + b
	if max < p {
		max = p
	}

	fmt.Fprintln(writer, max)
	writer.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  cin >> s;
  int x;
  x = s % 10;
  s = s / 10;
  x = x + s % 10;
  s = s / 10;
  x = x + s;
  cout << x << endl;
}

Measured memory_bytes: 3644
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key = lambda x: x[1])
time = 0
ans = "Yes"
for i in range(n):
    time += ab[i][0]
    if time <= ab[i][1]:
        continue
    else:
        ans = "No"
        break
print(ans)


Measured memory_bytes: 46856
def dfs(i, total):
    global ans
    if i == len(s):
        if eval(total) == 7:
            ans = total + "=7"
            return ans
        return 0
    dfs(i + 1, total + "+" + s[i])
    dfs(i + 1, total + "-" + s[i])

s = input()
ans = 0
dfs(1, s[0])
print(ans)

Measured memory_bytes: 3060
//#pragma warning(disable:4996)
#include <stdio.h>

int main() {
	int n, a, b, c, d;
	char s[200010];
	bool visited1[200010] = {};
	bool visited2[200010] = {};
	scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
	scanf("%s", &s);

	a -= 1; b -= 1; c -= 1; d -= 1;

	bool answer1 = false;
	visited1[c] = true;
	for (int i = c; i >= a; i--) {
		if (s[i] == '.') {
			if (visited1[i + 1] || visited1[i + 2]) {
				if (i == a) {
					answer1 = true;
					break;
				}
				visited1[i] = true;
			}
		}
	}

	bool answer2 = false;
	visited2[d] = true;
	for (int i = d; i >= b; i--) {
		if (s[i] == '.') {
			if (visited2[i + 1] || visited2[i + 2]) {
				if (i == b) {
					answer2 = true;
					break;
				}
				visited2[i] = true;
			}
		}
	}

	bool answer3 = false;
	if (d < c) {//途中で抜かす必要がある
		for (int i = b - 1;i< d; i++) {
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
				answer3 = true;
				break;
			}
		}
	}
	else {
		answer3 = true;
	}
	
	if (answer1&& answer2&& answer3) printf("Yes\n");
	else printf("No\n");
}



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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,k;
    cin >> n >> k;
    int32 cur = 1;
    REP(i,n){
        cur = min(cur + k, cur * 2);
    }
    ANS(cur);
    return 0;
}

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

#define DECIMAL_PLACES 4

int main(void)
{
  double a, b, c, d, e, f;
  double x, y;

  while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
    c /= a;
    b /= a;
    a /= a; // a を書き換えると上２つに影響するので最後に回す。

    f -= (c * d);
    e -= (b * d);
    d -= (a * d); // d を書き換えると上２つに影響するので最後に回す。

    f /= e;
    d /= e;
    e /= e; // e を書き換えると上２つに影響するので最後に回す。

    c -= (f * b);
    a -= (d * b);
    b -= (e * b); // b を書き換えると上２つに影響するので最後に回す。

    /* 四捨五入 */
    c = c * pow(10, (DECIMAL_PLACES));
    x = (double)(int)(c + 0.5);
    x = x * pow(10, -(DECIMAL_PLACES));

    f = f * pow(10, (DECIMAL_PLACES));
    y = (double)(int)(f + 0.5);
    y = y * pow(10, -(DECIMAL_PLACES));

    printf("%.3lf %.3lf\n", x, y);
  }

  return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n, k;
  cin >> n >> k;
  vector<bool> D(10, false);
  rep(i,k) {
    int j;
    cin >> j;
    D[j] = true; //嫌いな数字
  }
  auto keta = [&](ll x) {
    int cnt = 0;
    while (x > 0) {
      x /= 10;
      cnt++;
    }
    return cnt;
  };
  ll ans = n;
  while (true) {
    ll ten = 1;
    bool ok = true;
    rep(_, keta(ans)) { //各桁の数字を調べる
      ll temp = ans / ten;
      temp %= 10;
      if (D[temp]) {
        ok = false; break;
      }
      ten *= 10;
    }
    if (ok) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())

j = 1
Ans = 0
Q = 1
n = N

while n > 0:
    if n >= 10:
        if j == 1:
            Ans += 9 * Q
    else:
        if j == 1:
            Ans += N - Q + 1
    n = n // 10
    j = j * (-1)
    Q = Q * 10

print(Ans)

Measured memory_bytes: 3064
//In the Name of Allah Most Gracious, Most Merciful//
/*If you want something you've never had, you have  to do something you never did.*/

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


#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define M 100007
#define INF 1e9
#define INFL 1e18
#define PI acos(-1)
#define mp make_pair
#define fast_in_out ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move



ll bigmodRecur(ll b,ll p,ll m)
{
    if(p==0) return 1%m;
    if(p%2==0)//p is even
    {
        ll y=bigmodRecur(b,p/2,m);
        return (y*y)%m;//b^p=y*y
    }
    else
    {
        //b^p=b*b^(p-1)
        return (b*bigmodRecur(b,p-1,m));
    }
}

//Repeated Squaring Method
//
ll  bigmod(ll b,ll p,ll m)
{
    ll res=1%m;
    ll x=b%m;
    while(p)
    {
        if( p & 1 )res=(res*x) % m;
        x=(x*x)%m;
        p >>=1;
    }
    return res;
}

int main()
{
    fast_in_out;
   //  #ifndef ONLINE_JUDGE
   //    freopen("input.txt","r",stdin);
   //    freopen("output.txt","w",stdout);
  //   #endif
 ll  b,p,m;
   cin>>p;
     m=1e9+7;
    // ll n=(p-1)*p/2;
     b=10;
     //n=n%m;
     ll ans=bigmod(b,p,m);
     ll ans1=(2*bigmod(b-1,p,m))%m;
     ll ans2=bigmod(b-2,p,m);
     ans=((ans-ans1+ans2)+m)%m;
//    ll ans=bigmodRecur(b,p,m);
    cout<<ans<<endl;
}


Measured memory_bytes: 3536
class UnionFind():
    #https://note.nkmk.me/python-union-find/ 
    #note.nkmk.me  2019-08-18 
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


#初期入力、集合とユニオンファインド
import sys
input = sys.stdin.readline
N,M,K = (int(x) for x in input().split())

#接続（友好関係、ブロック関係）
uf =UnionFind(N+1)
conn_fri ={i:set() for i in range(1,N+1)}
conn_blo ={i:set() for i in range(1,N+1)}
for i in range(M):
    a,b = (int(x) for x in input().split())
    uf.union(a,b)
    conn_fri[a].add(b)
    conn_fri[b].add(a)
for i in range(K):
    c,d = (int(x) for x in input().split())
    conn_blo[c].add(d)
    conn_blo[d].add(c)

#友達候補の数＝同じグループにいる、友達関係でない、ブロック関係でない
ans ={i:0 for i in range(1,N+1)}
for i in range(1,N+1):
    root =uf.find(i)
    all =uf.size(root)
    same_groop_block =0
    for j in conn_blo[i]:
        if uf.same(i,j): #同じグループにいるけどブロック関係
            same_groop_block +=1
    ans[i] =all -len(conn_fri[i]) -same_groop_block -1 #-1 自分を引く

#出力
print(*ans.values())
#print(all)




Measured memory_bytes: 105600
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<utility>
#include<vector>

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

int solve(){
  long long h, w; cin >> h >> w;
  long long ans = (((h+1)/2) * ((w+1)/2)) + ((h/2) * (w/2));
  if(h==1 || w==1)  ans = 1;
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int H[100010]={};

	cin >> N;
	for(int i=0;i<N;i++)
		cin >> H[i];
	
	int ans=0;
	int cnt=0;
	for(int i=1;i<N;i++)
	{
		if(H[i-1]>=H[i])cnt++;
		else cnt=0;
		ans=max(ans,cnt);
	}

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



Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define cmdMax 10
 
typedef struct node *link;
struct node{
    int key;
    link left,right;
};
 
link insert(link head,link z){
    link y=NULL;
    link x=head;
     
    while(x!=NULL){
        y=x;
        if(z->key < x->key)x=x->left;
        else x=x->right;
    }
     
    if(y==NULL)head=z;
    else if(z->key < y->key)y->left=z;
    else y->right=z;
    return head;
}
 
void preorder(link u){
    if(u==NULL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
 
void inorder(link u){
    if(u==NULL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
 
int find(link u,int key){
    if(u==NULL)return 0;
    if(u->key==key)return 1;
    if(u->key>key)return find(u->left,key);
    return find(u->right,key);
}
 
int search(link u){
    if(u->left==NULL)return u->key;
    return search(u->left);
}
 
link delete(link u,int key){
    if(u==NULL)return NULL;
    if(u->key==key){
        if(u->left==NULL && u->right==NULL)return NULL;
        else if(u->right==NULL){
            return u->left;
        }else if(u->left==NULL){
            return u->right;
        }else{
            u->key=search(u->right);
            u->right=delete(u->right,u->key);
        }
    }else if(u->key >key){
        u->left=delete(u->left,key);
    }else{
        u->right=delete(u->right,key);
    }
    return u;
}
 
int main(void){
    int m,i,key;
    char cmd[cmdMax];
    link head=NULL,z;
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%s",cmd);
        if(!strcmp(cmd,"insert")){
            scanf("%d",&key);
            z = malloc(sizeof(*z));
            z->key=key;z->left=NULL;z->right=NULL;
            head=insert(head,z);
        }else if(!strcmp(cmd,"print")){
            inorder(head);
            printf("\n");
            preorder(head);
            printf("\n");
        }else if(!strcmp(cmd,"find")){
            scanf("%d",&key);
            if(find(head,key)!=0)printf("yes\n");
            else  printf("no\n");
        }else if(!strcmp(cmd,"delete")){
            scanf("%d",&key);
            head=delete(head,key);
        }
    }
    return 0;
}



Measured memory_bytes: 14184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  map<char,int> cnt;
  for(char c : s) ++cnt[c];
  if(cnt.size() != 2) cout << "No";
  else{
    for(auto& p : cnt){
      if(p.second != 2){
        cout << "No";
        return 0;
      }
    }
    cout << "Yes";
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,d;
int main()
{
	cin>>n>>d;
	d=d*2+1;
	if(n%d)
	{
		cout<<n/d+1<<endl;
	}
	else
	{
		cout<<n/d<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct edge{int to,cost;};
typedef pair<int,int> P;
int V;
vector<edge> G[200001];
ll mincost[200001],INF=1e18,used[200001]={0};
int prim(){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(mincost,mincost+V,INF);
    mincost[0]=0;
    ll res=0;
    que.push(P(0,0));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(used[v]) continue;
        res+=mincost[v];
        used[v]++;
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(mincost[e.to]>e.cost) mincost[e.to]=e.cost,que.push(P(mincost[e.to],e.to));
        }
    }
    return res;
}
int main(){
    int n,x,y;
    cin>>n;
    V=n;
    vector<P> A,B;
    rep(i,n) cin>>x>>y,A.push_back(P(x,i)),B.push_back(P(y,i));
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    rep(i,n-1) G[A[i].second].push_back({A[i+1].second,A[i+1].first-A[i].first}),G[A[i+1].second].push_back({A[i].second,A[i+1].first-A[i].first});
    rep(i,n-1) G[B[i].second].push_back({B[i+1].second,B[i+1].first-B[i].first}),G[B[i+1].second].push_back({B[i].second,B[i+1].first-B[i].first});
    cout<<prim();
}

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

int main() {
  int H,W;
  while(1){
    cin >> H >> W;
    if(H == 0 && W == 0)
      break;
    for(int i=1; i<=H; i++){
      for(int j=1; j<=W; j++){
      cout << "#";
    }
    cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3076
#include <stdio.h>

int main(){
  int n,k;
  if(scanf("%d",&n)==1 && scanf("%d",&k)==1){}
  char ss[n];
  if(scanf("%s",ss)==1){}
  
  ss[k-1]=ss[k-1]+32;
  
  printf("%s",ss);
  
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  int n, q, temp;
  std::vector<int> S, T;
  
  std::cin >> n;
  for (auto i=0; i<n; ++i) {
    std::cin >> temp;
    S.emplace_back(temp);
  }
  std::cin >> q;
  for (auto i=0; i<q; ++i) {
    std::cin >> temp;
    T.emplace_back(temp);
  }
  
  int cnt = 0;
  
  for (auto &&target : T) {
    auto i=0, j=n;
    //std::cout << "searching " << target << std::endl;
    while (i != j) {
      auto mid = (i + j) / 2;
      //std::cout << "\ti = " << i << ", j = " << j << ", mid = " << mid << std::endl;
      if (S.at(mid) == target) {
        ++cnt;
        break;
      } else if (S.at(mid) > target) {
        j = mid;
      } else {
        i = mid + 1;
      }
    }
  }
  
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;


int main()
{
   ll n,m,i,j,k,w; cin>>n>>w;
   ll val[n],wt[n];
   for(i=0;i<n;i++) cin>>wt[i]>>val[i];
   ll dp[n+1][w+1]={0};
   for(i=0;i<n+1;i++)
   {
       for(j=0;j<w+1;j++)
       {
           if(i==0 || j==0) dp[i][j]=0;

           else if(wt[i-1]>j) dp[i][j]=dp[i-1][j];

            else dp[i][j]=max(dp[i-1][j-wt[i-1]]+val[i-1],dp[i-1][j]);
       }
   }
   cout<<dp[n][w];
}


Measured memory_bytes: 79104
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

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

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val M = sc.nextInt
    val A = Array.fill(N)(Array.fill(sc.nextInt)(sc.nextInt))

    val a = ArrayBuffer.fill(M)(0)
    A.foreach {
      _.foreach { i =>
        a(i - 1) = a(i - 1) + 1
      }
    }
    a.count(_ == N).toString
  }
}


Measured memory_bytes: 25800
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main() {
  string T, P;
  cin >> T >> P;
  for(int i = 0; i < int(T.size() - P.size()) + 1; ++i) {
	if(P == T.substr(i, P.size())) {
	  printf("%d\n", i);
	}
  }
  return 0;
}

Measured memory_bytes: 3944
//
// Created by yuu on 2019-04-16.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){
    int A[5];
    for (int i = 0; i < 5; ++i) {
        cin>>A[i];
    }
    int K;
    cin>>K;

    sort(A,A+5);

    if(A[4]-A[0] > K){
        cout<<":("<<endl;
    }else{
        cout<<"Yay!"<<endl;
    }

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
double x,y,t=0.001;

double ka(double a,double b,double c,double d) {
	double e,f,g;
	e=sqrt((a-c)*(a-c)+(b-d)*(b-d));
	f=sqrt((a-x)*(a-x)+(b-y)*(b-y));
	g=sqrt((c-x)*(c-x)+(d-y)*(d-y));
	return 180*acos((f*f+g*g-e*e)/(2*f*g))/3.141592;
}

int main() {
	double s,a,b,c,d,e,f;
	while(cin >> a >> b >> c >> d >> e >> f >> x >> y) {
    s=ka(a,b,c,d)+ka(c,d,e,f)+ka(a,b,e,f);
	if (360-t<s && 360+t>s) cout << "YES" << endl; else cout << "NO" << endl;
	}
	return 0;
}

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

int main() {
  long long n;
  cin>>n;
  long long A=1;
  long long B=1;
  for(int i=0;i<n;i++){
    long long  x;long long y;
    cin>>x >>y;
    long long a=(x+A-1)/x;long long b=(y+B-1)/y;
    long long ma=max(a,b);
    A=ma*x; B=ma*y;
  }
  cout << A+B<<endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
  char str[1000];
  long a, b, c, d;
  
  fgets(str, sizeof(str), stdin);
  sscanf(str, "%ld %ld %ld", &a, &b, &c);
  
  d = c - a - b;
  if(d < 0){
    printf("%s\n", "No");
  }else if(4 * a * b < d * d){
	printf("%s\n", "Yes");
  }else{
    printf("%s\n", "No");
  }
  
  return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h> 
using namespace std; 
typedef  pair<int, int> iPair; 
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
 
int a[100005];
int tree[200005];
 
void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main()
{
        ios_base::sync_with_stdio(false);
        string s;
        cin >> s;
        for(int i=0;i<s.length();i++){
            if(i%2==0){
                if(!(s[i]=='R' || s[i]=='U' || s[i]=='D')){
                    cout << "No" << endl;
                    return 0;
                }
            }
            else{
                if(!(s[i]=='L' || s[i]=='U' || s[i]=='D')){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        cout << "Yes" << endl;
        return 0;
}

Measured memory_bytes: 256
"""According to a fortune-teller, a white stone placed to the immediate left of a red stone 
WR leads to nok
"""
n = int(raw_input())
s = list(raw_input())
import collections


def f(s):
	cc = collections.Counter(s)
	if cc['R'] == 0 or cc['W'] == 0:
		return 0
	i = 0
	j = len(s) - 1
	#while(i < len(s) and s[i] == 'R'): i +=1
	#while(j>=0 and s[j] == 'W'): j -=1
	
	c = 0
	while(i < j):
		if s[i] == 'W' and s[j] == 'R':
			s[i],s[j] = s[j],s[i]
			i += 1
			j -= 1
			c += 1
		while(i < j and s[i] == 'R'): i+=1
		while(i < j and s[j] == 'W'): j-=1
	return min(c, cc['R'], cc['W'])

print f(s)

Measured memory_bytes: 82444
# D - Div Game
from collections import defaultdict
from math import sqrt
from typing import ValuesView


def prime_factorize_indices(n: int) -> ValuesView[int]:
    """Prime factorization of n (trial division)."""
    if n < 1:
        raise ValueError

    prime_factors = defaultdict(int)
    while n % 2 == 0:
        n //= 2
        prime_factors[2] += 1

    for i in range(3, int(sqrt(n)) + 1, 2):
        while n % i == 0:
            n //= i
            prime_factors[i] += 1
        if n == 1:
            break

    if n > 2:  # n is prime
        prime_factors[n] += 1

    return prime_factors.values()


def main():
    N = int(input())
    calc = lambda n: int((sqrt(8 * n + 1) - 1) / 2)
    print(sum(calc(e) for e in prime_factorize_indices(N)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 10164
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<ll,ll>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define f(i,x,z) for(int i=x;i<z;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"
#define srt(v) sort(v.begin(), v.end())
int main()
{
	float a,b,c;
	cin>>a>>b>>c;
	if(a/b<=c)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
   return 0;
}


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

int main(int argc, const char * argv[]) {
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int n, a;
    cin >> n;
    int result = 1000000000;
    for (int i=0; i<n; i++){
        cin >> a;
        int exp = 1;
        for (int j=1; j<31; j++){
            exp *= 2;
            if(a % exp != 0) {
                if(result >= j - 1){
                    result = j - 1;
                }
                break;
            }
        }
    }

    cout << result << endl;
}


Measured memory_bytes: 256
from operator import itemgetter
N,M = map(int, input().split())

all_lst = []
for i in range(N):
  all_lst.append(list(map(int, input().split())))
  
all_lst.sort(key=itemgetter(0))

m = 0
ans = 0

for i in all_lst:
  a = i[0]
  b = i[1]
  if (m < M):
    if (b <= (M - m)):
      ans += a * b
      m += b
    else:
      ans += a * (M - m)
      m += (M - m)
  else:
    break
print(ans)

Measured memory_bytes: 28972
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

int min(int a, int b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

int avd_i(int a, int b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

int main() {
	
	string S;
	bool c1 = false, c2 = false;

	cin >> S;

	for (int i = 0; i < S.size(); i++) {

		if (!c1&&S[i] == 'C')c1 = true;
		if (c1 && !c2&&S[i] == 'F')c2 = true;

	}

	if (c1&&c2)cout << "Yes" << endl;
	else cout << "No" << 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;
using ll = long long;
using P = pair<int,int>;

const ll INF = (ll)1e18+1;

int main(){
    int n; ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    ll l = -INF, r = INF;
    while(l+1 < r){
        ll x = (l+r)/2;
        bool ok = [&]{
            ll tot = 0;
            rep(i,n){
                if(a[i] < 0){
                    int l = -1, r = n;
                    while(l+1 < r){
                        int c = (l+r)/2;
                        if(a[c]*a[i] < x) r = c; else l = c;
                    }
                    tot += n-r;
                }
                else{
                    int l = -1, r = n;
                    while(l+1 < r){
                        int c = (l+r)/2;
                        if(a[c]*a[i] < x) l = c; else r = c;
                    }
                    tot += r;
                }
                if(a[i]*a[i] < x) tot--;
            }
            tot /= 2;
            return  tot < k;
        }();
        if(ok) l = x; else r = x;
    }
    cout << l << endl;
}

Measured memory_bytes: 4852
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABHM = ReadInts();
            var A = ABHM[0];
            var B = ABHM[1];
            var H = ABHM[2];
            var M = ABHM[3];

            var Hnokakudo = (((H * 60)+M) * 0.5) % 360;
            var Mnokakudo = (M * 6) % 360;
            //WriteLine(Hnokakudo);
            //WriteLine(Mnokakudo);

            var kakudo = Min(Abs(Hnokakudo - Mnokakudo), 360 - Abs(Hnokakudo - Mnokakudo));
            //WriteLine(kakudo);

            if (kakudo == 90)
            {
                WriteLine(Sqrt(A * A + B * B));
            }
            else
            {
                WriteLine(Sqrt(A * A + B * B - 2 * A * B * Cos(kakudo * PI / 180)));

            }

        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27948
#include<iostream>
#include<stdio.h>
using namespace std;

#define MAX 100000
#define INFTY 1200000000

int num(char ch)
{
    if(ch == 'S'){ return 0; }
    else if(ch == 'H'){ return 1; }
    else if(ch == 'C'){ return 2; }
    else if(ch == 'D'){ return 3; }else{}
    return 0;
}

char suit(int i)
{
    if(i == 0){ return 'S'; }
    else if(i == 1){ return 'H'; }
    else if(i == 2){ return 'C'; }
    else if(i == 3){ return 'D'; }else{}
    return 'Z';
}

void Merge(int* A, int* s, int left, int mid, int right)
{
    int R[MAX], L[MAX];
    int ch_R[MAX], ch_L[MAX];
    int i, j, k, n1, n2;
    n1 = mid - left;
    n2 = right - mid;
    for(i = 0; i < n1; i++){ L[i] = A[i + left]; ch_L[i] = s[i + left]; }
    for(j = 0; j < n2; j++){ R[j] = A[j + mid]; ch_R[j] = s[j + mid]; }

    L[n1] = INFTY;
    R[n2] = INFTY;
    i = j = 0;

    for(k = left; k < right; k++){

        if(L[i] <= R[j]){ A[k] = L[i]; s[k] = ch_L[i]; i++; }

        else{ A[k] = R[j]; s[k] = ch_R[j]; j++; }
    }
}

void MergeSort(int* A, int* s, int left, int right)
{
    int mid;
    if(left + 1 < right){
        mid = (left + right) / 2;
        MergeSort(A, s, left, mid);
        MergeSort(A, s, mid, right);
        Merge(A, s, left, mid, right);
    }
    return;
}

int partition(int* A, int* s, int p, int r)
{
    int i, j, x;
    x = A[r];
    i = p - 1;
    for(j = p; j < r; j++){
        if(A[j] <= x){ i++; swap(A[i], A[j]); swap(s[i], s[j]); }
    }
    swap(A[i + 1], A[r]);
    swap(s[i + 1], s[r]);

    return i + 1;
}

void quicksort(int* A, int* s, int p, int r)
{
    if(!(p < r)) return;
    int q;
    q = partition(A, s, p, r);
    quicksort(A, s, p, q - 1);
    quicksort(A, s, q + 1, r);
}

bool is_stable(int* s, int* t, int n)
{
    int i = 0;
    while(i < n){ if(s[i] != t[i]) return false; i++; };
    return true;
}

int main()
{
    int i, n;
    char ch;
    int A[MAX], B[MAX], s[MAX], t[MAX];
    scanf("%d", &n);

    for(i = 0; i < n; i++){
        cin >> ch; s[i] = num(ch); t[i] = s[i];
        scanf("%d", &A[i]); B[i] = A[i];
    }

    quicksort(A, s, 0, n - 1);
    MergeSort(B, t, 0, n);

    if(is_stable(s, t, n)){ printf("Stable"); } else{ printf("Not stable"); }
    printf("\n");

    for(int i = 0; i < n; i++){ cout << suit(s[i]); printf(" %d\n", A[i]); }

    return 0;
}

Measured memory_bytes: 3580
while True:
    a, b, c = input().split()
    if b == "?":
        break
    elif b == "+":
        print (int (a) + int(c))
    elif b == "-":
        print (int(a)-int(c))
    elif b == ("*"):
        print (int(a)*int(c))
    elif b == ("/"):
        print (int(a)//int(c))
    



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

int main() {
  int N;
  string S;
  cin >> S;
  N = S.size();
  vector<char> kouho1(N);
  vector<char> kouho2(N);
  
  //kouho1:01010101.....
  for (int i = 0; i < N; i += 2) {
    kouho1.at(i) = '0';
  }
  for (int i = 1; i < N; i += 2) {
    kouho1.at(i) = '1';
  }
  
  //kouho2:1010101......
  for (int i = 0; i < N; i += 2) {
    kouho2.at(i) = '1';
  }
  for (int i = 1; i < N; i += 2) {
    kouho2.at(i) = '0';
  }
  
  int change1 = 0;
  int change2 = 0;
  
  for (int i = 0; i < N; i++) {
    if (!(kouho1.at(i) == S.at(i))) {
      change1 += 1;
    }
  }
  for (int i = 0; i < N; i++) {
    if (!(kouho2.at(i) == S.at(i))) {
      change2 += 1;
    }
  }
  
  cout << min(change1, change2) << endl;
}


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

typedef int long long ll;
const static int N=1000;
ll tt[200002];
ll sm[200002];
int main(){
    ll n;
    ll c;
    cin>>n>>c;
    ll s[n],t[n],cc[n];
    for(ll i=0;i<n;i++){
        cin>>s[i]>>t[i]>>cc[i];
        
    }
    
    
    for(int j=1;j<=c;j++){
        
        rep(i,200002)tt[i]=0;
        for(int i=0;i<n;i++){
            if(cc[i]==j){
                //tt[2*s[i]-1]++;
                //tt[2*t[i]]--;
                for(int ii=2*s[i]-1;ii<2*t[i];ii++){
                    tt[ii]++;
                }
            }
        }
       /* for(int i=1;i<200002;i++){
            tt[i]+=tt[i-1];
        }*/
        for(int j=0;j<200002;j++){
            if(tt[j]>0)sm[j]++;
        }
    }
   
    int ans=max_element(sm,sm+200002)-sm;
    cout<<sm[ans]<<endl;
    
    
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main()
{
	// 整数の入力
	string s;
	int a,b;
	a = 0;
	b = 0;
	cin >> s;
	//vector<int> h(s.size());
	for (int i = 0; i < s.size(); i++)
	{
		//奇数番目
		if (i % 2 == 1) {
			if (s.at(i) != '0') a++;
			if (s.at(i) != '1') b++;
		}
		//偶数番目
		if (i % 2 == 0) {
			if (s.at(i) != '0') b++;
			if (s.at(i) != '1') a++;
		}
	}
	if (a > b) cout << b << endl;
	else cout << a << endl;
}

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

int main() {
  long long n;
  cin >> n;
  int a[n];
  map<int , int> mp;
  for (int i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    mp.insert(make_pair(i, 0));
    if (mp.count(a[i])) {
      mp[a[i]]++;
    }
  }
  for (int i = 1; i <= n ; i++) {
    cout << mp[i] << endl;  
  }
  return 0;
}

Measured memory_bytes: 13840