akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] t = new int[n];
		for(int i = 0;i < n;i++)t[i] = sc.nextInt();
		int m = sc.nextInt();
		int[] sum = new int[m];
		int[] p = new int[m];
		int[] x = new int[m];
		for(int i = 0;i < m;i++) {
			p[i] = sc.nextInt();
			x[i] = sc.nextInt();
		}
		for(int i = 0;i < m;i++) {
			for(int k = 0;k < n;k++) {
				if(k == p[i]-1)sum[i] += x[i];
				else sum[i] += t[k];
			}
			System.out.println(sum[i]);
		}
	}

}


Measured memory_bytes: 21844
a=input()
n=len(a)-1
for i in range(2**n):
    result=['+','+','+']
    for j in range(n):
        if ((i>>j)&1)==1:
            result[j]='-'
    if eval(''.join([a[0],result[0],a[1],result[1],a[2],result[2],a[3]]))==7:
        print(''.join([a[0],result[0],a[1],result[1],a[2],result[2],a[3]])+'=7')
        exit()

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007
typedef pair<int, int> P;
int dp[1050][1050];

signed main() {
	int h, w;
	char a[1050][1050];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[j][i];
		}
	}
	dp[0][0] = 1;
	for (int i = 1; i < w; i++) {
		if (a[i][0] == '#') dp[i][0] = 0;
		else dp[i][0] = dp[i - 1][0];
	}
	for (int i = 1; i < h; i++) {
		if (a[0][i] == '#') dp[0][i] = 0;
		else dp[0][i] = dp[0][i - 1];
	}
	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			if (a[j][i] == '#') dp[j][i] = 0;
			else  dp[j][i] = dp[j - 1][i] + dp[j][i - 1];
			dp[j][i] %= inf;
		}
	}
	cout << dp[w - 1][h - 1] << endl;

	END;
}

Measured memory_bytes: 9472
def resolve():
    import sys

    def LI():
        return list(map(int, sys.stdin.readline().rstrip().split()))  # 空白あり

    def S():
        return sys.stdin.readline().rstrip()

    N, M = map(int, S().split())
    A = LI()
    A.sort()

    def f(n,x):  # A[n]+A[i]>=x となる i の最小値
        left = -1
        right = N
        while left + 1 < right:
            mid = (left + right) // 2
            if A[n] + A[mid] < x:
                left = mid
            else:
                right = mid
        return right

    low = 2 * A[0]
    high = 2 * A[-1] + 1

    while low + 1 < high:
        mid = (low + high) // 2
        if sum(N - f(i,mid) for i in range(N)) >= M:
            low = mid
        else:
            high = mid

    a = low  # a以上のA[i]+A[j]がM個以上となる最大のa

    from itertools import accumulate

    B = [0] + list(accumulate(A))

    r = 0
    ans = 0
    for i in range(N):  # a+1以上のA[i]+A[j]を足し合わせていく
        b = f(i,a+1)
        r += N - b
        ans += B[N] - B[b]
        ans += A[i] * (N - b)

    ans += (M - r) * a  # A[i]+A[j] == a となるものを足し合わせる

    print(ans)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 90504
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll a[105][105]={{}};
  ll b[105][105]={{}};
  int n,m,l;
  int i,j,k;
  cin >> n >> m >> l;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      cin >> b[i][j];
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      ll o=0;
      for(k=0;k<m;k++){
	o+=a[i][k]*b[k][j];
      }
      if(j==0) cout << o;
      else cout << " " << o; 
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3276
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    long long N, X, M;

    scanf("%lld%lld%lld", &N, &X, &M);

    long long c[M];

    for(long long i = 0; i < M; i++){
        c[i] = 0;
    }

    long long x = X;
    long long f = 0, t = 0;
    long long a = 1, s;

    while(1){
        if(c[x % M] > 0){
            t = a - 1;
            s = x % M;
            break;
        }else{
            a++;
            c[x % M] = 1;
            x = (x * x) % M;
        }
    }

    long long y = X;
    a = 1;

    while(1){
        if(y % M == s){
            f = a-1;
            break;
        }else{
            a++;
            y = (y * y) % M;
        }
    }

    long long ans = 0;

    for(long long i = 0; i < f; i++){
        ans += X % M;
        X = (X * X) % M;
    }

    long long z = X;

    long long k = 0;
    for(long long i = f; i < t; i++){
        k += X % M;
        X = (X * X) % M;
    }

    ans += k * ((N-f) / (t-f));

    for(long long j = 1; j <= (N-f) % (t-f); j++){
        ans += z % M;
        z = (z * z) % M;
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 2488
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

A, B = map(int, input().split())
x = A % B
print(min(x, B - x))

Measured memory_bytes: 9264
#include<bits/stdc++.h>
#define maxn 100005
#define ll long long
using namespace std;
int S=1,T=2,tot=2;
int pre[maxn],to[maxn],las[maxn],cap[maxn],inc=1;
ll cost[maxn];
void AE(int a,int b,int c,ll d)
{
	pre[++inc]=las[a],las[a]=inc;
	to[inc]=b,cap[inc]=c,cost[inc]=d;
}
void ins(int a,int b,int c,ll d)
{
	//printf("%d %d %lld\n",a,b,d);
	AE(a,b,c,d),AE(b,a,0,-d);
}
int lk[maxn],lid[maxn]; ll dis[maxn];
int Q[maxn],inq[maxn],fr,tl;
int SPFA()
{
	for(int i=1;i<=tot;i++) dis[i]=-1e18,lk[i]=lid[i]=0;
	dis[S]=0,fr=tl=1,Q[tl]=S,inq[S]=1;
	while(tl>=fr)
	{
		int x=Q[fr]; fr++;
		inq[x]=0;
		for(int i=las[x];i;i=pre[i])
		{
			int y=to[i];
			if(cap[i]>0&&dis[y]<dis[x]+cost[i])
			{
				dis[y]=dis[x]+cost[i],lk[y]=x,lid[y]=i;
				if(!inq[y]) Q[++tl]=y,inq[y]=1;
			}
		}
	}
	return dis[T]>-1e18;
}
ll AddFlow()
{
	ll flow=1e18;
	for(int x=T;x!=S;x=lk[x])
		flow=min(flow,(ll)cap[lid[x]]);//,printf("%d--",lk[x]);
	//puts("");
	for(int x=T;x!=S;x=lk[x])
		cap[lid[x]]-=flow,cap[lid[x]^1]+=flow;
	return flow*dis[T];
}
struct node
{
	int x,y; ll v;
}itm[maxn],lim[maxn];
//int cmp1(node a,node b){return a.x<b.x;}
//int cmp2(node a,node b){return a.y<b.y;}
int n,m,mp[2222],lb[maxn][2],rb[maxn][2];
ll ans=0;
void Solve(int K)
{
	memset(las,0,sizeof(las)),inc=1;
	for(int i=1;i<=K;i++) lb[i][0]=lb[i][1]=1,rb[i][0]=rb[i][1]=100;
	for(int i=1;i<=m;i++)
	{
		int rk=lim[i].y,pos=lim[i].x;
		if(lim[i].v==3&&rk<K)
			lb[rk+1][0]=max(lb[rk+1][0],pos+1);
		if(lim[i].v==4&&rk<K)
			rb[K-rk][0]=min(rb[K-rk][0],pos-1);
		if(lim[i].v==1&&rk<K)
			lb[rk+1][1]=max(lb[rk+1][1],pos+1);
		if(lim[i].v==2&&rk<K)
			rb[K-rk][1]=min(rb[K-rk][1],pos-1);
	}
	for(int i=2;i<=K;i++)
	{
		lb[i][0]=max(lb[i][0],lb[i-1][0]);
		lb[i][1]=max(lb[i][1],lb[i-1][1]);
	}
	for(int i=K-1;i>=1;i--)
	{
		rb[i][0]=min(rb[i][0],rb[i+1][0]);
		rb[i][1]=min(rb[i][1],rb[i+1][1]);
	}
	tot=2+2*K+2*n;
	for(int i=1;i<=K;i++)
	{
		ins(S,i+2,1,0);
		ins(i+K+2*n+2,T,1,0);
		for(int j=1;j<=n;j++)
			if(itm[j].x>=lb[i][0]&&itm[j].x<=rb[i][0]) ins(i+2,j+K+2,1,0);
		for(int j=1;j<=n;j++)
			if(itm[j].y>=lb[i][1]&&itm[j].y<=rb[i][1]) ins(j+n+K+2,i+2*n+K+2,1,0);
	}
	for(int i=1;i<=n;i++) ins(i+K+2,i+n+K+2,1,itm[i].v);
	ll c=0;
	while(SPFA())
		c+=AddFlow();
	ans=max(ans,c);
}
int main()
{
	mp['U']=2,mp['D']=1,mp['L']=3,mp['R']=4;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d%lld",&itm[i].x,&itm[i].y,&itm[i].v);
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		char ty[3];int a,b;
		scanf("%s%d%d",ty,&a,&b);
		lim[i]=(node){a,b,mp[ty[0]]};
	}
	for(int i=1;i<=n;i++) Solve(i);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

ll X,Y;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> X >> Y;

    ll res=1;
    while (2*X<=Y){
        res++,X*=2;
    }

    cout << res << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
const int INF=int(1e9);
#define ll  long long
ll x[maxn],v[maxn];
ll dpr[maxn],dpl[maxn];
void init() {
	memset(x,0,sizeof(x));
	memset(v,0,sizeof(v));
	memset(dpr,0,sizeof(dpr));
	memset(dpl,0,sizeof(dpl));
}
int main() {
	int n;
	ll c,rsum=0,lsum=0,sum=0,ans=0;
	init();
	scanf("%d %lld",&n,&c);
	for(int i=1; i<=n; i++) {
		scanf("%lld %lld",&x[i],&v[i]);
		sum+=v[i];
	}
	for(int i=2; i<=n; i++) {
		rsum+=v[i-1];
		dpr[i]=max(dpr[i-1],rsum-x[i-1]*2);
	}
	for(int i=n-1; i>=1; i--) {
		lsum+=v[i+1];
		dpl[i]=max(dpl[i+1],lsum-(c-x[i+1])*2);
	}
	lsum=0;
	rsum=0;
	for(int i=1; i<=n; i++) {
		rsum+=v[i];
		ans=max(ans,rsum-x[i]+dpl[i]);
	}
	for(int i=n; i>=1; i--) {
		lsum+=v[i];
		ans=max(ans,lsum-(c-x[i])+dpr[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

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

map<long long, long long> dp;
long long N, A, B, C, D;

vector<long long> v = {2,3,5}, c;

long long solve(long long N) {
    if (dp.count(N))    return dp[N];

    long long ans = 1e18;
    if (N <= ans/D)     ans = min(ans, N*D);

    for (int i=0; i<3; i++) {
        long long p = v[i];
        long long C = c[i];
        long long r = N%p;
        ans = min(ans, r*D+solve(N/p)+C);
        if (N/p+1 < N) ans = min(ans, (p-r)*D+solve(N/p+1)+C);
    }

    return dp[N] = ans;
}

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

    int t;
    cin>>t;

    while (t--) {
        cin>>N>>A>>B>>C>>D;

        c = {A, B, C};

        dp.clear();
        dp[0] = 0;

        cout<<solve(N)<<endl;
    }
}


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

int main() {
	int A, K;
	vector<int> vec(3);
	for (int i = 0; i < 3; i++) {
		cin >> A;
		vec.at(i) = A;
	}
	sort(vec.begin(), vec.end());
	cin >> K;
	for (int j = 0; j < K; j++) {
		vec.at(2) *= 2;
	}
	int total = vec.at(0) + vec.at(1) + vec.at(2);
	cout << total << endl;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

// clang-format off
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec h = ivec(n);
    int ma = -1;
    rep (i, n) {
        chmax(ma, h[i]);
        if (ma - h[i] > 1) {
            print("No");
            return 0;
        }
    }
    print("Yes");
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
A = [int(i) for i in input().split()]
#3 2 2 4 1
B = [int(i) for i in input().split()]
#1 2 2 2 1

ans = 0
for i in range(n):
	ans = max(sum(A[:i+1])+sum(B[i:]),ans)

print(ans)

Measured memory_bytes: 3060
n = raw_input()
a = raw_input().split(' ')
a = map(int, a)
s = 0
sunuke = a[0]
arai = a[len(a)-1]
for i in a:
	s = s + i
m = abs(sunuke - (s - sunuke))
 
for i in range(1,len(a)-2):
	sunuke = sunuke + a[i]
	arai = s - sunuke
	if abs(arai-sunuke) < m:
		m = abs(arai-sunuke)
 
 
print m

Measured memory_bytes: 18416
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	if(c^'-')k=1,x=c&15;else k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (510)
int n,k,a[N],s,f(1);
void slv(int x);
vector<int>v;
signed main(){
	Rd(n),Rd(k);
	Frn1(i,1,n)s+=Rd(a[i]);
	for(;f*f<=s;++f)if(!(s%f))slv(s/f);
	for(;f;--f)if(!(s%f))slv(f);
	exit(0);
}
void slv(int x){
	v.clear();
	Frn1(i,1,n)if(a[i]%x)v.push_back(a[i]%x);
	sort(v.begin(),v.end());
	int i(0),sv(0);
	for(;sv<=k&&i<v.size();++i)sv+=v[i];
	for(--i,sv=0;i<v.size();++i)if((sv+=x-v[i])>k)return;
	wr(x),exit(0);
}

Measured memory_bytes: 256
A = []
for i in range(3):
    A.append(list(map(int, input().split())))

N = int(input())

B = []

for i in range(N):
    B.append(int(input()))

bingo = False

#check rows and columns
for i in range(3):
    rowMatches = 0
    colMatches = 0
    for j in range(3):
        if A[i][j] in B:
            rowMatches += 1
        if A[j][i] in B:
            colMatches += 1

    if (rowMatches == 3 or colMatches == 3):
        bingo = True
        break

if (bingo):
    print("Yes")
else:
    #check diagonals
    diag1 = 0
    diag2 = 0
    for i in range(3):
        if A[i][i] in B:
            diag1 += 1
        if A[i][3-1-i] in B:
            diag2 += 1

    if (diag1 == 3 or diag2 == 3):
        print("Yes")
    else:
        print("No")

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

using namespace std;
typedef long long ll;
typedef long double ld;
using graph = vector<vector<int>>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

template<class T> inline bool chmax(T &a,T b) { if (a<b) { a=b; return true; } return false; }
template<class T> inline bool chmin(T &a,T b) { if (b<a) { a=b; return true; } return false; }


int main(){
	int n;cin>>n;
	cout<<n/2+n%2<<endl;
}





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


int main() {
	double r;
	std::cin >> r;
	std::cout.setf(std::ios::fixed);
	std::cout.precision(6);
	std::cout << (M_PI * (r * r))<< " " << (M_PI * (r * 2)) << std::endl;
	return 0;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

int main()
{
  long long N;
  cin >> N;
  vector<long long> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }
  A.push_back(0);

  long long card = 0;
  long long ans = 0;
  rep(i, N + 1)
  {
    card += A[i];
    if (A[i] == 0)
    {
      ans += card / 2;
      card = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
A,B,C = map(int,input().split())

no_poison = A + B
if no_poison >= C - 1: # 解毒＞＝毒-1のとき(最後に毒食べるため-1する)
    ans = B + C 
else:
    ans = no_poison + B + 1
print(ans)

Measured memory_bytes: 2940
#include <stdio.h>

int main(int argc, char const *argv[]) {
    int s,m,h;

    scanf("%d", &s);
    m = 0;
    h = 0;

    if(s >59){
        m = s / 60;
        s = s % 60;
        if(m > 59){
            h = m / 60;
            m = m % 60;
        }

    }

    printf("%d:%d:%d\n",h,m,s);

    return 0;
}



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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(a>0 && c>0){
    c -= b;
    if (c>0) a -= d;
  }
  cout << (a<=0 ? "No" : "Yes") << endl;
}


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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  vector <long long int> a(n);
  map<long long int,long long int> m;
  for (long long int i = 0; i < n; ++i){
	cin >> a[i];
	m[a[i]] += 1;
  }
 long long int sum = 0;
	for (auto x : m){
		sum += (x.second * (x.second - 1))/2;
	}
	for (long long int i = 0; i < n; ++i){
		long long int ans = sum;
		ans -= (m[a[i]] * (m[a[i]] - 1) )/2;
		ans += ( (m[a[i]] - 1) * (m[a[i]] - 2))/2;
		cout << ans << "\n";
	}	
return 0;
}


Measured memory_bytes: 11136
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    X = [list(map(int,input().split())) for _ in range(N)]
    na,nb = X[0][0],X[0][1]
    for i in range(N-1):
        i += 1
        x,y = X[i][0],X[i][1]
        if (x >= na and y >= nb):
            na,nb = x,y
        elif (x < na and y >= nb):
            q = -(-na//x)
            na,nb = x*q,y*q
        elif (x >= na and y < nb):
            q = -(-nb//y)
            na,nb = x*q,y*q
        else:
            use = max(-(-na//x),-(-nb//y))
            na,nb = x*use,y*use
    
    print(na+nb)
    
if __name__ == "__main__":
    main()

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

const double eps = 1e-9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define FORD(i,a,b) for (int i = int(b)-1; i >= (a); i--)
#define FORIT(i,c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define mp make_pair
#define pb push_back

int main(){
    ios::sync_with_stdio(false);
    int N, H,W;
    cin >> H >> W >> N;
    vector<vector<int> > op(H, vector<int>(W));
    int x=0,y=0;
    FOR(i,0,N){
        int a;
        cin >> a;
        FOR(aa,0,a){
            op[x][y] = i+1;
            if(++y == W){
                y = 0;
                ++x;
            }
        }
    }
    FOR(h,0,H){
        if(h&1){
            FOR(w,0,W)cout << op[h][w] << ((w==W-1)?"\n":" ");
        } else {
            FORD(w,0,W)cout << op[h][w] << ((w==0)?"\n":" ");
        }
    }
	return 0;
}

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

int main(){
  long long N,M,K,tmp,pr;
  cin >> N >> M >> K;
  vector<long long> A(N),Am(N),B(M),Bm(M);
  pr = 0;
  for(int i=0; i<N; i++){
     cin >> tmp;
     A[i] = tmp;
     Am[i] = pr + tmp;
     pr = Am[i];
  }
  pr = 0;
  for(int i=0; i<M; i++){
     cin >> tmp;
     B[i] = tmp;
     Bm[i] = pr + tmp;
     pr = Bm[i];
  }
  long long num,maxnum=0;
  long long Anum = upper_bound(Am.begin(), Am.end(), K) - Am.begin();
  for(int i=Anum; i>=1; i--){
    num = i;
    num += upper_bound(Bm.begin(), Bm.end(), K-Am[i-1]) - Bm.begin();
    maxnum = max(num,maxnum);
  }
  num = upper_bound(Bm.begin(), Bm.end(), K) - Bm.begin();
  maxnum = max(num,maxnum);
  cout << maxnum;
  return 0;
}

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

int main()
{
  string x;cin>>x;
  int i;
  int counts=0;
  int delpair=0;
  for(i=0;i<x.length();i++)
  {
    if(x.at(i)=='S')counts++;
    else
    {
      if(counts>0)
      {
        delpair++;
        counts--;
      }
    }
  }
  cout<<x.length()-delpair*2<<endl;
}


Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let s: String = read();
    let price = 700 + 100 * s.chars().filter(|&s| s == 'o').count();
    println!("{}", price);
}


Measured memory_bytes: 4352
;; C - Welcome to AtCoder

(defun main ()
  (let* ((n (read)) ; 問題数
         (m (read)) ; 提出数
         (p-s (loop repeat m collect (cons (read) (read))))) ; 問題番号と結果
    (format t "~{~a~^ ~}~%" (solve n m p-s))))

(defun solve (n m p-s-lst)
  "正答数とペナルティ数のリストを返す"
  (let ((wa-count (make-array n :initial-element 0)) ; 各問の誤答数
        (ac-p     (make-array n :initial-element nil))) ; 正答したか
    (loop for p-s in p-s-lst
          for p = (1- (car p-s))
          for s = (cdr p-s)
          when (and (eq s 'WA) (not (aref ac-p p)))
            do (incf (aref wa-count p)) end
          when (eq s 'AC)
            do (setf (aref ac-p p) t) end)
    (list (loop for a across ac-p count a)
          (loop for p below n when (aref ac-p p) sum (aref wa-count p)))))

(main)


Measured memory_bytes: 61928
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 100000000
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}

int main(){

	char s[100009];
	cin>>s;
	int i=0;
	int ans[26]={0};
	while(s[i]!='\0'){
		ans[int(s[i])-97]++;
		i++;
	}
	rep(i,26){
		if(ans[i]==0){
			cout<<char(i+97)<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
}




Measured memory_bytes: 384
/**
class cfmaster {
 public:
  struct code {
  	see the details down there !
  };
};
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << (a + b - 1) / b << '\n';
  return 0;
}



Measured memory_bytes: 256
N,D = gets.chomp.split(" ").map(&:to_i)
x, y = N.times.map{gets.split.map(&:to_i)}.transpose
ans = 0
N.times do |i|
  if D >= (x[i] ** 2 + y[i] ** 2) ** 0.5
    ans +=1
  end
end
puts ans

Measured memory_bytes: 31932
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

struct SegT {
private:
    int sz; vector<int> node;
    const int INT = 2147483647;
public:
    SegT(int n) {
        sz = 1;
        while(sz < n) sz *= 2;
        node.resize(2 * sz - 1, INT);
    }
    SegT(vector<int> &v) {
        int n = v.size();
        sz = 1;
        while(sz < n) sz *= 2;
        node.resize(2 * sz - 1, INT);
        rep(i, n) {
            node[i + sz - 1] = v[i];
        }
        per(i, sz - 1) {
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
        }
    }
    void update(int k, int a) {
        k += sz - 1;
        node[k] = a;
        while(k > 0) {
            k = (k - 1) / 2;
            node[k] = min(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    int query(int a, int b, int k, int l, int r = -1) {
        if(r < 0) r = sz;
        if(r <= a || b <= l) return INT;

        if(a <= l && r <= b) return node[k];
        else {
            int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n, q; cin >> n >> q;
    SegT seg(n);
    rep(i, q) {
        int com, x, y; cin >> com >> x >> y;
        if(com == 0) seg.update(x, y);
        else {
            int ans = seg.query(x, y + 1, 0, 0, -1);
            cout << ans << endl;
        }
    }
	return 0;
}




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

inline void read(int&x){
	char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();
}

const int N = 601000, p = 924844033, G = 5;
struct Edge{int v,nxt;}a[N+N];
int head[N],sz[N],fac[N],inv[N];
int c[N];
int n,_;

inline int C(int nn,int mm){return (ll)fac[nn] * inv[mm]%p * inv[nn-mm]%p;}
inline int qm(const int&X){return X < p ? X : X - p;}
inline int qpow(int A,int B){
	int res = 1; while(B){
		if(B&1) res = (ll)res * A%p;
		A = (ll)A * A%p, B >>= 1;
	}return res;
}

inline void ad(){
	static int x,y; read(x), read(y);
	a[++_].v = y, a[_].nxt = head[x], head[x] = _;
	a[++_].v = x, a[_].nxt = head[y], head[y] = _;
}

void dfs(int x,int las){
	sz[x] = 1;
	for(int i=head[x];i;i=a[i].nxt)
		if(a[i].v != las){
			dfs(a[i].v,x);
			++c[sz[a[i].v]];
			sz[x] += sz[a[i].v];
		}
	++c[n-sz[x]];
}

namespace NTT{
	int rev[N];
	void ntt(int*a,int n,int sgn){
		for(int i=1;i<n;++i) if(i<rev[i]) swap(a[i], a[rev[i]]);
		for(int i=1;i<n;i<<=1){
			int gn = qpow(G,(p-1)/(i<<1));
			for(int j=0;j<n;j+=(i<<1)){
				int g = 1;
				for(int k=0;k<i;++k,g=(ll)g*gn%p){
					int x = a[j+k], y = (ll)g * a[j+k+i]%p;
					a[j+k] = qm(x+y), a[j+k+i] = qm(x-y+p);
				}
			}
		}
		if(!sgn){
			int iv = qpow(n,p-2); reverse(a+1,a+n);
			for(int i=0;i<n;++i) a[i] = (ll)iv * a[i]%p;
		}
	}
	void work(int*a,int*b,int n){
		int nn = 1, len = -1;
		while(nn <= n+n) nn <<= 1, ++len;
		for(int i=1;i<nn;++i) rev[i] = (rev[i>>1]>>1)|((i&1)<<len);
		ntt(a,nn,1), ntt(b,nn,1);
		for(int i=0;i<nn;++i) a[i] = (ll)a[i] * b[i]%p;
		ntt(a,nn,0);
	}
}

int arr[N],brr[N];

int main(){
	read(n);
	for(int i=1;i<n;++i) ad();
	dfs(1,0);
	
	fac[0] = inv[0] = 1;
	for(int i=1;i<=n;++i) fac[i] = (ll)fac[i-1] * i%p;
	inv[n] = qpow(fac[n], p-2);
	for(int i=n;i;--i) inv[i-1] = (ll)inv[i] * i%p;
	
	brr[0] = 1;
	for(int i=1;i<=n;++i){
		arr[i] = (ll)c[i] * fac[i]%p;
		brr[i] = inv[i];
	}
	reverse(arr,arr+n+1);
	NTT::work(arr,brr,n+1);
	
	for(int i=1;i<=n;++i)
		printf("%lld\n",((ll)C(n,i)*n - (ll)arr[n-i]*inv[i]%p+p)%p);
	return 0;
}

Measured memory_bytes: 32640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

ll pow(ll k, ll n) {
  if (k == 0) return 0;
  if (n == 0) return 1;
  
  int i = 0;
  while (i < n) {
    k *= k;
    i++;
  }
  return k;
}

int main() {
  int X; cin >> X;
  vector<bool> expo(X+1);
  
  expo[1] = 1;
  repi(b,2,X) {
    int v = b*b;
    while(v<=X) {
      expo[v] = 1;
      v *= b;
    }
  }
    
  repr(i,X,1) {
    if(expo[i]) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    LL n, x;
    cin >> n >> x;
    vector<LL> b(n), u(n), l(n);
    rep(i, n) cin >> b[i] >> l[i] >> u[i];

    vector<pair<LL, int>> d(n);
    rep(i, n) d[i] = make_pair((x-b[i])*u[i] + b[i]*l[i], i);
    sort(all(d));
    reverse(all(d));

    vector<LL> sum_d(n+1, 0);
    rep(i,n) sum_d[i+1] = sum_d[i] + d[i].first;

    LL sum_bl = 0;
    rep(i, n) sum_bl += b[i]*l[i];

    LL ok = x*n, ng = -1;
    while(abs(ok - ng) > 1){
        LL mid = (ok+ng)/2;
        LL sub_x = mid / x;
        LL rem = mid % x;

        LL tmp = 0;
        bool f = 0;
        if(sub_x >= n){
            ng = mid;
            continue;
        }
        rep1(i, n+1){
            if(i <= sub_x){
                tmp = sum_d[sub_x+1] - (sum_d[i] - sum_d[i-1]);
            }else{
                tmp = sum_d[sub_x];
            }
            int j = d[i-1].second;
            if(b[j] < rem){
                tmp += (rem-b[j])*u[j] + b[j]*l[j];
            }else{
                tmp += rem*l[j];
            }
            if(tmp >= sum_bl){
                f = 1;
                break;
            }
        }
        // cout << mid << " : " << tmp << " " << sum_bl << endl;
        if(f) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;

}


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

string s, t;
string ans;

bool chk(int pos)
{
    ans = s;
    for (int i = 0; i < (int)t.size(); i++) {
        if (s[pos+i] == '?' || s[pos+i] == t[i]) ans[pos+i] = t[i];
        else return false;
    }

    for (int i = 0; i < (int)ans.size(); i++) {
        if (ans[i] == '?') ans[i] = 'a';
    }
    return true;
}

int main()
{
    //string s, t;
    cin >> s >> t;
    string out;

    for (int i = 0; i < (int)s.size(); i++) {
        if (chk(i)) {
            if (out == "" || ans < out) out = ans;
        }
    }

    if (out.empty()) cout << "UNRESTORABLE";
    else cout << out;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int dp[1000], w[1000], v[1000], a, n, t = 0, i, j, mv;
int main() {
  while (cin >> a, a) {
    t++;
    cin >> n;
    fill(dp, dp + a + 1, 0);
    for (i = 0; i < n; i++)
      scanf("%d,%d", &v[i], &w[i]);
    for (i = 0; i < n; i++)
      for (j = a; j >= 0; j--)
        if (j + w[i] <= a) dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
    mv = 0;
    for (i = 0; i <= a; i++)
      if (dp[i] > dp[mv]) mv = i;
    cout << "Case " << t << ':' << endl << dp[mv] << endl << mv << endl;
  }
}

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn split(n: u64) -> Vec<u64> {
    let mut n = n;
    let mut ds = vec![];
    while n > 0 {
        ds.push(n%10);
        n /= 10;
    }
    ds.reverse();
    ds
}

fn main() {
    input!{
      n: u64,
    }
    let ds = split(n);
    let mut ans: u64 = ds.iter().sum();
    for i in 0..ds.len() {
        let mut ds = ds.clone();
        if ds[i] >= 1 {
            ds[i] -= 1;
            for j in i+1..ds.len() {
                ds[j] = 9;
            }
            let sum: u64 = ds.iter().sum();
            ans = max(ans, sum);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  Int ans=0;
  for(Int i=1;i<=n;i++)
    if((to_string(i).size())&1) ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;cin>>s>>t;s.pub('1');t.pub('2');
	int i,j,n=s.size(),m=t.size();
	static int dp[3002][3002]={0};
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			maxeq(dp[i+1][j],dp[i][j]);
			maxeq(dp[i][j+1],dp[i][j]);
			if(s[i]==t[j]){maxeq(dp[i+1][j+1],dp[i][j]+1);}
		}
	}
	int y=n-1,x=m-1;
	string ans;
	while(-1){
		if(dp[y][x]==0){break;}
		if(s[y-1]==t[x-1]&&dp[y-1][x-1]+1==dp[y][x]){ans.pub(s[y-1]);y--;x--;}
		else if(dp[y-1][x]==dp[y][x]){y--;}
		else{x--;}
	}
	REV(ans);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(),(x).end()
#define lowbit(x) x&-x
#define pb push_back
#define ls (id<<1)
#define rs (id<<1|1)
#define Rint register int
#define UNI(x) sort(ALL(x)),x.resize(unique(ALL(x))-x.begin())
#define GETPOS(c,x) (lower_bound(ALL(c),x)-c.begin())
#define LEN(x) strlen(x)
#define MS0(x) memset((x),0,sizeof((x)))
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<pii> Vpii;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(ll &x) { scanf("%lld", &x); }
void _R(ull &x) { scanf("%llu", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const ll &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
const int MAXN=2e6+10,MAXM=4e6+10;
const int INF=INT_MAX,SINF=0x3f3f3f3f;
const ll llINF=LLONG_MAX;
const int MOD=1e9+7,mod=998244353;
const int inv2=5e8+4;
const int Lim=1<<20;

ll x=100,p;
db r=1.01;

void solve()
{
    R(p);
    for(int i=1;i<=9999999;i++)
    {
        x=x*r;
        if(x>=p)return W(i);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);
    int t=1;
    //R(t);
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
const int d[4][2] = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
int main() {
  int n;
  cin >> n;
  vector<ll> lo(4, 1e12), hi(4, -1e12);
  for (int i = 0; i < n; ++i) {
    ll x, y;
    cin >> x >> y;
    for (int k = 0; k < 4; ++k) {
      ll result = x * d[k][0] + y * d[k][1];
      lo[k] = min(lo[k], result);
      hi[k] = max(hi[k], result);
    }
  }
  ll ans = 0;
  for (int k = 0; k < 4; ++k)
    ans = max(ans, hi[k] - lo[k]);
  cout << ans;
}

Measured memory_bytes: 3624
use std::io::*;

fn main(){
    let n : usize = input();
    let a : isize = input();
    let b : isize = input();
    let x : Vec<isize> = (0..n).map(|_| input()).collect();
    let mut ans = 0;
    for i in 1..n{
        ans += if (x[i] - x[i - 1]) * a < b {(x[i] - x[i - 1]) * a} else {b};
    }
    println!("{}", ans);
}

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define N 100010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pp pop_back
#define mapiter map<int, int>::iterator
#define pii pair<int, int>
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 0; i <= n; ++i)
#define forr(i, x, n) for(int i = x; i <= n; ++i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
  
const int inf = 1e9 + 1;
const ll modw = 1e9 + 7;
  
using namespace std;

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

int main() {
    barnarnar
	ll a, b;
	cin >> a >> b;
	cout << a * b / gcd(a, b);
    return 0;
}















Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    int c = 0,d = 0, e = 0;
    rep(i,n){
        int p;
        cin >> p;
        if(p<=a)c++;
        else if(p<=b)d++;
        else e++;
    }
    cout << min({c,d,e}) << endl;
}

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

N = int(input())

a = N*(N+1)//2
b = 3*(N//3)*(N//3+1)//2
c = 5*(N//5)*(N//5+1)//2
d = 15*(N//15)*(N//15+1)//2

print(a-b-c+d)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define LL long long
#define maxn 100050
#define mm(a,b) memset(a,b,sizeof(a))
using namespace std;
struct node{
	int to,w;
	node(int to,int w):to(to),w(w){}
};
LL dis[maxn];
int vis[maxn];
vector<node>e[maxn];
void dfs(int id){
    for(int i=0;i<e[id].size();i++){
        int next=e[id][i].to,ww=e[id][i].w;
        if(vis[next]) continue;
        dis[next]=dis[id]+(LL)ww;
        vis[next]=1;
        dfs(next);
    }
}
int main(){
//	freopen("input.txt","r",stdin);
	int n; cin>>n;
	for(int i=0;i<=n;i++) e[i].clear();
	for(int i=1;i<=n-1;i++){
		int a,b,c;
		cin>>a>>b>>c;
		e[a].push_back(node(b,c));
		e[b].push_back(node(a,c));
	}
	mm(vis,0);
	mm(dis,0);
	int q,k;
	cin>>q>>k;
	vis[k]=1;
	dfs(k);
	while(q--){
		int a,b;
		cin>>a>>b;
		cout<<dis[a]+dis[b]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13184
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>
#include <iomanip>

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

using namespace std;
using lli = long long int;
using ll = long long;

int main() {
    lli N, M;
    cin >> N >> M;

    if (N == M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s; cin >> s;
    char c = 'a';
    
    while(c <='z') {
        if(s.find(c) != string::npos)  c++;
        else {
            std::cout << c << std::endl;
            return 0;
        }
    }
    
    std::cout << "None" << std::endl;
    
    
    // Your code here!
    
}


Measured memory_bytes: 512
#include<stdio.h>
int n,m,p,i,j,a[51],b[51],c[51][51];
int main()
{
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&a[i],&b[i]);
		c[a[i]][b[i]]++;
		c[b[i]][a[i]]++;
	}
	for(i=1;i<=n;i++){
		p=0;
		for(j=0;j<51;j++){
			p+=c[i][j];
		}
		printf("%d\n",p);
	}
	return 0;
}

Measured memory_bytes: 128
#include <climits>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

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

	for(int n, m; cin >> n >> m, n;) {
		vector<vector<int> > pos(n), danger(n);
		vector<vector<vector<int> > > dp(n, vector<vector<int> >(m + 1));
		for(int i = 0; i < n; ++i) {
			int num;
			cin >> num;

			for(int j = 0; j < m + 1; ++j)
				dp[i][j].resize(num, INT_MAX);

			for(int j = 0; j < num; ++j) {
				int x, d;
				cin >> x >> d;
				pos[i].push_back(x);
				danger[i].push_back(d);
			}
		}
		
		for(int i = 0; i < dp[0][m].size(); ++i)
			dp[0][m][i] = 0;

		for(int i = 0; i < dp[1][m - 1].size(); ++i)
			dp[1][m - 1][i] = 0;

		int ans = INT_MAX;

		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < m + 1; ++j) {
				for(int k = 0; k < dp[i][j].size(); ++k) {
					if(dp[i][j][k] == INT_MAX)
						continue;

					if(j) {
						if(i + 2 >= n)
							chmin(ans, dp[i][j][k]);
						else
							for(int l = 0; l < dp[i + 2][j - 1].size(); ++l)
								chmin(dp[i + 2][j - 1][l], dp[i][j][k] + (danger[i][k] + danger[i + 2][l]) * abs(pos[i][k] - pos[i + 2][l]));
					}

					if(i + 1 >= n)
						chmin(ans, dp[i][j][k]);
					else
						for(int l = 0; l < dp[i + 1][j].size(); ++l)
							chmin(dp[i + 1][j][l], dp[i][j][k] + (danger[i][k] + danger[i + 1][l]) * abs(pos[i][k] - pos[i + 1][l]));
				}
			}
		}

		cout << ans << endl;
	}


	return EXIT_SUCCESS;
}

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

using namespace std;

bool isprime(int d) {
  if (d == 2) return true;
  if (d <= 1 || d % 2 == 0) return false;
  for (int i = 3; i < d / 2; i += 2) if (d % i == 0) return false;
  return true;
}

int primes[100001], arr[100001];
int main(int argc, const char *argv[]) {
  for (int i = 0; i < 100001; i++) primes[i] = isprime(i);
  for (int i = 100000; i >= 2; i--) arr[i] = primes[i] & primes[(i + 1) / 2];
  for (int i = 1; i < 100001; i++) arr[i] += arr[i - 1];

  int Q, l, r;

  cin >> Q;

  for(int i = 0; i < Q; i++) {
    cin >> l >> r;
    cout << arr[r] - arr[l - 1] << endl;
  }
}


Measured memory_bytes: 1408