akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
    int i,t,u,H,W;
    for(i=0;;i+=1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        else{
            for(t=1;t<=H;t+=1){
                if(t%2==1){
                    for(u=1;u<=W;u+=1){
                        if(u%2==1){
                            if(u==W){
                                printf("#\n");
                            }
                            else{
                                printf("#");
                            }
                        }
                        else if(u%2==0){
                            if(u==W){
                                printf(".\n");
                            }
                            else{
                                printf(".");
                            }
                        }
                    }
                }
                else if(t%2==0){
                    for(u=1;u<=W;u+=1){
                        if(u%2==1){
                            if(u==W){
                                printf(".\n");
                            }
                            else{
                                printf(".");
                            }
                        }
                        else if(u%2==0){
                            if(u==W){
                                printf("#\n");
                            }
                            else{
                                printf("#");
                            }
                        }
                    }
                }
            }    
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 588
n,m = map(int,input().split())
oks = [True]*(n+1)
for i in range(m):
    a = int(input())
    oks[a] = False
dp = [0]*(n+1)
dp[0] = 1
for i in range(n+1):
    for j in range(i+1,min(n+1,i+3)):
        if oks[j]:
            dp[j] += dp[i]
            dp[j] %= 1000000007
print(dp[n])


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

int main()
{
    int N,x[400]={},y[400]={},b[400]={},p[400]={},ans=0;

    cin>>N;

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

        cin>>x[i]>>y[i]>>b[i]>>p[i];

        int A,B;
        A = x[i] * b[i] + y[i] * p[i];
        B = ( x[i] * max(b[i],5) + y[i] * max(p[i],2) ) * 0.8;

        cout<<min(A,B)<<endl;

    }

    return 0;
}


Measured memory_bytes: 3096
import itertools
import math
from collections import defaultdict

def input_ints():
    return list(map(int, input().split()))

def solve():
    n = int(input())
    ans = 0
    for x in range(1, n + 1):
        if len(str(x)) % 2 == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3568
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff, P = 1e9 + 7;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int N = 8010;
bitset <16384> f, g;
char s[N];
int sx, sy, p[2], d[2][N];
int main(){
	scanf("\n%s", s + 1);
	int now = 0, l = strlen(s + 1);
	int tmp = 1;
	while (tmp <= l && s[tmp] == 'F') tmp++;
	p[0] = 0, p[1] = 0;
	for (int i = tmp; i <= l; i++){
		if (s[i] == 'F') d[now][p[now]]++;
			else p[now ^= 1]++;
	}
	f.reset();
	f[l] = true; 
	for (int i = 1; i <= p[0]; i++)
		f = (f << d[0][i]) | (f >> d[0][i]);
	g.reset();
	g[l] = true;
	for (int i = 1; i <= p[1]; i++)
		g = (g << d[1][i]) | (g >> d[1][i]);
	int q; //read(q);
	q = 1;
	for (int i = 1; i <= q; i++){
		read(sx), read(sy);
		sx = sx - tmp + 1;
		if (abs(sx) + abs(sy) > l){
			printf("No\n");
			continue;
		}
		if (f[sx + l] == 1 && g[sy + l] == 1) 
			printf("Yes\n"); else printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 256
#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,k,s;
  cin>>n>>k>>s;
  const Int MAX = 1e9;
  if(s==MAX){
    for(Int i=0;i<n;i++){
      if(i) cout<<" ";
      if(i<k) cout<<s;
      else cout<<1;
    }
    cout<<endl;
    return 0;
  }
  for(Int i=0;i<n;i++){
    if(i) cout<<" ";
    if(i<k) cout<<s;
    else cout<<s+1;
  }
  cout<<endl;
  return 0;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	int ans = 0, mn = INT_MAX;
	for (int i = 0; i < n; ++i) {
		int v;
		cin >> v;
		mn = min(mn, v);
		if (v == mn) {
			++ans;
		}
	}
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 256
import java.io.*;


public class Main{
    public static void main(String[] args)throws IOException{
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br=new BufferedReader(isr);
	String nst = br.readLine();
	int n = Integer.parseInt(nst);
	long fact =1;
	for(int i=1;i<=n;i++)
	    fact*=i;
	System.out.println(fact);
    }
}
	    

Measured memory_bytes: 16860
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
map<string,int>sad;
int a[100005];
int main()
{
    _SAD()
    int x,a,b,cnt=0;
    cin>>x;
    for(int i=0;i<x;i++)
    {
        cin>>a>>b;
        cnt+=(b-(a-1));
    }
    cout<<cnt<<NL;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

int main(){
  string S, T; cin >> S >> T;
  int ls = S.size();
  int lt = T.size();
  int ans = 1e5;
  rep(i,ls-lt+1){
    int tans = 0;
    rep(j,lt){
      if(S[i+j] != T[j]) tans++;
    }
    ans = min(ans, tans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,0)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a)
	{
		return parent[a]!=a?parent[a]=find(parent[a]):a;
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
		}
		else
		{
			parent[b]=a;
			if(rank[a]==rank[b])rank[a]++;
		}
		return true;
	}
};
vector<pair<int,pair<int,int> > >e;
vector<pair<int,int> >G[500];
map<pair<int,int>,bool>M;
int n,m;
bool dfs(int u,int p,int to,int cost)
{
	bool flag=u==to;
	for(int i=0;i<G[u].size();i++)
	{
		if(G[u][i].first!=p)
		{
			if(dfs(G[u][i].first,u,to,cost))
			{
				if(cost==G[u][i].second)M[minmax(u,G[u][i].first)]=1;
				flag=true;
			}
		}
	}
	return flag;
}
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		a--,b--;
		e.push_back(make_pair(c,minmax(a,b)));
	}
	sort(e.begin(),e.end());
	UF uf(n);
	for(int i=0;i<m;i++)
	{
		int a=e[i].second.first,b=e[i].second.second,c=e[i].first;
		if(uf.unite(a,b))
		{
			G[a].push_back(make_pair(b,c));
			G[b].push_back(make_pair(a,c));
		}
		else
		{
			dfs(a,-1,b,c);
			M[make_pair(a,b)]=1;
		}
	}
	long long ans=0;
	int cnt=0;
	for(int i=0;i<m;i++)
	{
		if(!M[e[i].second])
		{
			cnt++,ans+=e[i].first;
		}
	}
	cout<<cnt<<" "<<ans<<endl;
}



Measured memory_bytes: 6652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int x,res,ans=0;
    cin>>x;
    for (int i=1; i<=x; i++) {
        for (int j=1; j<=100; j++) {
            for (int k=2; k<=10; k++) {
                res=pow(j,k);
                if (res<=x) ans=max(res,ans);
            }
        }
    }
    cout<<ans<<endl;
}


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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ll i,n,m,k,cnt=0,ans=0,l1,l2,rem,temp;
	cin >> n >> m >> k;
	ll a[n],b[m];
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}
	for(i=0;i<m;i++)
	{
		cin >> b[i];
	}
	vector<ll> pre1(n),pre2(m);
	pre1[0]=a[0];
	for(i=1;i<n;i++)
	{
		pre1[i]=pre1[i-1]+a[i];
	}
	pre2[0]=b[0];
	for(i=1;i<m;i++)
	{
		pre2[i]=pre2[i-1]+b[i];
	}
	ans=0;
	for(i=0;i<n;i++)
	{
		rem=k-pre1[i];
		if(rem<0)
			continue;
		temp=upper_bound(all(pre2),rem)-pre2.begin();
		ans=max(ans,i+1);
		if(temp==0)
			continue;
		// dbg(temp);
		ans=max(ans,temp+i+1);
		// dbg(ans);
	}
	//cout << endl;
	for(i=0;i<m;i++)
	{
		rem=k-pre2[i];
		if(rem<0)
			continue;
		temp=lower_bound(all(pre1),rem)-pre1.begin();
		
		ans=max(ans,i+1);
		if(temp==0)
			continue;
		ans=max(ans,temp+i+1);
		// dbg(temp);
		// dbg(ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 9536
n,m=[int(j) for j in input().split()]
dp=[10**8]*(2**n)
dp[0]=0
cost=[]
for i in range(m):
    x,y=[int(j) for j in input().split()]
    tmp=[int(j) for j in input().split()]
    ind=0
    for j in tmp:
        ind|=1<<(j-1)
    cost.append((ind,x))

for i in range(1<<n):
    for j in range(m):
        dp[i|cost[j][0]]=min(dp[i|cost[j][0]],dp[i]+cost[j][1])

if dp[-1]!=10**8:
    print(dp[-1])
else:
    print(-1)


Measured memory_bytes: 46168
using System;

    class Program
    {
      static void Main(string[] args)
      {
        var line = Console.ReadLine();
        char[] check = { 'A', 'C' };

        for (int i = 0; i < line.Length; i++)
        {
            if (line[i] == check[0]) {
                if (line[i + 1] == check[1])
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }

        Console.WriteLine("No");
        return;

      }
    }

Measured memory_bytes: 11092
#include <set>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int n,u,v,low[2020],sz[2020],accu[2020];
vector<int> G[2020];
char s[2020];
void test(int num,int fa = -1){
	low[num] = 0;sz[num] = 0;accu[num] = 0;
	int csu = 0,cmx = 0,mxid = -1;
	for(auto ct:G[num]){
		if(ct == fa)continue;
		test(ct,num);
		csu+=low[ct]+sz[ct];
		if(low[ct]+sz[ct]>cmx){
			mxid = ct;
			cmx = low[ct]+sz[ct];
		}
		accu[num] = accu[num]+accu[ct]+sz[ct];
		sz[num]= sz[num]+sz[ct];
	}
	csu%=2;
	for(auto ct:G[num]){
		if(ct == fa)continue;
		if(ct!=mxid){
			cmx-=accu[ct]+sz[ct];
		}
	}
	low[num] = max(cmx,csu);
	sz[num] += s[num]-'0';
//	cout<<num<<' '<<low[num]<<' '<<accu[num]<<' '<<sz[num]<<endl;;
}
int main() {
	cin>>n>>(s+1);
	for(int i=1;i<n;i++){
		read(u);read(v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int ans = 10000000;
	for(int i=1;i<=n;i++){
		test(i);
		//cout<<low[i]<<endl;
		if(low[i] == 0){
			ans = min(ans,accu[i]/2);
		}
	}
	if(ans == 10000000)ans = -1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

void solve(int idx, vector< vector< tuple< int, int > > >& path, vector< bool >& v) {
  if (v[idx]) return;
  v[idx] = true;
  for (auto c : path[idx]) {
    int ci=get<0>(c);
    int cz=get<1>(c);
    solve(ci, path, v);
  }
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  vector< vector< tuple< int, int > > > path(n, vector< tuple< int, int > >(0));
  for (int i=0; i<m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    path[x].push_back(make_tuple(y, z%2));
    path[y].push_back(make_tuple(x, z%2));
  }
  vector< bool > v(n, false);
  int cost = 0;
  for (int i=0; i<n; ++i) {
    if (v[i]) continue;
    cost++;
    solve(i, path, v);
  }
  cout << cost << endl;
  return 0;
}


Measured memory_bytes: 10496
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> T(N);
    for (ll i = 0; i < N; i++) {
        cin >> T[i];
    }

    ll sum = accumulate(T.begin(), T.end(), (ll)0);

    ll M;
    cin >> M;
    vector<ll> P(M), X(M);
    for (ll i = 0; i < M; i++) {
        cin >> P[i] >> X[i];
        P[i]--;

        cout << sum - T[P[i]] + X[i] << endl;
    }
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
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(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...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL fac[SIZE],inv[SIZE];
LL mypow(LL x,LL y){
    LL res=1;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
LL C(int x,int y){
    if(y<0||y>x)return 0;
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
void build(){
    assert(MOD>=SIZE);
    fac[0]=1;
    REPP(i,1,SIZE)fac[i]=fac[i-1]*i%MOD;
    REPP(i,1,SIZE)inv[i]=mypow(i,MOD-2);
}
LL AA[SIZE];
int main(){
    build();
    int n; R(n);
    LL ans=0;
    LL now=fac[n];
    FOR(i,2,n){
        ADD(now,fac[n]*inv[i]);
    }
    FOR(i,1,n){
        R(AA[i]);
        ADD(ans,now*AA[i]);
        ADD(now,-fac[n]*inv[n-i+1]);
        ADD(now,fac[n]*inv[i+1]);
    }
    W(ans);
    return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        string S; cin >> S;
        vector<int> E(N + 1), W(N + 1);
        rep(i, N) E[i + 1] = E[i] + (S[i] == 'E');
        rep(i, N) W[i + 1] = W[i] + (S[i] == 'W');
        int ans = N;
        rep(i, N) {
            int sum = W[i] - W[0] + E[N] - E[i + 1];
            set_min(ans, sum);
        }
        cout << ans << endl;
        return 0;
    }
};

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


Measured memory_bytes: 2964
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
    ld a, b;
    cin >> a >> b;
    cout << (int)(a*b);
}



















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

int main(){
    ll n;
    ll k;
    cin>>n>>k;
    vector<pair<ll,ll>>c(n);
    rep(i,n)cin>>c[i].first>>c[i].second;
    sort(c.begin(),c.end());

    for(int i=1;i<n;i++)c[i].second=c[i-1].second+c[i].second;
    
    ll ans=c[0].first;

    for(int i=0;i<n;i++){
        if(c[i].second>=k){
            ans=c[i].first;
            break;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1792
s = raw_input()
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        print i+1,i+2
        exit(0)
for i in xrange(len(s)-2):
    if s[i]==s[i+2]:
        print i+1,i+3
        exit(0)
print-1,-1

Measured memory_bytes: 5892
#include<bits/stdc++.h>
using namespace std;
void solve();
int main()
{
//	freopen("SNOOKER.inp","r",stdin);
//	freopen("SNOOKER.out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}
/*----------------------------------------------------------------------
 
-----------------------------------------------------------------------*/
using ll =  long long;
#define endl "\n"
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define what_is(x)  cerr << #x << " is :" << (x) << endl
const int MOD =  1e9+7;
const ll inf = LLONG_MAX;
const int MAX_N = 1e5 + 7;

int n,k;

ll a[MAX_N], dp[MAX_N];
void solve()
{
	fill(dp,dp+MAX_N,inf);
	cin >> n >> k;
	for(int i = 1; i <= n ; i++)
	{
		cin >> a[i];
	}
	
	dp[0] = dp[1] = 0;
	dp[2] = abs(a[2]-a[1]);
	for(int i = 3; i <= n; i ++)
	{
		for(int j = 1; j <= k && i-j > 0; j++)
			dp[i] = min(	abs(a[i]-a[i-j] )+ dp[i-j], 
							dp[i]
					);
	}
	
	cout << dp[n] ;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll x, y;
    cin >> x >> y;
    
    if(abs(x-y) <= 1) {
        out("Brown");
    }
    else {
        out("Alice");
    }

    re0;
}

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

ll solve() {
    ll A, B, M;
    cin >> A >> B >> M;
    vector<ll> PA(A), PB(B);
    ll ma = 1e8, mb = 1e8;
    for ( int i = 0; i < A; i++ ) {
        cin >> PA[i];
        ma = min(ma, PA[i]);
    }
    for ( int i = 0; i < B; i++ ) {
        cin >> PB[i];
        mb = min(mb, PB[i]);
    }
    ll ans = ma + mb;
    ll x, y, c;
    for ( int i = 0; i < M; i++ ) {
        cin >> x >> y >> c;
        x--, y--;
        ans = min( ans, PA[x] + PB[y] - c);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i], a[i]--;

    vector<int> ql(q), qr(q), qi(q);
    rep(i, q) cin >> ql[i] >> qr[i], ql[i]--;
    iota(qi.begin(), qi.end(), 0);

    int width = n / sqrt(q);
    sort(qi.begin(), qi.end(), [&](int i, int j) {
        if (ql[i] / width != ql[j] / width) return ql[i] < ql[j];
        return qr[i] < qr[j];
    });

    vector<int> cnt(n), ans(q);
    int sum = 0;
    int l = 0, r = 0;

    auto add = [&](int i) { if (cnt[a[i]]++ == 0) sum++;};
    auto del = [&](int i) { if (--cnt[a[i]] == 0) --sum;};
    
    for (int i : qi) {
        while (ql[i] < l) add(--l);
        while (r < qr[i]) add(r++);
        while (l < ql[i]) del(l++);
        while (qr[i] < r) del(--r);
        ans[i] = sum;
    }
    
    rep(i, q) cout << ans[i] << endl;
}


Measured memory_bytes: 15476
#include <bits/stdc++.h>
#define int long long int
#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define MOD1 1e9 + 7
#define MOD2 998244353
#define f first
#define s second
#define endl '\n'
#define pii pair<int, int>
#define piii pair<pii, int>
#define precise(i) cout << fixed << setprecision(i)
#define codejam cout << "Case #" << ii + 1 << ": ";
#define impossible cout << "IMPOSSIBLE" << endl;
#define error(s) throw runtime_error(s)
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R){int val=rng()%R;assert(val >= 0);return val;}

const long double PI = atan(1.0) * 4;
const int64_t INF64 = 3e18;
const int32_t INF32 = 2e9 + 7;
const int32_t LOG = 21;
const int32_t MOD = MOD1;

using namespace std;


//-------------------DEBUGGING-------------------------
void my_debugger(string s,int LINE_NUM){cerr<<endl;}
template<typename start,typename... end>
void my_debugger(string s,int LINE_NUM,start x,end... y) 
{
    if(s.back()!=',') {s+=',';cerr<<"LINE("<<LINE_NUM<<"): ";}
    int i=s.find(',');
    cerr<<s.substr(0,i)<<" = "<<x;
    s=s.substr(i+1);
    if(!s.empty()) cerr<<", ";
    my_debugger(s,LINE_NUM,y...);
}

#ifdef AJIT
#define debug(...) my_debugger(#__VA_ARGS__,__LINE__,__VA_ARGS__);
#else
#define debug(...) ;
#endif

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


int32_t main()
{
      getFaster;
      //files_init();
      int tests = 1;
      //cin >> tests;
      rep(ii, 0, tests)
      {
            int MOD=MOD1;
            int n;
            cin>>n;
            int num=1,num1=1,num2=1;
            rep(i,1,n+1)
            {
                  num1=num1*10;
                  num1%=MOD;
            }
            rep(i,1,n+1)
            {
                   num2=num2*9;
                   num2%=MOD;
            }
            rep(i,1,n+1)
            {
                  num=num*8;
                  num%=MOD;
            }

            int ans=(num1-2*num2+num)%MOD;
            ans=(ans+MOD)%MOD;
            cout<<ans<<endl;
            
      }
      return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>

int main(){
  long long x;
  scanf("%lld",&x);
  
  for(long long a=0;a>=0;a++){
    if(a<64){
      for(long long b=-64;b<a;b++){
        if(a*a*a*a*a-b*b*b*b*b==x){printf("%lld %lld",a,b);return 0;}
        if(a*a*a*a*a-b*b*b*b*b-x<0){break;}
      }
    }
    if(a>=64){
      for(long long b=1;b<=2*a;b++){
        if(a*a*a*a*a-b*b*b*b*b==x){printf("%lld %lld",a,b);return 0;}
        if(a*a*a*a*a-b*b*b*b*b-x<0){break;}
      }
    }
  }
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	map<string, int> mp;
	int n;
	cin >> n;
	rep(i, n) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;

}

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

	solve();
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;

void PUNKS_NOT_DEAD() {
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1];
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    PUNKS_NOT_DEAD();
}


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

int main()
{
  int s;
  cin >> s;
  int ld = s % 10 + ((s / 10) % 10) * 10;
  s /= 100;
  int ud = s % 10 + ((s / 10) % 10) * 10;
  string result;
  result = (ld > 0 && ld <= 12)? ((ud > 0 && ud <= 12)? "AMBIGUOUS" : "YYMM") : "MMYY";
  if(ld == 0 && (ud == 0 || ud > 12) || ud == 0 && ld > 12 || ld > 12 && ud > 12)
    result = "NA";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

long long int gcm(long long a,long long b){
	long long r,tmp;
	if(a<b){
		tmp=a;
		a=b;
		b=tmp;
	}
	
	r=a%b;
	while(r!=0){
		a=b;
		b=r;
		r=a%b;
	}
	return b;
}

int main(){
	long long N,M,ans;
	scanf("%lld%lld",&N,&M);
	char S[N+1],T[M+1];
	scanf("%s",S);
	scanf("%s",T);
	
	long long g=gcm(N,M);
	ans=N/g*M;
	for(long long i=0;i<g;i++){
		if(S[N/g*i]!=T[M/g*i])ans=-1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


void smain() {

    int k,a,b;
    cin>>k>>a>>b;
    if(b<=a+1){
        cout<<k+1;
        return;
    }

    int cur=1;
    int u=min(a-1,k);
    k-=u;
    cur+=u;

    int y=k/2;
    cur+=y*(b-a);
    if(k&1)
        cur++;

    cout<<cur;





}

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

#define debug(x) cerr << #x <<" = " << x << endl;

const int MAX = 1e5 + 100;
int h[MAX], dp[MAX], k;

int dp_solve(int idx)
{
	if(idx == 0) return 0;
	int &ans = dp[idx];
	if(~ans) return ans;
	ans = INT_MAX;
	for(int i = idx-1; i >= max(0, idx-k); i--)
		ans = min(ans, dp_solve(i) + abs(h[i] - h[idx]));
	return ans;
}

int main()
{
	int n;
	scanf("%d %d", &n, &k);
	for(int i = 0; i < n; i++)
		scanf("%d", h + i);

	memset(dp, -1, sizeof dp);
	printf("%d\n", dp_solve(n-1));
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  string t;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '1'){
      t.push_back('1');
    }else if(s[i] == '0'){
      t.push_back('0');
    }else{
      if(t.size() != 0){
        t.pop_back();
      }
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 3608
//master
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        String t = sc.next();

        String sl = s+s;

        if(sl.contains(t)) p("Yes");
        else p("No");
        return;
        
    }

    public static <T> void p(T message) {
        System.out.println(message);
    }

    public static <T> void pe(T message) {
        System.err.println(message);
    }

    public static <T> void pp(T message) {
        System.out.print(message);
    }
    
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 37120
N, T = map(int, input().split())
lst_t = list(map(int, input().split()))
ans = 0


for i in range(N - 1):
    s, t = lst_t[i], lst_t[i+1]
    interval = t - s
    if interval < T:
        ans += interval
    else:
        ans += T
ans += T


print(ans)

Measured memory_bytes: 26708
unittest
{
	assert( [ "8" ].parse.expand.solve == 10 );
	assert( [ "1000000000000" ].parse.expand.solve == 2499686339916 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	auto ans = 0L;
	for( auto d = 1L; d <= n ^^ 0.5L; d++ )
	{
		// n / m == d になるmの範囲を計算
		auto l = n / ( d + 1 );
		auto r = n / d;
		
		// n % m == d になるmを二分探索
		auto m = ( l + r ) / 2;
		while( l < m && m < r )
		{
			auto a = n % m;
			if( a == d )
			{
				ans += m;
				break;
			}
			if( a < d ) r = m;
			else        l = m;
			m = ( l + r ) / 2;
		}
	}
	return ans;
}


Measured memory_bytes: 256
Module Module1

    Sub Main()
        'let'
        Dim N As Long = Console.ReadLine()
        Dim a() As Long =
            Array.ConvertAll(Of String, Long)(Console.ReadLine.Split(), AddressOf Long.Parse)

        Array.Sort(a)

        'var'
        Dim ans As Long = 0

        For i As Long = 0 To N - 1
            ans += New Long() {-1, 1}(i Mod 2) * a(i)
        Next

        Console.WriteLine(Math.Abs(ans))

    End Sub

End Module

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int N,M,Q;
  cin>>N>>M>>Q;
  vector<vector<int>> A(N+1, vector<int>(N+1, 0));
  for(int i=0; i<M; i++){
    int l,r;
    cin>>l>>r;
    A[l][r]++;
  }
  for(int i=0; i<Q; i++){
    int p,q,ans=0;
    cin>>p>>q;
    if(p==1 && q==N)
      cout<<M<<endl;
    else{
      for(int i=p; i<=q; i++){
        for(int j=p; j<=q; j++){
          ans+=A[i][j];
        }
      }
      cout<<ans<<endl;
    }
  }  
}


Measured memory_bytes: 1920
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;

int a,b,c,d;
int main(){
    scanf("%d %d %d %d", &a,&b,&c,&d);
    if((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d)printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define chmax(x, y) x = max(x,y);

int main(){

int n,t;
cin>>n>>t;
vector <pair<int,int>> a(n);

for (int i=0; i<n; i++){
  int a1,b1;
  cin>>a1>>b1;
  a[i]=make_pair(a1,b1);
}
vector <vector<int>> dp(3001, vector<int> (3001, 0));


for (int i=0; i<n; i++){
  for (int j=0; j<t; j++){
    int anow, bnow;
    anow=a[i].first;
    bnow=a[i].second;

  }
}
int ans=0;

sort(a.begin(), a.end());
for (int i=0; i<n; i++){
  for (int j=0; j<t; j++){
     chmax(dp[i+1][j],dp[i][j]);
     if (j+a[i].first<t){
       chmax(dp[i+1][(j+a[i].first)],dp[i][j]+a[i].second);

     }
   }

   
   chmax(ans,(dp[i][t-1]+a[i].second));
}


  cout<<ans;
}


Measured memory_bytes: 35584
a, b, n, m = [int(i) for i in input().split()]

def gcd(p,q):
  while q!=0:
    p,q=q,p%q
  return p

def lcm(p,q):
  return p*q//gcd(p,q)

nm = lcm(n, m)

def count(k):
    min_cand = a // k if a % k == 0 else a // k + 1
    if b < min_cand * k:
        return 0
    max_cand = b //k
    if max_cand * k < a:
        return 0

    return max_cand - min_cand + 1

size = count(n) + count(m) - count(nm)

print(b - a + 1 - size)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "

const int N = 1e5+1;
int p[N], n, m;
void init()
{
  for (int i = 1; i <= n; ++i) p[i] = i;
}
int pa(int x)
{
  return x==p[x]?x:p[x]=pa(p[x]);
}
bool merge(int x, int y)
{
  x = pa(x), y = pa(y);
  if (x != y)
    {
      p[x] = y;
      return true;
    }
  return false;
}
vector<int> g[N];
int cnt[N];
int tot = 0;
vector<ii> ans;
void answer(int u, int v)
{
  ++cnt[u];
  ans.pb(mp(u, v));
  ++tot;
}
void dfs(int cur, int p)
{
  for (auto nxt : g[cur])
    if (nxt != p)
      dfs(nxt, cur);
  if ((cnt[cur]%2) == 1)
    {
      assert(p);
      answer(cur, p);
    }
  else
    {
      if (p) answer(p, cur);
    }
}
  
int main()
{
  memset(cnt, 0, sizeof(cnt));
  scanf("%d %d", &n, &m);
  init();
  for (int i = 1; i <= m; ++i)
    {
      int u, v; scanf("%d %d", &u, &v);
      if (merge(u, v)) g[u].pb(v), g[v].pb(u);
      else answer(u, v);
    }
  for (int i = 1; i <= n; ++i) if (pa(i) != pa(1)) assert(false);
  if ((m%2) == 1)
    {
      puts("-1");
      return 0;
    }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) assert((cnt[i]%2) == 0);
  assert(tot == m);
  for (auto e : ans)
    printf("%d %d\n", e.first, e.second);
}


Measured memory_bytes: 12532
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int n;
struct P { double x,y;};
vector<P> p;

double dist(P a, P b){ //2点間の距離を求める関数
  double dx = a.x-b.x;
  double dy = a.y-b.y;
  return sqrt(dx*dx + dy*dy);
}

double f(double x, double y){
  double res = 0;
  rep(i,n){
    res = max(res, dist((P){x,y}, p[i])); //与えられたx,y座標から最も遠い点までの距離を探索
  }
  return res; //与えられたx,yで全ての点を包含できる半径
}

double g(double x){//xを決め打った時に半径を最小化できるyを探す
  double l = 0, r = 1000;
  rep(i,80){
    double c1 = (l*2 + r)/3;
    double c2 = (l + r*2)/3;
    if(f(x,c1)>f(x,c2)) l = c1;
    else r = c2;
  }
  return f(x,l); //その時の半径を返す
}

int main(){
  cin >> n;
  p = vector<P>(n);
  rep(i,n) cin >> p[i].x >> p[i].y;
  
  double l = 0, r = 1000;
  rep(i,80){
    double c1 = (l*2 + r)/3;
    double c2 = (l + r*2)/3;
    if(g(c1)>g(c2)) l = c1; //
    else r = c2;
  }
  
  double ans = g(l);
  printf("%.10f\n",ans);
  
  return 0;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}
int32_t main(){
	fast;
	int n,k;
	cin >> n >> k;
	int ans = 0;
	int dp[k + 5] = {0};

	for(int i=1  ; i<=k ; i++){
		int t = k/i;
		int pos = pow(t , n , MOD);
		// pos = (pos * i)%MOD;
		dp[i] = pos;
	}
	for(int i=k ; i>=2 ; i--){
		for(int j=1 ; j*j <= i ; j++){
			if(i % j == 0){
				dp[j] = (dp[j] - dp[i] + MOD)%MOD;
				if(j * j != i && j != 1)
					dp[i/j] = (dp[i/j] - dp[i] + MOD)%MOD;
			}
		}
	}
	for(int i=1;  i<=k ; i++){
		ans = (ans + dp[i]*i)%MOD;
	}
	cout << ans;
}

Measured memory_bytes: 4424
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef long double ld;

const int maxN = 3e3 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

int n, i, j;
ld dp[maxN][maxN], p[maxN], sum; 

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	dp[0][0] = 1.0;
	for (i = 1; i <= n; i++){
		cin >> p[i];
		dp[i][0] = dp[i - 1][0] * (1.0 - p[i]);
		dp[0][i] = 0;
	}
	for (i = 1; i <= n; i++){
		for (j = 1; j <= n; j++){
			dp[i][j] = (dp[i - 1][j - 1] * p[i]) + (dp[i - 1][j] * (1.0 - p[i]));
		}
	}
	for (i = n; 2 * i > n; i--){
		sum += dp[n][i];
	}
	cout << fixed << setprecision(10);
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 141184
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int Search(int x, int y, vector<string> &d) {
	if (y == d.size() - 1 && x == d[0].size() - 1)
		return true;
	if (x < d[0].size() - 1 && d[y][x + 1] == '#') {
		if (y < d.size() - 1 && d[y + 1][x] == '#')
			return false;
		if (y > 0 && d[y - 1][x + 1] == '#')
			return false;
		return Search(x + 1, y, d);
	}
	if (y < d.size() - 1 && d[y + 1][x] == '#'){
		if (x > 0 && d[y + 1][x - 1] == '#')
			return false;
		return Search(x, y + 1, d);
	}
	else
		return false;
}

int main(void) {
	int h, w, i;
	cin >> h >> w;
	vector<string> d(h);
	for (i = 0; i < h; i++)
		cin >> d[i];
	if (Search(0, 0, d))
		printf("Possible\n");
	else
		printf("Impossible");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	double a, b, h, m; cin >> a >> b >> h >> m;
	double rad = 2 * PI * ((h / 12.0) + (m / 60.0 / 12.0) - (m / 60.0));
	double c = (a * a) + (b * b) - (2 * a * b * cos(rad));
	printf("%.20f", sqrt(c));
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4228
use proconio::input;

fn main() {
    input! {
        mut a: i64,
        b: i64,
        mut c: i64,
        d: i64,
    }

    while a > 0 && b > 0 {
        c -= b;
        a -= d;
    }

    if c <= 0 {
        println!("Yes");
    } else {
        println!("No");
    }

}


Measured memory_bytes: 2112