akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
using namespace std;


main(){


  
  double a=0.0;
  while( cin >> a){
    double sum=a;

    for(int j=2;j<=10;j++){
      if(j%2==0){
	a*=2;
	sum+=a;
      }
      else{
	a/=3;
	sum+=a;
      }

    }
    cout<<setprecision(10);///////////ツ青クツ度ツづーツ１ツ０ツ個づ可指ツ津ィ
    cout << sum << endl;
  }


  return 0;
}

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

using namespace std;

const int N = 1e6+100;
long long int a[N], ans;
char c[N];
bool viz[N];

int main () {
    string s;
    cin >> s;
    long long int l, r;
    long long int n=s.size();
    l=0, r=0;
    s=s+'V';
    while(true) {
        r=l+1;
        while(r<n) {
            if(!(s[r]=='>'&&s[r+1]=='<'))
                r++;
            else
                break;
        }
        if(l>=n)
            break;
            //cout << l << ' ' << r << '\n';
        long long int op = 0, cl = 0;
        for(int i = l ; i <= min(r,n-1) ; i++ ) {
            if(s[i]=='<')
                op++;
            else
                cl++;
        }
        ans+=(cl*(cl+1))/2;
        ans+=(op*(op+1))/2;
        ans-=min(cl,op);
        l++;
        while(l<n) {
            if(!(s[l]=='>'&&s[l+1]=='<'))
                l++;
            else
                break;
        }
        l++;
    }
    cout << ans;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll sum = 0;
    for(int i=0;i<s.length();i++){
        int val = s[i] - '0';
        sum += val;
    }
    if(sum%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

// modint
const ll mod = 1e9+7;
template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
      return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inv();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
    
  ModInt inv() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
  
  static int get_mod() { return mod; }
};
 
using mint = ModInt<mod>;
int main(){
  cout << setprecision(10);
  ll N,K; cin >> N >> K;

  mint ans = 0;
  for(ll k = K; k <= N+1; k++){
    mint tmp1 = N * k;
    tmp1 -= k * (k-1) / 2;
    mint tmp2 = k * (k-1) / 2;

    ans += tmp1 - tmp2 + 1;

  }

  cout << ans << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, k, ans = 0;
	cin >> n >> k;
	rep(i,n){
		int x;
		cin >> x;
		ans+=2*(min(x, k-x));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())
P = []
for _ in range(N) :
  P.append(int(input()))
#print (P)
P.sort(reverse=True)
P[0] /= 2
print (int(sum(P)))




Measured memory_bytes: 38672
#include<bits/stdc++.h>
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define M 1000000007
using namespace std;
long long int findProductSum(vector<long long int> A, int n)
{
    long long int array_sum = 0;
    for (int i = 0; i < n; i++)
        array_sum = array_sum + A[i];

    long long int array_sum_square = 1;
    array_sum_square = (array_sum_square*array_sum)%M;
    array_sum_square = (array_sum_square*array_sum)%M;

    long long int individual_square_sum = 0;
    for (int i = 0; i < n; i++) {
        long long int prod = 1;
        prod = (prod*A[i])%M;
        prod = (prod*A[i])%M;
        individual_square_sum = (individual_square_sum + prod) % M;
    }

    return (((array_sum_square - individual_square_sum)%M+M)%M)/2;
}
int main() {

    jaldi

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

//long long int ans = findProductSum(a,n);
//    ans = ans%M;
//    cout<<ans<<'\n';
    vector<long long int> suffix(n-1,0);
    suffix[n-2]=a[n-1];
    for(long long int i=n-3;i>=0;i--) {
        suffix[i] = (suffix[i+1]+a[i+1]);
    }

    long long int ans = 0;
    for(long long int i=0;i<n-1;i++) {
        long long int product = 1LL;
        product = ((a[i]%M)*(suffix[i]%M) )% M;
        ans = (ans+product)%M;
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 6344
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); i++)
#define rep1(i,n) for(int (i) = 1; (i) <= (int)(n); i++)
#define INF 1000000
#define MOD 998244353



int main()
{
    int K,N;
    cin >> K >> N;
    
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    vector<int> B(N);
    rep(i, N-1) B[i] = A[i+1] - A[i];
    B[N-1] = K + A[0] - A[N-1];
    
    cout << K - *max_element(all(B)) << endl;
    
    
    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n+1);
	rep(i, n+1) {
		a[i] =i;
	}
	ll sum(0);
	ll mi(0), ma(0);
	rep(i, k-1) {
		mi += a[i];
		ma += a[n - i];
	}
	//cout << mi << endl;
	//cout << ma;
	ll amari = 1000000007;
	for (int i = k; i <= n + 1; ++i) {
		mi += a[i - 1];
		ma += a[n - i+1];
		ll dist = ma - mi+1;
		sum += dist;
		if (sum >= amari) {
			sum %= amari;
		}
		//cout << "alive" << endl;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n, K;
    cin >> n >> K;

    vector<ll> A(n);
    rep(i, n) {
        cin >> A[i];
        A[i] *= 1000;
    }

    ll left = 0, right = 1e12+1;
    // left: 着る回数がKよりおおきくなる最大の長さ
    while (right - left > 1) {
        ll mid = (left + right) / 2;
        
        ll sum = 0;
        rep(i, n) {
            ll cnt = (ll)((A[i]-1) / mid);
            sum += cnt;
        }

        if (sum > K) {
            left = mid;
        }
        else {
            right = mid;
        }
    }

    ll res = (right + 999) / 1000;
    put(res);

}
signed main(){ Main();return 0;}

Measured memory_bytes: 4844
#include<stdio.h>
#define INFTY 2000000000
#define MAX 600000

int i,j,k,L[MAX/2 + 2],R[MAX/2 + 2],C = 0;

void merge(int A[],int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  for(i = 0 ; i < n1 ; i++){
    L[i] = A[left + i];
  }
  for(i = 0 ; i < n2 ; i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for (k = left ; k < right ; k++){
    C++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{ 
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(){
  int S[MAX],n;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&S[i]);
  }

  mergeSort(S,0,n);

  for(i = 0 ; i < n ; i++){
    if(i)printf(" ");
    printf("%d",S[i]);
  }
  printf("\n");
  printf("%d\n",C);
  
  return 0;
}



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

int main(){
  int n;
  cin >> n;
  int a = 0;
  int s;
  cin >> s;
  while (s%2 == 0){
    a += 1;
    s /= 2;
  }
    for (int i = 0;i < n-1;i++){
      int s1,b;
      cin >> s1;
      b = a;
      a = 0;
      while (s1%2 == 0){
        a += 1;
        s1 /= 2;
      }
      if (a > b)
        a = b;
    }
  cout << a << endl;
}
        

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

int main() {
  long long x, y; cin >> x >> y;
  long long temp = x;
  int ans;
	
  for (int i = 1; i <= 100; i++) {
    ans = i;
    if (temp * 2 > y) break;
    else temp *= 2;
  }
	
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll,ll> P;
template <typename T> std::string tostr(const T& t){std::ostringstream os; os<<t; return os.str();}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
 
int main(){
    int n,t;
    cin>>n>>t;
    vector<int> v(n),v2(n),check(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        v2[i]=v[i];
    }
    sort(v2.begin(),v2.end());
    map<int,int> m;
    //ソート後の添え字を格納
    for(int i=0;i<n;i++){
        m[v2[i]]=i;
    }
    int ans=0,pos=n-1,dis=0;
    for(int i=0;i<n;i++){
        //最大値と一致した場合
        if(v[i]==v2[pos]){
            m.erase(v[i]);
            check[pos]=1;
            pos--;
            for(int l=pos;l>=0;l--){
                if(check[l]==0){
                    pos=l;
                    break;
                }
            }
        }else{
            int tmp=abs(v[i]-v2[pos]);
            if(tmp>dis){
                dis=tmp;
                ans=1;
                check[m[v[i]]]=1;
                m.erase(v[i]);
            }else if(tmp==dis){
                ans++;
                check[m[v[i]]]=1;
                m.erase(v[i]);
            }else{
                check[m[v[i]]]=1;
                m.erase(v[i]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  string ans = "";
  while(n != 0)
  {
    ans += (n % 2 == 0 ? '0' : '1');
    n -= (n % 2 == 0 ? 0 : 1);
    n /= -2;
  }
  if (ans == "")
  {
    cout << 0;
    return;
  }
  reverse(ans.begin(), ans.end());
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3604
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    ret = 0
    for n in range(N):
        tmp = 2 ** n
        if ret < tmp and tmp <= N:
            ret = tmp

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N = gets.chomp.to_i

numbers = N.times.map { gets.chomp.to_i }

max = numbers.max
max_index = numbers.index(max)

second = [ numbers[0...max_index], numbers[max_index+1..-1] ].flatten.max

0.upto(N-1) do |i|
    puts i == max_index ? second : max
end


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

//#define FILEIO

using namespace std;

const int SZ = 52;
const double EPS = 1e-9;
const int MOD = 100000008;
const int INF = ( 1 << 30 ) - 1;
const double PI = 2 * acos( 0.0 );

template <class T> T MIN(T a, T b) { return (a < b) ? a : b; }
template <class T> T MAX(T a, T b) { return (a > b) ? a : b; }
template <class T> void SWAP(T &a, T &b) { T c; c = a; a = b; b = c; }
template <class T> T GCD(T a, T b) { T c; while(b > 0) { c = a % b; a = b; b = c; } return a; }

bool CMP(int a, int b)
{
     return (a > b);
}

int main()
{
    #ifdef FILEIO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int n, k, d[200005], i, mx, tmp, ans, x;

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

    mx = 0;
    d[i] = d[0] + k;
    for(i = 0; i < n; i++)
    {
        tmp = d[i + 1] - d[i];
        //cout <<  "tmp:" << tmp << endl;
        mx = MAX(mx, tmp);
        //mx = x;
        //cout <<"i: " << i <<  "mx: " << mx << endl;
    }
    ans = d[i] - d[0] - mx;
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<int>> graph;
const ll MOD = 1000000007;
using namespace std;

int dfs(int now, graph &g, int n, set<int> s)
{
  if (s.count(now) == 1)
  {
    return 0;
  }
  s.insert(now);
  if (s.size() == n)
  {
    return 1;
  }

  int val = 0;

  for (auto v : g[now])
  {
    val += dfs(v, g, n, s);
  }
  return val;
}

int main()
{
  int n, m;
  cin >> n >> m;
  graph g(n);
  REP(i, m)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  set<int> s;
  cout << dfs(0, g, n, s) << endl;
}


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

public class Main {
 
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	    int n = in.readInt();
	    for(int a = 0; a<120; a++) {
	    	for(int b = -64; b<=120; b++) {
	    		if(Math.pow(a, 5) - Math.pow(b,5) == n) {
	    			System.out.println(a + " " + b); 
	    			return; 
	    		}
	    			
	    	}
	    }
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 36472
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

char stdibuf[2500015];
uint32_t stdibufl;

bool arr[101];

uint32_t nextpint(void){ char c=stdibuf[stdibufl++]; while(c<'0'||'9'<c) c=stdibuf[stdibufl++]; uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=stdibuf[stdibufl++]; } return x; }
void printint(uint32_t x){ if(x<0){x=-x; putchar_unlocked('-');}else if(x==0){putchar_unlocked('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar_unlocked(s[i]); putchar_unlocked('\n'); }

uint32_t h[100000];
uint8_t is[100000];

int main(void){
	read(0, stdibuf, 2500014);
	uint32_t n=nextpint();
	uint32_t m=nextpint();
	for(uint32_t i=0; i<n; i++){
		h[i]=nextpint();
	}
	for(uint32_t i=0; i<m; i++){
		uint32_t a=nextpint()-1;
		uint32_t b=nextpint()-1;
		if(h[a]<=h[b]) is[a]=1;
		if(h[a]>=h[b]) is[b]=1;
	}
	uint32_t ans=0;
	for(uint32_t i=0; i<n; i++){
		ans+=is[i];
	}
	printint(n-ans);
}


Measured memory_bytes: 4128
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    ll mi = LINF;
    ll s = 0;
    for (int i = 0; i < n; i++) {
        s += a[i];
        if (i < n - 1) {
            chmin(mi, abs(sum - 2LL * s));
            chmin(mi, abs(sum - 2LL * (sum - s)));
        }
    }
    cout << mi << endl;
}

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

int main(){int s = 0, t = 0, temp;for(int i = 0; i < 4; ++i) {scanf("%d", &temp);s += temp;}for(int i = 0; i < 4; ++i) {scanf("%d", &temp);t += temp;}printf("%d\n", max(s, t));return 0;} 

Measured memory_bytes: 1020
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
#include<cstdio>
 
 
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007
#define MAX_H 101
#define MAX_W 101


int main(){

    int money[6] = {500,100,50,10,5,1};


    int n;
    while(cin >> n,n){
        int count = 0;
        int change = 1000-n;
        for(int i = 0;i < 6;i++){
            while(change >= money[i]){
                count++;
                change-=money[i];
            }
        }
        cout << count << endl;
    }



    return 0;
}



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

typedef long long ll;
const int MAXN = 100010;
const int MAXM = 200010;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int st[MAXN], to[MAXM<<1];
int e, nxt[MAXM<<1];
inline void Add(int u, int v) {
	to[++e] = v, nxt[e] = st[u];
	st[u] = e;
}

int n, m, size;
bool vis[MAXN], col[MAXN];
ll ans;

inline bool dfs(int u) {
	vis[u] = true, size++;
	bool res = false;
	int i;
	for(i = st[u]; i; i = nxt[i]) {
		int v = to[i];
		if(vis[v]) {
			if(col[v] == col[u]) res = true;
			continue;
		}
		col[v] = col[u]^1, res |= dfs(v);
	}
	return res;
}

int main() {
	int i;
	n = read(), m = read();
	for(i = 1; i <= m; i++) {
		int u = read(), v = read();
		Add(u, v), Add(v, u);
	}
	ll cnt0 = 0, cnt1 = 0, cnt2 = 0;
	bool oc;
	for(i = 1; i <= n; i++) {
		if(vis[i]) continue;
		size = 0, oc = dfs(i);
		if(size == 1) cnt2++;
		else if(oc) cnt1++;
		else cnt0++;
	}
	ans = cnt2*((n-cnt2)<<1)+cnt2*cnt2;
	ans += cnt0*cnt0*2+cnt1*cnt1+cnt0*cnt1*2;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5248
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005
vi a;
ll n,m,v,p;

bool check(ll ps)
{
	// if(ps<p)
	// 	return 1;
	ll vl=a[ps]+m;
	ll rem=m*(v-1),num;
	vi tmp(n,0);
	tmp[ps]=m;
	ll cnt=0;
	rep(i,0,n)
	{
		if(a[i]>vl)
			cnt++;
	}
	if(cnt>=p)
		return 0;
	repr(i,0,n)
	{
		if(i==ps)
			continue;
		num=min(m,max(0,vl-a[i]));
		// if(num<0)
		// 	continue;
		tmp[i]=num;
		if(num>=rem)
			return 1;
		rem-=num;
	}
	rep(i,0,p-1)
	{
		num=m-tmp[i];
		if(num>=rem)
			return 1;
		rem-=num;
	}
	return 0;
}

void solve()
{
	cin>>n>>m>>v>>p;
	a.resize(n);
	rep(i,0,n)
	{
		cin>>a[i];
	}
	sort(all(a));
	reverse(all(a));
	// what_is(check(n-1));
	ll l=p,r=n-1,mid;
	while(l<=r)
	{
		mid=(l+r)/2;
		if(check(mid))
			l=mid+1;
		else
			r=mid-1;
	}
	cout<<l<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
n=int(input())
a=[int(j) for j in input().split()]
from collections import Counter
c=Counter(a)
l=c.most_common()
ll=[]
for i,j in l:
    ll.append(j)
ll.sort()
s=sum(ll)
rem=0
for k in range(1,n+1):
    rest=k-rem
    while ll and ll[-1]>s//rest:
        s-=ll[-1]
        ll.pop()
        rem+=1
        rest-=1
    print(s//rest)






Measured memory_bytes: 52032
#include<bits/stdc++.h>
using namespace std;
int trimin(int a,int b,int c){
    return min(min(a,b),c);
}


int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int c[n];
    for(int i=0;i<n;i++)cin >> a[i] >> b[i] >> c[i];
    int dp[n][3];
    for(int i=0;i<n;i++){
        dp[i][0] = 0;
        dp[i][1] = 0;
        dp[i][2] = 0;
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    
    for(int i=1;i<n;i++){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
    }
    cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;
}


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

class Proc{
public:
  string nam;
  int tim ;
  Proc(){
    nam="";
    tim=0;
  }
};
Proc Q[100001];

class Queue{
private:
   int fp;
   int rp;
public:
  Queue(){  fp=0;rp=0;}

  int next( int p ) const {return (p+1)%100001;}
  bool isFull(){ return (next(rp)==fp);}
  bool isEmpty(){return (rp==fp);}
  void push (Proc d);
  Proc front();
  void pop();

};

void Queue::push(Proc d){
if(isFull())
return;

Q[rp]=d;
rp=next(rp);
}

Proc Queue::front(){
if(isEmpty()){
  Proc er;
  er.tim=-1;
  return er;
}
return Q[fp];
}

void Queue ::pop(){
  if(isEmpty())return;
  fp=next(fp);
}


int main(){
  Queue que;
  int n,q;
  cin>>n>>q;
  for (int  i = 0; i < n; i++) {
    Proc p;
    cin>>p.nam>>p.tim;
    que.push(p);
  }
int total_tim =0;
while (!que.isEmpty()) {
Proc p=que.front();
que.pop();
if(p.tim<=q){
total_tim+=p.tim;
cout <<p.nam<<' '<<total_tim<<endl;
}else{
  total_tim +=q;
  p.tim-=q;
  que.push(p);
}

}

  
  return 0;
}

Measured memory_bytes: 7072
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索


*/
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 3e18+7
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());


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

    int N;
    cin>>N;
    vector<int> t(N),v(N+1),S(N+1);
    for(int i=0;i<N;i++) cin>>t[i];
    for(int i=0;i<N;i++) cin>>v[i];
    S[0]=0;
    for(int i=1;i<N;i++){
        S[i]+=S[i-1]+t[i-1];
    }
    S[N]=S[N-1]+t[N-1]; v[N]=0;
    double speed=0.0,ans=0.0;
    for(int i=0;i<N;i++){
        for(double j=0.0;j<t[i];j+=0.5){
            bool flag=true;
            speed+=0.5;
            if(speed>v[i]) flag=false;
            for(int k=i+1;k<=N;k++){
                if(speed- ( S[k]-(S[i]+j+0.5) ) <=v[k]) continue;
                else flag=false;
            }
            if(flag){
                ans+=(speed-0.5)*0.5+0.125;
            }else{
                bool flag2=true;
                speed-=0.5;
                if(speed>v[i]) flag2=false;
                for(int k=i+1;k<=N;k++){
                    if(speed- ( S[k]-(S[i]+j+0.5) ) <=v[k]) continue;
                    else flag2=false;
                }
                if(flag2){
                    ans+=speed*0.5;
                }else{
                    ans+=(speed)*0.5-0.125;
                    speed-=0.5;
                }
            }
            //if((int)(j+0.5)%10==0) cout<<j<<" "<<ans<<endl;
        }
    }
    printf("%.10lf\n",ans);
}

Measured memory_bytes: 256
process.stdin.on("data",function(c){
	var t=["Sun","Mon","Tues","Wednes","Thurs","Fri","Satur"],d=new Date;
	d.setYear(2004);
	(c+"").trim().split("\n").some(function(n){
		n=n.split(" ");
		if(!+n[0]){
			return 1;
		}
		d.setMonth(+n[0]-1,+n[1]);
		console.log(t[d.getDay()]+"day");
	});
}).resume();

Measured memory_bytes: 7652
#include <iostream>
#include <vector>
#include <climits>

int main()
{
	int n,k;
	std:: cin>>n>>k;
	std::vector<int> h(n);
	
	for(int i=0;i<n;i++){
		std::cin>>h[i];
	}
	
	std::vector<long long> dp(n,INT_MAX);
    dp[0]=0;
	for(int now=0;now<n-1;now++){
		for(int next=now+1;next<std::min(n,now+1+k);next++){
			dp[next]=std::min(dp[next],dp[now]+abs(h[next]-h[now]));
		}
	}
	
	std::cout<<dp[n-1]<<std::endl;
}

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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N, K;
	cin >> N >> K;
	vector<int>A(N);
	vector<int>X(N, 0), Y(N, 0);
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}

	for (int i = 0; i < N; i++){
		for (int j = i + 1; j < N; j++) {
			if (A[i] > A[j]) {
				X[i] += 1;
			}
			else if (A[i] < A[j]) {
				Y[i] += 1;
			}
		}
	}

	ll mod = 1e9 + 7;
	ll ans = 0;

	for (int i = 0; i < N; i++){
		ans += (K * (K + 1) / 2 % mod) * X[i] % mod + (K * (K - 1) / 2 % mod) * Y[i] % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
a,b,c = I()
s = set([a,b,c])
if len(s) == 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 7836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1000005,INF=1<<30;

int f(int money){
    int cnt=0;
    cnt+=money/500;
    money%=500;
    
    cnt+=money/100;
    money%=100;
    
    cnt+=money/50;
    money%=50;
    
    cnt+=money/10;
    money%=10;
    
    return cnt;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    bool ok=false;
    while(1){
        int N;cin>>N;
        if(N==0) break;
        
        if(ok) cout<<endl;
        vector<int> A(4),ans(4);
        for(int i=0;i<4;i++) cin>>A[i];
        int maxi=INF,s=INF;
        
        for(int a=0;a<=A[0];a++){
            for(int b=0;b<=A[1];b++){
                for(int c=0;c<=A[2];c++){
                    for(int d=0;d<=A[3];d++){
                        if(a*10+b*50+c*100+d*500>=N){
                            int e=A[0]-a+A[1]-b+A[2]-c+A[3]-d+f(a*10+b*50+c*100+d*500-N);
                            if(e<maxi||(e==maxi&&a+b+c+d<s)){
                                ans[0]=a;
                                ans[1]=b;
                                ans[2]=c;
                                ans[3]=d;
                                maxi=e;
                                s=a+b+c+d;
                            }
                        }
                    }
                }
            }
        }
        
        A=ans;
        
        if(A[0]) cout<<"10 "<<A[0]<<endl;
        if(A[1]) cout<<"50 "<<A[1]<<endl;
        if(A[2]) cout<<"100 "<<A[2]<<endl;
        if(A[3]) cout<<"500 "<<A[3]<<endl;
        
        ok=true;
    }
}






Measured memory_bytes: 3132
import heapq
import sys
readline = sys.stdin.readline
def dijkstra(n):
    inf = 10 ** 6 + 1
    dist = [0] + [inf] * (n - 1)
    q = [(0, 0)]
    while q:
        u = heapq.heappop(q)[1]
        for (v, c) in edge[u]:
            alt = dist[u] + c
            if dist[v] > alt:
                dist[v] = alt
                heapq.heappush(q, (alt, v))
    return dist
n = int(input())
edge = [[]] * n
for _ in range(n):
    l = list(map(int, readline().split()))
    edge[l[0]] = (e for e in zip(l[2::2], l[3::2]))
for i, c in enumerate(dijkstra(n)):
    print(i, c)


Measured memory_bytes: 40508
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
// #include <cmemcopy>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    char s[50];
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for(int i=0; i<n; i++) {
        scanf("%s", s);
        if(strcmp(s, "AC") == 0) {
            ac++;
        }
        else if(strcmp(s, "WA") == 0) {
            wa++;
        }
        else if(strcmp(s, "TLE") == 0) {
            tle++;
        }
        else if(strcmp(s, "RE") == 0) {
            re++;
        }
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    return 0;
}

Measured memory_bytes: 3816
"use strict";
    
const main = arg => {
    const N = parseInt(arg.split("\n")[0]);
    let A = arg.split("\n")[1].split(" ");
    let flg = true;
    let cnt = 0;
    
    while(flg) {
        if(A.filter(n=>n%2==0).length !== N) {
            flg = false;
        } else {
            A = A.map(n=>n / 2);
            cnt++;
        }
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21448
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, m= [int(i) for i in input().split(" ")]

c = []
i = 2
mt = m

while i * i <= mt:
    ci = 0
    while mt % i == 0:
        mt = mt // i
        ci += 1
    if ci > 0:
        c.append(ci)
    i += 1
if mt > 1:
    c.append(1)
    
p = 1
for j in range(0, len(c)):
    p *= comb(n - 1 + c[j], c[j])

print(p % (10**9 + 7))

Measured memory_bytes: 3688
s = input()
if s[0] != 'A':
    print('WA')
    exit()
if s[2:-1].count('C') != 1:
    print('WA')
    exit()
s = s[1:2] + s[2:-1].replace('C', '') + s[-1:]
if s.islower():
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int A = 0;
  int B = 0;
  int C = 0;
  std::cin >> A >> B >> C;
  std::vector<int> Num(3, 0);
  Num[0] = A;
  Num[1] = B;
  Num[2] = C;
  std::sort(Num.begin(), Num.end());

  std::cout << Num[2] * 10 + Num[1] + Num[0] << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int n,k,judge;
    scanf("%lld%lld",&n,&k);
    if(n>k){
        judge=n%k;
        if(judge<=k-judge) n=judge;
        else n=k-judge;
    }else if(n<k){
        if(n>k-n) n=k-n;
    }else{
        n=0;
    }
    printf("%lld",n);
    return 0;
}

Measured memory_bytes: 1728
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var nab = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nab[0];
        var a = nab[1];
        var b = nab[2];
        Console.WriteLine(n / (a + b) * a + Min(n % (a + b), a));
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rc(s) return cout<<s,0
using namespace std;
int main(){
   long long int ans=0,n,a,b,p[1000];
   cin>>n;
   cin>>a>>b;
   for(int i=0;i<n;i++)
    cin>>p[i];
   for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    for(int c=0;c<n;c++)
   if(p[i]<=a&&p[j]>a&&p[j]<=b&&p[c]>b&&p[i]!=-1&&p[j]!=-1&p[c]!=-1){
    ans++;
    p[i]=-1;
    p[j]=-1;
    p[c]=-1;
   }
   cout<<ans;
   return 0;}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a;
    int b;
    cin >> a;
    
    if(a%2 == 0){
        b = a/2;
    }
    else{
        b = (a+1)/2;
    }
    
    cout << (double)b/a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define forn(i,n) for (int i=0;i<n;i++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define trav(a,x) for (auto& a : x)

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) ((int)(x).size())
#define mem(x,a) memset(x,a,sizeof(x))

typedef vector<int> vi;
typedef pair<int,int> pii;

const int MOD = 1e9+7;
const int INF = 1e18;
const int N = 2e5 + 5;

int f (int a){return a * (a - 1) /2 ;}
int32_t main()
{
 int n;
 cin >> n;
 int a[n] , cnt[n+1];
 mem(cnt , 0);
 forn(i,n) {cin >> a[i] ;++cnt[a[i]] ;}

 int sm = 0 ;
 rep(i,1,n+1)sm += f(cnt[i]);

 forn(i,n)cout << sm - cnt[a[i]] + 1 <<"\n" ;

 return 0;
}        

Measured memory_bytes: 5760
//Created by Aminul on 6/27/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        long a = in.nextInt();
        pw.println((a) + (a * a) + (a * a * a));

        pw.close();
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 27068
#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 rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,q;
    string s;
    cin >> n >> q >> s;
    vc t(q),d(q);
    rep(i,q) cin >> t[i] >> d[i];
    int ans = n;
    rep(_,2) {
        int ok = -1,ng = n;
        auto f = [&](int x) {
            rep(i,q) {
                if(t[i] != s[x]) continue;
                if(d[i] == 'L') {
                    if(x > 0) x--;
                    else return true;
                } else {
                    if(x < n-1) x++;
                    else return false;
                }
            }
            return false;
        };
        while(abs(ok-ng) > 1) {
            int mid = (ng+ok)/2;
            if(f(mid)) ok = mid;
            else ng = mid;
        }
        ans -= ok+1;
        reverse(all(s));
        rep(i,q) d[i] = (d[i] == 'L' ? 'R' : 'L');
    }
    cout << ans << endl;
}


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

P = [2]
for i in range(3, 1001, 2):
    flag = True
    for p in P:
        if i % p == 0:
            flag = False
            break
    if flag:
        P.append(i)

ans = 1
for p in P:
    if p > N:
        break
    t = 0
    i = 1
    while (p ** i) <= N:
        t += N // (p ** i)
        i += 1
    ans *= 1 + t

print(ans % ((10 ** 9) + 7))


Measured memory_bytes: 3060
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>

using namespace std;
typedef long long ll;

ll gcd(ll , ll);

vector<pair<ll, int> > prime_factor(ll n) {
    vector<pair<ll, int> > res;
    for(ll i = 2; i * i <= n; i++) {
        if(n%i) continue;
        res.push_back(pair<ll, int>(i, 0));
        while(n%i==0){
            n /= i;
            res.back().second++;
        }
        
    }
    if(n != 1) res.push_back(pair<ll, int>(n, 1));
    return res;
}

int main(void){
    ll a, b;
    cin>>a>>b;
    ll G=gcd(a, b);
    vector <pair<ll, int> > x=prime_factor(G);

    int ans=x.size()+1;
    cout<<ans<<endl;
    return 0;
    
    
}
ll gcd(ll m, ll n){
    if(n==0){
        return m;
    }
    else return(gcd(n, m%n));
}


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

int main() {
  int N,b,g,f,w;
  f = 1;
  w = 1;
  cin >> N;
  b = N;
  vector<int> a(N + N);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      g = a.at(j + f);
      if(a.at(i) == g) {
        b = b - 1;
        a.at(j + f) = 101 + w;
      }
      w++;
    }
    f++;
  }
  cout << b << endl;
      
       
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int a, b; cin >> a >> b;
    for(int x = 0; x <= 1000; x++)
    {
        if(((int)(x * 0.08) == a) && ((int)(x * 0.1) == b))
        {
            cout << x << endl;
            return;
        }
    }
    cout << -1 << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

/*** Template Begins ***/

typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;

#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; } 

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

// Constants //

const int N = 1e5+7;
const int xinc[] = {0, 0, 1, -1};
const int yinc[] = {1, -1, 0, 0};

/*** Template Ends ***/

void solve()
{
  ll h,w;
  cin>>h>>w;
  ll dp[h][w];
  char v[h][w];
  ll i,j;
  for(i=0;i<h;i++)
  {
    for(j=0;j<w;j++)
      cin>>v[i][j];
  }
  for(i=0;i<h;i++)
  {
    for(j=0;j<w;j++)
      dp[i][j]=0;
  }
  dp[0][0]=1;
  for(i=0;i<h;i++)
  {
    for(j=0;j<w;j++)
    {
      if(v[i][j]=='.')
      {
        if(i>0)
          dp[i][j]=(dp[i][j]%hell+dp[i-1][j]%hell)%hell;
        if(j>0)
          dp[i][j]=(dp[i][j]%hell+dp[i][j-1]%hell)%hell;
      }
    }
  }

  cout<<dp[h-1][w-1];  
}
  
int main(){
  
  ios;
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int t;
  //cin >> t;
  t = 1;
  while(t--)
    solve();

  return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define moda 998244353
#define pi 3.14159265358979323846
#define io ios::sync_with_stdio(0); cin.tie(0);
#define deb(x) cout<<x<<"\n";
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define F first
#define S second

const int N = 100*1000 + 5;
int height[N];
int cost[N];
int n, k;

int ab(int a)
{
    if(a < 0)
        a = (-1) * a;
    return a;
}

int costtoreach(int stone)
{
    if(cost[stone] != -1)
        return cost[stone];
    else
    {
        for(int i = 1 ; i <= k && stone - i >= 0 ; ++i)
        {
            if(cost[stone] == -1)
                cost[stone] = ab(height[stone] - height[stone - i]) + costtoreach(stone - i);
            else
                cost[stone] = min(ab(height[stone] - height[stone - i]) + costtoreach(stone - i), cost[stone]);
        }
    }
    return cost[stone];
}

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

    for(int i = 0 ; i < n ; ++i)
        cin >> height[i];

    for(int i = 1 ; i < n ; ++i)
        cost[i] = -1;

    cost[0] = 0;

    cout << costtoreach(n - 1);

return 0;
}



Measured memory_bytes: 12136
#include<stdio.h>

int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, minj;
  for (i=0; i<N-1; i++) {
    minj = i;
    for (j=i; j<N; j++) {
      if (A[j] < A[minj]) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
    if (minj != i) sw++;
  }
  return sw;
}

int main() {
  int A[100], N, i, sw;

  scanf("%d", &N);
  for (i=0; i<N; i++) scanf("%d", &A[i]);

  sw = selectionSort(A, N);

  for (i=0; i<N; i++) {
    if (i) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}



Measured memory_bytes: 2148