akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int D,G,S,C,m=1000;
  cin>>D>>G;
  G/=100;
  vector<int>p(D),c(D);
  for(int i=0;i<D;i++){
    cin>>p.at(i)>>c.at(i);
    c.at(i)/=100;
  }
  for(int i=0;i<(1<<10);i++){
    bitset<10>s(i);
    S=0,C=0;
    for(int j=0;j<D;j++){
      if(s.test(j))S+=(j+1)*p.at(j)+c.at(j),C+=p.at(j);
      if(S>=G)m=min(C,m);
      else{
        int k;
        for(k=D-1;k>=0;k--)if(!s.test(k))break;
        if(k>=0&&(k+1)*(p.at(k)-1)>=G-S)m=min(C+(G-S+k)/(k+1),m);
      }
    }
  }
  cout<<m<<endl;
}

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

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

  sort(a, a + N);
  reverse(a, a + N);

  int Asum = 0;
  int Bsum = 0;

  for (int i = 0; i < N; i += 2){
      Asum += a[i];
  }
  for (int i = 1; i < N; i += 2){
      Bsum += a[i];
  }

  cout << Asum - Bsum << endl;

}




Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public void kami() {
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		
		while(H != 0 || W != 0){
			while(0 < H){
				for(int i = 1; i <= W; i++){
					System.out.print("#");
				}
				System.out.println();
				H--;
			}
			System.out.println();
			H = sc.nextInt();
			W = sc.nextInt();
		}
		
	}

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

}

Measured memory_bytes: 26688
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    for(int i=0; i<n/4+1; i++)
    for(int j=0; j<n/7+1; j++){
        if(n==4*i+7*j){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
        
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

int main(){
    string s ;
    cin >> s ;
    if (s.at(2)== s.at(3) && s.at(4)== s.at(5))
    {
        cout << "Yes" << endl ;
    }else
    {
        cout << "No" << endl ;
    }
    
    
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(input[i]);
        }

        int q = Integer.parseInt(br.readLine());
        input = br.readLine().split(" ");
        int target;

        StringBuilder sb = new StringBuilder("");
        for (int i = 0; i < q; i++) {
            target = Integer.parseInt(input[i]);

            sb.append(solve(a, target, 0) ? "yes" : "no").append("\n");
        }

        System.out.print(sb.toString());
    }

    public static boolean solve(int[] arr, int target, int start) {
        if (target == 0) return true;
        else if (start == arr.length) return false;
        else return solve(arr, target, start + 1) || solve(arr, target - arr[start], start + 1);
    }
}

Measured memory_bytes: 24776
h,w = gets.split.map(&:to_i)
hw = h * w
n = gets.to_i
as = gets.split.map(&:to_i)

grid = Array.new(h)

cs = as.map.with_index(1) {|a,i| [i] * a }.flatten

cs.each_slice(w).each_with_index do |ar, i|
  if i.odd?
    ar.reverse!
  end
  grid[i] = ar
end

grid.each {|row| puts row.join(' ')}

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cerr << x << endl
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 998244353;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<P> a(K);
    rep(i,K) cin >> a[i].first >> a[i].second;
    vector<ll> dp(N+1);
    dp[1] = 1, dp[2] = -1;
    for(int i=1; i<N; i++)
    {
        rep(j,K)
        {
            int nl = i+a[j].first, nr = i+a[j].second+1;
            if(nl <= N) dp[nl] = (dp[nl] + dp[i]) % MOD;
            if(nr <= N) dp[nr] = (MOD + dp[nr] - dp[i]) % MOD;
        }
        dp[i+1] += dp[i];
        dp[i+1] %= MOD;
    }
    // debug(dp);
    cout << dp[N] << endl;
}


Measured memory_bytes: 4784
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<iterator>

#define rep(i, n) for(int i=0; i<n; i++)

typedef long long ll;

using namespace std;

#define NMIN 3
#define NMAX 2000
#define LMAX 1000

int N;
vector<int> L;

void solve(void){
	sort(L.begin(), L.end(), greater<int>() );
	
	ll count = 0;
	for(int k=0; k<N; k++){
		for(int j=k+1; j<N; j++){
			const int i = j+1;
			
			if( L[k] < L[j] + L[i] ){
				//vector<int>::iterator it = 
				auto it = 
				lower_bound( 
					L.begin() + i, 
					L.end(), 
					L[k] - L[j], 
					greater<int>()
				);
				
				count += distance(L.begin()+i, it);
			}
		}
	}
	
	cout << count << endl;
	
	return;
}


int main(void){
	cin >> N;
	
	L.resize(N);
	
	rep(i, N){
		cin >> L[i];
	}
	
	solve();
	
	return 0;
}


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

using namespace std;

int N, A, B;
void show(int a, int b)
{
  for (int i = 1; i <= N; i++) {
    if (i == a) cout << 'A';
    else if (i == b) cout << 'B';
    else cout << ' ';
  }
  cout << endl;
}

int main()
{
  cin >> N >> A >> B;

  while (1) {
    if (A + 1 == B) {
      cout << "Borys" << endl;
      break;
    } else {
      A++;
    }
    if (B - 1 == A) {
      cout << "Alice" << endl;
      break;
    } else {
      B--;
    }
  }
  return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> hidari(M);
    vector<int> migi(M);
    int m=-1;
    int Ma=1000000;

    for(int i=0; i<M; i++){
        cin >> hidari[i];
        m = max(m, hidari[i]);
        cin >> migi[i];
        Ma = min(Ma, migi[i]);
    }

    if(Ma<m){
        cout << 0 << endl;
    }
    else{
        cout << Ma-m+1 << endl;
    }
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

void Main() {
  ll A, B, C;
  cin >> A >> B >> C;

  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
    puts("0");
    return;
  }

  ll ma = max(A, max(B, C));
  ll mi = min(A, min(B, C));
  ll mu = A + B + C - ma - mi;

  ll ans = mi * mu;

  cout << ans << endl;
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int a[100010],cnt[100010],sum,n,q,b,c;
int main(){
	cin>>n;
	long long int i,j,k;
	for(i=1;i<=n;i++){
		cin>>a[i];
		cnt[a[i]]++;
		sum+=a[i];
	}
	cin>>q;
	while(q--){
		cin>>b>>c;
		cnt[c]+=cnt[b];
		sum=sum+cnt[b]*(c-b);
		cnt[b]=0;
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 5196
#include"stdio.h"
int main()
{
	char X,Y,Z;
	char a[12]={'A','B','C','D','E','F'};
	int b[6]={10,11,12,13,14,15},t,j,i;
	scanf("%c%c%c",&X,&Z,&Y);
   for(i=0;i<6;i++)
   {
	   if(a[i]==X)t=i;
	   if(a[i]==Y)j=i;
   }
if(t==j)
printf("=",b[t],b[j]);
if(t<j)
printf("<",b[t],b[j]);
if(t>j)
printf(">",b[t],b[j]);
}

Measured memory_bytes: 128
#include<stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;


int main(int argc, char const *argv[])
{
	int a1,b,c,k;
    cin>>a1>>b>>c;
    cin>>k;
    int acum=0;
    for(int i=1;i<=k;i++){
    	int maxi=max(a1,max(b,c));
	    if(maxi==a1){a1=2*a1;acum=a1+b+c;		}
	    else if (maxi==b){b=b*2;acum=a1+b+c;}
	    else {c=c*2;acum=a1+b+c;}
	}
    cout<<acum;
   return 0;
}

Measured memory_bytes: 256
N=int(input())
L=[]
for i in range(N):
    L.append(input())
C=[]
W=['AC', 'WA', 'TLE', 'RE' ]
Q=[0,0,0,0]
for i in range(N):
    for j in range(4):
        if L[i]==W[j]:
            Q[j]=Q[j]+1
            break
print('AC x '+str(Q[0]))
print('WA x '+str(Q[1]))
print('TLE x '+str(Q[2]))
print('RE x '+str(Q[3]))

Measured memory_bytes: 16148
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int n, k, cnt = 0, pp, h, l;
	string s, s1, s2;
	vector<int>list;
	int sum = 0, maxn = -9999;


	for (int i = 0; i < 5; i++) {
		int num;
		cin >> num;
		list.push_back(num);
		//((num/10)-1)
		if (num%10!=0 && maxn < 10 - (num % 10)) {
			maxn = 10 - (num % 10);
			k = i;
		}
	}

	for (int i = 0; i < 5; i++) {
		if (k == i)continue;
		if (list[i] % 10 == 0) {
			sum += list[i];
		}
		else {
			sum += list[i] + (10 - (list[i] % 10));
		}

	}

	sum += list[k];

	cout << sum << endl;





	
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
G = [[]for i in range(N)]
for i in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
ans = 0
H = [[0]]
while H:
    h = H.pop()
    if len(h)==N:
        ans+=1
        continue
    p = h[-1]
    for v in G[p]:
        if not(v in h):
            H.append(h+[v])
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 30;
vector<long long int> baum;
long long int n, ans, minma = INF;
long long int Baum = 0, Baum3 = 0;

void cut(long long int f) {
	long long int s = f + Baum3, t = s + Baum3;
	long long int p;
	long long int sp[3] = {}, tp[3] = {};
	p = lower_bound(baum.begin(), baum.end(), s) - baum.begin();
	if (s == baum[p]) {
		sp[0] = baum[p + 1];
		sp[1] = baum[p - 1];
		sp[2] = baum[p];
	}
	else {
		sp[0] = baum[p];
		sp[1] = baum[p - 1];
		sp[2] = INF;
	}
	p = lower_bound(baum.begin(), baum.end(), t) - baum.begin();
	if (t == baum[p]) {
		tp[0] = baum[p + 1];
		tp[1] = baum[p - 1];
		tp[2] = baum[p];
	}
	else {
		tp[0] = baum[p];
		tp[1] = baum[p - 1];
		tp[2] = INF;
	}
	for (int i = 0; i <= 2; i++) {
		if (sp[i] == INF) break;
		minma = sp[i] - f;
		for (int j = 0; j <= 2;j ++){
			if (tp[j] == INF) break;
			minma = min( minma, min( tp[j] - sp[i], Baum - tp[j] + f ));
			ans = max(ans, minma);
			minma = sp[i]-f;
		}
	}
}

int main() {
	cin >> n;
	baum.push_back(0);
	for (int i = 0; i < n; i++) {
		int in;
		scanf("%d", &in);
		Baum += in;
		baum.push_back(in);
	}
	baum.push_back(baum[1]);
	Baum3 = Baum / 3;

	for (int i = 2; i <= n+1; i++) {
		baum[i] += baum[i - 1];
	}
	for (int i = 0; i < n + 1; i++) {
		if (baum[i] > Baum3) break;
		cut(baum[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2120
while True:
    h = int(input())
    if h == 0:
        break
    dataset = [h] + [int(input()) for _ in range(4)]
    if len(set(dataset)) == 3 or len(set(dataset)) == 1:
        print(*[3]*5, sep="\n")
        continue
    
    for data in dataset:
        if data == 1:
            print(2 if 3 in dataset else 1)
        elif data == 2:
            print(2 if 1 in dataset else 1)
        else:
            print(2 if 2 in dataset else 1)

Measured memory_bytes: 7728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl
int gcd(int x, int y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}
int main() {
    IN(int, n);
    IN(int, l);
    int ans = (n-1)*n/2+l*n;
    if (l>0) {
        ans -= l;
    }else if(n-1+l<0){
        ans -= n-1+l;
    }
    COUT(ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int x = scanner.nextInt();
        int p = x;
        while (!isPrime(p)) {
            ++p;
        }
        System.out.println(p);

    }

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

}


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

using namespace std;

const int N = 2505;
const int INF = 1e9;
vector<pair<int,int>> g[N];
vector<int> rg[N];
int n,m,dis[N],reachable[N];

void dfs(int x){
	reachable[x] = true;
	int l = rg[x].size();
	for(int i=0;i<l;i++){
		int v = rg[x][i];
		if(reachable[v]) continue;
		dfs(v);
	}
}

bool bellman_ford(){
	for(int i=2;i<=n;i++){
		dis[i] = -INF;
	}
	
	for(int k=0;k<=n;k++){
		bool updated = false;
		for(int i=1;i<=n;i++){
			int l = g[i].size();
			if(!reachable[i]||dis[i]==-INF) continue;
			for(int j=0;j<l;j++){
				int v = g[i][j].first;
				if(!reachable[v]) continue;
				int c = g[i][j].second;
				if(dis[v]<dis[i]+c){
					updated = true;
					dis[v] = dis[i]+c;
				}
			}
		}
		if(!updated) return true;
	}
	return false;
}

int32_t main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int p;
	cin>>n>>m>>p;
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		g[a].emplace_back(b,c-p);
		rg[b].push_back(a);
	}

	dfs(n);
	
	if(bellman_ford()) cout<<max(0,dis[n])<<endl;
	else cout<<-1<<endl;
	return 0;
}


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

const int maxn = 2e5+5, inf = 1e9+7;
int n, a[maxn], ans[maxn], lis[maxn];
vector<int> vs[maxn], seq;
vector<pair<int,int>> changes;


void dfs(int v, int p = -1){
	seq.emplace_back(a[v]);
	auto it = lower_bound(lis, lis+maxn, a[v]);
	changes.push_back({int(it-lis), *it});
	*it = min(*it, a[v]);
	ans[v] = lower_bound(lis, lis+maxn, inf)-1-lis;
	for(int e: vs[v]) if (e != p) dfs(e, v);
	seq.pop_back();
	pair<int,int> aux = changes.back();
	changes.pop_back();
	lis[aux.first] = aux.second;
}

int main(){
	scanf("%d", &n);
	fill(lis+1, lis+maxn, inf);
	lis[0] = 0;
	for(int i = 0; i<n; i++) scanf("%d", &a[i]);
	for(int i = 0; i<n-1; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		vs[--x].emplace_back(--y);
		vs[y].emplace_back(x);
	}
	dfs(0);
	for(int i = 0; i<n; i++) printf("%d\n", ans[i]);

	return 0;
}

Measured memory_bytes: 36044
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string s[1000] = {""};
	int m[1000] = {0};
	int h[1000][1000] = {0};
	int i = 0;
	int j = 0;
	while(1){
		cin >> s[i];
		if(s[i] == "-") break;
		cin >> m[i];
		for (int k = 0; k < m[i]; ++k)
		{
			cin >> h[i][k];
		}
		i++;
	}
	i = 0;
	while(1){
		if(s[i] == "-") break;
		for (int k = 0; k < m[i]; ++k)
		{
			for (int l = 0; l < h[i][k]; ++l)
			{
				s[i] += s[i][0];
				s[i].erase(0,1);
			}
		}
		cout << s[i] << endl;
		i++;
	}
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int h, a;
    cin >> h >> a;
    int ans;
    ans = h / a;
    if (h % a != 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    
    adj=[[]for _ in range(N)]
    
    
    for i in range(N):
        S=list(input())
        for j in range(N):
            if S[j]=="1":
                adj[i].append(j)
            
    import queue
    
    ans=0
    
    
    def bfs(x):
        q=queue.Queue()
        q.put((x,1))
        V=[-1]*N
        V[x]=1
        flag=0
        while not q.empty():
            v,d=q.get()
            for nv in adj[v]:
                if V[nv]==-1:
                    V[nv]=d+1
                    q.put((nv,d+1))
                if abs(V[nv]-V[v])!=1:
                    flag=1
                    break
                
        if flag:
            return -1
        return max(V)
    
    ans=0
    for i in range(N):
        temp=bfs(i)
        if temp==-1:
            ans=-1
            break
        ans=max(ans,temp)
    print(ans)
    
                    

        
        

main()


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

 int main()
 {
	int k;
 string s;

 cin >> k;
 cin >> s;

 if (s.size() > k) {
 s = s.substr(0, k) + "...";
 }

 cout << s << '\n';

 return 0;
 }


Measured memory_bytes: 3584
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());//int型
		String sline = sc.next();
		sc.close();
		String[] s =new String[n];
		for (int i=0; i<n; i++){
			s[i] = String.valueOf(sline.charAt(i));
		}
		ArrayList<Integer> divind = new ArrayList<Integer>();
		
		for(int i=0; i<n-1; i++) {
			if (s[i].equals(".")&&s[i+1].equals("#")) { 
				divind.add(i);
			}
		}
		int cnt = 0;
		int[] sharps = new int[n]; // #の累積和
		int[] dots = new int[n];
		for (int i=0; i<n; i++){
			if (s[i].equals("#")) {
				cnt++;
			} 
			sharps[i] = cnt;
		}
		int ans = 10000000;
		int tmp = 10000000;
		
		cnt = 0;
		for (int i=n-1; i>-1; i--){
			if (s[i].equals(".")) {
				cnt++;
			} 
			dots[i] = cnt;
		}
		/*
		for (int i=0; i<n; i++){
			System.out.print(sharps[i]);
		}
		System.out.print("\n");
		for (int i=0; i<n; i++){
			System.out.print(dots[i]);
		}
		System.out.print("\n");
		*/
		for (int i=0; i<n-1; i++) {
			// System.out.println(in);
			tmp = sharps[i]+dots[i+1];
			ans = Math.min(tmp, ans);
		}
		ans = Math.min(ans, dots[0]);
		ans = Math.min(ans, sharps[n-1]);

		System.out.println(ans);
	}

}


Measured memory_bytes: 53516
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vl A(N);
  rep(i,N) {
    cin >> A[i];
  }
  ll ans = LINF;
  {
    ll res = 0;
    ll acc = 0;
    rep(i,N) {
      acc += A[i];
      if(i&1) {
        if(acc>=0) {
          res += 1+acc;
          acc = -1;
        }
      } else {
        if(acc<=0) {
          res += 1-acc;
          acc = 1;
        }
      }
    }
    chmin(ans,res);
  }
  {
    ll res = 0;
    ll acc = 0;
    rep(i,N) {
      acc += A[i];
      if(i&1) {
        if(acc<=0) {
          res += 1-acc;
          acc = 1;
        }
      } else {
        if(acc>=0) {
          res += 1+acc;
          acc = -1;
        }
      }
    }
    chmin(ans,res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
const int MAXN = 1e5 + 5;

int n;
long long ans;
long long dp[MAXN][5];
struct node{
	int a, b, c;
}node[MAXN];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		node[i].a = a;
		node[i].b = b;
		node[i].c = c;
	}
	dp[1][1] = node[1].a;
	dp[1][2] = node[1].b;
	dp[1][3] = node[1].c;
	for(int i = 2; i <= n; i++){
		dp[i][1] = max(dp[i-1][2]+node[i].a, dp[i-1][3]+node[i].a);
		dp[i][2] = max(dp[i-1][1]+node[i].b, dp[i-1][3]+node[i].b);
		dp[i][3] = max(dp[i-1][2]+node[i].c, dp[i-1][1]+node[i].c);

	}
	ans = dp[n][1];
	for(int i = 2; i <= 3; i++){
		ans = max(ans, dp[n][i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5376
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int a;
    String s;
    std::cin >> a >> s;
    std::cout << (a >= 3200 ? s : "red") << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
#include<string>
#include<math.h>
#include<vector>
#include <iostream>
#include <algorithm>

using namespace std;
const int INF=1e9+5;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin>>N;
    vector<int>dp(3);
    for(int day=0;day<N;day++){
        vector<int>new_dp(3,0);
        vector<int>c(3);
        for(int i=0;i<3;i++)
            cin>>c[i];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(i!=j){
                    new_dp[j]=max(new_dp[j],dp[i]+c[j]);
                }
            }
        }
        dp=new_dp;
    }
    cout<<max(max(dp[0],dp[1]),dp[2]);
    return 0;
}


Measured memory_bytes: 256
package main

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

type pair struct {
	l, r int
}

func main() {
	n, q := getInt(), getInt()
	s := []rune(getString())
	ps := make([]pair, q)
	for i := range ps {
		ps[i].l = getInt() - 1
		ps[i].r = getInt() - 1
	}

	cSum := make([]int, n+1)
	for i := 0; i < n-1; i++ {
		cSum[i+1] = cSum[i]
		if (s[i] == 'A') && (s[i+1] == 'C') {
			cSum[i+1]++
		}
	}

	for _, p := range ps {
		res := cSum[p.r] - cSum[p.l]
		fmt.Println(res)
	}
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := 200001
	sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 5632
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int N, M, X;

vector<int> c;
vector<vector<int>> a;
long long minkane(vector<int> v, int k) {
    if(k == N) {
        long long ret = 0LL;
        vector<int> rikai(M);
        rep(i, 0, N) {
            if(v[i] == 1) {
                ret += c[i];
                rep(j, 0, M) { rikai[j] += a[i][j]; }
            }
        }
        bool ok = true;
        rep(i, 0, M) {
            if(X > rikai[i])
                ok = false;
        }
        if(ok) {
            return ret;
        } else {
            return INF;
        }
    } else {
        vector<int> r1 = v;
        vector<int> r2 = v;
        r1.push_back(1);
        r2.push_back(0);
        return min(minkane(r1, k + 1), minkane(r2, k + 1));
    }
}
int main() {
    cin >> N >> M >> X;
    a.assign(N, vector<int>(M));
    c.assign(N, 0);
    rep(i, 0, N) {
        cin >> c[i];
        rep(j, 0, M) { cin >> a[i][j]; }
    }
    vector<int> v;
    long long res = minkane(v, 0);
    if(res == INF) {
        cout << -1 << endl;
    } else {
        cout << res << endl;
    }
}


Measured memory_bytes: 3640
import itertools
e, o = map(int, input().split())
new = []
for x in range(1, e+1):
    new.append(2*x)
for x in range(1, o*2):
    if x%2==1:
        new.append(x)
counter = 0
for x in itertools.combinations(new, 2):
    if int(x[0]+x[1]) %2 == 0:
        counter +=1
print(counter)

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

int main(){
  ll n;
  cin >> n;
  vector<ll>a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  reverse(a.begin(),a.end());
  ll b=2,e=2;
  ll remain1,remain2;
  for(int i=0; i<n; i++){
    remain1=(b-1)/a[i];
    remain2=e/a[i];
    if(a[i]*(remain1+1)>e){
      cout << -1 << endl;
      return 0;
    }
    b=a[i]*(remain1+1);
    e=a[i]*(remain2+1)-1;
    //cout << b << " " << e << endl;
    //cout << remain << endl;
  }
  cout << b << " " << e << endl;
}
  
  

  
  
  


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

int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1 != m2)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
using namespace std;
priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>>Q;
long long dist[200000], a[200000], n, L, maxn;
bool G(int t) { if (a[t] > a[t - 1] && a[t] > a[t + 1])return true; return false; }
int main() {
	cin >> n >> L; for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = 1; i <= n; i++) {
		if (G(i) == true) { Q.push(make_pair(L - a[i], i)); dist[i] = L - a[i]; }
	}
	while (!Q.empty()) {
		long long a1 = Q.top().first, a2 = Q.top().second; Q.pop(); a[a2] = 0; maxn = a1;
		if (a2 >= 2 && G(a2 - 1) == true) { dist[a2 - 1] = a1 + (L - a[a2 - 1]); Q.push(make_pair(dist[a2 - 1], a2 - 1)); }
		if (a2 <= n - 1 && G(a2 + 1) == true) { dist[a2 + 1] = a1 + (L - a[a2 + 1]); Q.push(make_pair(dist[a2 + 1], a2 + 1)); }
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 5516
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
char s[100009];
int main()
{
	scanf("%s",s);
	int l=strlen(s);
	for(int i=0;i<=l/2;i++)
	{
		if(s[i]=='p' && s[l-i-1]!='q')
		{
			printf("No");
			return 0; 
		}
		if(s[i]=='q' && s[l-i-1]!='p')
		{
			printf("No");
			return 0; 
		}
		if(s[i]=='b' && s[l-i-1]!='d')
		{
			printf("No");
			return 0; 
		}
		if(s[i]=='d' && s[l-i-1]!='b')
		{
			printf("No");
			return 0; 
		}
	}
	printf("Yes");
}	

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long
//cout << fixed << setprecision (10);   小数点以下１０桁まで

int main() {
  int  a,b,c;
  cin >>a>>b>>c;

 cout << b*(c/a) << endl;
  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll a[114514], b[114514], imos[114514];
signed main() {
	ll n, m, ans = 0;
	cin >> n >> m;
	rep(i, m)cin >> a[i] >> b[i];
	rep(i, m) {
		imos[a[i]]++;
		imos[b[i] + 1]--;
	}
	for (int i = 1; i < n + 1; i++) {
		imos[i] = imos[i - 1] + imos[i];
	}
	rep(i, n + 1) {
		if (imos[i] == m)ans++;
	}
	cout << ans << endl;
	ggr
}


Measured memory_bytes: 2560
/*
 * Author : Sadi
 * Sat 27/06/2020
 * 19:14:37.80
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



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

    int A, B;
    cin >> A >> B;
    cout << A * B - A - B + 1 << endl;

    return 0;
}


Measured memory_bytes: 3528
w,h,n=gets.split.map(&:to_i)

l=0
b=0

n.times{
  x,y,a=gets.split.map &:to_i
  case(a)
  when 1
    l=[l,x].max
  when 2
    w=[w,x].min
  when 3
    b=[b,y].max
  when 4
    h=[h,y].min
  end
}

p [(w-l),0].max*[(h-b),0].max

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
int main(){
    vector<pair<int,int> > num;
    while(true){
        int a,b;    cin>>a>>b;
        if(a==0&&b==0){
            break;
        }
        if(a>b) swap(a,b);
        num.push_back(make_pair(a,b));
    }
    rep (i,num.size()) {
        cout<< num[i].first<<" "<<num[i].second<<endl;
    }
}


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


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    dp = [[float("-inf")] * 3 for _ in range(N)]
    dp[0][0] = a[0]
    dp[0][1] = b[0]
    dp[0][2] = c[0]
    for i in range(1, N):
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i]
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i]
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i]
    print(max(dp[-1]))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, a, b, c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 66908
def intersection_ll(s0, s1, t0, t1):
  x0, y0 = s0
  x1, y1 = s1
  X0, X1 = t0
  X1, Y1 = t1
  p = (x1-x0)*(y0-Y0) - (y1-y0)*(x0-X0)
  q = (x1-x0)*(Y1-Y0) - (y1-y0)*(X1-X0)
  return (X0 + p*(X1-X0)/float(q), Y0 + p*(Y1-Y0)/float(q))

n = int(input())
for i in range(n):
  x0,y0,x1,y1,X0,Y0,X1,Y1 = map(int,input().split())
  print("%.08f %.08f" % intersection_ll((x0, y0), (x1, y1), (X0, Y0), (X1, Y1)))



Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[100], t[100];
    int i,j,l;
    cin>>s>>t;

    sort(s,s+strlen(s));
    sort(t,t+strlen(t));
    reverse(t,t+strlen(t));
    l=max(strlen(s),strlen(t));
    for(i=0; i<l; i++)
    {
        if(s[i]!=t[i])
        {
            if(s[i]<t[i])
            {
                cout<<"Yes";
                return 0;
            }
            else
            {
                cout<<"No";
                    return 0;
            }
        }
    }
    cout<<"No";
    return 0;
}


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

int main(){
  int a[26];
  fill_n(a, 26, 0);
  
  string s;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++){
    a[s[i]-'a']++;
    //cout << s[i]-'a' << endl;
  }
  
  for(int i = 0; i < 26; i++){
    if(a[i] >= 2){
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
ll power(ll x,ll y)
{
    ll res=1;
  
    while(y>0)
    {
        if(y&1)
            res=res*x;
        res%=mod;
        y=y>>1;
        x=x*x;
        x%=mod;
    } 
    return res; 
}
int main()
{  
    FAST
    string s;
    cin>>s;
    ll n=s.length();
    ll ans=0;
    ll x=0,y;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='1')
        {
            y=power(3,(n-i-1));
            if(i==0)
                y+=2;
            else
                y+=1;
            y%=mod;
            y*=power(2,x);
            y%=mod;
            ans+=y;
            ans%=mod;
            x++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 512
n, m, t = map(int, input().split())
a = list(map(int, input().split()))
a = [-m] + a + [t + m]

ans = 0
for i in range(len(a) - 1):
    if a[i + 1] - a[i] > m * 2:
        ans += a[i + 1] - a[i] - m * 2

print(ans)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b, n;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << (a+b-n>=0?a+b-n:0);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[]) {
  int x;
  int r, i;
  scanf("%d", &x);
  while(1) {
    r = 0;
    for (i = 2; i < x; i++) {
      if (x % i == 0) {
	r = 1;
	break;
      }
    }
    if (r == 0) break;
    x++;
  }
  printf("%d\n", x);
  return 0;
}


Measured memory_bytes: 128
x=STDIN.read
a=x.split[0].to_i
b=x.split[1].to_i
c=x.split[2].to_i

if a > b
  w = a;a = b;b= w;
end
if b > c
  w = b;b = c;c= w;
end
if a > b
  w = a;a = b;b= w;
end

puts sprintf("%d %d %d\n",a,b,c)

Measured memory_bytes: 8568
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


int fac[N];
int po(int a, int n){
    int res = 1;
    while(n){
        if(n & 1) res = ( res * a ) % mod ;
        a = (a * a) % mod ;
        n >>= 1; 
    }
    return res ;
}

int ncr (int n , int r){
    int res = fac[n]; 
    if(n < r){
        return 0 ;
    }
    res = (res * po(fac[r] , mod - 2)) % mod ;
    res = (res * po(fac[n-r] , mod - 2)) % mod ;
    return res ;
}
void solve()
{
    fac[0] = 1; 
    rep(i , N) if(i) fac[i] = (fac[i-1] * i) % mod ;
    int n , k , res = 0;
    cin >> n >> k; 
    int a[n] ;
    rep(i , n) cin >> a[i];
    sort(a , a + n) ;
    rep(i , n){
        res = (res - (ncr(n - i - 1 , k - 1) * a[i]) % mod + mod) % mod ;
    }
    repD(i , n - 1, 0){
        res = (res + (ncr(i , k - 1) * a[i]) % mod ) % mod ;
    }
    res = (res + mod) % mod;
    cout << res ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

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

using namespace std;

int main(){
  string s;
  long long x;
  cin >> s;
  cin >> x;
  for(int i=0;i<(int)s.size()-1;i++){
    if('z'-s[i]+1<=x && s[i]!='a'){
      x-='z'-s[i]+1;
      s[i]='a';
    }
    cout << s[i];
  }
  long long t = s[(int)s.size()-1]-'a';
  t=(t+x)%26;
  cout << (char)('a'+t) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
P R[100];
bool B[200][200];
void solve(){
	sort(R, R + N, greater<P>());
	int ans = 0;
	rep(i, N){
		int rx = R[i].first, ry = R[i].second;
		for(int y = ry + 1; y < 2 * N; y++){
			bool b = false;
			for(int x = rx + 1; x < 2 * N; x++){
				if(B[x][y]){
					ans++;
					B[x][y] = false;
					b = true;
					break;
				}
			}
			if(b) break;
		}
	}
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		R[i] = P(a, b);
	}
	rep(i, N){
		int c, d;
		cin >> c >> d;
		B[c][d] = true;
	}
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

using namespace std;

int n, ma, mb, a[45], b[45], c[45];
int dp[50][410][410];  // dp[i][j][k]:i種類目までの薬品で、物質Aをjグラム、物質Bをkグラム入手するときの最小コスト

int main(){
    cin >> n >> ma >> mb;
    rep(i, n){
        cin >> a[i] >> b[i] >> c[i];
    }
    rep(i, n+1){
        rep(j, 401){
            rep(k, 401){
                if(j == 0 && k == 0){
                    dp[i][j][k] = 0;
                }else{
                    dp[i][j][k] = IINF;
                }
            }
        }
    }
    REP(i, 1, n+1){
        REP(j, 1, 401){
            REP(k, 1, 401){
                dp[i][j][k] = dp[i-1][j][k];
                if(j >= a[i-1] && k >= b[i-1]){
                    if(dp[i-1][j-a[i-1]][k-b[i-1]] < IINF){
                        dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-a[i-1]][k-b[i-1]] + c[i-1]);
                    }
                }
            }
        }
    }
    int ans = IINF, l = ma, m = mb;
    while(l <= 400 && m <= 400){
        ans = min(ans, dp[n][l][m]);
        l += ma;
        m += mb;
    }
    if(ans < IINF){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 28928