akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

ans = 0
for key in t:
    left = 0
    right = n
    while (left<right):
        mid = (left + right)//2
        if ( key == s[mid]):
            ans += 1
            break
        elif ( key > s[mid]):
            left = mid + 1
        else:
            right = mid
print(ans)



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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t l,r,d;
  cin >> l >> r >> d;
 
  int count = 0;
  int value = (l/d)*d;
  for(int i=1;i<=200;i++){
    if(value>=l && value <=r) count++;
    value += d;
    if(value>r) break;
  }
  cout << count << endl;
  return 0;
}




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

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int n=Integer.parseInt(scan.next());
    int[] array=new int[n];
    for(int i=0;i<array.length;i++){
      array[i]=Integer.parseInt(scan.next());
    }

    int count=0;
    for(int i=0;i<array.length-1;i++){
      for(int j=array.length-1;j>i;j--){
        if(array[j]<array[j-1]){
          int tmp=array[j-1];
          array[j-1]=array[j];
          array[j]=tmp;
          count++;
        }
      }
    }

    for(int i=0;i<array.length;i++){
      if(i<array.length-1){
        System.out.print(array[i]);
        System.out.print(" ");
      }else{
        System.out.println(array[i]);
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 26268
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
ll po(ll a, ll b){
    ll res = 1;
    while(b){
        if(b & 1) res = res * a;
        a = a * a;
        b >>= 1LL;
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n, p;
    cin >> n >> p;
    map<ll, ll> factor;    
    for(ll i = 2; i * i <= p; i++){
        while(p % i == 0){
            factor[i]++;
            p /= i;
        }
    }
    if(p > 1){
        factor[p]++;
    }
    ll g = 1;
    for(auto &x : factor){
        g *= po(x.F, x.S / n);
    }
    cout << g;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int[] k = new int[m];
		int[] s = new int[m];
		for (int i = 0; i < m; i++) {
			k[i] = scanner.nextInt();
			for (int j = 0; j < k[i]; j++) {
				s[i]= s[i] | (1<<(scanner.nextInt()-1));
			}
		}
		int[] p = new int[m];
		for (int i = 0; i < m; i++) {
			p[i] = scanner.nextInt();
		}
		
		// ① 全組み合わせをbit表現で展開するループ
		int count = 0;
		for (int i = 0; i < (1<<n); i++) {
			boolean ok = true;
			for (int mi = 0; mi < m; mi++) {
				// ② bitを順番に走査するループ
				
				int ons = s[mi] & i;
				int oncount = 0;
				for (int j = 0; j < n; j++) {
					if ((1 & ons>>j) == 1) {
						oncount++;
					}
				}
				if ((oncount % 2) != p[mi]) {
					ok = false;
					break;
				}
			}
			if (ok) {
				count++;
			}
		}
		System.out.println(count);

	}
}


Measured memory_bytes: 23892
N = int(input())
A_arr = [int(x) for x in input().split()]

def gcd(x, y):
    if y > x:
        x,y = (y, x)
    m = x % y
    if m == 0:
        return y
    return gcd(m, y)

m = A_arr[0]
for A in A_arr[1:]:
    m = gcd(m, A)

print(m)


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

using namespace std;

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

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

    sort(l, l + n);
    int ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += l[n - i - 1];
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  
  const int x=n;
  
  string s[x];
  double m[x];
  
  for(int i=0;i<x;i++)
  {
    
    cin>>m[i];
    cin>>s[i];
  }
  
  double ans;
  
  for(int i=0;i<x;i++)
  {
    if(s[i]=="BTC")
    {
      ans+=(m[i]*380000);
    }
    else
    {
      ans+=m[i];
    }
  }
  
  cout<<ans<<endl;
  
  return 0;
}
  
  

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
l=m=n=0
for i in a:
  if i%4==0:
    l+=1
  elif i%2==0:
    m+=1
  else:
    n+=1
if l>=n or (m==0 and l+1>=n):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <set>

#include <algorithm>
using namespace std;

int main() {
    int a;
    int b;
   int c;
   int d;
  
   cin >> a >> b >> c >> d;
  
  int numa = 0;
  int numb = 0;
  
  if (a > b) {
    numa = b;
    
  }else if (a < b){
     numa = a;
  }else if (a == b){
     numa = a;
  }
  
  if (c > d) {
    numb = d;
    
  }else if (c < d){
     numb = c;
  }else if (c == d){
     numb = c;
  }
  
  
  
   cout << numa + numb << endl;
  
  
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

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

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

int32_t main() { 
	
	setIO();

    str S; cin >> S;

    int res = 0, cnt = 0;
    F0R(i,sz(S)) {
        if (S[i] == 'R') cnt++;
        else cnt = 0;
        res = max(res,cnt);
    }

    cout << res << "\n";

}

Measured memory_bytes: 3564
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	ll n,m, ans;
	ans = 0;
	cin >> n >> m;
	vector<ll> a(n);
	rep(i, n)
	{
		cin >> a[i];
	}
	ll sum = 0;
	rep(i, n)
	{
		sum += a[i];
	}

	rep(i, n)
	{
		if (sum <= 4 * m * a[i])
		{
			ans++;
		}
	}

	if (m <= ans)
	{
		cout << "Yes" << "\n";
	}
	else
	{
		cout << "No" << "\n";
	}

	return 0;
}

Measured memory_bytes: 3628
//paths
//E:\workSpace\cf edu\binary search practice
//E:\workSpace\A2oj Ladder  Codeforces Div. 2, B
//E:\workSpace\Contest
#include<bits/stdc++.h>
using namespace std;

#define ll long long

int main()
{

#ifndef ONLINE_JUDGE
	freopen("E:/workSpace/file/input.txt", "r", stdin);
	freopen("E:/workSpace/file/output.txt", "w", stdout);
#endif

	vector<ll>a(2), b(2);
	for (ll i = 0; i < 2; i++)cin >> a[i];
	for (ll i = 0; i < 2; i++)cin >> b[i];

	ll mx = -2e18;
	for (ll i = 0; i < 2; i++)
	{
		for (ll j = 0; j < 2; j++)
		{
			mx = max(mx, (a[i] * b[j]));
		}
	}

	cout << mx << "\n";
}

Measured memory_bytes: 3604
# https://atcoder.jp/contests/abc091/tasks/arc092_a
n = int(input())
coordinates_red = [list(map(int, input().split())) for _ in range(n)]
coordinates_blue = [list(map(int, input().split())) for _ in range(n)]
coordinates_red.sort()
coordinates_blue.sort()
#print(coordinates_red)
#print(coordinates_blue)

start = 0
ans = 0
for blue in coordinates_blue:
    candidate = []
    for red in coordinates_red:
        #print(blue)
        #print(red)
        if red[0] < blue[0] and red[1] < blue[1]:
            candidate.append(red)
    if candidate:
        candidate.sort(key=lambda x: x[1])
        coordinates_red.remove(candidate.pop(-1))
        ans += 1

print(ans)

Measured memory_bytes: 3064
n = int(input())

a = list(map(int,input().split()))

ap = {}
am = {}


for i in range(1,n+1):
    j = i - 1

    if (i + a[j]) in ap:
        ap[i+a[j]] = ap[i+a[j]] + 1
    else:
        ap[i+a[j]] = 1
    
    if (i - a[j]) in am:
        am[i-a[j]] = am[i-a[j]] + 1
    else:
        am[i-a[j]] = 1

ans = 0
for i in ap.keys():
    if i in am:
        ans += am[i] * ap[i]
print(ans)

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

int n, cnt[5];

/*
K = (X+1)*p0 + (Y+1)*p1 + (Z+1)*p2 + (K+1)*p3
K - Kp3 = (X+1)*p0 + (Y+1)*p1 + (Z+1)*p2 + p3
K (1 - p3) = (X+1)*p0 + (Y+1)*p1 + (Z+1)*p2 + p3
K = ((X+1)*p0 + (Y+1)*p1 + (Z+1)*p2 + p3) / (1 - p3)
*/

double dp[305][305][305];

double solve(int a, int b, int c){
    if(a < 0 || b < 0 || c < 0) return 0;
    if(a+b+c == 0) return 0;
    if(dp[a][b][c] != -1) return dp[a][b][c];
    double x = (1 + solve(a-1, b, c)) * a * 1.0/n;
    double y = (1 + solve(a+1, b - 1, c)) * b * 1.0/n;
    double z = (1 + solve(a, b+1, c-1)) * c * 1.0/n;
    
    double prob = (n-a-b-c) * 1.0/n;
    double k = (x+y+z+prob)/(1 - prob);
    return dp[a][b][c] = k;
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        cnt[x]++;
    }
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= n; j++)
            for(int k = 0; k <= n; k++)
                dp[i][j][k] = -1;
    //cout << cnt[1] << " " << cnt[2] << " " << cnt[3] << endl;
    printf("%.9lf\n", solve(cnt[1], cnt[2], cnt[3]));
	return 0;
}



Measured memory_bytes: 219520
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int X[N],L[N];
    pair<int,int> p[N];
    rep(i,N) {
        cin>>X[i]>>L[i];
        int x,y;
        x=X[i]-L[i];
        y=X[i]+L[i];
        p[i]={y,x};
    }
    sort(p,p+N);
    int ans=0;
    int rm=-INF;
    rep(i,N){
        if(rm<=p[i].second){
            rm=p[i].first;
            ans++;
        }
    }
    cout << ans << endl;




}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main () {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    for (int i = 1; i <= b; i++) {
        for (int j = 1; j <= a; j++) {
            cout << 0;
        }
        for (int j = a + 1; j <= w; j++) {
            cout << 1;
        }
        cout << endl;
    }
    for (int i = b + 1; i <= h; i++) {
        for (int j = 1; j <= a; j++) {
            cout << 1;
        }
        for (int j = a + 1; j <= w; j++) {
            cout << 0;
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
    int N,L,sum=0;
   cin >>N>>L; int M[N],S[N];
   for(long long int i=0;i<N;i++){
   M[i]=L+i;
   S[i]=abs(M[i]);
   sum+=M[i];
   }
   sort(S,S+N);
   for(int i=0;i<N;i++){
      if(M[i]*(-1)==S[0]){
      S[0]*=(-1);
      break;
      }
   }
   cout <<sum-S[0];
 }



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

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

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int H,W,N,ANS;
    cin >> H >> W >> N;
    if(H>W){   
        ANS = N/H;
        if(N%H>0){
            ANS++;
        }
    }else{
        ANS = N/W;
        if(N%W>0){
            ANS++;
        }
    }
    cout << ANS << endl;
    return 0;
}

Measured memory_bytes: 256
tenzyou=10**18
input()
A=[int(i) for i in input().split()]
if 0 in A:
  print(0)
  exit()
sortedA=sorted(A)[::-1]
multi = 1
for a in A:
  multi *= a
  if multi > tenzyou:
    print(-1)
    exit()

print(multi)


Measured memory_bytes: 21704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
const long long INF = 1LL << 60;
// map<int,int> mp;

int main() {
  int x, y;
  cin >> x >> y;

  if ((4 * x - y) >= 0 & (4 * x - y) % 2 == 0 & (y - 2 * x) >= 0 &
      (y - 2 * x) % 2 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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


int main()
{
	int cc=0;
	string a,b;
	cin>>a>>b;
	for(int i=0;i<3;i++)
	{
		if(a[i]==b[i])
			cc++;
	}
	cout<<cc;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> road(N, 0);
  int a, b;
  for (int i=0; i<M; i++) {
    cin >> a >> b;
    road.at(a-1)++;
    road.at(b-1)++;
  }
  
  for (int i=0; i<N; i++) {
    cout << road.at(i) << endl;
  }
}

Measured memory_bytes: 3632
from collections import defaultdict
from itertools import accumulate
import heapq
n,m,s,t=map(int, input().split())
s-=1
t-=1
yen={}
snk={}
adj=defaultdict(list)
for _ in range(m):
    u,v,a,b=map(int, input().split())
    u-=1    
    v-=1    
    adj[u].append(v)
    adj[v].append(u)
    yen[u,v]=a
    yen[v,u]=a
    snk[u,v]=b
    snk[v,u]=b
 
def dijkstra(s, t, cost):
    q=[]
    d=[float('inf')]*n
    d[s]=0
    heapq.heappush(q, (d[s], s))
    while q!=[]:
        du, u=heapq.heappop(q)
        if du>d[u]:
            continue
        for v in adj[u]:
            if d[v]>du+cost[u,v]:
                d[v]=du+cost[u,v]
                heapq.heappush(q, (d[v], v))
    return d
 
d1=dijkstra(s, t, yen)
d2=dijkstra(t, s, snk)
ans=list(accumulate(reversed([y+s for y,s in zip(d1, d2)]), min))
for ai in reversed(ans):
    print(10**15-ai)


Measured memory_bytes: 99688
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  int w, fee;
  int ryoukin[] = {0, 125, 140, 160};
  const int Kihon = 1150;
  const int Bef = 4280;

  while (true) {
    cin >> w;
    if (w == -1)
      break;
    fee = Kihon;
    for (int i = 3; i > 0; i--) {
      fee += (w > i * 10 ? w - i * 10 : 0) * ryoukin[i];

      w -= w > i * 10 ? w - i * 10 : 0;
    }
    cout << Bef - fee << endl;
  }
  return 0;
}

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

int main() {
    int N,K;
    cin >> N >> K;

    vector<int> dice(N);
    lrep(i, 0, N) cin >> dice[i], dice[i]++;

    vector<ll> cumsum(N+1,0);
    lrep(i, 0, N) cumsum[i+1] = cumsum[i] + dice[i];
    ll sum = 0;
    lrep(i, 0, N-K+1){
        sum = max(sum,cumsum[i+K] - cumsum[i]);
    }
    cout << fixed << setprecision(7) << (double)(sum)/2 << endl; 
}

Measured memory_bytes: 2560
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
	N4RUTO;
	int t;
	t=1;
	// cin>>t;
	while(t--){
		int n;
		cin>>n;
		map<int,int> a;
		int sum = 0;
		loop(i,0,n-1){
			int x;
			cin>>x;
			a[x]++;
			sum+=x;
		}
		int q;
		cin>>q;
		loop(i,0,q-1){
			int x,y;
			cin>>x>>y;
			sum-=x*a[x];
			sum+=y*a[x];
			a[y]+=a[x];
			a[x]=0;
			cout<<sum<<"\n";
		}
	}
	return 0;
}

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

int main() {
    int n, u;
    cin >> n >> u;
    vector<int> c(n);
    vector<int> t(n);
    rep(i,n){
        int ci, ti;
        cin >> ci >> ti;
        c[i] = ci; 
        t[i] = ti;
    }

    int ans = 10000;
    rep(i,n){
        if(t[i] <= u) ans = min(ans,c[i]);
    }

    if(ans == 10000) cout << "TLE" << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[105],ans=0;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	int n,k;
	scanf ("%d %d",&n,&k);
	for (int i=1;i<=n;i++)
		scanf ("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=k;i++)
		ans+=a[i];
	printf ("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#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;
 
struct _3D
{
  double x,y,z;
  _3D(double x=-1,double y=-1,double z=-1):x(x),y(y),z(z){}
};
int N;
bool used[600];
 
double get3Dangle(_3D A,_3D B,_3D C)
{
  double a = sqrt(pow(B.x-C.x,2)+pow(B.y-C.y,2)+pow(B.z-C.z,2));
  double b = sqrt(pow(A.x-C.x,2)+pow(A.y-C.y,2)+pow(A.z-C.z,2));
  double c = sqrt(pow(B.x-A.x,2)+pow(B.y-A.y,2)+pow(B.z-A.z,2));
  return acos((a*a+c*c-b*b)/(2.0*a*c));
}
 
int main()
{
  _3D a[3];
  a[0].x = 0,a[0].y = 0,a[0].z = 1;
  a[1].x = 0,a[1].y = 0,a[1].z = 0;
  a[2].x = 1,a[2].y = 0,a[2].z = 0;
  //cout << get3Dangle(a[0],a[1],a[2]) << endl;
 
  while(cin >> N,N)
    {
      vector<_3D> vec;
      if(true)
    {
      rep(i,600)used[i] = false;
      double x,y,z;
      rep(i,N)
        {
          cin >> x >> y >> z;
          vec.push_back(_3D(x,y,z));
        }
    }
      int M;
      cin >> M;
      double x,y,z,agl;
      int cnt = 0;
      rep(i,M)
        {
          cin >> x >> y >> z >> agl;
          rep(j,N)
        {
          if(used[j])continue;
          double agr = fabs(get3Dangle(vec[j],_3D(0,0,0),_3D(x,y,z)));
          if(equals(agr,agl) || agr < agl)
            {
              cnt++;
              used[j] = true;
            }
        }
        }
 
      cout << cnt << endl;
     
       
    }
  return 0;
}

Measured memory_bytes: 1332
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<functional>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<set>
#include<map>

#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 2e9
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
const double PI = acos(-1);

using namespace std;

int main(void) {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//	freopen("input.txt", "r", stdin);
	
	int H, W, K; cin >> H >> W >> K;
	vector<string> v(H);
	int ans = 0;
	for (int i = 0; i < H; i++) cin >> v[i];
	for (int r = 0; r < (1 << H); r++) {
		for (int c = 0; c < (1 << W); c++) {
			int cnt = 0;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (((r >> i) & 1) == 0 && ((c >> j) & 1) == 0 && v[i][j] == '#') cnt++;
				}
			}
			if (cnt == K) ans++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3588
# =map(int,input().split())
import sys
n=int(input())
a=[]
for i in range(n):
    x=int(input())
    a.append(x)
key=1
ans=0
for _ in range(n):
    ans+=1
    if a[key-1]==2:
        print(ans)
        sys.exit()
    else:
        key=a[key-1]
print(-1)


    


Measured memory_bytes: 7084
N,A,B = map(int,input().split())

if (B - A) % 2 == 0:
  print((B - A) // 2)
else:
  NA = N - A
  B1 = B - 1
  if NA < B1:
    distance = N - B
    adjust = distance + 1
    moveA = A + adjust
    print(((N - moveA) // 2) + adjust)
  else:
    distance = A - 1
    adjust = distance + 1
    moveB = B - adjust
    print(((moveB - 1) // 2) + adjust)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        if (N % K == 0) {
            System.out.println(0);
        } else {
            System.out.println(1);
        }
    }
}

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

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

int main() {
int N, ans;
  cin >> N;
  ans =0;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N-1);
  rep(i ,N)
    cin >> a.at(i);
  rep(i ,N){
    cin >> b.at(i);
    ans += b.at(i);
  }
  rep(i ,N-1)
    cin >> c.at(i);
rep(i, N-1){
if(a.at(i+1) - a.at(i) == 1)
  ans += c.at(a.at(i)-1);
}
cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    int x; cin >> x;
    if (x == 0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678], cnt[12345678];
signed main() {
	ll n, m, q, k, a = 1, b = 0, c = 1, keta = 0, ans = 0; string s, t; char z;
	cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> test[h]; ans += test[h];
		cnt[test[h]]++;
	}
	cin >> q;
	for (int h = 0; h < q; h++) {
		cin >> a >> b;
		ans -= a * cnt[a]; ans += b * cnt[a];
		cnt[b] += cnt[a]; cnt[a] = 0;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

    // 標準入力からデータを読み込む準備
    Scanner sc = new Scanner(System.in);

    // 最初の文字の固まりを整数値と想定して読み込む 
    int x = sc.nextInt();
    int answer = x*x*x; 

    System.out.println(answer);
    sc.close();
} 
}


Measured memory_bytes: 26280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

ld x[10], y[10];
int perm[10];

int main() {
	int N;
	cin >> N;
	int frac=1;
	for(int i=0; i<N; ++i){
		cin >> x[i] >> y[i];
		perm[i]=i;
		frac *= i+1;
	}
	ld sum=0.0;
	for(int i=0; i<N; ++i){
		for(int j=i+1; j<N; ++j){
			sum += pow((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]), 0.5);
		}
	}
	ld ans=sum*(2*frac/N)/frac;
	cout << setprecision(18) << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
using namespace std;

int main() {
  int n, a[100];
  bool res = true;
  scanf("%d", &n);
  for(int i=0;i<n;i++) scanf("%d", &a[i]);
  
  for(int i=0;i<n;i++) {
    if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0) {
      res = false;
      break;
    }
  }
  
  if(res) printf("APPROVED");
  else printf("DENIED");
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define MAX_N   (10000)

static long sqcheck[MAX_N];
static long sqs[MAX_N];
static long counts[MAX_N];

int main() {
  long d, i, j, k, hn, n, sqsize;

  while (1) {
    scanf("%d", &n);
    if (n == 0) break;

    hn = (n - 1) / 2;

    for (i = 0; i < n; i++) sqcheck[i] = counts[i] = 0;

    sqsize = 0;
    for (i = 1; i < n; i++) {
      k = (i * i) % n;
      if (! sqcheck[k]) {
        sqs[sqsize++] = k;
        sqcheck[k] = 1;
      }
    }

    for (i = 0; i < sqsize; i++) {
      for (j = 0; j < sqsize; j++) {
        if (i != j) {
          d = sqs[i] - sqs[j];
          if (d < 0) d += n;
          if (d > hn) d = n - d;
          counts[d]++;
        }
      }
    }

    for (i = 1; i <= hn; i++)
      printf("%ld\n", counts[i]);
  }

  return 0;
}

Measured memory_bytes: 792
x, n = map(int, input().split())
if n != 0:
  n = list(map(int, input().split()))
  ans = []
  for i in range(101):
    if n.count(x + i) == 0:
      ans.append(x + i)

    if n.count(x - i) == 0:
      ans.append(x - i)
    
    if ans != []:
      break

  print(min(ans))
else:
  print(x)

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

struct UnionFind {
  vector<int> data;

  UnionFind(int n){
    data.resize(n+1);
    fill(data.begin(), data.end(), -1);
  }

  int root(int x){
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);

    if(rx!=ry){
      if(data[ry] < data[rx])swap(rx, ry);

      data[rx]+=data[ry];
      data[ry]=rx;
    }
  }

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

  int size(int x){
    return -data[root(x)];
  }
};

int main(){
  int w,h;cin>>w>>h;
  vector<pll>pq(w+h);
  rep(i, w+h){
    cin>>pq[i].first;
    pq[i].second = i;
  }
  sort(pq.begin(), pq.end());

  UnionFind uf(w+h);

  ll cw=w+1, ch=h+1;
  ll result = 0;
  for(auto p: pq){
    if(p.second >= w){
      result += p.first*cw;
      ch--;
    }else{
      result += p.first*ch;
      cw--;
    }
//    cout<<result<<' '<<p.first<<':'<<cw<<' '<<ch<<endl;
  }

  cout<<result<<endl;

  return 0;

  cout<<"###"<<endl;
  for(auto pp:pq)cout<<pp.first<<' '<<pp.second<<endl;

  return 0;
}



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

using namespace std;
using namespace placeholders;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA ...a) {
  while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator<<(ostream &os, vector <T> v) {
  os << "[";
  for (auto vv : v) os << vv << ",";
  return os << "]";
}
template <class L, class R> ostream &operator<<(ostream &os, pair <L, R> p) {
  return os << "(" << p.first << "," << p.second << ")";
}

#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

int n, m, d;
map <int, int> cnt, nd;

void run() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &d), cnt[d]++;
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) scanf("%d", &d), nd[d]++;

  bool ok = 1;
  for (auto p : nd) {
    if (cnt[p.first] < p.second) ok = 0;
  }
  puts(ok ? "YES" : "NO");
}

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


Measured memory_bytes: 18944
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N, K; cin >> N >> K;

    string S; cin >> S;

    S.at(K-1) = tolower(S.at(K-1));
    cout << S << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if(a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

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

const int INF = 1e9;
const long mod = 1e9 + 7;

long long calc(long long n, long long acc) {
  if (n == 1) {
    return acc;
  }
  return calc(n-1, (n * acc) % mod);
}
int main() {
  int n, m;
  cin>>n>>m;
  if (abs(n-m) > 1) {
    cout<<0<<endl;
    return 0;
  }
  long long  num_n = calc(n, 1);
  long long num_m = calc(m, 1);

  if (n == m) {
    cout<<(2 * num_n * num_m) % mod<<endl;
  } else {
    cout<<(num_n * num_m) % mod<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,p;
  cin >> a >> p;
  cout << (a*3 + p)/2 << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int n, b[200001];
    set<int> s={0};
    long long c=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        b[a]=i;
    }
    s.insert(n+1);
    for(int i=1;i<=n;i++){
        auto it=s.lower_bound(b[i]);
        long long p=(*it)-b[i],q;
        //cout<<i<<" "<<b[i]<<" "<<(*it);
        it--;
        //cout<<" "<<(*it)<<endl;
        q=b[i]-(*it);
        c+=p*q*i;
        //cout<<c<<endl;
        s.insert(b[i]);
    }
    cout<<c<<endl;
}

Measured memory_bytes: 10368
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n[] = new int[3];
		
		n[0] = sc.nextInt();
		n[1] = sc.nextInt();
		n[2] = sc.nextInt();
		
		Arrays.sort(n);
		
		if(n[0] == 5 && n[1] == 5&& n[2]==7){
			System.out.println("YES");

		} else {
			System.out.println("NO");
		}


		sc.close();
	}
}

Measured memory_bytes: 10068
n,a,b = map(int,input().split())
t = 0
t1 = 1

s = input()
for i in range(n):
    if s[i]=="a":
        if t < a+b:
            print("Yes")
            t += 1
        else:
            print("No")
    elif s[i] == "b":
        if t < a+b and t1 <= b:
            print("Yes")
            t1 += 1
            t += 1
        else:
            print("No")
    else:
        print("No")

        



Measured memory_bytes: 53080
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
char in[110];
int main(){
	scanf("%s",in);
	long long a;
	scanf("%lld",&a);
	int no=0;
	for(int i=0;in[i];i++){
		if(in[i]!='1'){
			no=i;break;
		}
	}
	a--;
	if(a<no){
		printf("%c\n",in[a]);
	}else{
		printf("%c\n",in[no]);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    ll C;
    cin>>N>>C;
    vec x(N), v(N);
    rep(i,N) cin>>x[i]>>v[i];
    vec sum(N), walk_sum(N);
    multiset<ll> left, walk_left;
    for(ll i = N-1 ; i>=0; --i){
        sum[i] = v[i];
        walk_sum[i] = v[i];
        if(i == N-1) {
            sum[i] -= C - x[i];
            walk_sum[i] -= 2*(C - x[i]);
        }else {
            sum[i] += sum[i+1] - (x[i+1] - x[i]);
            walk_sum[i] += walk_sum[i+1] - 2*(x[i+1] - x[i]);
        }
        left.insert(sum[i]);
        walk_left.insert(walk_sum[i]);
    }
    /*rep(i,N) cout<<sum[i]<<' ';
    cout<<endl;*/
    auto fite = left.end();
    --fite;
    ll ans, right = 0;
    ans = max(0LL, *fite);
    rep(i,N){
        auto ite = left.lower_bound(sum[i]);
        left.erase(ite);
        auto ite2 = walk_left.lower_bound(walk_sum[i]);
        walk_left.erase(ite2);
        right += v[i] - x[i];
        if(i > 0) right += x[i-1];
        ans = max(ans, right);
        if(i != N-1){
            ite = left.end(); --ite;
            ans = max(ans, right + *ite - x[i]);
            ite2 = walk_left.end(); --ite2;
            ans = max(ans, right + *ite2);
        }
        /*if(i == 9){
            cout<<right<<' '<<*ite2<<' '<<ans<<endl;
        }*/
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main(){
    string S;
    cin >> S;

    int count = 0;
    if (S.length() >= 2){
        for (int i = 1; i < S.length(); i++){
            if (S[i] != S[i-1]){
                count ++;
            }
        }
    }
    
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  ll m;
  cin >> m;
  ll ans=0;
  rep(i,320000){
    ll y=i+1;
    if(m%y==0&&m/y>=n)ans=max(ans,y);
    if(m%y==0&&y>=n)ans=max(ans,m/y);
  }
  cout << ans << endl;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cout << #x << " = " << (x) << "\n";

const int maxn = 5000 + 5;
int n, k;
int a[maxn];
bitset<maxn> prf[maxn];
bitset<maxn> suf[maxn];

void solve() {
	cin >> n >> k;
	long long sum = 0;
	FOR(i, 1, n + 1) cin >> a[i], sum += a[i];
	if (sum < k) {
		cout << n << "\n";
		return;
	}
	prf[0][0] = suf[n + 1][0] = 1;
	FOR(i, 1, n + 1) {
		prf[i] = prf[i - 1] | (prf[i - 1] << a[i]);
	}
	FORd(i, n + 1, 1) {
		suf[i] = suf[i + 1] | (suf[i + 1] << a[i]);
	}
	int ans = n;
	FOR(i, 1, n + 1) {
		bitset<maxn> l = prf[i - 1];
		bitset<maxn> r = suf[i + 1];
		static int sum[maxn];
		sum[0] = 1;
		FOR(j, 1, maxn) {
			sum[j] = sum[j - 1] + r[j];
		}
		FOR(j, 0, maxn) if (l[j]) {
			int lo = max(0, k - a[i] - j);
			int hi = min(maxn - 1, k - j - 1);
			if (lo <= hi) {
				int tot = sum[hi];
				if (lo) tot -= sum[lo - 1];				
				if (tot) {
					ans--;
					break;
				}
			}
		}
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

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

int main(){
  int N; cin >> N;
  string a;
  map<string, int> m;
  for(int i=0; i<N; i++){
    cin >> a;
    if(m.count(a)==0){
      m[a]=1;
    }else{
      m[a]+=1;
    }
  }
  int M; cin >> M;
  for(int i=0; i<M; i++){
    cin >> a;
    if(m.count(a)==0){
      m[a]=1;
    }else{
      m[a]-=1;
    }
  }
  int ans=0;
  for (auto i = m.begin(); i != m.end() ; ++i){
    ans=max(ans,i->second);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int ans=0;
    vector<int> V(N,0);
    vector<int> C(N,0);
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }
    vector<int> sa(N,0);
    for(int i=0;i<N;i++){
        sa[i]=V[i]-C[i];
    }
    for(int i=0;i<N;i++){
        if(sa[i]>0) ans += sa[i];
    }
    cout << ans << endl;
    return 0;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def bit_count(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N,L = inputIL()

l = [i for i in range(L,L+N)]
a = [abs(i) for i in l]
p = a.index(min(a))

print(sum(l)-l[p])

Measured memory_bytes: 72820
#B問題
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n-2):
    p1 = p[i]
    p2 = p[i+1]
    p3 = p[i+2]
    if p2 != max(p1,p2,p3) and p2 != min(p1,p2,p3):
        count+=1
        
print(count)

Measured memory_bytes: 3316
#include <stdio.h>
	int main(void) {
		int a, b, sum;
		scanf("%d %d", &a, &b);
		if(a>9 || a<1 || b>9 || b<1){
			printf("error.\n");
			return 1;
		}
		sum = a + b;
		if(sum >= 10) printf("error");
		else printf("%d",sum);
		return 0;
	}

Measured memory_bytes: 128