akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=998244353;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

#define MAX_N 1000010
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){// this size is really ok??
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r);
}

ll mod_pow(ll x,ll n){
  x%=MOD;
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

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

  ll N,M,K;
  cin>>N>>M>>K;

  setComb();

  ll ans=0;
  for(ll i=0;i<=K;i++){
    ll res=M;
    mul(res,mod_pow(M-1,N-1-i));
    mul(res,comb(N-1,i));
    add(ans,res);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 27088
N = gets.to_i
a = gets.chomp.split.map {|x| x.to_i}.sort!.reverse!
Alice = 0
Bob = 0
a.each.with_index {|ai,i|
    if i%2 == 0 then
        Alice += ai
    else
        Bob += ai
    end
}
puts Alice-Bob

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

void Add(ll &a, ll b){
    a=(a+b)%mod;
    return;
}

void Pro(ll &a, ll b){
    a=(a*b)%mod;
    return;
}
ll ruijou(ll n, ll k){
    if(!k) return 1;
    ll a=ruijou(n,k/2);
    a=(a*a)%mod;
    return k%2 ? (a*n)%mod : a;
}


const ll MaxN=201001;

ll f[MaxN], rf[MaxN];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    REP(i, 1, MaxN) f[i] = (f[i - 1] * i) % mod;
    REP(i, 0, MaxN) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(ll n, ll k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}


int main(){
    init();
    ll S; cin>>S;
    ll N=S/3;
    ll ans=0;
    rep(i,N){
        ll K=S-(3*(1+i));
        Add(ans,C(K+i,i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6772
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
    Scanner cin = new Scanner();
	  while (true)
	  {
	    int n = cin.nextInt();
	    if (n == 0)
	    {
	      break;
	    }
	    int sa = 0, sb = 0;
	    for (int i = 0; i < n; i++)
	    {
	      int a = cin.nextInt(), b = cin.nextInt();
	      if (a > b)
	      {
	        sa += a + b;
	      }
	      else if (a < b)
	      {
	        sb += a + b;
	      }
	      else
	      {
	        sa += a;
	        sb += b;
	      }
	    }
	    Console.WriteLine("{0} {1}", sa, sb);
	  }
	  return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

Measured memory_bytes: 5764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    rep(i, n){
        cout << s[i] << t[i];
    }
    cout << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
<?php
while(true){
    $card = trim(fgets(STDIN));
    if($card == "-"){ 
        break; 
    }
    
    $count = trim(fgets(STDIN));
 
    for($i = 0; $i < $count; $i++){
        $shuffle = trim(fgets(STDIN));
        $divide1 = substr($card, 0, $shuffle);
        $divide2 = substr($card, $shuffle);      
        $card = $divide2.$divide1;
    }
    echo $card.PHP_EOL;
}
?>


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100004];
ll a[102];
void solve (ll k,ll n)
{
	if (dp[k]!=-1)
		return;
	else
	{
		ll mi=INT_MAX;
		for (ll i=0;i<n;i++)
			mi=min(mi,a[i]);
		if (k<mi)
		{
			dp[k]=0;
			return;
		}
		else
		{
			ll f=0;
			for (ll i=0;i<n;i++)
			{
				if (k>=a[i])
				{
					solve(k-a[i],n);
					if (dp[k-a[i]]==0)
						f=1;
				}

			}
			if (f)
				dp[k]=1;
			else
				dp[k]=0;
		}
	}
}
int main()
{
	ll n,k;
	cin>>n>>k;
	for (ll i=0;i<n;i++)
		cin>>a[i];
	//memset(dp,0,sizeof(dp));
	for (ll i=0;i<=k;i++)
		dp[i]=-1;
	solve(k,n);
	(dp[k]==1)?cout<<"First":cout<<"Second";
}

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

int n;
double Ans,d1,x;

int main()
{
#ifdef h10
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
#endif
	int i;
	scanf("%d%lf%lf",&n,&d1,&x);
	for (i=n;i>=1;i--)
	{
		if (i==1) Ans+=d1+x/2.0;
		else
		{
			Ans+=d1+(i-0.5)*x;
			d1+=(2*d1+5*x)/(2.0*i); //((2i+2)*d1+5x)/2i
			x+=(2*x)/i; //(i+2)*x/i
		}
	}
	printf("%.10lf\n",Ans);
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = 0;
        int max = n-1;

        int c = 0;
        String s;
        String even = "Male";
        while(true){
            System.out.println(c);
            s = sc.next();
            if(s.equals("Vacant")){
                return;
            }

            if(c == 0){
                even = s;
                min = 1;
            }else{
                if((c % 2 == 0 && s.equals(even)) || (c % 2 == 1 && !s.equals(even))){
                    min = c+1;
                }else{
                    max = c-1;
                }
            }
            c = (max + min) / 2;
            System.out.flush();
        }
    }
}


Measured memory_bytes: 24232
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 2000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll x(n);
  init();
  ll ans = 0;
  re(i, n) std::cin >> x[i];

  for(ll i=0;i<n-1;i++){
    ll b = n-1-i;
    ll p = pp(fac[n-1], inv[b]);
    p = pp(p, x[n-1]-x[i]);
    ans = (ans + p)%P;
  }

  vll s(n);
  re(i, n) s[i] = ((i==0?0:s[i-1]) + x[i])%P;
  for(int b=2;b<n;b++){
    ll p = pp(fac[n-1], pp(inv[b], inv[b-1]));
    ll pl = (s[n-2] - s[b-2] + P)%P;
    ll mi = (s[n-2-(b-1)]);
    ll tmp = (pp(pl, p) - pp(mi, p) + P)%P;
    ans = (ans+tmp)%P;
  }
  /*
  for(ll i=0;i<n-2;i++){
    for(ll j=i+1;j<n-1;j++){
      ll b = j==j-i+1;
      ll p = pp(fac[n-1], pp(inv[b], inv[b-1]));
      p = pp(p, x[j]-x[i]);
      ans = (ans + p)%P;
    }
  }
  */
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 49272
N = int(input())
R = [tuple(map(int, input().split())) for _ in range(N)]
# 左端でソート
R.sort(key=lambda x: x[0]-x[1])
prev_L_arm = R[0][0] - R[0][1]
prev_R_arm = R[0][0] + R[0][1]
ans = N
for i in range(1, N):
    L_arm = R[i][0] - R[i][1]
    R_arm = R[i][0] + R[i][1]
    if L_arm < prev_R_arm:
        prev_R_arm = min(prev_R_arm, R_arm)
        ans -= 1
    else:
        prev_R_arm = R_arm
print(ans)

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

int main(){
  int n;
  cin>>n;
  bool light[n];
  int a[n];
  REP(i,n){
    cin>>a[i];
  }
  REP(i,n){
    light[i]=false;
  }
  light[0]=true;
  int cnt=0;
  int j=0;
  for (int i = 0; i < n; i++)
  {
    light[a[j]-1]=true;
    cnt++;
    j=a[j]-1;
    if (light[1])
    {
      /* code */
      break;
    }
    
  }
  if (light[1])
  {
    /* code */
    cout<<cnt<<endl;
  }
  else
  {
    cout<<"-1"<<endl;
  }
  
  
  }

Measured memory_bytes: 768
// abc166_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, m, a, b, ans = 0;
  cin >> n >> m;
  vector<int> h(n+1),ma(n+1);
  for (int i=1;i<=n;++i){
    cin >> h.at(i);
    ma.at(i)=0;
  }
  rep(i, m) {
    cin >> a >> b;
    ma.at(a)=max(ma.at(a),h.at(b));
    ma.at(b)=max(ma.at(b),h.at(a));
  }

  for (int i=1;i<=n;++i){
    ans+=h.at(i)>ma.at(i);
  }

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


Measured memory_bytes: 3936
// Author :mdragneell
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

 
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define pi  pair< int,int >
#define pl  pair< ll,ll >
#define f first
#define s second
 
ll const N=1e5+5;
ll const mod=1e9+7;
ll min(ll x,ll y) { if(x < y) return x; else return y; }
ll max(ll x,ll y) { if(x > y) return x; else return y; }
ll gcd(ll x,ll y) { if(x == 0) return y; else return gcd(y%x,x);}


struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
       
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
struct compare { 
    bool operator()(const pair<ll, ll>& value,  
                                const ll& key) 
    { 
        return (value.first < key); 
    } 
    bool operator()(const ll& key,  
                    const pair<ll, ll>& value) 
    { 
        return (key < value.first); 
    } 
}; 

bool compare1(const pair<ll,ll> &a, 
            const pair<ll,ll> &b) 
{ 
    if(a.first<b.first) 
        return true ;
    else if(a.first==b.first) 
        return (a.second > b.second); 
    else return false;
} 

ll powmod(ll x, ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        y>>=1;
        if(y<=0)
            break;

        x=(x*x)%mod;
    }

    return res;
}


int main()
{
 
 
       ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
       /* #ifndef ONLINE_JUDGE
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        #endif*/


        ll tt=1;
        //cin>>tt;

        while(tt--)
        {
            ll n,m=1e9;
            cin>>n;

            vector<ll>v(n);
            ll ans=0;

            for(int i=0;i<n;i++)
            {
                cin>>v[i];
                m=min(v[i],m);

                if(m==v[i])
                    ans++;


            }
            cout<<ans<<endl;







        }  
 
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <limits.h>
#include <stdlib.h> 
  
#define WHITE 0
#define BLACK 1
#define MAX 100
#define N -1
 
int D[MAX],W2v[MAX][MAX],cl[MAX];

int main(){
  int n, i, j, min, u, v, p, q, x; 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j = 0;j < n;j++){
      W2v[i][j] = N;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&x);
    scanf("%d",&q);
    for(j = 0;j < q;j++){
      scanf("%d",&v);
      scanf("%d",&p);  
      W2v[x][v] = p;
    }
  }  
  for(i=0;i<n;i++){
    D[i] = INT_MAX;
    cl[i] = WHITE;
  }
  D[0] = 0; 
  while(1){
    min = INT_MAX;
    for(i=0;i<n;i++){
      if(D[i] < min && cl[i] == WHITE){
        min = D[i];
         u = i;
      }
    }  
    if(min == INT_MAX) break;
    cl[u] = BLACK;
    for(v=0;v<n;v++){
      if(W2v[u][v] == N) continue;
      if(D[v]>W2v[u][v]+D[u]) D[v]=W2v[u][v]+D[u];
    }
  } 
  for(i=0;i<n;i++){
    printf("%d %d\n",i,D[i]);
  }
  return 0;
}

Measured memory_bytes: 640
n,m=map(int, input().split())
es=[[] for i in range(n)]

for i in range(m):
    a,b=map(int, input().split())
    es[a-1].append([b-1,1])
    es[b-1].append([a-1,1])

from heapq import heappush, heappop

def dijkstra(edges, size, source):
    # edge=探索するグラフ
    # size=グラフの点の数
    # source=スタート点
    distance = [float('inf')] * size
    muki=[size]*size
    distance[source] = 0
    visited = [False] * size
    pq = []
    heappush(pq, (0, source))
    while pq:
        dist_v, v = heappop(pq)
        visited[v] = True
        for u, weight in edges[v]:
            if not visited[u]:
                new_dist = dist_v + weight
                if distance[u] > new_dist:
                    muki[u]=v
                    distance[u] = new_dist
                    heappush(pq, (new_dist, u))
    return distance, muki

dis, muki=dijkstra(es,n,0)

if n not in muki[1:]:
    print('Yes')
    for i in range(1,n):
        print(muki[i]+1)
else:
    print('No')

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

struct Point{
  double x,y;
};


void koch(int n,Point a,Point b){
  if(n==0) return;

  Point s,t,u;
  double th = M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
   koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
   koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}


int main(){
  Point a,b;
  int n;

  scanf("%d", &n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}




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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] s = new int[N];
		int[] t = new int[N];
		int sum = 0;
		
		for(int i = 0; i < N; i++) {
			s[i] = sc.nextInt();
			sum += s[i];
			if(s[i] % 10 != 0) {
				t[i] = s[i];
			}
		}
		
		Arrays.sort(t);
		
		if(sum % 10 != 0) {
			System.out.println(sum);
		} else {
			for(int i = 0; i < N; i++) {
				if(t[i] > 0) {
					System.out.println(sum - t[i]);
					return;
				}
			}
			System.out.println(0);
		}
	}
}


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

int main() {
   int  n,w,gmax=0;
   cin>>n>>w;
   vector<int> weights(n,0),values(n,0);

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

   vector<vector<long long int>> dp(n+1,vector<long long int>(100001));

   for(int i=0;i<=n;i++)
   {
       for(int j=0;j<100001;j++)
       {

           if(j==0)
           {
               dp[i][j]=0;
               continue;
           }

           if(i==0)
           {
               dp[i][j]=w+1;
               continue;
           }

           if(values[i-1]<=j)
           {
               dp[i][j]=min(weights[i-1]+dp[i-1][j-values[i-1]],dp[i-1][j]);
           }
           else
            dp[i][j]=dp[i-1][j];
       }
   }
    
    for(int j=0;j<100001;j++)
       {
           if(dp[n][j]<=w)
            gmax=max(gmax,j);
       }

   cout<<gmax;

   return 0;
}


Measured memory_bytes: 80256
#include <stdio.h>
int solve(int ,int);
int a[2014],n,m;
int main(){
int b[2014],i;

scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&a[i]);
scanf("%d",&m);
for(i=0;i<m;i++)scanf("%d",&b[i]);
for(i=0;i<m;i++){
if(solve(0,b[i]))printf("yes\n");
else printf("no\n");
}
return 0;
}

int solve(int x,int  y){
if(y==0){
return 1;
}
if(x+1>n){
return 0;
}
if(solve(x+1,y-a[x])||solve(x+1,y)){
return 1;
}
else return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using  namespace  std;
int main(){
  string S; cin>>S;
  for(int i = 0; i < 3;i++) {
  if (S.at(i)=='1')
    cout<<'9';
  else if (S.at(i)=='9')
      cout<<'1';
  else 
      cout << S.at(i);
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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 V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc148/tasks/abc148_e>
 問題文============================================================
 E - Double Factorial
 =================================================================
 解説=============================================================
 末尾が10となるのは素因数に2と5がペアで含まれる場合
 
 今回の場合
　Nが奇数:素因数2が出てこないので 0
　Nが偶数:素因数2は大量に出てくるので素因数5の個数が答え
 
 素因数5の個数の求め方は偶奇の区別がない時は
 Nを 5,5*5,5*5*5,...で割った値の総和になる。
 今回は偶数のみなので
 Nを 5,5*5,5*5*5,...で割った値の"半分"の総和になる。
 
 https://atcoder.jp/contests/abc148/submissions/9079100
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    if(N%2 == 1) return 0;
    for(ll x = 5; x <= N;x*=5) res += N/x/2;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int N;

int main(){
  cin >> N;
  
  double i;
  for(i = 1; i < 50000; i++){
    if((int)(i * 1.08) == N) break;  //int変換は切り捨て
  }

  if(i != 50000)           //求める価格は存在しない
    cout << i << endl;
  else
    cout << ":(" << endl;

  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if (a>b){
        cout << "a > b" << endl;
    }else if (a==b){
        cout << "a == b" <<endl;
    }else{
        cout << "a < b" <<endl;
    }
}


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

void solve() 
{
    ll ans=0;
    int n;string s;cin>>n>>s;
    vector<int>R,G;map<int,bool>B;
    REP(i,n){
        if(s[i]=='R')R.push_back(i);
        if(s[i]=='G')G.push_back(i);
        if(s[i]=='B')B[i]=1;
    }
    int BS=n-R.size()-G.size();
    REP(i,R.size())REP(j,G.size()){
        int l=abs(R[i]-G[j]);
        int p=BS;
        if(BS>0&&B[min(R[i],G[j])-l])p--;
        if(BS>0&&B[max(R[i],G[j])+l])p--;
        if(BS>0&&(R[i]+G[j])%2==0&&B[(R[i]+G[j])/2])p--;
        ans+=p;
    }cout<<ans<<endl;
}

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

Measured memory_bytes: 4248
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int n;cin>>n;
  vector<int> count(n, 0);
  rep(i,n-1){
    int a;cin>>a;
    a--;
    count[a]++;
  }
  rep(i,n){
    cout<<count[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3956
cnv0 n x =
  if x' >= n' then n - x else x'
  where
    x' = x - 1
    n' = if n `mod` 2 == 0 then n `div` 2 else (n+1) `div` 2

cnv1 (x,y) = if y > x then (y,x) else (x,y)
  

ans n (a:b:_) = 
  let a' = cnv0 n a
      b' = cnv0 n b
      (a'',b'') = cnv1 (a',b')
  in
    (b'' `mod` 3) + 1

main = do
  n <- getLine
  k <- getLine
  c <- getContents
  let n' = read n :: Int
      k' = read k :: Int
      c' = map (map read) $ map words $ lines c :: [[Int]]
      o  = map (ans n') c'
  mapM_ print o
  

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

// #undef DEBUG
// #define DEBUG
/// {{{ DEBUG --- ///
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if(&o == &cerr) { o << '{'; for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? ", " : ""); o << "}"; } else { for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? " " : ""); } return o; }
#ifdef DEBUG
#ifdef USE_COUT
#define dump(...) (cout<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n")
#else
#define dump(...) (cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n")
#endif
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
template<class T, class U> ostream & operator<<(ostream &o, pair<T, U> const &p) { o << "(" << p.first << ", " << p.second << ")"; return o; }
#else
#define dump(...) (0)
#endif
/// }}}--- ///

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int m; cin >> m;
  int n = m * m;
  vector<int> a(m);
  for(int i = 0; i < m; i++) cin >> a[i], a[i]--;
  vector<int> ord(m);
  iota(begin(ord), end(ord), 0);
  sort(begin(ord), end(ord), [&](int x, int y) {
      return a[x] < a[y];
      });
  auto b = a;
  b.emplace_back(-1);
  b.emplace_back(n);
  sort(begin(b), end(b));
  vector<int> c(m + 1);
  for(int i = 1; i <= m + 1; i++) c[i-1] = b[i] - b[i-1] - 1;
  vector<int> ans;
  int rest = 0;
  vector<int> req;
  dump(1);
  for(int i = 0; i < m; i++) {
    int x = ord[i];
    dump(x);
    int r = m - 1 - x;
    int l = x;
    rest += c[i];
    for(int j = 0; j < l; j++) {
      if(rest <= 0) return (cout << "No" << endl, 0);
      rest--;
      ans.emplace_back(x);
    }
    for(int j = 0; j < r; j++) {
      req.emplace_back(x);
    }
  }
  dump(1);
  ans.insert(end(ans), begin(req), end(req));
  int head = 0;
  int id = 0;
  vector<int> res;
  vector<int> cnt(m);
  for(int i = 0; i < n; i++) {
    if(head < m && a[ord[head]] == i) {
      if(cnt[ord[head]] != ord[head]) return (cout << "No" << endl, 0);
      cnt[ord[head]]++;
      res.emplace_back(ord[head]+1);
      head++;
    } else {
      cnt[ans[id]]++;
      res.emplace_back(ans[id] + 1);
      id++;
    }
  }
  dump(1);
  cout << "Yes" << endl;
  cout << res << endl;
}




Measured memory_bytes: 3728
#include<iostream>
#include<string>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
	if(a>=b && b>=c){
	cout<<c+b<<endl;
	}
	else if(a>=c &&c>=b){
	cout<<c+b<<endl;
	}
	else if(b>=a && a>=c){
	cout<<a+c<<endl;
	}
	else if(b>=c && c>=a){
	cout<<a+c<<endl;
	}
	else if(c>=a && a>=b){
	cout<<b+a<<endl;
	}
	else if(c>=b && b>=a){
	cout<<a+b<<endl;
	}
	
}

Measured memory_bytes: 256
a = [list(map(int, s.split())) for s in open(0)] [0]
n, r = a[0] // (a[1] + a[2]), a[0] % (a[1] + a[2])

if a[0] <= a[1] + a[2]:
    if a[0] >= a[1]:
        print(a[1])
    else:
        print(a[0])
else:
    if a[1] == 0:
        print(0)
    else:
        if r <= a[1]:
            print(n * a[1] + r)
        else:
            print(n * a[1] + a[1])

Measured memory_bytes: 3064
def main():
    N = int(input())
    S = input()
    ans = tmp = S.count('E')
    prev = ''
    for c in S:
        if c == 'E':
            tmp -= 1
        if prev == 'W':
            tmp += 1
        ans = min(ans,tmp)
        prev = c
    print(ans)
main()

Measured memory_bytes: 73756
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N,M,X;
  cin>>N>>M>>X;
  vector<int>A(M);
  for (int i=0;i<M;i++){
    cin>>A[i];
  }
  int tmp1=0;
  int tmp2=0;
  for (int i=0;i<M;i++){
    if (A[i]<X) ++tmp1;
    else ++tmp2;
  }
  int ans=0;
  ans=min(tmp1,tmp2);
  cout<<ans<<endl;
}
  


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    string s;ll k;cin>>s>>k;
    ll n=s.size();
    rep(i,0,n-2){
        if(s[i]=='a')continue;
        ll t=s[i]-'a';
        ll ad=26-t;
        if(k>=ad){
            k-=ad;
            s[i]='a';
        }
    }
    ll t=s[s.size()-1]-'a';
    t=(t+k)%26;
    s[s.size()-1]=(char)('a'+t);
    cout<<s<<endl;
    
    return 0;
}



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

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

  int n;
  cin >> n;
  vector<string> w;
  set<string> s;
  rep(i, n) {
    string a;
    cin >> a;
    w.push_back(a);
    s.insert(a);
  }


  if (s.size() != n) {
    puts("No");
    return 0;
  }

  rep(i, n-1) {
    if (w[i][w[i].size()-1] != w[i+1][0]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[330001],b[330001];
bool check(int lim,int x)
{
	int L=0,R=lim+1;
	for(int i=n;i;i--)
	{
		if(i!=n)
		{
			if(b[i]==-1)R=min(R+1,lim+1);
			if(b[i]==1)L=max(L-1,0);
		}
		if(a[i]==-1)L++;
		if(a[i]==1)R--;
		if(R-L<2)return 1;
	}
	return x<=L||x>=R;
}
int r,c,x,y;
char s[330001],t[330001];
int main()
{
	cin>>r>>c>>n>>x>>y>>(s+1)>>(t+1);
	for(int i=1;i<=n;i++)a[i]=(s[i]=='L'?-1:s[i]=='R'?1:0),b[i]=(t[i]=='L'?-1:t[i]=='R'?1:0);
	if(check(c,y))puts("NO"),exit(0);
	for(int i=1;i<=n;i++)a[i]=(s[i]=='U'?-1:s[i]=='D'?1:0),b[i]=(t[i]=='U'?-1:t[i]=='D'?1:0);
	if(check(r,x))puts("NO"),exit(0);
	puts("YES");
}


Measured memory_bytes: 2176
X = str(input())
X = X.replace("ST","")
lx = len(X)
s_count = 0
t_count = 0
for i in range(lx):
  if X[i] == "S":
    s_count += 1
  else:
    if s_count:
      s_count -= 1
    else:
      t_count += 1
   
print(s_count + t_count)

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

int main() {
    string T;
    cin >> T;
    int n = T.size();
    rep(i,n){
        if(T[i]=='?') T[i] = 'D';
    }
    cout << T << endl;
}

Measured memory_bytes: 3756
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function root(uf::Array{Int,1},x)
	s=x
	while uf[s]>0
		s=uf[s]
	end
	s
end
function same(uf::Array{Int,1},x,y)
	root(uf,x)==root(uf,y)?true:false
end
function unite(uf::Array{Int,1},x,y)
	l = root(uf,x)
	r = root(uf,y)
	if l!=r
		if uf[l] < uf[r]
			uf[l] += uf[r]
			uf[r] = l
		else
			uf[r] += uf[l]
			uf[l] = r
		end
	end
end


function main()
	n,m,k = readline() |> split |> parseMap
	uf = -ones(Int,n)
	fd = -ones(Int,n)
	for i in 1:m
		a,b = readline() |> split |> parseMap
		unite(uf,a,b)
		fd[a] -= 1
		fd[b] -= 1
	end
	for i in 1:n
		fd[i] -= uf[root(uf,i)]
	end
	for i in 1:k
		c,d = readline() |> split |> parseMap
		if same(uf,c,d)
			fd[c] -= 1
			fd[d] -= 1
		end
	end
	for i in 1:n-1
		print(fd[i]," ")
	end
	println(fd[n])
end

main()

Measured memory_bytes: 172188
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    string n;
    cin >> n;

    int x = n.back() - '0';
    if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9) {
        cout << "hon\n";
    }else if(x == 3) cout << "bon\n";
    else cout << "pon\n";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
ll n, k;
V<ll> v;
ll dp[N], dp2[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for(ll i=1; i*i<=n; i++){
    v.pb(i);
    v.pb(n/i);
  }
  v.pb(0);
  uniq(v);
  n = sz(v)-1;
  dp[0] = 1;
  FOR(_, 0, k+1){
    ll s = 0;
    FOR(i, 0, n){
      (s += dp[i]) %= MOD;
      dp2[n-i-1] = s*(v[n-i]-v[n-i-1])%MOD;
    }
    swap(dp, dp2);
  }
  cout << dp[0] << endl;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int D;
    cin>>D;
    vector<int> c(26);
    rep(i,26){
        int tmp=0;
        cin>>tmp;
        c[i]=tmp;
    }
    vector<vector<int>> s(365,vector<int>(26));
    vector<int> last(26,1);//最後にiのテストをやってからの経過日数とする
    rep(i,D){
        rep(j,26){
            int stmp=0;
            cin>>stmp;
            s[i][j]=stmp;
        }
    }
    vector<int> ans;
    //減少量が一番少なくなるように割り当てる
    //作戦.「やらなかった場合に一番減少量が多いテストをやる」

    rep2(i,1,D+1){
        //i日目にやるやつを決める
        int testnum=0;
        int minusmax=0;
        rep(j,26){
            if((c[j]*last[j])*-1<minusmax){
                testnum=j;
                minusmax=(c[j]*last[j])*-1;
            }
        }
        //i日目にtestnum番のテストをやることに決めたので
        //testnum番以外のlastを1増やす
        rep(j,26){
            if(j!=testnum){
                last[j]++;
            }
        }
        ans.push_back(testnum+1);

    }
    rep(i,D){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3712
def main():
    x,y = map(int,input().split())
    prices = [300000,200000,100000]
    ans = 0
    if x <= 3:
        ans += prices[x-1]

    if y <= 3:
        ans += prices[y-1]

    if x == 1 and y == 1:
        ans += 400000

    print(ans)


main()


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  vector<vector<int>>vec(a+1,vector<int>(b));
  for(int i=0;i<a+1;i++){
    for(int j=0;j<b;j++){
      cin>>vec.at(i).at(j);
    }
  }
  int count=0;
  vector<int>sum(a+1);
  for(int i=1;i<a+1;i++){
    for(int j=0;j<b;j++){
      sum.at(i)+=vec.at(0).at(j)*vec.at(i).at(j);
    }
    if(sum.at(i)+c>0)
      count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
int N;
int a[15];
int s1=0,sum;
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[N]);
		if(a[N]%2==0){
			s1++;
		}
	}
	if(N==2&&a[0]==1&&a[1]==1){
		printf("8\n");
	}
	else{
		sum=pow(3,N)-pow(2,s1);
	    printf("%d\n",sum);
	}
	
	
	return 0;
} 

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
N = int(input())
S = list(input())[: -1]
Q = int(input())
qs = list(map(int, input().split()))
cs = [0] * (N + 1)
c = []
d = []
for i in range(N):
  cs[i + 1] = cs[i] + (S[i] == "M")
  if S[i] == "C": c.append(i)
  if S[i] == "D": d.append(i)
ccs = [0] * (N + 1)
ccounts = [0] * (N + 1)
for i in range(N):
  ccs[i + 1] = ccs[i] + cs[i] * (S[i] == "C")
  ccounts[i + 1] = ccounts[i] + (S[i] == "C")

#print(cs, c)
#print(ccs)
for k in qs:
  res = 0
  for i in d:
    l = i
    r = min(N, i + k)
    res += max(0, ccs[r] - ccs[l] - cs[i] * (ccounts[r] - ccounts[l]))
  print(res)

Measured memory_bytes: 144120
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a;
  double b,c;
  cin>>a>>b;
  c=0;
  vector<ll>vec(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
    c+=vec.at(i);
  }
  double g;
  g=c/4/b;
  sort(vec.begin(),vec.end());
  if(vec.at(a-b)>=g){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}


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

int main(){
    int n;
    cin >> n;
    long long A[100010];
    for (int i=1;i<=n+1;i++) cin >> A[i];
    long long B[100010];
    for (int i=1;i<=n;i++) cin >> B[i];

    long long ans = 0;
    for (int i=n+1;i>=2;i--){
        if (A[i] > B[i-1]){
            ans = ans + B[i-1];
        }
        else{
            long long t = B[i-1] - A[i];
            ans = ans + min(B[i-1], A[i]+A[i-1]);
            if (A[i-1] - t > 0) A[i-1] = A[i-1] - t;
            else A[i-1] = 0;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		int ops = 0;
		if(N>=M) {
			System.out.println(ops);
			return;
		}
		int [] X = new int [M];
		for(int i=0; i<M; i++) {
			X[i] = sc.nextInt();
		}
		int [] dist = new int [M-1];
		Arrays.sort(X);
		for(int i=1; i<M;i++) {
			dist[i-1] = X[i] - X[i-1]; 
		}
		Arrays.sort(dist);
		for(int i=0; i<M-N; i++) {
			ops+=dist[i];
		}
		System.out.println(ops);
		sc.close();
	}
}

Measured memory_bytes: 50020
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define MAX 100000
typedef long long ll;
map<int,ll> ma;

	
int main(){
	int n,m;
	cin >> n >> m;
	ll a[MAX + 1] = {};
	ll s[MAX + 1] = {};

	cin >> a[1];
//map
	s[1] = a[1] % m;
	ma[0]++;
	ma[s[1]]++;

	for (int i=2;i<=n;i++) {
		cin >> a[i];
		s[i] = (s[i-1] + a[i]) %m;
		// mapを作る
		ma[s[i]]++;
	}

	ll cnt = 0;
/*
	for (int l = 1; l <= n; l++) {
		for (int r = l; r <= n; r++) {
			if ((s[r] - s[l-1]) % m == 0) {
				cnt++;
			}}}
*/
	// valueが2以上のものにたいして、vC2を足し合わせていく
	for (auto &item: ma) {
		if (item.second >= 2) {
			ll  v = item.second;
			cnt += v * (v-1)/2;
		}
	}

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


Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool prime[1000010];

void set_prime() {
	prime[0] = 1;
	prime[1] = 1;
	for (int i = 2; i < 2000; i++) {
		int j = 2;
		while (i * j <= 1000000) {
			prime[i*j] = 1;
			j++;
		}
	}
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	set_prime();
	while (true) {
		int n;
		cin >> n;
		if (n == 0) break;
		int cnt = 0;
		REP(i, n + 1, n * 2) if (!prime[i]) cnt++;
		cout << cnt << endl;
	}

    return 0;
}



Measured memory_bytes: 4136
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string s;
  string t;
  cin >> N >> s >> t;
  int i = 0,j = 0;
  int cnt = 0;
  while(j < t.size()){
    if(s[i] == t[j] || s[i] == '\0')j++;
    if(s[i] != '\0')i++;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
def check(a,b,c):
    if a == b:
        return False
    if b == c:
        return False
    if c == a:
        return False
    m = max(a,b,c)
    if m >= (a+b+c)-m:
        return False
    return True

N = int(input())
L = list(map(int,input().split()))
ans = 0
if N >= 3:
    for i in range(0,N-2):
        for j in range(i+1,N-1):
            for k in range(j+1,N):
                if check(L[i],L[j],L[k]):
                    ans += 1
print(ans)

Measured memory_bytes: 9108
string = input()

w = 0
e = 0
s = 0
n = 0

for i in range(len(string)):
    if string[i] == 'W':
        w = 1
    elif string[i] == 'E':
        e = 1
    elif string[i] == 'S':
        s = 1
    else:
        n = 1
        
if w == e and s == n:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  for(int i=0;i<9;i++){
    if(((400+i*200)<=a)&&(a<(600+i*200))){
      cout<<8-i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3616
import collections
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]

c = collections.Counter(d)


for i in t:
  if i in c:
    c[i] = c[i] - 1
  elif i not in c:
    print("NO")
    exit()


for i in c:
  if c[i] < 0:
    print("NO")
    exit()

print("YES")

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

using ll=long long; 

void solve(){
	int a,b;
	cin>>a>>b;
	int sum=1;
	int cnt=0;
	while(sum<b){
		sum+=a-1;
		cnt++;
	}
	cout<<cnt<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a;
    cin >> a;
    a *= 2;
    cout << a / 60 << " " << a % 60 << endl;
}

Measured memory_bytes: 3184
import java.io.*;

public class Main{
    public static void main(String args[]) throws Exception{
    	final int PRICE= 100;
    	final double PRECISION= 1.0e3;
    	int num_hrs, win_hrs;
    	double edge;
    	int vote_tot,vote_win;
    	double div;
    	
    	BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
    	String str;
        while( !( (str= br.readLine()).equals("0 0 0") ) ){
        	String[] buf= str.split(" ");  
        	num_hrs= Integer.parseInt(buf[0]);
            win_hrs= Integer.parseInt(buf[1])-1;
        	   edge= Double.parseDouble(buf[2])/100;
            vote_tot= vote_win= 0;
            for(int i=0;i<num_hrs;i++){
            	if( i==win_hrs ){
            		vote_win= Integer.parseInt(br.readLine());
            		vote_tot+= vote_win;
            	} else{
                	vote_tot+= Integer.parseInt(br.readLine());
            	}
            }
            
            if( vote_win !=0 ){
            	div= (1-edge)*PRICE*vote_tot/vote_win;
            	div= (int)(div*PRECISION +1)/PRECISION;
            	System.out.println((int)Math.floor(div));
            } 
            else{ System.out.println(0); }
        }
    }
}

Measured memory_bytes: 22340