akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int x, y;
  cin >> x >> y;
  if (x % y == 0)
    cout << -1;
  else
    cout << x;

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
h=h[::-1]

if k>=n:
  print(0)
  
elif k!=0:
  for i in range(k):
    h[i]=0
  print(sum(h))

else:
  print(sum(h))
  






Measured memory_bytes: 26180
#include<stdio.h>
   
   int S[1000000],N;
int binarySearch(int v){
int a=0;
int b=N;
int u;
int s[1000000];
while(a<b){
u=(a+b)/2;
if(v==S[u])
return 1;
if(v>S[u])
a=u+1;
else if(v<S[u])
b=u;
}

return 0;

}

int main(){
  
int i,k,q; 
int c =0;
   
    scanf("%d", &N);
     for ( i = 0; i < N; i++ ){ 
scanf("%d", &S[i]);
}
    
 scanf("%d", &q);
     for ( i = 0; i < q; i++ ){ 
scanf("%d", &k);

if(binarySearch(k))
c++;
}

   
  

      
  
   
    printf("%d\n",c);
   
    return 0;
}

Measured memory_bytes: 2236
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)













int main(){
    ll a;
    string s;
    cin >> a >> s;
    if(a >= 3200){
        cout << s << endl;
    }
    else{
        cout << "red" << endl;
    }
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;


typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll k, a, b;
    cin>>k>>a>>b;
    string ans = "NG";
    for(ll i=a;i<=b;++i){
        if(i%k==0){
            ans = "OK";
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N,K; cin >> N >> K;
  if(N % (2*K + 1) != 0){
    cout << N/(2*K + 1) + 1;
  }
  else{
    cout << N/(2*K + 1);
  }
}
  

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

int H, W;
string board[110];
bool goodx[110], goody[110];

int main(void) {
  cin >> H >> W;

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

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (board[i][j] == '#') {
        goodx[i] = true;
        goody[j] = true;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    if (goodx[i]) {
      for (int j = 0; j < W; j++) {
        if (goody[j]) {
          cout << board[i][j];
        }
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
(_,K),*T=[map(int,t.split())for t in open(0)]
A,B=map(sorted,T)
d=[2**40,0]
exec("i=sum(d)//2;d[sum(max(0,a-i//b)for a,b in zip(A,B[::-1]))>K]=i;"*41)
print(d[0])

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

int main()
{
    int N;
    cin>>N;
    vector<long long> A(N);
    for (long long &a: A)
        cin>>a;

    sort(A.begin(), A.end());
    vector<int> target(N);
    if (A[0]>=0)
    {
        target[0] = -1;
        for (int i=1; i<N; i++)
            target[i] = 1;
    }
    else if (A[N-1]<=0)
    {
        for (int i=0; i<N-1; i++)
            target[i] = -1;
        target[N-1] = 1;
    }
    else
    {
        for (int i=0; i<N; i++)
            target[i] = A[i]<0 ? -1 : 1;
    }

    vector<long long> ax;
    vector<long long> ay;
    //vector<long long> ad;
    function<long long(int, int, int)> f = [&](int s, int e, int d) -> long long
    {
        if (e-s==1)
            return A[s];
        if (d>0)
        {
            long long x, y;
            if (target[s+1]>0)
            {
                //  - + + +
                x = f(s, e-1, -d);
                y = A[e-1];
            }
            else
            {
                //  - - - +
                x = A[s];
                y = f(s+1, e, d);
            }
            ax.push_back(y);
            ay.push_back(x);
            return y-x;
        }
        else
        {
            long long x, y;
            if (target[s+1]>0)
            {
                //  + - - - 
                x = f(s, e-1, d);
                y = A[e-1];
                ax.push_back(x);
                ay.push_back(y);
                return x-y;
            }
            else
            {
                //  + + + -
                x = A[s];
                y = f(s+1, e, -d);
                ax.push_back(y);
                ay.push_back(x);
                return y-x;
            }
            
        }
    };
    cout<<f(0, N, 1)<<endl;
    for (int i=0; i<N-1; i++)
        cout<<ax[i]<<" "<<ay[i]<<endl;
        //cout<<ax[i]<<" "<<ay[i]<<" "<<ad[i]<<endl;
}


Measured memory_bytes: 12652
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;

int main(){
//  int N;
  int X;
  int Y;
  int sum =0;
  cin >> X;
  cin >> Y;
		
  if(X==1 && Y==1){
    sum+=400000;
  }

  if(X==1){
    sum+=300000;
  }
  else if(X==2){
    sum+=200000;
  }
  else if(X==3){
    sum+=100000;
  }

  if(Y==1){
    sum+=300000;
  }
  else if(Y==2){
    sum+=200000;
  }
  else if(Y==3){
    sum+=100000;
  }

  cout << sum;
  
  return 0;
}





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

using namespace std;

bool dfs(long v, long pos, long *x, bool *vis, vector<vector<pair<long, long>>> &g){
    x[v] = pos;
    vis[v] = true;
    bool ans = true;
    for(auto u : g[v]){
        long to = u.first;
        long dist = u.second;
        if(vis[to]){
            if(x[to] != pos + dist) return false;
        }
        else{
            ans = ans & dfs(to, pos + dist, x, vis, g);
        }
    }
    return ans;
}

int main(){
    long N, M;
    cin >> N >> M;
    long r, l, d, x[N]; 
    bool vis[N]; fill(vis, vis + N, false);
    vector<vector<pair<long, long>>> G(N);
    for(long i=0; i<M; i++){
        cin >> r >> l >> d;
        r --; l --;
        G[r].push_back({l, d});
        G[l].push_back({r, -d});
    }
    bool ans = true;  // ture means satisfaction
    for(long i=0; i<N; i++){
        if(!vis[i]){
            ans = dfs(i, 0, x, vis, G);
            if(!ans) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  map<string, int> m;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    m[s]++;
  }

  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <math.h>

using namespace std;
int main() {

	string s;
	string t  = ",";
	string rep = " ";

	cin >> s;

	if (!t.empty()) {
		std::string::size_type pos = 0;
		while ((pos = s.find(t, pos)) != std::string::npos) {
			s.replace(pos, t.length(), rep);
			pos += rep.length();
		}
	}

	cout << s;

	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<vector<int>> d(n, vector<int>(n,-19191919));
    rep(i,m){
        int a,b,c;
        cin >>a >>b >>c;
        d[a][b] = c;
    }

    rep(k,n)rep(i,n)rep(j,n) d[i][j] = max(d[i][j], d[i][k]+d[k][j]);
    cout << d[0][n-1] << endl;
    return 0;
}



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

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        char str[3];
        bool state[2]={false,false};
        bool prev=false;
        int cnt=0;
        for(int i=0; i<n; i++){
            cin >> str;
            int lr;
            if(str[0]=='l') lr=0;
            else lr=1;
            if(str[1]=='u') state[lr]=true;
            else state[lr]=false;

            if(state[0]!=prev && state[1]!=prev){
                prev =state[0];
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5;
const ll mod=1e9+7;
int n;
int main(){
string s;cin>>s;
if(s.back()!='s') s+='s';
else s+="es";
cout<<s;
    return 0;
}


Measured memory_bytes: 3592
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  using key_t = pair<const string, int>;
  int N;
  cin >> N;
  auto cmp = [](const key_t &x, const key_t &y) {
    return x.first < y.first || (!(y.first < x.first) && x.second > y.second);
  };
  map<key_t, int, decltype(cmp)> m(cmp);
  REP1(i, N) {
    int P;
    string S;
    cin >> S >> P;
    m[make_pair(S, P)] = i;
  }
  for (const auto &[k, v] : m) {
    cout << v << endl;
  }
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<pair<int, int>> r(n), b(n);
  for(int i = 0; i < n; i++) cin >> r.at(i).first >> r.at(i).second;
  for(int i = 0; i < n; i++) cin >> b.at(i).first >> b.at(i).second;
  
  vector<bool> r_used(n, false);
  
  sort(r.begin(), r.end());
  sort(b.begin(), b.end());
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    int keep = -1;
    for(int j = 0; j < n; j++){
      if(r.at(j).first < b.at(i).first && r.at(j).second < b.at(i).second && r_used.at(j) == false){
        if(keep == -1){
          keep = j;
          continue;
        }
        else if(r.at(j).second > r.at(keep).second){
          keep = j;
        }
      }
    }
    if(keep != -1){
      ans++;
      r_used.at(keep) = true;
    }
  }
  
  cout << ans << '\n';
}

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

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

    long long ans = 0;
    long long max = -1;
    for(int i=0; i<n; i++) {
        if(i==0) {
            max = a[i];
            continue;
        }

        if( max - a[i] >= 0){
        ans += max - a[i];
        }
         
        if(max <= a[i]) max = a[i];
    }

    cout << ans << endl;
}

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

int main()
{
	ll x,y;
	cin>>x>>y;
	ll ans = 1;
	while(y >= (2*x))
	{
		x*=2;
		ans++;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC099_C solver = new ABC099_C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC099_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] dp = new int[100010];

            dp[0] = 0;
            for (int i = 1; i <= 100000; i++) {
                dp[i] = Integer.MAX_VALUE;
                int power = 1;
                while (power <= i) {
                    dp[i] = Math.min(dp[i], dp[i - power] + 1);
                    power *= 6;
                }

                power = 1;
                while (power <= i) {
                    dp[i] = Math.min(dp[i], dp[i - power] + 1);
                    power *= 9;
                }
            }
            out.print(dp[n]);
        }

    }
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;
vector<string> S;
int O[26];

const int NUMC=26;
class Trie {
public:
	vector<vector<int> > V;
	vector<int> num,P,I,D;
	int find(string s) {
		int cur=0;
		ITR(it,s) if((cur=V[cur][*it+1])==0) return -1;
		return cur;
	}
	void create(vector<string> S) { // 0 is for backtrack
		V.push_back(vector<int>(NUMC+1));
		num.push_back(0);
		P.push_back(0);
		I.push_back(-1);
		D.push_back(0);
		sort(S.begin(),S.end());
		ITR(it,S) {
			int cur=0;
			ITR(c,(*it)) {
				if(V[cur][*c+1]==0) {
					V.push_back(vector<int>(NUMC+1));
					V[cur][*c+1]=V.size()-1;
					num.push_back(0);
					P.push_back(cur);
					I.push_back(-1);
					D.push_back(D[cur]+1);
				}
				cur=V[cur][*c+1];
			}
		}
	}
	
	void compress(int cur,int pre) {
		int i,to=0,tar;
		FOR(i,NUMC) if(V[cur][i+1]) to++,tar=V[cur][i+1];
		
		if(to==1 && I[cur]==-1 && cur) {
			V[P[cur]][pre] = tar;
			P[tar]=P[cur];
			compress(tar,pre);
		}
		else {
			FOR(i,NUMC) if(V[cur][i+1]) compress(V[cur][i+1],i+1);
		}
		
	}
	void dfs(int cur) {
		int i;
		FOR(i,NUMC) if(V[cur][i+1]) dfs(V[cur][i+1]), num[cur] += num[V[cur][i+1]];
		
	}
	
	int query(int tar,int cur) {
		int ret=0,i;
		if(I[cur]==tar) return 1;
		char c=S[tar][D[cur]];
		FOR(i,NUMC) if(V[cur][i+1]) {
			if(O[i]<O[c]) ret += num[V[cur][i+1]];
			if(O[i]==O[c]) ret += query(tar,V[cur][i+1]);
		}
		return ret+(I[cur]>=0);
	}
	
};

Trie T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>s;
		FORR(c,s) c-='a';
		S.push_back(s);
	}
	
	T.create(S);
	FOR(i,N) T.I[T.find(S[i])]=i, T.num[T.find(S[i])]++;
	T.compress(0,-1);
	T.dfs(0);
	
	cin>>Q;
	while(Q--) {
		cin>>x>>s;
		FOR(i,26) O[s[i]-'a']=i;
		cout<<T.query(x-1,0)<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
ll modinv(ll a) {ll b=MOD,u=1,v=0;
    while(b){ll t=a/b;a-=t*b;swap(a,b);u-=t*v;swap(u,v);}
    u%=MOD;if(u<0)u+=MOD;return u;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  bool judge = true;
  ll h,w,a,b;cin>>h>>w>>a>>b;
  ll x[w],y[w];
  x[0]=1;y[0]=1;
  for(i=1;i<w;i++){
    x[i]=(x[i-1]*(h-a+i-1))%MOD;
    qmod(x[i],modinv(i));
    y[i]=(y[i-1]*(a+i-1))%MOD;
    qmod(y[i],modinv(i));
  }
  for(i=b;i<=w-1;i++){
    pmod(res,(x[i]*y[w-1-i])%MOD);
    //cout<<res<<endl;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1920
import Data.List
import Data.Int
import Data.Ratio

main = do
  [n,k] <- map read.words<$>getLine
  a     <- map read.words<$>getLine
  print $ solve (Mod k) a

solve :: ModInt -> [Int] -> ModInt
solve k a = (k * (k-1)/2) * largers + inversion * k where
  count f xs = Mod $ length $ filter f xs
  inversion = snd $ foldl f ([],Mod 0) a
  f (xs,acc) e = (e:xs,acc + count (>e) xs)
  largers = go a' (Mod 0) (Mod 0)
  go (x:y:xs) n m
    | x == y = m + go (y:xs) (n+1) m
    | otherwise = m + go (y:xs) (n+1) (n+1)
  go (_:_) n m = m
  a' = sortBy (flip compare) a


modulo = 10^9+7

newtype ModInt = Mod Int deriving (Eq)

instance Show ModInt where
  show (Mod a) = show a
instance Bounded ModInt where
  maxBound = Mod $ modulo - 1
  minBound = 0
-- Caution! If (value>=modulo), this does not work.
instance Enum ModInt where
  toEnum a = Mod $ mod a modulo
  fromEnum (Mod a) = a
instance Num ModInt where
  (Mod a) + (Mod b) = Mod $ mod (a+b) modulo
  (Mod a) * (Mod b) = Mod $ mod (a*b) modulo
  abs = id
  signum = const 1
  fromInteger a = Mod $ fromIntegral $ mod a $ fromIntegral modulo
  negate 0 = 0
  negate (Mod a) = Mod $ modulo - a
instance Fractional ModInt where
  recip a = a ^ (modulo-2)
  fromRational r = Mod (n * signum d) / Mod (abs d) where
    [n,d] = [fromIntegral] <*> ( [numerator,denominator] <*> [r] )


Measured memory_bytes: 2044
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

// define
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(i,n) FOR(i,0,n)
#define MIN_V(v) *min_element(v.begin(), v.end())
#define MAX_V(v) *max_element(v.begin(), v.end())

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned long long ULL;

// conversion
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
inline int countChar(string s, char c) {int cnt,i; cnt=0; REP (i,s.size()) {if (s[i]==c) cnt++;} return cnt;}
template<class T> inline string toString(T x) {ostringstream sout; sout<<x; return sout.str();}
//===========================================================================//

//=function prototype========================================================//

//===========================================================================//

//=variables=================================================================//

//===========================================================================//
int main(void)
{
  // Scan begin.
  int n, m;
  cin >> n >> m;
  VI broken(n+1);
  REP(i,m) {
    int idx;
    cin >> idx;
    broken[idx] = 1;
  }
  // Scan done.

  // Code begin.
  const LL mod = 1000000007;
  vector<LL> dp(n + 2);
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
  }
  cout << dp[0] << endl;
  // Code done.

  return 0;
}

//=functions=================================================================//

//===========================================================================//

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

int main()
{
	int n, w;
	while (cin >> n >> w && n != 0 || w != 0)
	{
		int bar[11];
		for (int i = 0; i < 11; i++)
		{
			bar[i] = 0;
		}
		int barNum = 0;
		int maxHeight = 0;
		for (int i = 0; i < n; i++)
		{
			int vn;
			cin >> vn;
			bar[vn / w]++;
			maxHeight = max(maxHeight, bar[vn/w]);
			barNum = max(barNum,vn / w);
		}

		double ans = 0.0;
		for (int i = 0; i <= barNum; i++)
		{
			ans += (double)(bar[i] * (barNum - i)) / (double)(maxHeight * barNum);
		}
		ans += 0.01;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int i,c;
  c=0;
  
  for (i=1 ; i<=N ; i++){
    int a,b;
    cin >> a >> b;
    c += (b-a+1);
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,H,W;
pair<int,pair<int,int> >A[1<<17];
#include<vector>
struct UF{
	int n;
	vector<int>parent;
	vector<pair<int,int> >rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,make_pair(1,0))
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a)
	{
		return parent[a]!=a?parent[a]=find(parent[a]):a;
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a].first<rank[b].first)
		{
			parent[a]=b;
			rank[b].first+=rank[a].first;
			rank[b].second+=rank[a].second;
		}
		else
		{
			parent[b]=a;
			rank[a].first+=rank[b].first;
			rank[a].second+=rank[b].second;
		}
		return true;
	}
};
main()
{
	cin>>N>>H>>W;
	for(int i=0;i<N;i++)
	{
		cin>>A[i].second.first>>A[i].second.second>>A[i].first;
	}
	sort(A,A+N);
	reverse(A,A+N);
	UF uf(H+W);
	long ans=0;
	for(int i=0;i<N;i++)
	{
		int x=A[i].second.first,y=A[i].second.second;
		x=uf.find(x-1),y=uf.find(H+y-1);
		if(x==y)
		{
			if(uf.rank[x].first>=uf.rank[x].second+1)
			{
				ans+=A[i].first;
				uf.rank[x].second++;
			}
		}
		else
		{
			if(uf.rank[x].first+uf.rank[y].first>=uf.rank[x].second+uf.rank[y].second+1)
			{
				ans+=A[i].first;
				uf.unite(x,y);
				uf.rank[uf.find(x)].second++;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3712
#include <stdio.h>

int main (){
  int N,i,j,k,v;
  int A[100];

  scanf("%d",&N);

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

  for (i=1; i<=N-1 ;i++){

    for(k=0;k<N-1;k++){
      printf("%d ",A[k]);
  }
  printf("%d\n",A[k]);

  v = A[i];
  j = i - 1;

  while (j >= 0 && A[j]>v){
    A[j+1] = A[j];
    j--;
    A[j+1] = v;
  }
}

for(k=0;k<N-1;k++){
  printf("%d ",A[k]);
 }
printf("%d\n",A[k]);
 
return 0;
}




Measured memory_bytes: 2064
#include <stdio.h>
int main()
{
    int N, M;
    int A[102];
    int C = 0, D = 0;
    scanf("%d%d", &N, &M);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
        (C = C + A[i]);
    }
    for (int i = 0; i < N; i++)
    {
        if (A[i] * 4 * M >= C)
        {
            D++;
        }
    }
    if (D >= M)

        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 1664
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($y = 0; $y < $H; $y++){
    fscanf(STDIN, "%s", $str);
    $map[$y] = $str;
    for($x = 0; $x < $W; $x++){
        if($map[$y][$x] == "#"){
            $list[] = [$y,$x];
        }
    }
}
$count = 0;
while($list){
    $nextList = [];
    foreach($list as list($y, $x)){
        if($x){
            if($map[$y][$x-1] == "."){
                $map[$y][$x-1] = "#";
                $nextList[] = [$y, $x-1];
            }
        }
        if($y){
            if($map[$y-1][$x] == "."){
                $map[$y-1][$x] = "#";
                $nextList[] = [$y-1, $x];
            }
        }
        if($x < $W-1){
            if($map[$y][$x+1] == "."){
                $map[$y][$x+1] = "#";
                $nextList[] = [$y, $x+1];
            }
        }
        if($y < $H-1){
            if($map[$y+1][$x] == "."){
                $map[$y+1][$x] = "#";
                $nextList[] = [$y+1, $x];
            }
        }
    }
    $list = $nextList;
    if($list)$count++;
}
echo $count;


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

import sys
from bisect import bisect_right

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

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

N = INT()
A = LIST()
A.sort()

# m番目の大きさのやつが、最後の1匹になれるか
def calc(m):
    if m == -1:
        return False
    a = A[m]
    a += sum(A[:m])
    # 自分の2倍まではいける
    idx = bisect_right(A, a*2)
    a += sum(A[m+1:idx])
    # 全て取り込んだ後で、その先に行ければ行く
    for i in range(idx, N):
        b = A[i]
        if a*2 >= b:
            a += b
        else:
            return False
    # 最後まで行けるなら、最後の1匹になれる
    return True

print(N-bisearch_min(-1, N-1, calc))


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

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    int a;
    cin >> a;
    cout << (ll)pow(a,3) << endl;
    return 0;
}


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

int main() {
    string c1, c2;
    cin >> c1 >> c2;
    if (c1.at(0) == c2.at(2) && c1.at(1) == c2.at(1) && c1.at(2) == c2.at(0))
        cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

int n;vector<int> v[110000];int c[110000],ans[110000];pair<int,int> dig[110000];
int cind,ansM;

void f(int ver){
  //cout << "ver : " << ver << endl;
  vector<int> next;
  for(int nver : v[ver]){
    if(ans[nver] != -1)continue;
  //cout << "nver : " << nver << " " << cind << endl;
    next.push_back(nver);
    ans[nver] = c[cind];
    ansM += c[cind];
    cind++;
  }
  for(int nver : next){
    f(nver);
  }
}
int h,w;bool m[2100][2100];int tate[2100][2100], yoko[2100][2100];
signed main(){
  cin>>h>>w;
  rep(i,h){
    string s;cin>>s;
    rep(j,w)m[j][i] = (s[j] == '.');
  }
  rep(i,h+1)m[w][i] = false;
  rep(i,w+1)m[i][h] = false;
  rep(i,h+1){
    int cnt = 0;
    rep(j,w+1){
      if(m[j][i]){
        cnt++;
      }else{
        yoko[j][i] = 0;
        repd(k,j-cnt,j){
          yoko[k][i] = cnt;
        }
        cnt = 0;
      }
    }
  }
  rep(i,w+1){
    int cnt = 0;
    rep(j,h+1){
      if(m[i][j]){
        cnt++;
      }else{
        tate[i][j] = 0;
        repd(k,j-cnt,j){
          tate[i][k] = cnt;
        }
        cnt = 0;
      }
    }
  }
  int ans = 0;
  rep(i,h){
    rep(j,w){
      if(!m[j][i])continue;
      ans = max(ans, yoko[j][i] + tate[j][i] - 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 77440
#include<stdio.h>
#include<iostream>
using namespace std;
char s[52][52],p[52][52];
int h,w;
void check(int x,int y) {
	if(s[x][y]=='#'){
		p[x][y]='#';
		return ;
	}
	int count=0;
	if(s[x-1][y]=='#'){
		count++;
	}
	if(s[x+1][y]=='#'){
		count++;
	}
	if(s[x][y-1]=='#'){
		count++;
	}
	if(s[x][y+1]=='#'){
		count++;
	}
	if(s[x+1][y-1]=='#'){
		count++;
	}
	if(s[x+1][y+1]=='#'){
		count++;
	}
	if(s[x-1][y-1]=='#'){
		count++;
	}
	if(s[x-1][y+1]=='#'){
		count++;
	}
	p[x][y]=count+'0';
//	printf("---%d %d %d\n",x,y,p[x][y]);
}
int main() {
	scanf("%d%d\n",&h,&w);
	for(int i=0; i<h; i++) {
		cin>>s[i];
	}
	for(int i=0; i<h; i++) {
		for(int j=0; j<w; j++) {
			check(i,j);
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%c",p[i][j]);
		}
		printf("\n");
	}
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  string s;cn(s)
  int ans = 0;
  rpi(i,s.size()/2){
    if ( s[i] != s[s.size()-1-i] )++ans;
  }
  co(ans)
}

Measured memory_bytes: 256
N,K=map(int,input().split())
def C(a,b):
    ret=1
    for i in range(0,b):
        ret*=a-i
    for i in range(0,b):
        ret=ret//(i+1)
    return ret
if K>N-K+1:
    for i in range(1, N-K+2):
        print((C(N-K+1,i)*C(K-1,i-1))%(10**9+7))
    for i in range(N-K+2, K+1):
        print(0)
else:
    for i in range(1, K+1):
        print((C(N-K+1,i)*C(K-1,i-1))%(10**9+7))

Measured memory_bytes: 3316
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
int read()
{
	int res=0,ch,flag=0;
	if((ch=getchar())=='-')             //判断正负
		flag=1;
	else if(ch>='0'&&ch<='9')           //得到完整的数
		res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')
		res=res*10+ch-'0';
	return flag?-res:res;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=1e6+10;
#define int long long
int primes[N];
signed main()
{
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j+=i)
			sum+=j;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define all_acc(x) (x).begin(),(x).end(),0LL
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

int accumulate(int* a,int n){
    return accumulate(a,a+n,0LL);
}

int accumulate(vector<int> a){
    return accumulate(a.begin(),a.end(),0LL);
}

vector<pair<int,int>> soinsuu(int n){
    vector<pair<int,int>> ret;
    for(int i=2;i*i<=n;i++){
        if(n%i !=0) continue;
        int ex=0;
        while(n%i ==0){
            ex++;
            n /= i; //n変更することで、それ以降の約数で割り切れることはない
        }
        ret.push_back(make_pair(i,ex));
    }
    //nが素数だった場合
    if(n!=1) ret.push_back(make_pair(n,1));
    return ret;
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

signed main(){ 
    int n;
    cin>>n;

    vector<int> f(n+1,0);
    for(int i=1;i<=n;i++){
        int a=i;
        while(a<=n){
            f[a] = f[a]+1;
            a+=i;
        }
    }

    int result=0;

    for(int i=1;i<=n;i++){
        result+=i*f[i];
    }

    cout<<result<<endl;
}  

Measured memory_bytes: 81420
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	n := readi()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readi()
	}

	ans := 0
	for {
		s, ok := start(a)
		if !ok {
			break
		}
		for i := s; i < n; i++ {
			if a[i] == 0 {
				break
			} else {
				a[i] = a[i] - 1
			}
		}
		ans++
	}

	fmt.Println(ans)
}

func start(slice []int) (int, bool) {
	for i, v := range slice {
		if v != 0 {
			return i, true
		}
	}
	return 0, false
}

func equal(a, b []int) bool {
	if len(a) != len(b) {
		return false
	}
	for i, v := range a {
		if v != b[i] {
			return false
		}
	}
	return true
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

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

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X;
  cin>>X;
  int N=X/500;
  int M=(X-N*500)/5;
  cout<<N*1000+M*5<<endl;
}


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

using namespace std;

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

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++) {
			if (i * 4 + j * 7 == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#pragma endregion

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    REP(i, n) cin >> p[i];
    sort(ALL(p));
    int ans = 0;
    REP(i, k){
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
def main():
    dict_str = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
    C = input()
    res_idx = dict_str.index(C)
    print(dict_str[res_idx+1])


if __name__ == "__main__":
    main()

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

int keta(int n) {
    int res;
    for(int i = 0; i < 100; i++) {
        n = n / 10;

        if(n == 0) {
            res = i + 1;
            break;
        }
    }
    return res;
}

int main() {
    int k, a, b;
    bool p = 0;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++) {
        if(i % k == 0) {
            p = 1;
            break;
        }
    }
    if(p)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
struct SegTree {
    int N;
    vector<int> A;
    SegTree(int n) {
        N = 1;
        while (N < n) N *= 2;
        A.resize(2 * N);
    }
    void set(int idx, int val) {
        idx += N;
        A[idx] = val;
        idx >>= 1;
        while (idx > 0) {
            A[idx] = max(A[2*idx+0], A[2*idx+1]);
            idx >>= 1;
        }
    }
    int rangemax(int L, int R) {
        L += N, R += N;
        int ans = INT_MIN;
        while (L < R) {
            if (L & 1) ans = max(ans, A[L++]);
            if (R & 1) ans = max(ans, A[--R]);
            L >>= 1, R >>= 1;
        }
        return ans;
    }
};
int main() {
    int N, K; cin >> N >> K;
    vector<int> A(N); for (auto &a : A) cin >> a;
    SegTree st(300010);
    vector<int> dp(N);
    for (int i = 0; i < N; i++) {
        int val = st.rangemax(max(0, A[i] - K), min(300001, A[i] + K + 1));
        dp[i] = val + 1;
        st.set(A[i], dp[i]);
    }
    cout << *max_element(begin(dp), end(dp)) << '\n';
    return 0;
}


Measured memory_bytes: 9772
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll k; cin>>k;
	ll a; cin>>a;
	ll b; cin>>b;
	FOR(i,a,b+1){
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}

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

def prime_division(n):
    tn = n
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n //= i
        if cnt != 0:
            res.append([i, cnt])
    if n != 1:
        res.append([n, 1])
    return res

d = {}
for i in range(2, n + 1):
    t = prime_division(i)
    for j in t:
        if j[0] in d:
            d[j[0]] += j[1]
        else:
            d[j[0]] = j[1]

num = 1
for i in d.values():
    num *= i + 1

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


Measured memory_bytes: 3064
#include<bits/stdc++.h>
    #define _USE_MATH_DEFINES
    using namespace std;
        
    #define ll long long int
    #define pb push_back
    #define rep(i , j , n) for(ll i = j ; i < n ; i++)
    #define per(i , j , n) for(ll i = j ; i >= n ; i--)
    #define all(x) x.begin(), x.end()
    typedef pair<int, int>	pii;
    typedef pair<ll, ll>	pl;
    typedef vector<int>		vi;
    typedef vector<ll>		vll;
    typedef vector<bool>	vb;
    ll mod = 1e9 + 7;



    int main(){  
        ll n;
        cin >> n;
        vll v(n + 1,1), isp(n + 1,1);
        rep(i,2,n + 1){
            if(isp[i] == 0) continue;

            v[i] = 2;
            for(ll j = 2*i; j <= n; j += i){
                isp[j] = 0;
                ll k = j;
                ll co = 0;
                while(k % i == 0){
                    k = k/i;
                    co++;
                }
                v[j] *= (co + 1);
            }
        }
        ll ans = 0;
        rep(i,1,n + 1){
            ans += i*v[i];
        }
        cout << ans;

    }

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

int main() {
  long long N; cin >> N;
  int sisu;
  int ans=0;
  for (int i = 2; i <= sqrt(N); i++) {
    sisu = 0;
    while (N % i == 0) {
      N /= i;
      sisu += 1;
    }
    int jou=-1;
    rep(k,42){
      jou += (k+1);
      if(sisu>jou){
        ans+=1;
      }
    }
    if (N == 1){
      break;
    } 
  }
  if (N != 1) ans+=1;

  cout<<ans<<endl;
}

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

int main() {
        int T;
        int s;

        while(1) {
                cin >> T;
                if (T == 0) break;
                rep(i, 9) {
                        cin >> s;
                        T -= s;
                }
                cout << T << endl;
        }
        return 0;
}



Measured memory_bytes: 2992
import numpy as np
N, M, X = map(int, input().split())

C = []
A = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    c = tmp[0]
    a = tmp[1:]
    C.append(c)
    A.append(a)
A = np.array(A)

ans = 10**18
for bit in range(1 << N):
    cost = 0
    V = np.array([0] * M)
    for i in range(N):
        if bit & 1 << i:
            cost += C[i]
            V += A[i]
    if np.all(V >= X):
        ans = min(ans, cost)
if ans == 10**18:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 27128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

#include<cstring>
struct edge { int to, cap, rev; };
vector<edge> G[100000];
bool used[100000];
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, (int)G[to].size() });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < (int)G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, mod);
		if (f == 0)return flow;
		flow += f;
	}
}

int n, m;
int a[500];
int main() {
	cin >> n >> m;
	string u; cin >> u;
	int s = n, t = n+1;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (u[i] == 'L') {
			add_edge(i, t, a[i]);
		}
		else {
			add_edge(s, i, a[i]);
		}
	}
	rep(i, m) {
		int x, y, b; cin >> x >> y >> b; x--; y--;
		if (x < y) {
			add_edge(x, y, b);
		}
		else {
			add_edge(y, x, b);
		}
	}
	int f = max_flow(s,t);
	cout << f << endl;
	//stop
	return 0;
}


Measured memory_bytes: 5704