akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
  string s;
  string T;
  cin >> s >> T;
  int lenS = s.size(),lenT = T.size();
  bool flag = false;
  int ans;
  for(int i = lenS - lenT; i >= 0; --i){
    bool ok = true;
    for(int j = 0; j < lenT; ++j){
      int ptr = i + j;
      if(s[ptr] == '?') continue;
      if(s[ptr] != T[j]){
	ok = false;
	break;
      } 
    }
    if(ok){
      flag = true;
      ans = i;
      break;
    }
  }
  if(!flag){
    cout << "UNRESTORABLE" << endl;
  }else{
    for(int i = 0; i < lenS; ++i){
      if(i >= ans && i < ans + lenT){
	cout << T[i-ans];
      }else{
	if(s[i] == '?') cout << 'a';
	else cout << s[i];
      }
    }
    cout << endl;
  }
  
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import math

str_list = input().split()
num1 = int(str_list[0] + str_list[1])

# 連結して作った数値の平方根を求める
num2 = math.sqrt(num1)
# 整数型で返っていれば、平方数だとみなせる
if num2.is_integer():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){ 
   int n;
   cin>>n;
   string s;
   cin>>s;
   if(n%2!=0) cout<<"No";
   else{
      string a;
      rep(i,n/2){
         a+=s[i];
      }
      a+=a;
      (a==s)? cout<<"Yes":cout<<"No";
   }
   return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ans = 0
    count = 0
    for i in range(1,n+1,2):
        count = 0
        for j in range(1, n+1, 2):
            if i%j == 0:
                count += 1
        if count == 8:
            ans += 1
    print(ans)


if __name__=='__main__':
    main()


Measured memory_bytes: 2940
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = 0
t = 0
 
def gcd(a,b):
  while b:
    a,b = b,a%b
  return abs(a)
 
for i in range(n):
    t = abs(x[i]-k)
    ans = gcd(ans,t)
print(ans)


Measured memory_bytes: 14252
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int judge(int a, int b) {
	int res = 0;
	if (a < b)res = 1;
	else if (a > b)res = -1;
	return res;
}

int main() {
	int n, a,ba,cnt=1,flag;
	cin >> n;
	if (n == 1 || n == 2) { cout << cnt << endl; return 0; }
	cin >> ba >> a;
	flag = judge(ba, a);
	ba = a;
	rep(i, n-2) {
		cin >> a;
		if ((ba < a && flag == -1) || (ba > a && flag == 1)) {
				cnt++;flag = 0;
		}
		else {
			if (ba > a)flag = -1;
			if (ba < a)flag = 1;
		}
		ba = a;
	}

	cout << cnt << endl;
	return 0;
}


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

int main(void){
    int n, a, b;
    cin >> n >> a >> b;

    int ans = 0;

    for (int i = 0; i <= 9; i++){
        for (int j = 0; j <= 9; j++){
            for (int k = 0; k <= 9; k++){
                for (int l = 0; l <= 9; l++){
                    if ((1000 * i + 100 * j + 10 * k + l) <= n) {
                        if (a <= (i+j+k+l) && (i+j+k+l) <= b) {
                            ans += (1000 * i + 100 * j + 10 * k + l);
                        }
                    }
                }
            }
        }
    }

    if (a == 1 && n == 10000) {
        ans += 10000;
    }

    cout << ans;
    cout << "\n";
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		long ans = 0;
		if(a+b>=c*2){
			int min = Math.min(x, y);
			ans += min*c*2;
			x -= min;
			y -= min;
		}
		if(a>=c*2 && x>0){
			ans += x*c*2;
			y -= x;
			x = 0;
		}
		if(b>=c*2 && y>0){
			ans += y*c*2;
			x -= y;
			y = 0;
		}
		
		if(x>0) ans += x*a;
		if(y>0) ans += y*b;
		System.out.println(ans);
		return;
	}
}

Measured memory_bytes: 22868
N, K = map(int,input().split())

index = []

for i in range(N):
    sum_num = i+1
    cnt = 0
    while sum_num < K:
        sum_num *= 2
        cnt += 1
    index.append(cnt)

ans = 0
for i in range(N):
    ans += ((1/N)*(0.5**index[i]))

print(ans)

Measured memory_bytes: 3864
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;

namespace INPUT {
	const int L = 1 << 15;
	char _buf[L], *S, *T, c; int n;
	#define _gc (S == T ? (T = (S = _buf) + fread (_buf, 1, L, stdin), (S == T ? EOF : (*S++))) : (*S++))
	void readi (int &X) {
		for (c = _gc; c < '0' || c > '9'; c = _gc); X = c & 15;
		for (c = _gc; c >= '0' && c <= '9'; X = X * 10 + (c & 15), c = _gc);
	}
	void reads (char *s) {
		for (c = _gc; c != '#' && c != '.'; c = _gc); s[n = 1] = c;
		for (c = _gc; c == '#' || c == '.'; s[++n] = c, c = _gc);
	}
}
using INPUT :: readi;
using INPUT :: reads;

const int Maxn = 2005;

int N, M;
char a[Maxn][Maxn];
int st[Maxn], len[Maxn];
int Ans;

int main() {
	readi (N), readi (M);
	for (int i = 1; i <= N; i++) {
		reads (a[i]);
		for (int j = 1; j <= M; ++j)
			a[i][j] = (a[i][j] == '#' ? 1 : 0);
	}
	Ans = max (N, M); //后面的方法统计不到。 
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j < M; j++) {
			if (i > 1 && !(a[i - 1][j] ^ a[i][j] ^ a[i - 1][j + 1] ^ a[i][j + 1]))
				len[j]++; 
			else
				len[j] = 1; 
		}
		int tp = 0; 
		for (int j = 1; j <= M; j++) {
			while (tp && len[st[tp - 1]] >= len[j]) {
				int x = st[--tp]; 
				if (!tp)
					Ans = max(Ans, j * len[x]); 
				else
					Ans = max(Ans, (j - st[tp - 1]) * len[x]); 
			}
			st[tp++] = j; 
		}
	}
	printf("%d\n", Ans);
	return 0; 
}


Measured memory_bytes: 4224
n,k=map(int,input().split())
d=list(map(int,input().split()))

def f(x):
    x=str(x)
    x=list(x)
    for i in x:
        if int(i) in d:
            return False
    return True

ans=n

while f(n)==False:
    n+=1
print(n)


Measured memory_bytes: 73616
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
 
using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }
 
struct Point {
  double x,y,z;
  Point operator - ( const Point &p ) const { return (Point){x-p.x,y-p.y,z-p.z}; }
  bool operator < ( const Point &p ) const {
    return ( ( !equals(z,p.z) ) ? z > p.z : ( ( !equals(y,p.y) ) ? y < p.y : LT(x,p.x) ) );
  }
};

typedef pair<double,int> ii;

struct Edge{
  int to,cap; double cost; int rev;
  Edge(int to=0,int cap=0,double cost=0,int rev=0):to(to),cap(cap),cost(cost),rev(rev){}
};

const int MAX_V = 1100, IINF = INT_MAX;
int V;
vector<Edge> G[MAX_V];
double h[MAX_V],dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

inline void add_edge(int from,int to,int cap,double cost){
  G[from].push_back(Edge(to,cap,cost,G[to].size()));
  G[to].push_back(Edge(from,0,-cost,G[from].size()-1));
}

double min_cost_flow(int s,int t){
  double res = 0;
  fill(h,h+V,0);
  while(1){
    priority_queue<ii,vector<ii>,greater<ii> > Q;
    fill(dist,dist+V,IINF);
    dist[s] = 0;
    Q.push(ii(0,s));
    while(!Q.empty()){
      ii p = Q.top(); Q.pop();
      int v = p.second;
      if( dist[v] < p.first ) continue;
      for(int i=0;i<G[v].size();i++){
        Edge &e = G[v][i];
        if( LT(0,e.cap) && !equals(dist[v]+e.cost+h[v]-h[e.to],dist[e.to]) && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to] ) { 
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          Q.push(ii(dist[e.to],e.to));
        }
      }
    }
    //if( dist[t] == IINF ) break;
    rep(v,V) h[v] += dist[v];
    if( h[t] >= 0LL ) break;
    int d = IINF;
    for(int v=t;v!=s;v=prevv[v]) d = min(d,G[prevv[v]][preve[v]].cap);
    res += d * h[t];
    for(int v=t;v!=s;v=prevv[v]){
      Edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}


int N,K;
Point ps[100];

const double MAX = 10000;

double getDist(Point p){ return sqrt(p.x*p.x+p.y*p.y+p.z*p.z); }

void compute(){
  if( N <= K ) { puts("0"); return; }
  map<int,int> counter;
  bool failed = false;
  rep(i,N) counter[(int)ps[i].z]++;
  for(map<int,int>::iterator it = counter.begin(); it != counter.end(); it++ ) {
    if( it->second > K ) { failed = true; break; }
  }
  if( failed ) { puts("-1"); return; }
  rep(i,N*4) G[i].clear();
  int source = N * 2;
  int sink = source + 2;
  V = sink +1;
  add_edge(source,source+1,K,0);
  rep(i,N) { 
    add_edge(source+1,i,1,0);
    add_edge(i,N+i,1,-MAX);
    add_edge(N+i,sink,1,0); 
  }

  rep(i,N) rep(j,N) if( i != j && ps[i].z > ps[j].z ){
    add_edge(N+i,j,1,getDist(ps[i]-ps[j]));
  }

  printf("%.10f\n",min_cost_flow(source,sink)+N*MAX);
}

int main(){
  while( cin >> N >> K, N|K ){
    rep(i,N) cin >> ps[i].x >> ps[i].y >> ps[i].z;
    compute();
  }
  return 0;
}

Measured memory_bytes: 3836
import sys
s = input()
k = int(input())
ans = []
seqlen = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        seqlen += 1
    else:
        ans.append(seqlen)
        seqlen = 1
ans.append(seqlen)
if len(ans) == 1:
    print(len(s)*k//2)
    sys.exit()
key = 0
key0 = 0
key1 = 0
if s[-1] == s[0]:
    key0, key1 = ans[0], ans[-1]
    ans[0] = ans[0]+ans[-1]
    ans.pop()
    key = 1
for i in range(len(ans)):
    ans[i] = ans[i] // 2
answer = sum(ans)
if key0:
    print(answer*k+key0//2+key1//2-(key0+key1)//2)
else:
    print(answer*k)

Measured memory_bytes: 3064
(* O(n * m) *)
let _ =
  Scanf.scanf " %d %d" @@ fun n m ->
    let counts = Array.make m 0 in
    for _ = 1 to n do
      Scanf.scanf " %d" @@ fun k ->
        for _ = 1 to k do
          Scanf.scanf " %d" @@ fun a ->
            counts.(a - 1) <- counts.(a - 1) + 1
        done
    done;
    let f acc c = acc + if c = n then 1 else 0 in
    Array.fold_left f 0 counts |> Printf.printf "%d\n"

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 1000009
#define M5 500009
#define pi 3.14159265
#define epsilon 1e-6
ll power(ll x,ll n,ll m){
    ll res=1;
    while(n>0){
        if(n&1) res=(res*x)%m;
        n/=2;
        x=(x*x)%m;
    }
    return res;
}
bool same(ld a,ld b){
    return fabs(a-b)<epsilon;
}
// ll sp[M6*10];
// void sieve(){
//     for(int i=2;i<M6*10;i++) sp[i]=i;
//     for(int i=2;i*i<M6*10;i++){
//         if(sp[i]!=i) continue;
//         for(int j=i*2;j<M6*10;j+=i) {
//             if(sp[j]==j) sp[j]=i;
//         }
//     }
// }
ll n,m,A[M5];
int  main()
{   ios_base::sync_with_stdio (0), cin.tie (0);
    //sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=0,i,j,k,l,r,a,b,c;
    //cin>>tc;
    while(t++<tc){
        //cout<<"Case #"<<t<<": ";
        cin>>n>>k;
        ll sum=0;
        for(i=1;i<=n;i++) {cin>>A[i]; sum+=A[i];}
        vector<ll> v;
        for(i=1;i*i<=sum;i++){
            if(sum%i==0){
                v.pb(i); v.pb(sum/i);
            }
        }
        sort(A+1,A+n+1);
        sort(v.begin(),v.end());
        ll ans;
        for(i=v.size()-1;i>=0;i--){
            vector<ll> vs;
            for(j=1;j<=n;j++) if(A[j]%v[i]) vs.pb(A[j]%v[i]);
            if(vs.size()==0){ans=v[i];break;}
            sort(vs.begin(), vs.end());
            ll cur=0;
            for(j=0;j<vs.size();j++){
                if(cur+vs[j]<=k) {
                    cur+=vs[j];
                    vs[j]=0;
                }
                else break;
            }
            for(;j<vs.size();j++){
                if((v[i]-vs[j])<=cur) {
                    cur-=v[i]-vs[j];
                    vs[j]=0;
                }
                else break;
            }
            if(vs[vs.size()-1]==0){
                ans=v[i]; break;
            }
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  char c;
  cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') {
cout<<"vowel"<<endl;
  }
  else {
cout<<"consonant"<<endl;
  }
  }

Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
int main(){
long long a,b,d;
  cin>>a>>b>>d;
  if(a<d){
    b+=a;
    a=0;
    b-=d;
  }
  else a-=d;
 if(b<1)b=0;
  cout<<a<<" "<<b<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 3005;
int n;
vector<int> arr(N);
int memo[N][N];
vector<int> fa;
vector<int> fb;

int go(int st, int end, int ch, int ta, int tb) {
	if(end < st) {
		return 0;
	}

	int &ans = memo[st][end];
	if(ans != -inf)
		return ans;
	ans = 0;

	if(!ch) {
		// ans = -inf;
		// ans = max(go(st + 1, end, !ch, ta + arr[st], tb), go(st, end - 1, !ch, ta + arr[end], tb));
		ans = go(st, end - 1, !ch, ta, tb) + arr[end];
		// db(sz(fa));
		// fa.pb(arr[end]);
		if(ans < go(st + 1, end, !ch, ta, tb) + arr[st]) {
			ans = go(st + 1, end, !ch, ta, tb) + arr[st];
			// fa.pop_back();
			// db(sz(fa));
			// fa.pb(arr[st]);
		}
		// else {
		// 	ans = go(st, end - 1, !ch, ta + arr[end], tb);
		// 	fa.pb(arr[end]);
		// }

	}
	else {
		// ans = inf;
		// ans = min(go(st + 1, end, !ch, ta, tb + arr[st]), go(st, end - 1, !ch, ta, tb + arr[end]));
		ans = go(st, end - 1, !ch, ta, tb) - arr[end];
		// fb.pb(arr[end]);
		if(ans > go(st + 1, end, !ch, ta, tb) - arr[st]) {
			ans = go(st + 1, end, !ch, ta, tb) - arr[st];
			// fb.pop_back();
			// fb.pb(arr[st]);
		}
	
	}
	return ans;
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    // cout.precision(12);cout << fixed;

    cin >> n;
    rep(i,n)
    	cin >> arr[i];

    rep(i,n) {
    	rep(j,n) 
    		memo[i][j] = -inf;
    }

    cout << go(0,n-1,0,0,0) << '\n';
}

Measured memory_bytes: 70912
import math
a,b,x = map(int, input().split())
x = x/a
if a*b>x*2:
  print(90-math.degrees(math.atan(2*x/b**2)))
if a*b<x*2:
  d = a*b-x
  print(math.degrees(math.atan(2*d/a**2)))
if a*b == x*2:
  print(45)

Measured memory_bytes: 9308
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i,0,n)
#define BFOR(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit)
#define BREP(bit,n) BFOR(bit,0,n)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(100010,0);
  
  REP(i,n){
    int x;
    cin >> x;
    x++;
    a[x]++;
    a[x-1]++;
    a[x+1]++;
  }
  
  sort(a.begin(),a.end());
  
  cout << a[100009] << endl;

}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int count = 0;
  for(int i = 0; i < N-2; i++){
    if(S.at(i) == 'A'){
      if(S.at(i + 1) == 'B'){
        if(S.at(i + 2) == 'C'){
          count ++;
        }
      }
    }
  }
  cout << count << endl;
}



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

int main(){
double a;
double s;
s=0;
a=1;
s+=a;
for(int i=0;i<5;i++){
a*=2;
s+=a;
if(i==4)break;
a/=3;
s+=a;}
while(cin>>a){
a*=s;
if(a<10)printf("%10.8f\n",a);
if(a>=10)printf("%11.8f\n",a);}
}

Measured memory_bytes: 1236
#include <iostream>

using namespace std;

bool f(int a, int b, int x) {
    return a <= x && a + b >= x;
}

int main() {

    int a, b, x;
    cin >> a >> b >> x;

    if (f(a, b, x)) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int n,a=0,b=0,i,d1,d2;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&d1,&d2);
        if(d1==d2){
            a=a+1;
            if(a==3){
                b=b+1;
            }
        }else{
            a=0;
        }
    }
    if(b>0){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}
 

Measured memory_bytes: 1736
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        x: i64,
        p: f64,
    }
    let x = (x + 1) / 2;
    let p = p / 100.0;
    puts!("{}\n", x as f64 / p);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define l_ength size
const int inf = 1<<30;
const int mod = 1000000007;
using ll = long long;
using namespace std;

int n; ll k;
vector<int> graph[100100];
bool visited[100100];
ll ans = 0;

void dfs( int target, int dist ){
	visited[target] = true;
	ll cnt = 0;
	for( auto node : graph[target] ){
		if( !visited[node] ){
			++cnt;
			if( dist >= 1 ) ans *= max(0ll, k-cnt-1);
			else ans *= max(0ll, k-cnt);
			ans %= mod;
			dfs(node, dist+1);
		}
	}
}

int main(){
	cin >> n >> k;
	for( int i = 0; i < n-1; ++i ){
		int x, y; cin >> x >> y;
		--x; --y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	ans = k;
	dfs(0, 0);
	cout << ans%mod << endl;
	return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    array<int,100000> is_ac = {}, wa = {};
    int p; string s;
    for (int i=0;i<m;i++){
        cin>>p>>s;
        p--;
        if (s == "AC"){
            is_ac[p]=1;
        }else{
            if (is_ac[p]==0){
                wa[p]++;
            }
        }
    }
    int ans1=0,ans2=0;
    for (int i=0;i<n;i++){
        if (is_ac[i]==1){
            ans1++;
            ans2+=wa[i];
        }
    }
    printf("%d %d",ans1,ans2);
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int input;
		int a,b,c,d;
		int count=0;
		int tmp_a, tmp_b, tmp_c;
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){
			input = scanner.nextInt();
			
			for(a=9; a>=0; a--){
				if( (tmp_a = (input - a)) >= 0){
					for(b=9; b>=0; b--){
						if((tmp_b = (tmp_a - b)) >= 0){
							for(c=9; c>=0; c--){
								if((tmp_c = (tmp_b - c)) >= 0){
									if(tmp_c <= 9){
										count++;
									}
								}
							}
						}
					}
				}
			}
			System.out.println(count);
			count = 0;
		}
	}
}

Measured memory_bytes: 18552
#include <bits/stdc++.h>
using namespace std;
// int N が既に与えられているとする. 
int main(){
  int n = 3;
  int flag_five = 0;
  int flag_seven = 0;
  int l, i = 0, a[n];
  while (std::cin >> l) {
    a[i] = l;
    i++;
    if (i >= n) {
      break;
    }
  }
  
  for(int i=0; i<n; i++){
    if (a[i] == 5) {
      flag_five++;
    }
    else if (a[i] == 7){
      flag_seven++;
    }
  }
  
  if (flag_five == 2 && flag_seven ==1){
    std::cout << "YES" << std::endl;
  }
  else{
    std::cout << "NO" << std::endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) {
                break;
            }
            int[] hCounts = new int[h * 1000 + 1];
            int[] hSums = new int[h + 1];
            for (int i = 1; i <= h; i++) {
                hSums[i] = hSums[i - 1] + sc.nextInt();
                for (int j = 0; j < i; j++) {
                    hCounts[hSums[i] - hSums[j]]++;
                }
            }
            int[] wCounts = new int[w * 1000 + 1];
            int[] wSums = new int[w + 1];
            for (int i = 1; i <= w; i++) {
                wSums[i] = wSums[i - 1] + sc.nextInt();
                for (int j = 0; j < i; j++) {
                    wCounts[wSums[i] - wSums[j]]++;
                }
            }
            long count = 0;
            for (int i = 1; i < hCounts.length && i < wCounts.length; i++) {
                count += hCounts[i] * wCounts[i];
            }
            sb.append(count).append("\n");
        }
        System.out.print(sb);
    }
}



Measured memory_bytes: 108724
#include <bits/stdc++.h>
using namespace std;
const int dy[] = {0, 0, -1, 1}, dx[] = {-1, 1, 0, 0};
typedef pair< int, int > Pi;
const int INF = 1 << 30;

int H, W;
bool DONT[30][30][30][30];
int COST[30][30][30][30];
int min_cost[30][30];

int bfs(int sy, int sx)
{
  queue< Pi > que;
  fill_n(*min_cost, 30 * 30, INF);
  que.push(Pi(sy, sx));
  min_cost[sy][sx] = 0;
  while(!que.empty()) {
    Pi p = que.front(); que.pop();
    if(p == Pi(H - 1, W - 1)) return(min_cost[H - 1][W - 1]);
    for(int i = 0; i < 4; i++) {
      int nx = p.second + dx[i], ny = p.first + dy[i];
      if(nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
      if(DONT[p.first][p.second][ny][nx]) continue;
      if(min_cost[ny][nx] < INF) continue;
      min_cost[ny][nx] = min_cost[p.first][p.second] + 1;
      que.push(Pi(ny, nx));
    }
  }
  return(INF);
}
bool Check(int value)
{
  queue< Pi > que;
  fill_n(*min_cost, 30 * 30, -1);
  min_cost[0][0] = 0;
  que.push(Pi(0, 0));
  while(!que.empty()) {
    Pi p = que.front(); que.pop();
    if(p == Pi(H - 1, W - 1)) return(true);
    for(int i = 0; i < 4; i++) {
      int ny = dy[i] + p.first, nx = dx[i] + p.second;
      if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
      if(DONT[p.first][p.second][ny][nx]) continue;
      if(~min_cost[ny][nx]) continue;
      if(min_cost[p.first][p.second] + COST[p.first][p.second][ny][nx] > value) continue;
      min_cost[ny][nx] = min_cost[p.first][p.second] + 1;
      que.push(Pi(ny, nx));
    }
  }
  return(false);
}

int Solve()
{
  for(int i = 0; i < 4; i++) {
    for(int y = 0; y < H; y++) {
      for(int x = 0; x < W; x++) {
        int ny = y + dy[i], nx = x + dx[i];
        if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
        if(DONT[y][x][ny][nx]) continue;
        DONT[y][x][ny][nx] = true;
        COST[y][x][ny][nx] = bfs(y, x);
        DONT[y][x][ny][nx] = false;
      }
    }
  }
  int low = 0, high = W * H * 2;
  if(!Check(high)) return(-1);
  while(high - low > 0) {
    int mid = (low + high) >> 1;
    if(Check(mid)) high = mid;
    else low = mid + 1;
  }
  return(low);
}


int main()
{
  while(cin >> H >> W, H) {
    for(int i = 0; i < 2 * H - 1; i++) {
      if(i & 1) {
        for(int j = 0; j < W; j++) {
          int digit;
          cin >> digit;
          DONT[i / 2][j][i / 2 + 1][j] = digit;
          DONT[i / 2 + 1][j][i / 2][j] = digit;
        }
      } else {
        for(int j = 0; j < W - 1; j++) {
          int digit;
          cin >> digit;
          DONT[i / 2][j][i / 2][j + 1] = digit;
          DONT[i / 2][j + 1][i / 2][j] = digit;
        }
      }
    }
    cout << Solve() << endl;
  }
}

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


using namespace std;


const int maxi=1e6+2;
pair<int,int> a[maxi];

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

    int sum=0;

    for (int i=1;i<=n;i++)
    {
        int x,y;
        scanf("%d",&x);
        sum+=x;
    }

    cout<<sum-n;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
print(sum(abs(x-y) for x, y in zip(X, Y)))
print((sum((x-y)**2 for x, y in zip(X, Y)))**(1/2))
print((sum(abs(x-y)**3 for x, y in zip(X, Y)))**(1/3))
print(max([abs(x-y) for x, y in zip(X, Y)]))



Measured memory_bytes: 5652
class VW
  attr_reader :value, :weight
  def initialize(value, weight)
    @value = value
    @weight = weight
  end
  def to_s
    "V:#{@value} W:#{@weight}"
  end
end

# メモ化再帰での実装
# https://www.slideshare.net/iwiwi/ss-3578511
class MemoizeRecursive
  def main
    @n, upper_w = gets.split.map(&:to_i)

    @ks = Array.new(@n)
    @n.times do |i|
      # [Value, Weight]
      @ks[i] = VW.new(*gets.split.map(&:to_i))
    end
    # pp knapsacks

    # @memoの方でdoneを兼ねられるので省略
    # @done = Array.new(@n) { Array.new(upper_w+1, false) }
    # 既に求めた最大価値を格納（未計算はnil）
    @memo = Array.new(@n) { Array.new(upper_w+1) }

    ans = search(0, upper_w)
    puts ans

    # pp @memo
  end

  def search(i, upper_w)
    return 0 if @n <= i

    # 既に計算済みの場合はそれを返す
    # return @memo[i][upper_w] if @done[i][upper_w]
    return @memo[i][upper_w] unless @memo[i][upper_w].nil?

    item = @ks[i]
    # この品物は入らないので次に進む
    return search(i+1, upper_w) if upper_w < item.weight

    # この品物を入れない場合と入れる場合の両方で探索
    value1 = search(i+1, upper_w)
    value2 = search(i+1, upper_w - @ks[i].weight) + @ks[i].value
    value = [value1, value2].max
    # @done[i][upper_w] = true
    @memo[i][upper_w] = value
    value
  end
end

if __FILE__ == $0
  MemoizeRecursive.new.main
end



Measured memory_bytes: 16680
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int N;
int x[10], y[10];
 
double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}
 
void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    for(int i = 0; i < N; i++) v[i] = i + 1;
    do {
        for(int i = 0; i < N - 1; i++) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 768
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

H,W = I()
boa = []
for i in range(H):
    x = X()
    count += x.count("#")

a = H+W-1
print("Possible" if a == count else "Impossible")


Measured memory_bytes: 9980
#include<iostream>

using namespace std;

int foward[100000] = {};
int backward[100000] = {};
int n = 0;

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

int gcd_without(int i) {
    if(i == 0) return backward[n-2];
    else if(i == n-1) return foward[n-2];
    return gcd(foward[i-1], backward[n-i-2]);
}

int main() {
    cin >> n;

    int a[100000] = {};
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int last_v = 0;
    for(int i = 0; i < n; i++) {
        foward[i] = gcd(a[i], last_v);
        last_v = foward[i];
    }

    last_v = 0;
    for(int i = 0; i < n; i++) {
        backward[i] = gcd(a[n-i-1], last_v);
        last_v = backward[i];
    }

    int max = 0;
    for(int i = 0; i < n; i++) {
        // i以外のやつでgcd
        int gcd_value = gcd_without(i);
        if(max < gcd_value) max = gcd_value;
    }

    cout << max << endl;
}


Measured memory_bytes: 1408
#約数
def make_divisors(n): #約数をリストで返す
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

#素因数分解
def soinsu_bunkai(m):
    pf={}

    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:
        pf[m]=1
    return pf

# 初期入力
import sys
input = sys.stdin.readline
N = int(input())
div =make_divisors(N)
div.sort()
div_2 =div[1:]

count =0
for i in div_2:
    i2 = soinsu_bunkai(i)
    if len(i2) ==1:
        q,mod =divmod(N,i)
        if mod ==0:
            count +=1
            N =q
print(count)

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++)
        cin >> a[i];

    sort(a.begin(), a.end());
    double R = ((double)(a[0]+a[1]))/2.0;    
    for(int i = 2; i < a.size(); i++){
        R = ((double)a[i] + R )/ 2.0; 
    }


    cout << R << endl;
   
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
int main(){
  ll r,g,b,n;
  cin>>r>>g>>b>>n;
  ll ans=0;
  for(ll i=0;i<=n/r;i++){
    for(ll j=0;j<=n/g;j++){
      ll nokori=n-(i*r+j*g);
      if(nokori>=0&&nokori%b==0){
        ans++;
        //cout<<i<<" "<<j<<" "<<nokori/b<<endl;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
from math import sqrt
n = int(input())
ij = []
i = 0
nr = int(sqrt(n))+1
while (i<=nr):
    i += 1
    r = n % i
    if (r != 0):
        continue
    j = n // i
    ij.append(i+j-2)
#print(ij)
print(min(ij))


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

using namespace std;

int main(int argc, char const *argv[])
{
    int n; cin >> n;
    vector<int> w;
    int sum = 0;
    int ans = 100000000;
    int temp_sum = 0;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        sum += temp;
        w.push_back(temp);
    }

    for (int i = 0; i < n; i++)
    {
        temp_sum += w[i];
        ans = min(ans, abs(temp_sum - (sum - temp_sum)));
    }
    
    cout << ans <<  endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import os
import math

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    n, d = map(int, input().split())
    xy_s = [list(map(int, input().split())) for i in range(n)]

    cnt = 0
    for xy in xy_s:
        target = math.sqrt(pow(abs(xy[0]), 2) + pow(abs(xy[1]), 2))
        val = float(d)
        if target <= val:
            cnt += 1
    print(cnt)

    # 文字取得サンプル
    #   1行1項目 x = input()
    #   1行1項目(1文字ずつリストに入れる場合) x = list(input())
    #   N行N項目(1文字ずつリストに入れる場合) x = [list(input()) for i in range(n)]
    pass


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """4 5
0 5
-2 4
3 4
4 -4"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """12 3
1 1
1 1
1 1
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3"""
        output = """7"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """20 100000
14309 -32939
-56855 100340
151364 25430
103789 -113141
147404 -136977
-37006 -30929
188810 -49557
13419 70401
-88280 165170
-196399 137941
-176527 -61904
46659 115261
-153551 114185
98784 -6820
94111 -86268
-30401 61477
-55056 7872
5901 -163796
138819 -185986
-69848 -96669"""
        output = """6"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 106732
MOD = 10 ** 9 + 7
ONE = '1'.freeze

def nCk(n, k)
  res = 1
  i = k
  j = 1
  while i > 0
    res = res * (n - i + 1)
    res %= MOD
    j *= i
    j %= MOD
    i -= 1
  end
  res *= inv(j)
  res %= MOD
  res
end

def inv(x)
  res = 1
  beki = x
  (MOD - 2).to_s(2).reverse.chars do |digest|
    res = (beki * res) % MOD if digest == ONE
    beki = (beki * beki) % MOD
  end
  res
end

n, m = gets.split.map(&:to_i)

puts nCk(n, 2) + nCk(m, 2)


Measured memory_bytes: 1788
s=list(input())
n=len(s)+1
lc=[0]
rc=[0]
for i in range(n-1):
    if s[i]=='<':
        lc.append(lc[-1]+1)
    else:
        lc.append(0)
    if s[-1-i]=='>':
        rc.append(rc[-1]+1)
    else:
        rc.append(0)
rc=rc[::-1]
ans=[max(lc[i], rc[i]) for i in range(n)]
print(sum(ans))

Measured memory_bytes: 119284
let a, b, c = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let f a b c = a mod 2 = 1 || b mod 2 = 1 || c mod 2 = 1
let rec g n a b c = if f a b c then n else g (n + 1) (b / 2 + c / 2) (c / 2 + a / 2) (a / 2 + b / 2)
let _ = Printf.printf "%d\n" @@ if not @@ f a b c && a = b && b = c then -1 else g 0 a b c

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

int main()
{
    int p, q, r;
    std::cin >> p >> q >> r;
    std::vector<int> vec;
    vec.push_back(p);
    vec.push_back(q);
    vec.push_back(r);
    std::sort(vec.begin(), vec.end());
    std::cout << vec[0] + vec[1] << std::endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> p = {};
  int sum = 0;
  
  for(int j = 0; j < n; j++) {
    int i = 0;
    cin >> i;
    p.push_back(i);
    sum += i;
  }
  
  if ((sum % 10) != 0) {
    cout << sum << endl;
  } else {
    int nonzero_min = 100;    
    for (int a:p) {
      if (a % 10 != 0 && a < nonzero_min) {
        nonzero_min = a;
      }
    }
    if (nonzero_min == 100)
      sum = 0;
    
    cout << max(0, sum - nonzero_min) << endl;
  }
  
}

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

ac = 0
wa = 0
tle = 0
re = 0

for i in range(num):
    k = input()
    if k == "AC":
        ac += 1
    elif k == "WA":
        wa += 1
    elif k == "TLE":
        tle += 1
    elif k == "RE":
        re += 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int n,l;
int main(void){
    scanf("%d%d",&n,&l);
    string s[n];
    for(int i=-1;++i-n;)cin>>s[i];
    sort(s,s+n);
    for(int i=-1;++i-n;)cout<<s[i];
}

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

int main() {
  
  long long a,w,b,v,n;
  cin >> a >> w >> b >> v >> n;
  bool f = false;
  if(w == v){
    cout << "NO" << endl;
  }else{
    if(a > b){
        f = true;
      }
    for(long long i = 0;i<n;i++){
      if(f == true){
        a = a - w;
        b = b - v;
        if(a <= b){
          cout << "YES" << endl;
          break;
        }
      }else{
        a = a + w;
        b = b + v;
        if(a >= b){
          cout << "YES" << endl;
          break;
        }
      }
      if(i == n - 1){
        cout << "NO" << endl;
      }
    }
  }
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, p, q int
	fmt.Scan(&n)
	fmt.Scan(&p)
	fmt.Scan(&q)

	a1 := n + p
	a2 := n + q
	a3 := p + q

	min := Min(a1, a2, a3)

	fmt.Println(min)
}

func Min(nums ...int) int {
	if len(nums) == 0 {
		panic("function min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 512
function Main(input) {
    input = input.split(" ");
    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
    var isEven = ((a * b) % 2 === 0 )
    var s = isEven ? "Even" : "Odd";
    console.log('%s', s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
# -*- coding: utf-8 -*-

import sys
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, s, t = MAP()
A = LIST(N)

A.sort()
l = bisect_left(A, s)
r = bisect_left(A, t)

print(N - (r-l))


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <string>
#include <ctype.h>

using namespace std;

void solve()
{
	int ans = 0;
	string W, T;
	cin >> W;
	for (int i = 0; i < W.size(); ++i)
	{
		W[i] = tolower(W[i]);
	}
	while (cin >> T)
	{
		if (T == "END_OF_TEXT")
		{
			break;
		}
		for (int i = 0; i < T.size(); ++i)
		{
			T[i] = tolower(T[i]);
		}
		if (W == T)
		{
			++ans;
		}
	}
	cout << ans << endl;
}

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

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

int n;
ll a[2010], b[2010];

ll memo[2010][2];

ll rec(int ci,int turn) {

	ll &ret = memo[ci][turn];
	if (ret >= 0) return ret;

	if (turn == 0) {
		ret = abs(a[n] - b[ci]);
		
		for (int i = ci + 1; i < n; ++i) {
			ret = max(ret, rec(i, 1));
		}

	} else {
		ret = abs(a[ci] - b[n]);
		for (int i = ci + 1; i < n; ++i) {
			ret = min(ret, rec(i, 0));
		}
	}

	return ret;
}

int main(void) {
	ll z, w;
	cin >> n >> z >> w;

	a[0] = z;
	b[0] = w;

	rep(i, 1, n + 1) {
		cin >> a[i];
		b[i] = a[i];
	}

	rep(i, n + 1) memo[i][0] = memo[i][1] = -1;

	cout << rec(0, 0) << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 200005
#define maxc 200005
#define mod 1000000007
using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0;
  for(c = getchar();c < '0' || c > '9';c = getchar());
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res;
}
int n,c[maxn];
int lst[maxc],f[maxn];
int main(){
  n = getint();
  for(int i = 1;i <= n;i++) c[i] = getint();
  f[1] = 1;
  lst[c[1]] = 1;
  for(int i = 2;i <= n;i++){
    if(lst[c[i]] && lst[c[i]] < i - 1) f[i] = (f[i - 1] + f[lst[c[i]]]) % mod;
    else f[i] = f[i - 1];
    lst[c[i]] = i;
  }
  printf("%d\n",f[n]);
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	ll n;
	cin >> n;
	if (n % 2 == 1) cout << 0 << endl;
	else {
		ll k = 5;
		ll t = 0;
		while (k <= n) {
			t += n / k / 2;

			k *= 5;
		}
		cout << t << endl;
	}
}

Measured memory_bytes: 3580
sx, sy ,tx, ty = map(int,input().split())
momo=""
xz = abs(tx-sx)
yz = abs(ty-sy)
momo += "U" * yz + "R" * xz + "D" * yz + "L" * xz
momo += "L" * 1 + "U" * (yz+1) + "R" * (xz+1) + "D" * 1
momo += "R" * 1 + "D" * (yz+1) + "L" * (xz+1) + "U" * 1
print(momo)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 100
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) ((t)*)calloc(N, sizeof(t)) //t型N要素の配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?
typedef long long ll;
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)

int main() {
    ll A, B, C, K;
    scanf("%lld %lld %lld %lld", &A, &B, &C, &K);
    if (A >= K) printf("%lld\n", K);
    else if ((A + B) >= K) printf("%lld\n", A);
    else printf("%lld\n", 2 * A + B - K);
    return 0;
}

void printa_int(int *a, int size) {
    int i;
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("\n");
}

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

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	for(int i=0; i<N; ++i) cin >> A[i];
	sort(A.begin(), A.end());
	int ans = 1;
	long long prev = A[0];
	bool cnt = true;
	for(int i=1; i<N; ++i) {
		if(prev == A[i]) {
			if(cnt) --ans;
			else ++ans;
			cnt = !cnt;
		} else {
			++ans;
			cnt = true;
			prev = A[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
//    private static final int MOD = (int) Math.pow(10, 9) + 7;

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
//             while (true)// MAKE SURE TO REMOVE THIS
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        int N = in.nextInt(), A = in.nextInt(), B = in.nextInt();
        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = in.nextInt();
        }
        long H = 0;
        for (int i = 0; i < N - 1; i++) {
            long D = X[i + 1] - X[i];
            long HA = D * A;
            H += Math.min(HA, B);
        }
        System.out.println(H);
    }
}

Measured memory_bytes: 31460
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int[] antennas = new int[5];
        int k = 0;
        for(int i = 0; i < 6 && s.hasNextLine(); i++){
            if(i < 5){
                antennas[i] = Integer.parseInt(s.nextLine());
            }else if (i == 5){
                k = Integer.parseInt(s.nextLine());
            }else{
                System.exit(-1);
            }
        }

        if (available(antennas, k)){
            System.out.print("Yay!");
        }else{
            System.out.print(":(");
        }
    }

    public static boolean available(int[] antennas ,int k){
        for(int i = 0; i < antennas.length; i++){
            for(int j = i + 1; j < antennas.length; j++){
                int distance = Math.abs(antennas[i] - antennas[j]);
                if(distance > k){
                    return false;
                }
            }
        }
        return true;
    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
double xp1,yp1,xp2,yp2,x,y,xp,yp,l1,r1,l2,r2,sum;
int n;
int main(){
	scanf("%lf%lf%lf%lf",&xp1,&yp1,&xp2,&yp2);
	l1=xp2-xp1;
	r1=yp2-yp1;
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%lf%lf",&x,&y);
		l2=x-xp1;
		r2=y-yp1;
		sum=l1*l2+r1*r2;
		xp=xp1+l1*sum/((l1*l1)+(r1*r1));
		yp=yp1+r1*sum/((l1*l1)+(r1*r1));
		printf("%.8lf %.8lf\n",x+(xp-x)*2,y+(yp-y)*2);
	}
} 


Measured memory_bytes: 3228