akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
static const int MAX = 1000;

int top, S[MAX];

void intialize(){
    top = 0;
}

bool isEmpty(){
    if(top == 0) return true;
    return false;
}

bool isFull(){
    return top >= MAX-1;
}

void push(int x){
    // if(isFull()) エラー（オーバーフロー） 

    // top を加算してからその位置へ挿入
    S[++top] = x;
}

int pop(){
    // if(isEmpty()) エラー（アンダーフロー）

    top--;
    // top が指していた要素を返す
    return S[top+1]; 
}

int main(){
    int a, b;
    top = 0;
    char s[100];

    while(scanf("%s", s) != EOF){
        if( s[0] == '+' ){
            a = pop();
            b = pop();
            push(a + b);
        }else if( s[0] == '-' ){
            b = pop();
            a = pop();
            push(a - b);
        }else if( s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }else{
            // atoi() は文字列で表現された数値をint型に変換する
            push(atoi(s));
        }
    }

    printf("%d\n", pop());
}


Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int euler(int num){
	 int ret = num;
	 for(int i = 2; i*i <= num;  i++){
			if(num%i == 0) {
				  ret  = ret/i*(i-1);
				  while(num%i == 0)num /= i;
			}
	  }
	  if(num != 1) ret = ret/num*(num-1);
	  return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    int cnt = 0;
    for(int i = a; i <= b ; i++) {
        if(c % i == 0) cnt++;
    }
    cout << cnt << endl;

    
}


Measured memory_bytes: 3148
a,b,c=map(int,input().split())
if a <= b and b <= c:
 print(f"{a} {b} {c}")

elif b <= a and a <= c:
 print(f"{b} {a} {c}")

elif b <=  c and c <= a:
 print(f"{b} {c} {a}")

elif a <= c and c <= b:
 print(f"{a} {c} {b}")

elif c <= a and a <= b:
 print(f"{c} {a} {b}")

elif c <= b and b <= a:
 print(f"{c} {b} {a}")



Measured memory_bytes: 5608
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        k: i64,
        x: i64,
    }

    let ans = if 500 * k >= x { "Yes" } else { "No" };

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.io.PrintWriter

@JvmField val _writer = PrintWriter(System.out, false)
fun main(args: Array<String>) { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val n = readLine()!!.toInt()
    val ans = IntArray(n){0}
    readLine()!!.split(' ').forEach {
        ans[it.toInt()-1]++
    }

    ans.forEach {
        println(it)
    }
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N; cin >> N;

	vector<int> A(N);
	REP(i,N) cin >> A[i];

	SORT(A);

	ll ans = A.back();
	int cnt = -1;
	int idx = N-2;
	REP(i,N-2){
		ans += A[idx];
		cnt++;	
		if(cnt%2 == 1) idx--;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 3984
inp=input
li=list
iinp=lambda : int(inp())
ent=lambda : map(int,inp().split())
lient=lambda : [int(i) for i in inp().split()]
li0= lambda x: [0 for i in range(x)]
livalor=lambda valor,x: [valor for i in range(x)]
stent=lambda : [i for i in inp()]
filldp=lambda valor,x,y: [[valor for i in range(y)] for i in range(x)]

a,b,c,k=ent()
res=a if a<=k else k
k=k-a
if k<=0:
    print(res)
else:
    k=k-b
    if k<=0:
        print(res)
    else:
        res=res-k if k<=c else res-c
        print(res)

Measured memory_bytes: 9224
import bisect
import copy
N,K=map(int,input().split())
a=list(map(int,input().split()))
s=[0]*(N+1)
for i in range(N):
  s[i+1]=s[i]+a[i]
sumList=[]
for i in range(N):
  for j in range(i,N):
    tmp=s[j+1]-s[i]
    sumList.append(tmp)
sumList.sort()
#print(sumList)
tmp=len(bin(sumList[-1]))-2+1
tmp=2**tmp
ans=0
while(tmp != 0):
  #print(tmp)
  tmpList=[sumList[i] % tmp for i in range(len(sumList)) if sumList[i]%tmp>=(tmp//2)]
  #print(tmpList)
  if len(tmpList)>=K:
    ans+=tmp//2
    #print(tmp//2)
    sumList=copy.copy(tmpList)
  tmp = tmp // 2
  
print(ans)



    


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int64 query(const vector<int64>& v) { // Red -> 0 , Blue -> 1
  cout << "? ";
  REP(i, v.size()) {
    cout << v[i]+1 << " ";
  }
  cout << endl;
  string s;
  cin >> s;
  assert(s != "-1");
  return s == "Red" ? 0 : 1;
}

int main(void){
  int64 N;
  cin >> N;
  vector<int64> res(2*N, -1);
  int64 fir = 0;
  vector<int64> q;
  REP(i, N) {
    q.push_back(i);
  }
  fir = query(q);
  vector<int64> base;
  int64 l, r;
  int64 lbin = 0, rbin = N+1, mbin;
  while (rbin - lbin > 1) {
    mbin = (lbin + rbin) >> 1;
    q = vector<int64>();
    FOR(j, mbin, mbin + N) {
      q.push_back(j);
    }
    int64 ret = query(q);
//   cout << fir << " " << ret << endl;
    if (ret == fir) {
      lbin = mbin;
    } else {
      rbin = mbin;
    }
  }
  res[lbin] = fir;
  res[lbin+N] = 1-fir;
  l = lbin+1; r = lbin+N;
  FOR(i, lbin+1, lbin+N) {
    base.push_back(i);
  }
//  REP(i, 2*N) cout << res[i] << " ";
//  cout << endl;

//  cout << l << " " << r << endl;
  REP(i, 2*N) {
    if (res[i] == -1 && !(l <= i && i < r)) {
      base.push_back(i);
      res[i] = query(base);
      base.pop_back();
    }
  }
  int64 cnt[2] = {};
  base = vector<int64>();
  REP(i, 2*N) {
    if (res[i] == -1) continue;
    if (cnt[res[i]] < (N-1)/2) {
      base.push_back(i);
      cnt[res[i]]++;
    }
  }
  FOR(i, l, r) {
    base.push_back(i);
    res[i] = query(base);
    base.pop_back();
  }
  cout << "! ";
  REP(i, res.size()) {
    cout << (res[i] ? 'B' : 'R');
  }
  cout << endl;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MAX = 1e6 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// comb
long long COM(int n, int k) {
  if (n < k) {
    return 0;
  }
  if (n < 0 || k < 0) {
    return 0;
  }
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int X, Y;
void input() {
  cin >> X >> Y;

  ;
  ;
}

void solve() {
  COMinit();
  if (X > Y) swap(X, Y);  // X<=Yとする．
  if ((X + Y) % 3 != 0) {
    cout << 0 << endl;
    return;
  }

  int nn = (X + Y) / 3;
  if (nn == 1) {
    cout << 1 << endl;
    return;
  }

  int ans = 0;
  rep(i, 0, nn) {
    int j = nn - i;
    if ((i + 2 * j == X) && (2 * i + j) == Y) {
      ans = COM(i + j, i);
      break;
    }
  }

  cout << ans << endl;

  // int xx, yy;
  // xx = X, yy = Y;
  // int cnt = 0;
  // while (yy != xx * 2) {
  //   xx -= 1;
  //   yy -= 2;
  //   cnt++;
  // }

  // debug(cnt);

  // if (Y % X == 0) {
  //   cout << 1 << endl;
  //   return;
  // }
  // int n = X / 3;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 23680
h, w = map(int, input().split())
s = [["a"]*(w+2)] + [["a"] + list(input()) + ["a"] for i in range(h)] + [["a"]*(w+2)]

dx=[-1,0,1,-1,1,-1,0,1]
dy=[-1,-1,-1,0,0,1,1,1]

for i in range(1,h+1):
    for j in range(1,w+1):
        c=''
        if s[i][j]!='#':
            for x,y in zip(dx,dy):
                c+=s[i+x][j+y]
            s[i][j]=str(c.count('#'))
for i in range(1,h+1):
    print(''.join(s[i][1:-1]))
# mixed
# 提出 #5372018
# https://img.atcoder.jp/abc075/editorial.pdf

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

int dp[305][305][305];

int main(){
  
  string s;
  int K;
  
  cin>>s>>K;
  
  memset(dp,-1,sizeof(dp));

  s='x'+s;
  
  int len=s.size();
  
  dp[1][len-1][0]=0;
  
  for(int l=1;l<len;l++)
    
    for(int r=len-1;r>=l;r--){
      
      for(int k=0;k<=K;k++){
	
	if(dp[l][r][k]==-1) continue;
	
	if(s[l]==s[r]){
	  if(l==r) dp[l+1][r-1][k]=max(dp[l+1][r-1][k], dp[l][r][k]+1);
	  else dp[l+1][r-1][k]=max(dp[l+1][r-1][k], dp[l][r][k]+2);
	}
	
	if(l==r) continue;
	
	dp[l+1][r-1][k+1]=max(dp[l+1][r-1][k+1], dp[l][r][k]+2);
	dp[l+1][r][k]=max(dp[l+1][r][k], dp[l][r][k]);
	dp[l][r-1][k]=max(dp[l][r-1][k], dp[l][r][k]);
	dp[l+1][r-1][k]=max(dp[l+1][r-1][k], dp[l][r][k]);
      }
    }
  
  int ans=0;
  
  for(int i=0;i<=len;i++)
    for(int j=0;j<=len;j++)
      for(int k=0;k<=K;k++) ans=max(ans, dp[i][j][k]);
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 111104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ {
    class ALDS1_4_C {
        static HashSet<string> dic = new HashSet<string>();
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            for(int i = -0; i < n; i++) {
                string[] input = Console.ReadLine().Split();
                if (input[0] == "insert") dic.Add(input[1]);
                else {
                    string output = dic.Contains(input[1]) ? "yes" : "no";
                    Console.WriteLine(output);
                }
            }
        }
    }
}



Measured memory_bytes: 46564
#include<bits/stdc++.h>
using namespace std;
int main()
{
      long long t,n,c,d,f,g,h,i,j,k,l,a1,a2,a3,b1,b2,b3;
      cin>>t>>n>>c;
      d=t/n;
      if(t%n!=0)d++;
      cout<<c*d<<endl;

      return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	
	static void BubbleSort(int d[]){
		for(int i = d.length-1; i > 0; i--){
			for(int j = 0; j <i; j++){
				if(d[j] > d[j+1]){
					int work;
					work = d[j];
					d[j] = d[j+1];
					d[j+1] = work;
				}
				//printData(d);
				}
			}
	}
	
	
	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();

		int h[] = new int[N];

		for (int i = 0; i < N; i++) {
			h[i] = scan.nextInt();
		}
		
		BubbleSort(h);
		
		//System.out.println(N);
		//System.out.println(Arrays.toString(h));
		
		int ans;
		
		ans = h[N-1] - h[0];
		
		System.out.println(ans);
		
	}

}



Measured memory_bytes: 21844
from collections import defaultdict

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    B = [0] * N
    for i in range(N):
        B[i] = (i + 1) - A[i]
        A[i] += i + 1

    d = defaultdict(int)
    ans = 0
    for i in range(N-1,0,-1):
        d[B[i]] += 1
        ans += d[A[i-1]]

    print(ans)

    


if __name__ == "__main__":
    main()

Measured memory_bytes: 128588
import java.util.Scanner;

public class Main {
	public static long MOD = 1000000007l;
	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);
		int b = sc.nextInt();
		int w = sc.nextInt();
		long bunbo = 1;
		long allB = 0;
		long allW = 0;
		long tmp1 = 0;
		long tmp2 = 0;
		for (int i=1;i<=b+w;i++) {
			allB = (allB*2+tmp1)%MOD;
			allW = (allW*2+tmp2)%MOD;
			System.out.println(div((bunbo+allB-allW+MOD)%MOD, bunbo*2%MOD));
			tmp1 = (i-1>w-1)? div(tmp1*(i-1),i-1-w+1) : (i-1==w-1)? 1 : 0;
			tmp2 = (i-1>b-1)? div(tmp2*(i-1),i-1-b+1) : (i-1==b-1)? 1 : 0;
			bunbo = bunbo*2%MOD;
		}
	}
	public static long pow (long a, long b) {
		if (b==0) {
			return 1;
		} else if (b%2==0) {
			long tmp = pow(a,b/2);
			return tmp * tmp % MOD;
		} else {
			long tmp = pow(a,b/2);
			return (tmp * tmp % MOD)*(a%MOD)%MOD;
		}
	}
	public static long div (long a, long b) {
		return ((a%MOD) * pow(b, MOD-2))%MOD;
	}
}

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

ll a,b;
char res[100][100];

int main(){
    cin >> a >> b;
    for(ll i=0;i<100;i++){
        for(ll j=0;j<100;j++){
            if(i<50) res[i][j]='.';
            else res[i][j]='#';
        }
    }
    ll countb=0;
    for(ll i=0;i<50;i+=2){
        for(ll j=0;j<100;j+=2){
            if(countb==b-1) break;
            res[i][j]='#';
            countb++;
        }
        if(countb==b-1) break;
    }
    ll counta=0;
    for(ll i=99;i>=50;i-=2){
        for(ll j=0;j<100;j+=2){
            if(counta==a-1) break;
            res[i][j]='.';
            counta++;
        }
        if(counta==a-1) break;
    }
    cout << 100 << " " << 100 << endl;
    for(ll i=0;i<100;i++){
        for(ll j=0;j<100;j++){
            cout << res[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<immintrin.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<float> a(N);
	float B = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		B += 1 / a[i];
	}
	float ans = 1 / B;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int ll;
#define MOD (1e9+7);
#define INF (2e9)

int main(void){
	int n;
	cin>>n;
	int *a = new int[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ansp=0,ansm=0;//anspは初項が正
	int sum=0;

	if(a[0]<=0){
		sum= 1;
		ansp += -a[0]+1;
	}else{
		sum=a[0];
	}
	for(int i=1;i<n;i++){
		if(i%2==0){//正
			if(sum+a[i]<=0){
				ansp+=-(sum+a[i])+1;
				sum=1;
			}else{
				sum+=a[i];
			}
		}else{
			if(sum+a[i]>=0){
				ansp+=sum+a[i]+1;
				sum=-1;
			}else{
				sum+=a[i];
			}
		}
	}
	if(a[0]>=0){
		sum= -1;
		ansm += a[0]+1;
	}else{
		sum=a[0];
	}
	for(int i=1;i<n;i++){
		if(i%2==1){//正
			if(sum+a[i]<=0){
				ansm+=-(sum+a[i])+1;
				sum=1;
			}else{
				sum+=a[i];
			}
		}else{
			if(sum+a[i]>=0){
				ansm+=sum+a[i]+1;
				sum=-1;
			}else{
				sum+=a[i];
			}
		}
	}
	cout << min(ansp,ansm)<<endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define MAX 100001
#define MOD 1000000007
using namespace std;

int permutation(int n, int k ,int*a )
{
    if(k==0)
        return 1;

    int dp[n+1][k+1];

    for(int i=0 ;i<=n ;++i)
    {
        for(int j=0;j<=k;++j)
        {
            if(i==0 || j==0)
            {
                dp[i][j] = 1;
                continue;
            }
            if(j - a[i-1]  > 0 )
                dp[i][j] = dp[i][j-1] + ( dp[i-1][j] - dp[i-1][j-a[i-1]-1] );
            else
                dp[i][j] = dp[i][j-1] + dp[i-1][j];

            dp[i][j]%=MOD;
        }
    }   

    return (dp[n][k] - dp[n][k-1]+MOD)%MOD;
}

 
int32_t main()
{
    int n,k;
    cin>>n>>k;
    int*a = new int[n];
    for(int i=0;i<n;++i)
        cin>>a[i];

    cout << permutation( n, k, a) << endl;

    return 0;
}

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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.begin(),A.end());
	int ind = 0;
	int now = A[0];
	bool stop = false;
	while (!stop) {
		stop = true;
		int ni = ind;
		int nm = now;
		for (int i = 0; i < N; ++i) {
			if (A[i] != 0 && i != ind) {
				stop = false;
				A[i] %= now;
				if (A[i] != 0 && A[i] < nm) {
					ni = i;
					nm = A[i];
				}
			}
		}
		ind = ni;
		now = nm;
	}
	cout << now << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define lb long double
#define N 110
using namespace std;
struct Po{lb x,y;}a[N];
void get(Po &x){scanf("%Lf %Lf",&x.x,&x.y);}
int n;
lb ansn;
Po operator -(Po x,Po y){return (Po){x.x-y.x,x.y-y.y};}
lb operator *(Po x,Po y){return x.x*y.y-x.y*y.x;}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)get(a[i]);
	for (int i=3;i<=n;i++)ansn+=(a[i-1]-a[1])*(a[i]-a[1]);
	printf("%.1Lf\n",fabs(ansn/2));
	return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,cnt;
int main() {
    cin>>a>>b;
    set<ll> sa,sb;
    set<ll>::iterator it;
    sa.insert(1);
    sb.insert(1);
    for(ll i=2;i*i<=a;i++) {
        if(a%i==0) {
            sa.insert(i);
            while(a%i==0) a/=i;
        }
    }
    if(a>1) sa.insert(a);
    for(ll i=2;i*i<=b;i++) {
        if(b%i==0) {
            sb.insert(i);
            while(b%i==0) b/=i;
        }
    }
    if(b>1) sb.insert(b);
    for(it=sa.begin();it!=sa.end();it++) {
        if(sb.count(*it)) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  ll zero = 0;
  map<pair<ll, ll>, pair<int, int>> mp;
    
 rep(i, n){
    ll x, y;
    cin >> x >> y;
    if(x==0 && y==0 ){ zero++; continue;}
      ll g = gcd(x, y);
      x /= g; y /= g;
    if(x==0){ mp[{x, llabs(y)}].first++; continue;}
    if(y==0){ mp[{y, llabs(x)}].second++; continue;}
    
    if((x>0 && y>0) || (x<0 && y<0)) {mp[{llabs(x), llabs(y)}].first++;}
    if((x>0 && y<0) || (x<0 && y>0)) {mp[{llabs(y), llabs(x)}].second++;}
  }

  vector<int> w(n+1);
  w[0] = 1;
  rep(i, n+1){
    if(i == 0) continue;
    w[i] = ( w[i-1]*2 ) % mod;
  } 
  
  ll ans = 1;
  for(auto p: mp){
    int f = p.second.first; int s = p.second.second;
    ans = ans*(w[f] + w[s] -1) % mod;
  }
    ans = (mod + ans + zero-1 )%mod;
  
  cout << ans << endl;

    return 0;
  }

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
// using Graph = vector<vector<int>>;
using Graph = vector<vector<pair<ll,ll>>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

vector<bool> seen;  // 訪問済みの点
vector<ll> dist;

void dfs(const Graph &G, int v, ll dis) {
    seen[v] = true;
    dist[v] = dis;
    for (auto next_v : G[v]) { 
        if (seen[next_v.first]) continue;
        dfs(G, next_v.first, dis+next_v.second); // 再帰的に値を追加していく
    }
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    // グラフ
    Graph G(N);

    // firstに行き先の頂点番号、secondに辺コストを入れる
    pair<ll,ll> p;
    ll a, b, c;
    REP(i, N-1){
        cin >> a >> b >> c;
        a--; b--;
        
        p.first = b;
        p.second = c;
        G[a].push_back(p);
        
        p.first = a;
        p.second = c;
        G[b].push_back(p);
    }

    seen.assign(N, false);
    dist.assign(N, -1);

    ll Q, K;
    cin >> Q >> K;
    vector<ll> x(Q);
    vector<ll> y(Q);

    REP(i, Q){
        cin >> x[i] >> y[i];
    }

    dfs(G, K-1, 0);

    // REP(i, N){
    //     cout << dist[i] << endl;
    // }

    REP(i, Q){
        cout << dist[x[i]-1] + dist[y[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 17240
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
typedef long long LL;
const int N = 400500;
const int mod = 1e9 + 7;
int p[N], n, tr[N << 2][2];
void build(int o, int L, int R) {
	if (L + 1 == R) {
		tr[o][L & 1] = L;
		tr[o][R & 1] = n;
		return;
	}
	build(ls, L, mid);
	build(rs, mid, R);
	tr[o][0] = p[tr[ls][0]] < p[tr[rs][0]] ? tr[ls][0] : tr[rs][0];
	tr[o][1] = p[tr[ls][1]] < p[tr[rs][1]] ? tr[ls][1] : tr[rs][1];
}
pair<int, int> Q(int o, int L, int R, int l, int r) {
	if (l <= L && R <= r) {
		return make_pair(tr[o][0], tr[o][1]);
	}
	if (l >= mid)
		return Q(rs, mid, R, l, r);
	else if (r <= mid)
		return Q(ls, L, mid, l, r);

	auto t1 = Q(ls, L, mid, l, r);
	auto t2 = Q(rs, mid, R, l, r);
	return make_pair(p[t1.first] < p[t2.first] ? t1.first : t2.first,
	                 p[t1.second] < p[t2.second] ? t1.second : t2.second);
}
typedef pair<int, int> PII;
vector<PII> ans;
struct qq {
	int l, r, v;
	bool operator<(const qq &o) const { return v > o.v; }
};
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &p[i]);
	}
	p[n] = n + 1;
	build(1, 0, n);
	// solve(0, n);
	priority_queue<qq> q;
	q.push(qq{0, n, tr[1][0]});
	while (!q.empty()) {
		int l = q.top().l;
		int r = q.top().r;
		q.pop();
		if (l & 1) {
			auto ret = Q(1, 0, n, l, r);
			auto nxt = Q(1, 0, n, ret.second + 1, r);
			ans.push_back(make_pair(p[ret.second], p[nxt.first]));
			if (l != ret.second)
				q.push(qq{l, ret.second, p[Q(1, 0, n, l, ret.second).second]});
			if (ret.second + 1 != nxt.first)
				q.push(qq{ret.second + 1, nxt.first,
				          p[Q(1, 0, n, ret.second + 1, nxt.first).first]});
			if (nxt.first + 1 != r)
				q.push(qq{nxt.first + 1, r,
				          p[Q(1, 0, n, nxt.first + 1, r).second]});

		} else {
			auto ret = Q(1, 0, n, l, r);
			auto nxt = Q(1, 0, n, ret.first + 1, r);
			ans.push_back(make_pair(p[ret.first], p[nxt.second]));
			if (l != ret.first)
				q.push(qq{l, ret.first, p[Q(1, 0, n, l, ret.first).first]});
			if (ret.first + 1 != nxt.second)
				q.push(qq{ret.first + 1, nxt.second,
				          p[Q(1, 0, n, ret.first + 1, nxt.second).second]});
			if (nxt.second + 1 != r)
				q.push(qq{nxt.second + 1, r,
				          p[Q(1, 0, n, nxt.second + 1, r).first]});
		}
	}
	// sort(ans.begin(), ans.end(), cmp);
	for (auto &i : ans) {
		cout << i.first << " " << i.second << " ";
	}
	return 0;
}


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

int main() {    
    /* Input */
    char alpha;
    cin >> alpha;
    
    /* Main Logic */
    if (isupper(alpha)) {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
using namespace std;
#define s(a) a.size()
#define push(a,b) a.push_back(b)

int main(){
  string RED,GREEN,up;

  while(cin >> RED , RED != "-"){
    string ans = "";
    int R = 0,G = 0,U = 0;   
    int t = 0;   

    cin >> GREEN >> up;
        
    while(R < s(RED) || G < s(GREEN) || U < s(up)){
      if(t%2==0){
	if(GREEN[G] != up[U]){
	  push(ans,GREEN[G]);
	  G++;
	}
	else{
	  G++;U++; t++;
	}
      }
      else{
	if(RED[R] != up[U]){
	  push(ans,RED[R]);
	  R++; t++;
	}
	else{
	  R++;U++;
	}
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define ll double
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
 
ll dp[301][301][301];
ll solve(int one, int two, int three, int& n)
{
    if(one < 0 || two < 0 || three < 0)
        return 0;
    if(three == 0 && two == 0 && one == 0)
        return 0;
 
    if(dp[one][two][three] > 0)
        return dp[one][two][three];
 
    int remaining = one + two + three;
    ll exp_val = n+one*solve(one-1,two,three,n) + two*solve(one+1,two-1,three,n) +
                    three*solve(one,two+1,three-1,n);
 
    return dp[one][two][three] = exp_val/remaining;
}
 
int main(){
    int i,j,t,n,m,p,k;
    //fast_io;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        int one=0,two=0,three=0;
 
        fr(0,n){
            int x;
            cin >> x;
            if(x == 1)one++;
            else if(x == 2)two++;
            else three++;
        }
 
        memset(dp, -1, sizeof dp);
        cout<<fixed<<setprecision(9)<<solve(one,two,three,n);
    }
    return 0;
}

Measured memory_bytes: 216832
#include<bits/stdc++.h>
using namespace std;
char s[1000],t[1000];
int main()
{
	int n,i;
	scanf("%d\n%s %s",&n,s,t);
	for(i=0;i<n;i++)
	{
		printf("%c%c",s[i],t[i]);	
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first 
#define S second 
#define endl "\n"
#define Endl "\n"
#define emdl "\n"
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
// bool sortBy(const pair<int,pair<int,int>> &a,const pair<int,pair<int,int>> &b){
// 	if(a.S.F==b.S.F)
// 		return a.F<b.F;
// 	return a.S.F<b.S.F;
// }

// #define MAXN 1001
// int pf[MAXN]; 
// void sieve(){
// 	long long int i,j; 
//     pf[1] = 1; 
//     for (i=2; i<MAXN; i++) 
//     pf[i] = i;   
//     for (i=2; i*i<MAXN; i++){ 
//         if (pf[i] == i){
//             for (j=i*i; j<MAXN; j+=i) 
//                 if (pf[j]==j) 
//                     pf[j] = i; 
//         } 
//     } 
// }
// vector<int> factors(int x){ 
//     vector<int> ret; 
//     while (x != 1){ 
// 		int fact=pf[x];
//         ret.push_back(pf[x]); 
// 		while(fac!=1&&x%fact==0)
//         x/=fact; 
//     } 
//     return ret; 
// } 
// set<long long int>poww;
// void init(){
// 	long long int temp=1;
// 	for(int i=1;i<43;i++){
// 		poww.insert(temp);
// 		temp*=2;
// 	}
// }  

int main() {		
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	int qwe=1;
	//cin>>qwe;
	//init();
	// sieve();
	while(qwe--){
        int n;

        cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int mx = a[0];
        long long int ans=0;
        for(int i=0;i<n;i++){
            if(a[i]>=mx){
                mx=a[i];
            }else{
                ans+=mx-a[i];
            }
        }	
        cout<<ans;	

	}

	return 0;
}


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

void solve(long long N, std::vector<long long> x, std::vector<long long> y)
{
    long long FAC = 1; /* factorial of N */
    for (size_t i = 2; i <= N; i++)
    {
        FAC *= i;
    }
    vector<long long> p(N, 0);
    iota(p.begin(), p.end(), 0);

    double dist = 0.0;
    double dx = 0, dy = 0;
    int cnt = 0;
    do
    {
        // for (size_t j = 0; j < FAC; j++)
        // {
        //     cout << p[j] << (j == FAC - 1 ? "" : ", ");

        //     // dx = static_cast<double>(x[p[j + 1]] - x[p[j]]);
        //     // dy = static_cast<double>(y[p[j + 1]] - y[p[j]]);
        //     // dist += sqrt(dx * dx + dy * dy);
        // }

        for (size_t i = 0; i < N - 1; i++)
        {
            dx = static_cast<double>(x[p[i + 1]] - x[p[i]]);
            dy = static_cast<double>(y[p[i + 1]] - y[p[i]]);
            dist += sqrt(dx * dx + dy * dy);
        }

        // cout << cnt++ << endl;
    } while (next_permutation(p.begin(), p.end()) == 1);
    cout << setprecision(10) << dist / static_cast<double>(FAC) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &x[i]);
        scanf("%lld", &y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 384
from sys import stdin, setrecursionlimit, stdout
#setrecursionlimit(1000000)
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline()
mod=1000000007
res=['YES', 'NO']
############# CODE STARTS HERE #############
print(2*pi*ii())

Measured memory_bytes: 9476
#include <stdio.h>
int main(void){
    // Your code here!
    int H = 0;
    int A = 0;
    int time = 0;
    
    scanf("%d %d",&H,&A);
    
    while(H > 0) {
        H = H - A;
        time++;
    }
    printf("%d", time);
    
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    int c4 = 0;
    int c2 = 0;
    for(int& a:A){
        cin >> a;
        if(a%4==0) c4++;
        else if(a%2==0) c2++;
    }
    
    if(c4 + c2/2 >= N/2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640
inData = input().split(' ')

ans = 0
count = 0
maxCount = int(inData[2])
many = int(inData[1])
nedan = int(inData[0])

for i in range(0, maxCount):
    if nedan <= many:
        if count < maxCount:
            ans += 1
            many -= nedan
        else:
            break
    else:
        break

print(ans)

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

r_area = 0
l_area = 0
flag = None
for i, s in enumerate(S):
    if s == "R":
        if flag == "R":
            continue
        flag = "R"
        r_area += 1
    if s == "L":
        if flag == "L":
            continue
        flag = "L"
        l_area += 1

small_area = min(r_area, l_area)
large_area = max(r_area, l_area)
if small_area <= K:
    print(N-1)
else:
    print(N-(small_area+large_area-2*K))

Measured memory_bytes: 39920
#include<cmath>
#include<stdio.h>
//using namespace std;

int main() {
  int a;
  int b;
  scanf("%d%d",&a,&b);
  if(a > b){ 
    printf("a > b\n");
  }
  if(a < b){ 
    printf("a < b\n");
  }
  if(a == b){ 
    printf("a == b\n");
  }
  //return 0;
}


Measured memory_bytes: 2680
def f():
    n,k=map(int,input().split())
    l=list(map(int,input().split()))
    now=1

    for i in range(k.bit_length()):
        if k and k%2:now=l[now-1]
        l=tuple(l[l[i]-1]for i in range(n))
        k//=2
    print(now)
if __name__ == "__main__":
    f()

Measured memory_bytes: 32240
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int n,m;
  cin >> n >> m;
  int r = n;
  int l = 1;
  for (int i = 0; i < m; i++) {
    int x,y;
    cin >> x >> y;
    r = min(r,y);
    l = max(l,x);
  }
  cout << max(r - l + 1,0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> l(n);
	rep(i,n)cin>>l[i];
	sort(l.begin(),l.end());
	int sum = 0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			for(int k=j+1;k<n;k++){
				if(l[k]>=l[i]+l[j]){
					break;
				}
				sum++;
			}
		}
	}
	cout<<sum<<endl;



	return 0;
}

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

int main(void)
{
  int n,r;

  for(;;){
    scanf("%d %d",&n,&r);
    if(n==0)return 0;

    int fuda[n];
    for(int i=0;i<n;i++)
      fuda[i]=n-i;
    
    int p,c;

    for(int i=0;i<r;i++){
      scanf("%d %d",&p,&c);//3 1

      int fuda_tmp[p+c-1];
      for(int j=0;j<=p+c-2;j++)
	fuda_tmp[j]=fuda[j];
    
      //printf("%d\n",fuda[0]);
      //printf("\n");

      for(int j=0;j<c;j++){
	fuda[j]=fuda_tmp[j+p-1];
      }
    
      for(int j=0;j<p-1;j++){
	fuda[c+j]=fuda_tmp[j];
      }

      //for(int j=0;j<n;j++){printf("%d\n",fuda[j]);}
      
    }

  
    printf("%d\n",fuda[0]);
  }

  return 1;
}

Measured memory_bytes: 1184
def main():
    n, k = map(int, input().split())
    count = {}
    a = [int(x) for x in input().split()]
    for aa in a:
        if aa in count:
            count[aa] += 1
        else:
            count[aa] = 1
    count = sorted(count.items(), key=lambda x: x[1], reverse=True)
    print(sum(count[i][1] for i in range(k, len(count))))


if __name__ == '__main__':
    main()



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

using namespace std;

#define ll long long

signed main() {
	ll x, a, b;
	cin >> x >> a >> b;

	int n; cin >> n;
	while (n--) {
		string s; cin >> s;
		if (s == "nobiro") {
			x = max(0LL, x + a);
		}
		else if (s == "tidime") {
			x = max(0LL, x + b);
		}
		else {
			x = 0;
		}
	}

	cout << x << endl;

	return 0;
}


Measured memory_bytes: 3208
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const int inf = 1<<30;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);
int main(){
    int n, y;
    cin >> n >> y;
    int a = -1, b = -1, c = -1;
    rep(i,n+1){
        rep(j,n+1){
            int r = y - 10000 * i - 5000 * j;
            int k = r / 1000;
            if (r % 1000 == 0 && r >= 0 && i + j + k==n){
                a = i;
                b = j;
                c = k;
            }
        }
    }
    cout << a << ' ' << b << ' ' << c << endl;
}

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

int main() {
  int N,
  	  count = 1;
  
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  //cout << vec.at(0) << vec.at(1) << vec.at(2) << vec.at(3) << endl;
  
  for (int i = 0; i < N; i++) {
    if (i != 0 && (vec.at(i) > vec.at(i-1))) {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
s = input()
ans1 = 0 ; ans2 = 0
for i in range(len(s)) :
    #黒スタートで考える
    if i % 2 == 0 :
        if s[i] != "0" :
            ans1 += 1
    else :
        if s[i] != "1" :
            ans1 += 1

for i in range(len(s)) :
    #白スタートで考える
    if i % 2 == 0 :
        if s[i] != "1" :
            ans2 += 1
    else :
        if s[i] != "0" :
            ans2 += 1
print(min(ans1,ans2))


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

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    string s,t;
    cin>>s>>t;
    vector<vector<ll>> dp(t.size()+1,vector<ll>(s.size()+1,0));
    vector<string> dps(s.size()+1,"");

    for(int i=0;i<t.size();i++){
        vector<string> dpst(s.size()+1,"");

        for(int j=0;j<s.size();j++){
            if(t[i]==s[j]){
                dp[i+1][j+1]=dp[i][j]+1;
                dpst[j+1]=dps[j]+t[i];
            }else{
                if(dp[i+1][j]>dp[i][j+1]){
                    dp[i+1][j+1]=dp[i+1][j];
                    dpst[j+1]=dpst[j];

                }else{
                    dpst[j+1]=dps[j+1];
                    dp[i+1][j+1]=dp[i][j+1];
                }
            }
        }
        dps = dpst;
    }
    string ans="";
    int ma = 0;
    rep(i,s.size()+1){
       // cout<<dp[t.size()][i]<<endl;
        if(ma<dp[t.size()][i]){
            ma=dp[t.size()][i];
            ans = dps[i];
        }
    }
    cout<<ans<<endl;


return 0;
}


Measured memory_bytes: 87268
#include <iostream>

using namespace std;

int main() {
	int X;
	cin >> X;

	// 買ったとしたら何個買ったのか
	const int nMin = X / 105;
	const int nMax = X / 100;
	
	int result = 0;
	for(int n = nMin; n <= nMax; n++) {
		const int X2 = X - n * 100;
		if(X2 <= 5 * n) {
			result = 1;
			break;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
 
const long long Inf = 2e18;
const long long mod = 998244353;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int h, w, k;
char a[6][6];

int main()
{
	cin >> h >> w >> k;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for(int i = 0; i < 1 << h; i++)
	{
		for(int j = 0; j < 1 << w; j++)
		{
			int cnt = 0;
			for(int k = 0; k < h; k++)
			{
				if(i & (1 << k))
				{
					continue;
				}
				for(int l = 0; l < w; l++)
				{
					if(j & (1 << l))
					{
						continue;
					}
					if(a[k][l] == '#')
					{
						cnt++;
					}
				}
			}
			if(cnt == k)
			{
				ans++;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3632
N,M=map(int,input().split())
edge=[list(map(int,input().split())) for i in range(M)]
c=[[] for i in range(N)]
for i,j,w in edge:
    c[i-1].append(j-1)
    c[j-1].append(i-1)
a=0
v=[0]*N
import sys
sys.setrecursionlimit(10**6)
def dfs(c,v,p):
    v[p]=1
    for n in c[p]:
        if v[n]==0:
            dfs(c,v,n)
for i in range(N):
    if v[i]==1:
        continue
    dfs(c,v,i)
    a+=1
print(a)

Measured memory_bytes: 130064
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int answer;
	if (N <= 104) answer = 0;
	else if (N <= 134) answer = 1;
	else if (N <= 164) answer = 2;
	else if (N <= 188) answer = 3;
	else if (N <= 194) answer = 4;
	else answer = 5;
	cout << answer << '\n';
	return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto& i : v) cin >> i;

    double sum = 0.0;
    for(auto i : v){
        sum += (double) 1 / i;
    }
    cout << fixed << setprecision(10) << 1 / sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int days(int month) {
  int d;
  switch (month) {
    case 1: case 3: case 5: case 7: case 8: case 10: case 12:
      d = 31;
      break;
    case 4: case 6: case 9: case 11:
      d = 30;
      break;
    case 2:
      d = 29;
      break;
  }
  return d;
}

int main(void) {
  int i, j, a, b, c = 0;
  
  scanf("%d %d", &a, &b);
  
  for (i = 1; i <= a; i++)
    for (j = 1; i == a ? j <= b : j <= days(i); j++)
      if (i == j)
        c++;
  
  printf("%d", c);
  
  return 0;
}

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

int a[220000];
int ans[220000];
vector<int> adj[220000];
vector<int> dp(220000, 1 << 30);

void dfs(int cur, int prev = -1) {
    int i = lower_bound(dp.begin(), dp.end(), a[cur]) - dp.begin();
    int val = dp[i];
    dp[i] = a[cur];
    ans[cur] = lower_bound(dp.begin(), dp.end(), 1 << 30) - dp.begin();
    for (auto to : adj[cur]) {
        if (to == prev) continue;
        dfs(to, cur);
    }

    dp[i] = val;
}

int main() {
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(0);
    rep(i, n) {
        cout << ans[i] << endl;
    }
}

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

Measured memory_bytes: 128
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
// #define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
void solve(){
	ll n ;
	n=5;
	ll ans=0;
	for(ll i=0;i<n ;i++){
		ll a ;
		cin>> a;
		if(a==0)ans=i+1;
	}
	cout<<ans<<endl;
}
 
int main(){
	// mahakal(),fast;
	ll t =1 ;
	// cin>> t ;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void) {

	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
	 printf("a > b\n");
}
	else {
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
r, c = map(int, input().split())
A = []
for line in range(r):
    A.append(list(map(int, input().split())))

[A[i].append(sum(A[i])) for i in range(r)]

trans = []
for i in range(c+1):
    trans.append([A[j][i] for j in range(r)])
    trans[i].append(sum(trans[i]))

ret = []
for i in range(r+1):
    ret.append([trans[j][i] for j in range(c+1)])
    print(' '.join(map(str, ret[i])))

Measured memory_bytes: 7860
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
string s;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		ll x;cin>>x;
		ll ans = (x/500)*1000+(x%500)/5 *5;
		cout<<ans;

}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    
}

Measured memory_bytes: 2560