akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    int ans_max = min(A, B);
    int ans_min = 0;
    if (A + B <= N) {
        ans_min = 0;
    } else {
        ans_min = max(A, B) - (N - min(A, B));
    }
    cout << ans_max << " " << ans_min << endl;
    return (0^_^0);
}



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

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> cash(n);
    vector<vector<int>> book(n, vector<int>(m, 0));
    for(int i = 0; i < n; i++){
        cin >> cash[i];
        for(int j = 0; j < m; j++){
            cin >> book[i][j];
        }
    }
    int ans = pow(10, 9);
    for(int i = 0; i < pow(2, n); i++){
        int kane = 0, shift = 0;
        vector<int> check(m, 0);
        while(shift < n){
            if(i & (1 << shift)){
                kane += cash[shift];
                for(int j = 0; j < m; j++){
                    check[j] += book[shift][j];
                }
            }
            shift++;
        }
        sort(check.begin(), check.end());
        if(check[0] >= x) ans = min(kane, ans);
    }
    if(ans < pow(10, 9)) cout << ans << endl;
    else cout << -1 << endl; 
}

Measured memory_bytes: 4088
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cctype>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define VI vector<int>
#define VII vector<int,int>
#define MSI map<string,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define W1 while(1);
const int MOD = 1000000007;
int main()
{
	string A;
	string B;
	int n;
	cin >> A;
	cin >> B;
	n = A.length();
	if (n>B.length())
	{
		cout << "GREATER" << endl;
		return 0;
	}
	else if (n<B.length())
	{
		cout << "LESS" << endl;
		return 0;
	}
	else
	{
		REP(i, n)
		{
			if (A[i]>B[i])
			{
				cout << "GREATER" << endl;
				return 0;
			}
			else if (A[i]<B[i])
			{
				cout << "LESS" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  long long ans = 0;
  int cnt = 0;
  long long mn = 2000000000;
  for(int i = 0; i < n; ++i){
    long long k;
    cin >> k;
    if(k < 0) cnt++;
    k = abs(k);
    mn = min(mn, k);
    ans += k;
  }
  
  if(cnt % 2) ans -= mn * 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
n , m = (int(a) for a in input().split())
ans = [0]*n
ng = [0]*n
NG = 0
for i in range(m) :
    p,s = input().split()
    p = int(p)
    if s == "AC" :
        if ans[p-1] == 0 :
            NG += ng[p-1]
            ans[p-1] = 1
    else :
        if ans[p-1] == 0 :
            ng[p-1] += 1
 
print(ans.count(1) , NG)

Measured memory_bytes: 10340
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	
	int n;
	cin>>n;
	if(n >= 30){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	

	return 0;
}

Measured memory_bytes: 3552
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

ll mod_combi(ll n, ll m){
    ll tmp = mod_mul(fac[n],invfac[n-m]);
    return mod_mul(tmp,invfac[m]);
}


int main(void){

  int n,k;
  cin>>n>>k;

  make_fact(2001);
  make_invfact(2001);

  rep1(i,k){
    
    if(i-1<=n-k){

      cout << mod_combi(n-k+1,i)*mod_combi(k-1,i-1)%mod << endl;
    }
    else{
      cout << 0 << endl;
    }

  }

  return 0;

}


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

int main(void){
    int n,m;
    cin >> n >> m;
    
    vector<vector<int>> a(m);
    for(int i = 0;i < m;i++){
          int k;
          cin >> k;
          a[i].resize(k);
          for(int j= 0;j < k;j++){
                cin >> a[i][j];
                a[i][j]--;
          }
    }
    vector<int> p(m);
    for(int i = 0;i < m;i++){
          cin >> p[i];
    }
    int ans = 0;
    for(int i = 0;i < 1 << n;i++){
          bool ok = true;
          
          for(int j = 0;j < m;j++){
                int c = 0;
                for(int k:a[j]){
                      if((i >> k) & 1)c++;
                }
                if(c % 2 != p[j]) ok = false;
          }
          if(ok)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String[] pass = s.split("");
        boolean isGood = true;
        for (int i = 0; i < pass.length - 1 && isGood; i++) {
            if (pass[i].equals(pass[i + 1])) {
                isGood = false;
            }
        }

        System.out.println(isGood ? "Good" : "Bad");
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  ll res = 0;
  bool flag = true;
  for(int i = 1; i < N; ++i){
    if(A[i] == A[i-1]){
      flag = !flag;
    }
    if(A[i] != A[i-1]){
      if(flag) res++;
      flag = true;
    }
  }
  if(flag) res++;
  cout << res << endl;
}


Measured memory_bytes: 1024
N, T = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))

cost = 0
min_ = A[0]
dist = 0
#print(min_)
#print('dist = ', dist)
#print('cost = ', cost)
for i in range(1, N):
    if min_ > A[i]:
        min_ = A[i]
    dist_tmp = A[i] - min_
    if dist == dist_tmp:
        cost += 1
    elif dist < dist_tmp:
        cost = 1
        dist = dist_tmp
    #print(min_)
    #print('dist = ', dist)
    #print('cost = ', cost)
print(cost)

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

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

Proc Q[100001];

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

void Queue::push(Proc d){
  if(isFull()) return;
  Q[rp] = d;
  rp = next(rp);
}

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

  return Q[fp];
}

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

int main(){
  Queue que;

  int n, q;
  cin >> n >> q;

  for(int i=0; i<n; i++){
    Proc p;
    cin >> p.nam >> p.tim;

    que.push(p);
  }

  int total_tim = 0;

  while(!que.isEmpty()){
    Proc p = que.front();
    que.pop();

    if(p.tim<=q){
      total_tim += p.tim;

      cout << p.nam << ' ' << total_tim << endl;
    }
    else{
      total_tim += q;
      p.tim -= q;

      que.push(p);
    }
  }
  return 0;
}



Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<int> vec(n);
  for(auto &e: vec)cin>>e;
  sort(vec.begin(), vec.end());
  cout<<vec[n/2]-vec[n/2-1]<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int e[4];
    rep(i, 4)scanf("%d", e+i);
    sort(e, e + 4);
    bool is = (e[0] == e[1]) && (e[2] == e[3]);
    puts(is ? "yes" : "no");

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3208
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x,r,d,v,c;
    scanf("%d %d %d",&x,&r,&d);
    for(c=0;c<10;c++){
     v=(x*d)-r;
     printf("%d \n",v);
     d=v;
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  if(S[0]=='R' && S[1]=='R' && S[2]=='R') cout<<3<<endl;
  else if(S[0]=='S' &&S[1]=='S' && S[2]=='S') cout<<0<<endl;
  else if(S[1]=='S') cout<<1<<endl;
  else if(S[0]=='R' || S[2]=='R') cout<<2<<endl;
  else cout<<1<<endl;
}



Measured memory_bytes: 3624
/* Coached by Dukkha */
#include <stdio.h>

#define N 100000

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	static int aa[N], pp[N], qq[N];
	int n, i, d, ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	d = 0;
	for (i = 0; i < n; i++)
		pp[i] = d = gcd(d, aa[i]);
	d = 0;
	for (i = n - 1; i >= 0; i--)
		qq[i] = d = gcd(d, aa[i]);
	ans = 0;
	for (i = 0; i < n; i++) {
		d = gcd(i == 0 ? 0 : pp[i - 1], i == n - 1 ? 0 : qq[i + 1]);
		if (ans < d)
			ans = d;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
#include <cstdio>
using namespace std;
const int INF=1000000000;
int a[100000],b[100000],c[100000],N;
long long A[100000]={};
int main(){
	cin>>N;
	for(int i=0;i<N;++i)cin>>a[i];
	for(int i=0;i<N;++i)cin>>b[i];
	for(int i=0;i<N;++i)cin>>c[i];
	sort(a,a+N);
	sort(b,b+N);
	sort(c,c+N);
	long long t=N-1,ans=0;
	for(int i=N-1;i>=0;--i){
		while(1){
			if(b[i]>a[t]){
				A[i]=t+1;break;
			}else{
				if(t==0)break;
				--t;
			}

		}
//		cout<<A[i]<<" ";
	}
//	cout<<endl;
	t=0;
	for(int i=0;i<N;++i){
		while(1){
			if(b[i]<c[t]){
				ans+=A[i]*(N-t);
				break;
			}else{
				if(t==N-1)break;
				++t;
			}

		}
	}

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


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int R = 0;
  for(int i=0; i<N; i++){
    if(S[i] == 'R'){
      R++;
    }
  }
  int ans = 0;
  for(int i=0; i<R; i++){
    if(S[i] != 'R'){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3724
//#pragma  GCC optimize("Ofast")

//#ifdef  DEBUG
//#define _GLIBCXX_DEBUG
//#endif

// -Ofast
// -O3
// -O2
// -fsanitize=address
// -fsanitize=undefined

// add_compile_options()

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <unordered_map>
#include <cmath>
#include <cassert>
#include <random>
using namespace std;
//using namesparsace __gnu_pbds;

mt19937 rnd;

int solve();

int main()
{
    srand(time(0));
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

int max(int a, int b) {
    return a > b ? a : b;
}

const int maxN = 2e5 + 10;

int n, mx;
map < string, int > ma;
vector < string > a;

int solve() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ma[s]++;
        mx = max(mx, ma[s]);
    }
    for (auto it = ma.begin(); it != ma.end(); it++) {
        if (it->second == mx) {
            a.push_back(it->first);
        }
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < a.size(); i++) {
        cout << a[i] << '\n';
    }
}

Measured memory_bytes: 25584
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
ll n,q,m,k,l,ans;
string s;
vll a,b;
map<ll, vll> bits;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    
    cin >> n;
    map<int,int> cnt_buka;
    rep(i,n-1) {
        int x;
        cin >> x;
        cnt_buka[x]++;
    }
    vi buka(n);
    for(auto e:cnt_buka){
        buka[e.first-1] = e.second; 
    }
    rep(i,n) {
        if(i!=0) cout << " ";
        cout << buka[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 13444
#!/usr/bin/env python3

import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

good = 10
total = 0

if a%10 < good and a%10 != 0:
    good = a % 10

if b % 10 < good and b%10 != 0:
    good = b % 10

if c % 10 < good and c%10 != 0:
    good = c % 10

if d % 10 < good and d%10 != 0:
    good = d % 10

if e % 10 < good and e%10 != 0:
    good = e % 10

total += math.ceil(a / 10) * 10
total += math.ceil(b / 10) * 10
total += math.ceil(c / 10) * 10
total += math.ceil(d / 10) * 10
total += math.ceil(e / 10) * 10

total -= 10 - good

print(total)


Measured memory_bytes: 3064
#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 pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

double dp[3001][3001],p[3001];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>p[i];
    dp[0][0]=1;
    rep(i,n)rep(j,i+1){
        dp[i+1][j+1]+=dp[i][j]*p[i];
        dp[i+1][j]+=dp[i][j]*(1.0-p[i]);
    }
    double ans=0;
    FOR(i,(n+1)/2,n+1) ans+=dp[n][i];
    cout<<setprecision(10)<<fixed<<ans<<endl;
    return 0;
}


Measured memory_bytes: 68992
import java.util.Scanner;
public class Main {

  public static boolean find(String w, String t, int i) {
    int j = 0;
    while (j < w.length()) {
      if (i >= t.length())
        return false;
      if (w.charAt(j) != t.charAt(i))
        return false;
      i++;
      j++;
    }
    return true;
  }

  public static void count(String w, String t) {
    // t = t.toLowerCase();
    int i = 0;
    boolean found = false;
    while (i < t.length()) {
      if (t.charAt(i) == w.charAt(0)) {
        found = find(w, t, i);
        if (find(w, t, i))
          System.out.println(i);
      }
      i++;
    }
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String text = s.nextLine();
    String w = s.next();
    s.close();
    count(w, text);
  }

}



Measured memory_bytes: 26336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll m = 1e9 + 7;
bool is_pr(ll n)
{
    if(n==1)
        return false;
    for(int i=2;i*i<=n;i++)
        if(n%i==0)
        return false;
    return true;
}
int main()
{
   ll x;
   cin>>x;
   while(1)
   {
       if(is_pr(x))
        break;
       x++;
   }
   cout<<x<<"\n";
}


Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        a: f64,
        b: f64,
        p: f64,
        q: f64,
        r: f64,
    }
    let d = p * b - q * (b - a);
    let ans = b + d / (q + r);
    println!("{:.4}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 5080
#include<stdio.h>
#include<string.h>
void one_digit(char [],int);
void one_digit(char x[],int n){
    int s=0,i,str;
    for(i=0;i<n;i++){
        str=x[i]-'0';
        s+=str;
    }
    printf("%d\n",s);
    return;
}
int main(void){
    char num[1001];
    while(1){
        num[0]='\0';
        scanf("%s",num);
        if(num[0]!='0'){
            one_digit(num,strlen(num));
        }
        else{
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a, b;
		String op = "";

		while(true) {
			a = scan.nextInt();
			op = scan.next();
			b = scan.nextInt();

			switch(op) {
			case "+":
				System.out.println(a+b);
				break;
			case "-":
				System.out.println(a-b);
				break;
			case "*":
				System.out.println(a*b);
				break;
			case "/":
				System.out.println(a/b);
				break;
			case "?":
				scan.close();
				System.exit(0);

			}

		}

	}

}


Measured memory_bytes: 26348
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

string S;

int main() {
	cin >> S;
	int A = 0, B = 0;
	for (int i = 0; i < S.size(); ++i) {
		A += ((S[i] - '0') ^ (i % 2));
		B += ((S[i] - '0') ^ ((i+1) % 2));
	}
	cout << min(A, B) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(){
  int len,i,result=0;
  char input[200001],sabun[200001];
  
  scanf("%s",input);
  scanf("%s",sabun);
  len=strlen(input);
  
  for(i=0;i<len;i++){
    if(input[i]!=sabun[i]){
      result++;
    }
  }
  printf("%d",result);
  
}

Measured memory_bytes: 2128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] arr = new long[n+2];
		arr[0] = 0;
		arr[n+1] = 0;
		long cost = 0L;
		for(int i = 1; i <= n; i++) {
			arr[i] = sc.nextInt();
			cost += Math.abs(arr[i-1] - arr[i]);
		}
		cost += Math.abs(arr[n]);
		for(int i = 1; i <= n; i++) {
			long moto = Math.abs(arr[i-1]-arr[i])+Math.abs(arr[i]-arr[i+1]);
			long now = Math.abs(arr[i-1] - arr[i+1]);
			long a = cost - moto + now;
			System.out.println(a);
		}
	}
}

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

int main() {
  string s; cin >> s;
  vector<char> alpha(26);
  for(int i=0;i<26;i++){
    alpha.at(i) = 'a' + i;
  }
  vector<int> cnt(26,0);
  for(int i = 0; i <s.size();i++){
    for(int j = 0; j < 26;j++){
      if(s.at(i) == alpha.at(j)){
        cnt.at(j)++;
      }
    }
  }
  bool ans = true;
  for(int i = 0; i < 26;i++){
    if(cnt.at(i)>1) ans = false;
  }
  if(ans) cout << "yes" << endl;
  else cout << "no" << endl;
}


Measured memory_bytes: 3608
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, S := ReadInt(), ReadString()
	s := make([]int, N+1)
	for i := 0; i < N; i++ {
		s[i+1] = s[i]
		if S[i] == '.' {
			s[i+1]++
		}
	}

	ans := 1 << 60
	for l := 0; l <= N; l++ {
		v := l - s[l] + s[N] - s[l]
		ans = Min(ans, v)
	}
	fmt.Println(ans)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int H, W;
string s[50];

int main(){
    cin >> H >> W;
    rep(i, H) cin >> s[i];
    rep(x, H) {
        rep(y, W) {
            if (s[x][y] == '.') continue;
            bool adjacent = false;
            rep(dir, 4) {
                int nx = x + dx[dir];
                int ny = y + dy[dir];

                if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
                if (s[nx][ny] == '#') {
                    adjacent = true;
                    break;
                }
            }
            if (!adjacent) {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
const int mod = 1e9 + 7;
ll fact[1000006], inv[1000006];
ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    if (exp % 2 == 0)
        return (ans * ans) % mod;
    else
        return (((ans * ans)% mod) * base)% mod;
}
void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}
int main()
{
    Hello
    calcFacAndInv(1e5 + 5);
    int n, k;
    ll ans = 0;
    cin >> n >> k;
    int arr[n + 5];
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);
    for(int i = 0; i < n - k + 1; i++)
    {
        ll val = (((arr[i] + mod) % mod) * ncr(n - i - 1, k - 1)) % mod;
        ans = (ans + mod - val) % mod;
    }
    for(int i = k - 1; i < n; i++)
    {
        ll val = (((arr[i] + mod) % mod) * ncr(i, k - 1)) % mod;
        ans = (ans + val) % mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=1LL<<31-1=2147483647
constexpr ll INF = (ll)1e18;//1LL<<63-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/



signed main(){
	ll N,K;
	cin>>N>>K;
	vector<pair<ll,ll>> a(N);
	rep(i,N){
		cin>>a[i].first>>a[i].second;
	}

	ll minval=(1LL<<62)-1;
	rep(i,N)rep(j,N)rep(k,N)rep(l,N){
		ll x1=a[i].first;
		ll y1=a[j].second;
		ll x2=a[k].first;
		ll y2=a[l].second;
		ll t=0;
		rep(m,N){
			if(x1<=a[m].first && y1<=a[m].second && a[m].first<=x2 && a[m].second<=y2)t++;
		}
		if(t>=K)chmin(minval,(x2-x1)*(y2-y1));
	}
	p(minval);

	return 0;
}



Measured memory_bytes: 384
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)

def check(A, B, C, D):
    if A < B:
        return False
    if C < A % B:
        return False
    if D < B:
        return False
    x = gcd(B, D)
    return B <= C + x

def main():
    T = int(input())
    for _ in range(T):
        A, B, C, D = map(int, input().split())
        if check(A, B, C, D):
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 44012
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,x,y;
	cin>>n;
	long long a[n+1];
	cin>>x;
	long long sum=x/2;
	x%=2;
	for(int i=2;i<=n;i++)
	{
		cin>>y;
		if(y==0)
		{
			x=y;
			continue;
		}
		if(x>0) sum++,y--,x--;
		sum+=y/2;
		x=y%2;
	}
	cout<<sum<<endl;
	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int i;
	for (i = 1; i < 4; i++) {
		if ((a * b * i) % 2 == 1) {
			cout << "Yes";
			break;
		}
	}
	if ((a * b * i) % 2 == 0) {
		cout << "No";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

void solve()
{
	double x1, y1, x2, y2, x3, y3;
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &x3, &y3))
	{
		if(fabs(y2 - y1) < 1e-5)
		{
			printf("%.6f %.6f\n", x3, 2 * y1 -y3);
		}
		else if(fabs(x2 - x1) < 1e-5)
		{
			printf("%.6f %.6f\n", 2 * x1 - x3, y3);
		}
		else
		{
			double b1 = y1 - ((y2 - y1) / (x2 - x1)) * x1;
			double b2 = y3 + ((x2 - x1) / (y2 - y1)) * x3;
			double x_inter = (b2 - b1) / ((y2 - y1) / (x2 - x1) + (x2 - x1) / (y2 - y1));
			double y_inter = ((y2 - y1) / (x2 - x1)) * x_inter + b1;
			printf("%.6f %.6f\n", x_inter + x_inter - x3, y_inter + y_inter - y3);
		}
	}
}

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

Measured memory_bytes: 1236
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
int main() {
	int N;
	ll ans = 0;
	scanf("%d", &N);
	vector<int> A(N), B(N), C(N);
	vector<ll> D(N + 1, 0);
	rep(i, 0, N)scanf("%d", &A[i]);
	rep(i, 0, N)scanf("%d", &B[i]);
	rep(i, 0, N)scanf("%d", &C[i]);
	sort(all(A));
	sort(all(B));
	sort(all(C));
	for (auto i = B.begin(); i < B.end(); i++) {
		auto it2 = upper_bound(all(C), *i);
		D[i - B.begin()] = (ll)(C.end() - it2);
	}
	for (int i = N - 1; i != 0; i--)D[i - 1] += D[i];
	rep(i, 0, N) {
		auto it = upper_bound(all(B), A[i]);
		ans += (ll)D[it - B.begin()];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2176
s = list(input())
t = list(input())
n = len(s)
sl = [0] * n
tl = [0] * n
sd = {}
td = {}
for i in range(n):
    c = s[i]
    if c not in sd:
        sd[c] = i
        sl[i] = i
    else:
        sl[i] = sd[c]
for i in range(n):
    c = t[i]
    if c not in td:
        td[c] = i
        tl[i] = i
    else:
        tl[i] = td[c]
if sl == tl:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9648
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static int N;
    static int[] V, C;

    public static void Main(string[] args)
    {
        N = Input.NextInt();
        V= Input.LineInt();
        C = Input.LineInt();

        var D = new int[N];
        for (int i = 0; i < N; i++)
        {
            D[i] = V[i] - C[i];
        }

        var ans = D.Where(n => n > 0).Sum();

        Console.WriteLine(ans);
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
int flag=0;
while(a>0 && c>0){
    if(flag){
        a-=d;
        flag=0;
    }else{
    c-=b;
    flag=1;
    }
}
if(a<=0){
    cout<<"No";
}else{
cout<<"Yes";}

}


Measured memory_bytes: 3636
from collections import Counter
def sieve_eratosthenes(n):
    primes = [0, 1] * (n // 2 + 1)                  # 素数候補の配列。　0: 素数でない 1:素数である　　偶数は素数ではないので、初めから0としている。
    if n % 2 == 0:                                  # 上記の配列が 0 ~ n+1 になってるので一個除く、ただし n が奇数の場合は n+1 は自動的に除かれてるので放置
        primes.pop()
    primes[1] = 0                                   # 1 は素数ではない
    primes[2] = 1                                   # 2 は偶数だけど素数
    for p in range(3, int(n**0.5) + 2, 2):
        if primes[p]:
            for q in range(p * p, n + 1, 2 * p):    # p(p + 2k) k = 1,... と書ける物を素数候補から省く。　2k としているのは、奇数＋奇数の場合を考える必要はないため
                primes[q] = 0
    return primes

N = int(input())
M = 10**4
prime = sieve_eratosthenes(M)
P = []
for i in range(M):
    if prime[i]:
        if i%5==1:
            P.append(i)
print(*P[:N])




Measured memory_bytes: 68008
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n;
double ans=0.0,x;
string u;
cin >> n;
REP(i,n) {
  cin >> x >> u;
  if(u=="JPY") {
    ans+=x;
  } else {
    ans+=x*380000;
  }
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

d = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(d)]
# T = [int(input()) for i in range(d)]
c = 26
# m = int(input())
# Q = [list(map(int,input().split())) for i in range(m)]

ans = 0
L = [[-1] * c for i in range(d)]
T = [-1] * d  # この中には0-25を入れる

for i in range(d):
    ANS = [0] * c
    L[i] = L[i-1][:]
    for k in range(c):
        ANS[k] = S[i][k] + C[k] * (i - L[i][k])
    ind = ANS.index(max(ANS))
    ans += S[i][ind]
    L[i][ind] = i
    for j in range(c):
        ans -= C[j] * (i - L[i][j])
    # print(ans)
    # print(ind + 1)
    T[i] = ind


# print("fans",ans)
# print(L)
# print(T)

K = [[] for i in range(d)]

cp = 5
dp = 5

CC = [[C[i], i] for i in range(c)]
CC.sort(reverse=True)
for i in range(d):
    for k in range(cp):
        K[i].append(CC[k][1])

for i in range(d):
    DD = [[S[i][j], j] for j in range(c)]
    DD.sort(reverse=True)
    for k in range(dp):
        K[i].append(DD[k][1])

# print("K",K)
    
from random import randint

m = 5*10**5

Q = [[0] * 2 for i in range(m)]
for i in range(m):
    dd = randint(0, d-1)
    # print("dd",dd)
    # print(dd-1,randint(0, len(K[dd-1])-1))
    q = K[dd][randint(0, len(K[dd])-1)]
    Q[i][0] = dd
    Q[i][1] = q

# print(Q)

for i in range(m):
    # print(*T)
    # print(Q)
    dd = Q[i][0]
    q = Q[i][1]
    nans = ans
    # print("dd",dd)
    nans -= S[dd][T[dd]]
    nans += S[dd][q]
    for j in range(dd, d):
        # print("j",j)
        if T[j] == q:
            # print("break")
            break
        nans += C[q] * (j - L[j][q])
        nans -= C[q] * (j - dd)
        L[j][q] = dd
    
    old = T[dd]
    T[dd] = q

    for j in range(dd, d):
        # print("j",j)
        if T[j] == old:
            # print("break")
            break
        oldl = L[j-1][old] if j > 0 else -1
        nans += C[old] * (j - dd)
        nans -= C[old] * (j - oldl)
        L[j][old] = oldl

    # print(nans, ans)

    if nans < ans:
        if i != m-1:
            Q[i+1] = [dd, old]
        else:
            T[dd] = old
    
    ans = nans

# print(max(ans,nans))
for i in T:
    print(i+1)


Measured memory_bytes: 151336
#include<cstdio>
#include<algorithm>
#define ll long long
int n;
ll a[25];
ll dfs(int l,int r,ll vl,ll vr)
{
	if(l>r)return 0;
	ll ans=1e18;
	for(int x=l;x<=r;x++)
		ans=std::min(ans,a[x]*(vl+vr)+dfs(l,x-1,vl,vl+vr)+dfs(x+1,r,vl+vr,vr));
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	printf("%lld\n",dfs(2,n-1,1,1)+a[1]+a[n]);
	return 0;
}

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

namespace C
{
    class Program
    {
        const int INF = int.MaxValue;
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var N = int.Parse(input[0]);
            var M = int.Parse(input[1]);
            var X = int.Parse(input[2]);

            var A = new List<int[]>();
            for (int i = 0; i < N; i++)
            {
                A.Add(Console.ReadLine().Split(' ').Select(int.Parse).ToArray<int>());
            }

            int ans = INF;
            for (int bit = 0; bit < (1 << N); bit++) //2^N回繰り返す
            {
                var cost = 0;
                var D = new int[M];  //M個のアルゴリズムステータスを格納する。
                for (int i = 0; i < N; i++)
                {
                    if ((bit >> i & 1)==1)
                    {
                        cost += A[i][0];
                        for (int j = 0; j < M; j++)
                        {
                            D[j] += A[i][j+1];
                        }
                    }
                }
                bool ok = true;
                for (int j = 0; j < M; j++)
                {
                    if (D[j] < X)  //X以上でないアルゴリズムステータスが一つでもあったらok=falseとなる
                    {
                        ok = false;
                    }
                }
                if (ok)
                {
                    ans = Math.Min(ans, cost);
                }
            }

            if (ans == INF)
            {
                Console.WriteLine("-1");
            }
            else
            {
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 19268
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    # 100,100のグリッド作る
    grid = [["."]*100 for _ in range(50)]+ [["#"]*100 for _ in range(50)]
    A-=1
    B-=1

    # .を＃に置き換えていく
    for i in range(50):
        for j in range(100):
            if i%2 == 0 and j%2 == 0 and B > 0:
                grid[i][j] = "#"
                B-=1
    
    for i in range(51,100):
        for j in range(100):
            if i%2 == 0 and j%2 == 0 and A>0:
                grid[i][j] = "."
                A-=1
    
    print(100, 100)
    for i in range(100):
        print(''.join(grid[i]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

#define pb push_back

typedef long long ll;
const ll inf = 2e9+7;
const int MAX_N = 5e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[MAX_N],fac[MAX_N];

template <class T = int> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%inf;}a=a*a%inf;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<MAX_N;i++){fac[i]=fac[i-1]*i%inf;}for(int i=0;i<MAX_N;i++){inv[i]=POW(fac[i],inf-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%inf)*inv[n-r]%inf;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

class UnionFind {
private:
	int par[MAX_N];
	int rank[MAX_N];
public:
	void init(int n);
	int find(int x);
	void unite(int x,int y);
	bool same(int x,int y);
};

void UnionFind::init(int n) {
	for (int i = 0;i < n;i++) {
		par[i] = i;
		rank[i] = 0;
	}
}

int UnionFind::find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void UnionFind::unite(int x,int y) {
	x = find(x);
	y = find(y);
	if (rank[x] < rank[y]) par[x] = y;
	else {
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
}

bool UnionFind::same(int x,int y) {
	x = find(x);
	y = find(y);
	return x == y;
}
UnionFind d,t;

typedef pair<pair<int,int>,int> pa;

int main() {
	int n=in(),k=in(),l=in();
	d.init(n);t.init(n);
	for (int i = 0;i < k;i++) {
		int x=in(),y=in();
		d.unite(x-1,y-1);
	}
	for (int i = 0;i < l;i++) {
		int x=in(),y=in();
		t.unite(x-1,y-1);
	}
	int ans[n];
	vector<pa> dtpar;
	for (int i = 0;i < n;i++) {
		ans[i] = 0;
		dtpar.pb({make_pair(d.find(i),t.find(i)),(int)i});
	}
	sort(dtpar.begin(),dtpar.end());
	int spos=0,epos=0,score=1;
	for (int i = 1;i < dtpar.size();i++) {
		// cout << dtpar[i].first.first << " " << dtpar[i].first.second << endl;
		if (dtpar[i-1].first==dtpar[i].first) {epos=i;score++;}
		else {
			for(int j = spos;j <= epos;j++) {
				ans[dtpar[j].second]+=score;
			}
			score=1;spos=i;epos=i;
		}
	}
	for(int j = spos;j <= epos;j++) {
		ans[dtpar[j].second]+=score;
	}
	for (int i = 0;i < n;i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 12276
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

int conv(string s){
	return atoi(s.substr(0, 2).c_str()) * 60 + atoi(s.substr(3).c_str());
}

int main(){
	int n, t;
	cin >> n >> t;
	vector<pair<string, int> > ans;
	string pre;
	for(int i=0;i<n;i++){
		string a, b, c, d;
		cin >> a >> b >> c >> d;
		if(i){
			int tmp = conv(a) - conv(pre);
			if(tmp >= t) ans.push_back(make_pair(b, tmp));
		}
		pre = c;
	}
	cout << ans.size() << endl;
	for(int i=0;i<ans.size();i++) cout << ans[i].first << ' ' << ans[i].second << endl;
	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int a, b, q;
ll s[maxx], t[maxx], dd;

int main() {
	scanf("%d %d %d", &a, &b, &q);
	for(int i = 1; i <= a; i++) scanf("%lld", &s[i]);
	for(int i = 1; i <= b; i++) scanf("%lld", &t[i]);
	s[0] = s[1], t[0] = t[1];
	s[a + 1] = s[a], t[b + 1] = t[b];
	while(q--) {
		scanf("%lld", &dd);

		int cnt1 = upper_bound(s + 1, s + a + 1, dd) - s;
		cnt1 = a - cnt1 + 1; //s中有cnt1个比dd大的

		int cnt2 = upper_bound(t + 1, t + b + 1, dd) - t;
		cnt2 = b - cnt2 + 1; //t中有cnt2个比dd大的

		ll res = 0;
		ll ans1 = abs(dd - s[a - cnt1]);
		ll ans2 = abs(dd - s[a - cnt1 + 1]);
		ll res1 = abs(s[a - cnt1] - t[b - cnt2]);
		ll res2 = abs(s[a - cnt1 + 1] - t[b - cnt2]);
		res = min(ans1 + res1, ans2 + res2);

		ans1 = abs(dd - s[a - cnt1]);
		ans2 = abs(dd - s[a - cnt1 + 1]);
		res1 = abs(s[a - cnt1] - t[b - cnt2 + 1]);
		res2 = abs(s[a - cnt1 + 1] - t[b - cnt2 + 1]);
		ll tmp1 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp1);

		ans1 = abs(dd - t[b - cnt2]);
		ans2 = abs(dd - t[b - cnt2 + 1]);
		res1 = abs(t[b - cnt2] - s[a - cnt1]);
		res2 = abs(t[b - cnt2 + 1] - s[a - cnt1]);
		ll tmp2 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp2);

		ans1 = abs(dd - t[b - cnt2]);
		ans2 = abs(dd - t[b - cnt2 + 1]);
		res1 = abs(t[b - cnt2] - s[a - cnt1 + 1]);
		res2 = abs(t[b - cnt2 + 1] - s[a - cnt1 + 1]);
		ll tmp3 = min(ans1 + res1, ans2 + res2);

		res = min(res, tmp3);
		cout << res << endl;
	}
}

Measured memory_bytes: 2816
/*


*/
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
int main(){

   // freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
    string s,t;
    cin>>s>>t;

    int ans = 0;
    forn(i,3){
    	if(s[i] == t[i])ans++;
    }

    cout<<ans;

    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
#include<iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(n,x) for(ll i=0;i<n;i++) cin>>x[i];


int main()
{
	double n, k;
	cin >> n >> k;
	vector<double> p(n);
	for (ll i = 0; i < n; i++)cin >> p[i];
	ll sum, max;
	max = -1;
	vector<double> s(n+1);
	s[0] = 0;
	for (ll i = 0; i < n + 1 ; i++)
	{
		s[i + 1] = s[i] + p[i];
	}
	for (ll i = 0; i < n - k +1; i++)
	{
		sum = s[i + k] - s[i];
		if (max < sum)
		{
			max = sum;
		}
	}

	double ans;
	ans = (max + k) / 2;
	cout <<fixed<<setprecision(10)<< ans << "\n";

	return 0;
}

Measured memory_bytes: 6404
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,a[maxn],f;

int main()
{
	n=read(); f=0;
	rep(i,1,n)
	{
		a[i]=read();
		if(a[i]==0) f=1;
	}
	if(f) return puts("0"),0;
	ll tmp=1e18,nw=1;
	for(int i=1;i<=n;i++)
	{
		ll p=tmp/a[i];
		if(p>=nw) nw=nw*a[i];
		else return puts("-1"),0;
		if(nw>1e18) return puts("-1"),0;
	}
	cout<<nw<<endl;
	return 0;
}

Measured memory_bytes: 4416