akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
	
	public static void main(String[] args){
		
		Scanner sn = new Scanner(System.in);
		int i = 0;
		int N = 0;
		int D = 0;
        String str = sn.nextLine();
		try{
			String[] strlist = str.split(" ",0);
			N = Integer.parseInt(strlist[0]);
			if(N<1 || N > 20){
				System.out.println("error1");
				return;
			}
			D= Integer.parseInt(strlist[1]);
			if(D<1 || D>20){
				System.out.println("error2");
				return;
			}
		}catch(Exception e){
			System.out.println("error3");
			return;
		}
		sn.close();
		if(N%(2*D+1)==0){
			System.out.println(N/(2*D+1) );
		}else{
			System.out.println(N/(2*D+1) + 1);
		}
	}
}

Measured memory_bytes: 23892
import sys
readline = sys.stdin.readline
write = sys.stdout.write

from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]
        self.D = {}

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)
        self.D[fr, to] = forward

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**9 + 7
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow

def solve():
    N, M, S, T = map(int, readline().split())
    if N == M == 0:
        return False
    S -= 1; T -= 1
    E = []
    INF = 10**9
    dinic = Dinic(N)
    for i in range(M):
        a, b = map(int, readline().split()); a -= 1; b -= 1
        dinic.add_edge(a, b, 1)
        E.append((a, b))
    f = dinic.flow(S, T)

    used = [0]*N
    que = deque([S])
    used[S] = 1
    while que:
        v = que.popleft()
        for w, cap, _ in dinic.G[v]:
            if cap == 0 or used[w]:
                continue
            used[w] = 1
            que.append(w)
    que = deque([T])
    used[T] = 2
    while que:
        v = que.popleft()
        for w, cap, _ in dinic.G[v]:
            if cap > 0 or used[w]:
                continue
            used[w] = 2
            que.append(w)
    cnt = 0
    for a, b in E:
        if used[a] == 2 and used[b] == 1:
            cnt += 1
    if cnt:
        write("%d %d\n" % (f+1, cnt))
    else:
        write("%d %d\n" % (f, 0))
    return True
while solve():
    ...


Measured memory_bytes: 14484
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < n; i++)
 
using namespace std;
using ll = long long;
 
void solve();
 
int main(void){
    int N, Q;
    cin >> N >> Q;
    vector<int> edge[N];
    int val[N] = {0};
    int decide[N] = {0};
    rep(i, N-1){
        int a, b;
        scanf("%d%d", &a, &b);
        edge[a-1].push_back(b-1);
        edge[b-1].push_back(a-1);
    }
    rep(i, Q){
        int n, v;
        scanf("%d%d", &n, &v);
        val[n-1] += v;
    }
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int op = q.front();
        q.pop();
        while(!edge[op].empty()){
            auto a = edge[op].end();
            a--;
            edge[op].pop_back();
            if(decide[*a] == 0){
                val[*a] += val[op];
                q.push(*a);
            }
        }
        decide[op] = 1;
    }
    rep(i, N){
        if(i == N-1) printf("%d\n", val[i]);
        else printf("%d ", val[i]);
    }
    return 0;
}
 
void solve(){}

Measured memory_bytes: 16372
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
ll size = 100010;


int main(){
 ll n;
 cin>>n;
 ll res=0;
 vector<ll> c(size,0);
 for(ll i=0;i<n;i++){
  ll a,b;
  cin>>a>>b;
  c[a]++;
  c[b+1]--;
 }
 for(ll i=1;i<size;i++){
  c[i] += c[i-1];
 }
 for(ll i=0;i<size;i++){
  if( c[i] +1 >= i ) res = i-1;
 }
 cout<<res<<endl;

    return 0;
}



Measured memory_bytes: 3580
#include <iostream>
using namespace std;
using lint = long long int;

int main() {
	lint N;
	lint temptrans;
	lint mintrans = 1e16;
	lint ans = 0;
	
	cin >> N;
	for(int i=0;i<5;i++){
		cin >> temptrans;
		mintrans = min(mintrans, temptrans);
	}
	
	ans = 4 + N/mintrans + (N%mintrans != 0);
	
	cout << ans << "\n";
	
	return 0;
}

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

using namespace std;

signed main(){

   int a, b, c;
   cin>> a>> b>> c;

   int t=0;
   int T=0;
   int used[61]={0};
   while(1){
      int n=(t+a)%60;
      if(t<n){
         if(t<=c&&c<=n){
            cout<< T+(c-t)<< endl;
            return 0;
         }
      }else{
         if(t<=c){
            cout<< T+(c-t)<< endl;
            return 0;
         }else if(c<=n){
            cout<< T+(60-t)+c<< endl;
            return 0;
         }
      }
      T+=(a+b);
      t=(n+b)%60;
      if(used[t]){
         cout<< -1<< endl;
         return 0;
      }
      used[t]=1;
   }

   return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    string s;cin>>s;
    int n = s.size()-1;
    vector<int> a(n+1);
    rep(i,n+1) a[i]=s[i]-'0';

    vector<string> op(n);
    for(int i = 0;i<(1<<n);i++){
        int sum = a[0];
        for(int j = 0;j<n;j++){
            if(i & (1<<j)){
                op[j]="+";
                sum+=a[j+1];
            }else{
                op[j]="-";
                sum-=a[j+1];
            }
        }
        if(sum==7) break;
    }

    rep(i,n){
        cout<<a[i]<<op[i];
    }
    cout<<a[n]<<"=7"<<endl;


}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,x,num,minn=1000000000;
    ll sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        sum+=abs(x);
        if(x<0)num++;
        minn=min(minn,abs(x));
    }
    if(num%2)
    {
        printf("%lld\n",sum-2*minn);
    }
    else
        printf("%lld\n",sum);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 100005
const ll inf=1e9+7;
#define pb push_back
void solve();
int main()
{
	ios_base::sync_with_stdio(false);
	cout<<fixed;
	cout<<setprecision(10);
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}
ll h,w,i,j,k;

void solve()
{
	ll x1,y1,x2,y2;
	cin>>h>>w>>k;
	cin>>x1>>y1>>x2>>y2;
	ll dp[h+1][w+1];
	char arr[h+1][w+1];
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		{
			cin>>arr[i][j];
			dp[i][j]=inf;
		}
	}
	ll cnt[h+1][w+1];
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=k;j++)
		cnt[i][j]=0;
	}
		
		
	dp[x1][y1]=0;
	deque<pair<ll,ll>> s;
	s.push_back({x1,y1});
	while(!s.empty())
	{
		pair<ll,ll> p=s.front();
		s.pop_front();
		ll currx=p.first;
		ll curry=p.second;
		
		for(i=currx+1;i<=min(h,currx+k);i++)
		{
						if(dp[i][curry]==inf){

			if(arr[i][curry]=='@')
			break;
			dp[i][curry]=min(dp[i][curry],dp[currx][curry]+1);
			s.push_back({i,curry});}
			else
			{
				if(cnt[i][curry]==4)
				break;
				cnt[i][curry]++;
			}
		}
		for(i=currx-1;i>=max(1LL,currx-k);i--)
		{
						if(dp[i][curry]==inf){

			if(arr[i][curry]=='@')
			break;
			dp[i][curry]=min(dp[i][curry],dp[currx][curry]+1);
			s.push_back({i,curry});}
			else
			{
				if(cnt[i][curry]==4)
				break;
				cnt[i][curry]++;
			}
		}
		for(i=curry+1;i<=min(w,curry+k);i++)
		{
						if(dp[currx][i]==inf){
			if(arr[currx][i]=='@')
			break;
			dp[currx][i]=min(dp[currx][i],dp[currx][curry]+1);
			s.push_back({currx,i});}
			else
			{
				if(cnt[currx][i]==4)
				break;
				cnt[currx][i]++;
			}
		}
		for(i=curry-1;i>=max(1LL,curry-k);i--)
		{
			if(dp[currx][i]==inf)
			{
			if(arr[currx][i]=='@')
			break;
		
			dp[currx][i]=min(dp[currx][i],dp[currx][curry]+1);
			s.push_back({currx,i});
			}
			else
			{
				if(cnt[currx][i]==4)
				break;
				cnt[currx][i]++;
			}
		}
	}
	/*
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		cout<<dp[i][j]<<" ";
		cout<<endl;
	}
	*/
	
		if(dp[x2][y2]==inf)
		cout<<-1;
		else
		cout<<dp[x2][y2];
}
		
//BORA BITCH IM COMING FOR YOU!!!	
	
	
	
	
	
	
	
	

	
	


Measured memory_bytes: 21852
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

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

	string S;
	lli zero=0, ichi=0;
	cin >> S;
	for(int k = 0; k < S.length(); k++){
		if(S[k] == '0') zero++;
		else if(S[k] == '1') ichi++;
	}

	cout << min(zero, ichi) * 2;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

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

int main(){
    int h,w,k;cin>>h>>w>>k;
    int a[h][w];
    P p;
    rep(i,h){
        string s;cin>>s;
        rep(j,w){
            if(s[j]=='.'){
                a[i][j]=0;
            }
            else if(s[j]=='S'){
                a[i][j]=0;
                p=P(i,j);
            }
            else a[i][j]=-1;
        }
    }
    queue<P> q;
    q.push(p);
    vector<P> cand;
    while(q.size()){
        P t=q.front();q.pop();
        cand.push_back(t);
        if(a[t.first][t.second]>=k)continue;

        rep(i,4){
            int newy = t.first + dy[i];
            int newx = t.second + dx[i];
            if(newy<0)continue;
            if(newy>=h)continue;
            if(newx<0)continue;
            if(newx>=w)continue;
            if(a[newy][newx]!=0&&a[newy][newx]<=a[t.first][t.second]+1)continue;
            a[newy][newx]=a[t.first][t.second]+1;
            q.push(P(newy,newx));
        }

    }
    int res=1e9+7;

    for(auto au:cand){
        //cout<<au.first<<" "<<au.second<<endl;
        int miny=min(au.first,h-1-au.first);
        int minx=min(au.second,w-1-au.second);
        chmin(res,min(miny,minx));
    }
    //cout<<res<<endl;
    cout<<1+(res+k-1)/k<<endl;
}

Measured memory_bytes: 12396
#include <bits/stdc++.h>
#define ll long long
#define xx first
#define yy second
using namespace std;
int main () {
	#ifdef wll
	freopen ("testdata.in", "r", stdin);
	#endif
	ll s;
	scanf ("%lld", &s);
	ll l = 1, r = 1000000000;
	while (l < r) {
		ll mid = (l + r) / 2;
		if (mid * mid == s) {
			printf ("%lld %lld %lld %lld %lld %lld\n", 0, mid, mid, 0, 0, 0);
			return 0;
		}
		else if (mid * mid > s) {
			r = mid;
		}
		else {
			l = mid + 1;
		}
	}
	ll tmp = l * l - s;
	if (tmp <= l) {
		ll k = tmp;
		printf ("%lld %lld %lld %lld %lld %lld\n", l, l, 0LL, l - 1LL, l - tmp, 0LL);
	}
	else {
		ll x = s + 2 * l - l * l;
		printf ("%lld %lld %lld %lld %lld %lld\n", l, l - 1LL, 0LL, l - 2LL, x, 0LL);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{   
public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c =scanner.nextInt();
        if(a%b==0)
        {
            System.out.println((a/b)*c);
        }else 
        {
            System.out.println(((a/b)+1)*c);
        }
    }
}

Measured memory_bytes: 35792
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

#define ABS(x) ((x)<0 ? -(x) : (x))

#define MAXN 625+1
#define MAXD 25

int gaussjordan(int **A, int M, int N) {
	int i, j, k;

	int RANK = M;
	for (i=0; i<M; i++) {
		//Busco una fila con un 1 en la columna i
		for (k=i; k<M; k++) {
			if (A[k][i] == 1) break;
		}

		//Si no la encuentro
		if (k == M) {
			RANK--;
			continue;
		}

		//Si la encuentro, pasa a ser la fila i
		for (j=0; j<N; j++) swap(A[i][j], A[k][j]);

		for (k=0; k<M; k++) {
			if (k != i && A[k][i] == 1) {
				for (j=i; j<N; j++) {
					A[k][j] = ((A[k][j] - A[i][j])%2 + 2)%2;
				}
			}
		}
	}
	return RANK;
}

int main() {

//freopen("in.txt", "r", stdin);

int i, j, k, l, N, n[MAXD][MAXD], a[MAXN][MAXN], *aa[MAXN], R, C, K;
bool flag;

for (i=0; i<MAXN; i++) aa[i] = a[i];

cin >> C;
cin >> R;
cin >> K;

do {

N = 0;
for (i=0; i<R; i++) {
	for (j=0; j<C; j++) {
		n[i][j] = N++;
	}
}

memset(a, 0, sizeof(a));
for (i=0; i<R; i++) {
	for (j=0; j<C; j++) {
		cin >> a[n[i][j]][N];
		a[n[i][j]][n[i][j]] = 1;

		for (k=0; k<R; k++) {
			for (l=0; l<C; l++) {
				if (ABS(i-k) + ABS(j-l) == K) {
					a[n[i][j]][n[k][l]] = 1;
				}
			}
		}
	}
}

/*for (i=0; i<N; i++) {
	for (j=0; j<N; j++) {
		cout << a[i][j] << ' ';
	}
	cout << endl;
}*/

gaussjordan(aa, N, N+1);

flag = true;
for (i=0; i<N && flag; i++) {
	for (j=0; j<N; j++) {
		if (a[i][j] == 1) break;
	}
	if (j==N && a[i][N]==1) flag = false;
}
if (flag) cout << 1 << endl;
else cout << 0 << endl;

cin >> C;
cin >> R;
cin >> K;

} while (R!=0 || C!=0 || K!=0);

return 0;
}

Measured memory_bytes: 2400
/**
 *
 * AtCoder Beginner Contest 101 - Problem A: Eating Symbols Easy (https://abc101.contest.atcoder.jp/tasks/abc101_a)
 *
 * Abridge version.
 *
 * Solution: text
 */
#include <iostream>

using namespace std;

void solve(const string& S)
{
    int ans = 0;

    for (const auto& c : S)
        ans += (c == '+' ? 1 : -1);

    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    string S;
    cin >> S;

    solve(S);

    return 0;
}


Measured memory_bytes: 256
///------------------  CODE FOR FUN -------------------
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i = j; i <= k; i ++)
#define FORD(i,j,k) for(int i = j; i >= k; i --)
#define mp make_pair
//#define f first
//#define s second
//#define int long long
using namespace std;

const int MOD=1e9+7;
const int N = 200005;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    #define task""
//    freopen(task".inp","r",stdin);
//    freopen(task".out","w",stdout);
    FOR(i, 1, 5)
    {
        int x;
        cin >> x;
        if(x == 0) cout << i;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7L;

char w[105];
int cnt[30];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>w;

int n=0;
for(n=0; w[n]!='\0'; ++n);
for(int i=0; i<n; i++){
	int c=w[i]-'a';
	cnt[c]++;
}

for(int i=0; i<27; i++){
	if(cnt[i]%2){
		cout<<"No"<<endl;
		return 0;
	}
}

cout<<"Yes"<<endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;


void make_comb_yz(vector<ll> &y, vector<ll> &z, vector<ll> &dist)
{
  for(int i = 0; i < y.size(); i++)
  {
    for(int j = 0; j < z.size(); j++)
    {
      dist.push_back(y[i] + z[j]);
    }
  }
  sort(dist.begin(), dist.end());
  reverse(dist.begin(), dist.end());
}

int main()
{
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> xs(x);
  vector<ll> ys(y);
  vector<ll> zs(z);
  for(int i = 0; i < x; i++) cin >> xs[i];
  for(int i = 0; i < y; i++) cin >> ys[i];
  for(int i = 0; i < z; i++) cin >> zs[i];
  
  vector<ll> yz;
  vector<ll> all;
  make_comb_yz(ys, zs, yz);
  sort(xs.begin(), xs.end());
  reverse(xs.begin(), xs.end()); 
  for(int i = 0; i < k; i++){
    for(int j = 0; j < x; j++){
      if(i >= yz.size()) continue;
      all.push_back(yz[i] + xs[j]);
    }
  }
  sort(all.begin(), all.end());
  reverse(all.begin(), all.end());
  for(int i = 0; i < k; i++)
  {
    cout << all[i] << endl;
  }
}


Measured memory_bytes: 43240
s=input()
x=len(s)
d='abcdefghijklmnopqrstuvwxyz'
sum=0
count=0
ans='WA'
if s[0]=='A':
  for i in range(2,x-1):
    if s[i]=='C':
      sum+=1
  if sum==1:
    for i in range(1,x):
      for j in range(26):
        if s[i]==d[j]:
          count+=1
    if count==x-2:
      ans='AC'
print(ans)  

Measured memory_bytes: 3064
// (つД`)
#include <cstdio>

inline int outcome(int a, int b) {
    if (a == b) return 0;
    else if (a == 1) return 1; else if (b == 1) return -1;
    else return (a > b ? 1 : -1);
}

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    switch (outcome(a, b)) {
        case 1: puts("Alice"); break;
        case 0: puts("Draw"); break;
        case -1: puts("Bob"); break;
        default: puts("> <");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int x, y;
    while(cin >> x >> y) {
        if (x == 0 && y == 0) break;
        cout << min(x,y) << ' ' << max(x,y) << endl;
    }

    return 0;
}


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

int souwa(int x){
  int res=0;
  while(x>0){
    res+=x%10;
    x/=10;
  }
  return res;
}

int main(){
  int n,a,b; cin>>n>>a>>b;
  int res=0;
  for(int i=1; i<=n; i++){
    if(souwa(i)>=a && souwa(i)<=b) res+=i;
  }
  cout<<res<<endl;
}

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

static const int MAX=50;
static const int MAXX=50*50;

typedef long long ll;

ll dp[MAX+1][MAX+1][MAXX+1];


int main(){
    int N,A; cin >> N >> A;
    int x[N];
    for(int i=0;i<N;i++) cin >> x[i];
    
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=2500;k>=0;k--){
                if(k-x[i]>=0){
                    dp[i+1][j+1][k]+=dp[i][j][k-x[i]];
                }
                dp[i+1][j][k]+=dp[i][j][k];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=N;i++){
        ans+=dp[N][i][i*A];
    }
    cout << ans << endl;
}

Measured memory_bytes: 51072
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class BBishop {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll h, w;
	    in >> h >> w;

	    if(h==1 || w==1){
	        out << 1 << endl;
	        return;
	    }

	    ll ww = w%2 == 1 ? w/2+1 : w/2;
	    ll w2 = w/2;

	    ll hh = h%2 == 1 ? h/2+1 : h/2;
	    ll h2 = h/2;

	    //cout << hh sp ww sp h2 sp w2 << endl;
	    out << ww*hh + w2*h2 << endl;
	}
};


int main() {
	BBishop solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
l, r = map(int, input().split())
count = int()
baff = set()
if l <= 3 and r >= 673:
    print(0)
else:
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
                baff.add((i * j) % 2019)
                if (i * j) % 2019 == 0:
                    break
        else:
            continue
        break
    print(min(baff))

Measured memory_bytes: 3188
import sys

h, w = map(int, input().split())

masu = [list(map(str, input())) for i in range(h)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

flag = True
for i in range(h):
    for j in range(w):
        if masu[i][j] == '.':
            continue
        cnt = 0
        for k in range(4):
            ni = i + dy[k]
            nj = j + dx[k]

            if ni < 0 or ni >= h:
                continue
            if nj < 0 or nj >= w:
                continue
            if masu[ni][nj] == '#':
                cnt += 1

        if cnt == 0:
            flag = False


print("Yes") if flag else print("No")

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

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

    a--;
    long long p = c * d / __gcd(c, d);
    long long an = a - (a / c + a / d - a / p);
    long long bn = b - (b / c + b / d - b / p);

    cout << bn - an << endl;

    return 0;
}

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

using namespace std;

#define MAX 100

int main(){
  int n,pos = 0;
  char ch;
  vector<int> v[MAX];

  while(scanf("%d%c" ,&n ,&ch) != EOF){
    v[pos].push_back(n);
    if(ch == '\n'){
      pos++;
    }
  }
 
  int dp[MAX][MAX];

  dp[0][0] = v[0][0];
  for(int i = 1 ; i < pos ; i++){
    for(int j = 0 ; j < (int)v[i].size() ; j++){
      if(i <= pos / 2){
	if(!j){
	  dp[i][j] = v[i][j] + dp[i-1][j];
	}else if(j == (int)v[i].size()-1){
	  dp[i][j] = v[i][j] + dp[i-1][j-1];
	}else{
	  dp[i][j] = v[i][j] + max(dp[i-1][j-1],dp[i-1][j]);
	}
      }else{
        dp[i][j] = v[i][j] + max(dp[i-1][j],dp[i-1][j+1]);
      }
    }
  }

  cout << dp[pos-1][0] << endl; 

  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N);
    for (auto &i : A) cin >> i;

    int ans = A[0];
    for (auto &i : A) ans = __gcd(ans, i);

    cout << ans << endl;
}

Measured memory_bytes: 3780
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S;

void solve(){
    rep(i, S.size()){
        if(S[i] == ',') S[i]=' ';
    }

    cout << S << endl;
}

int main(){
    cin >> S;

    solve();
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int x,y,tmp;
	
	scanf("%d %d",&x,&y);
	
	if(x<y){
	    tmp=x;
	    x=y;
	    y=tmp;
	}
	
	while(y>0){
		tmp=x%y;
		x=y;
		y=tmp;
	}
	
	printf("%d\n",x);
	
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

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

	int A, B, cnt = 0, temp = 1;
	cin >> A >> B;

	while (temp < B)
	{
		temp += A - 1;
		cnt++;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <unordered_map>
typedef long long int ll;
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<" "<<x<<"\n";
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main() {
    cr7
    ll s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe\n";
    else cout << "safe\n";
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> C(N), S(N), F(N);
    for(int i=0; i<N-1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }
    for(int n=0; n<N-1; n++){
        ll ans=0;
        for(int i=n; i<N-1; i++){
            if(ans<=S[i]) ans+=S[i]-ans+C[i];
            else if((ans-F[i])%F[i]==0) ans+=C[i];
            else{
                ans+=F[i]-(ans-F[i])%F[i]+C[i];
            }
        }
        cout << ans << endl;
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n;
vector<int> es[100000];

int solve(int v, int pa) {
	int res = 0;
	REP(i, es[v].size()) if (es[v][i] != pa) res ^= solve(es[v][i], v) + 1;
	return res;
}

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n - 1) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		es[x].push_back(y);
		es[y].push_back(x);
	}
	cout << (solve(0, -1) != 0 ? "Alice" : "Bob") << endl;
	return 0;
}


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

const double pi = 3.14159265358979;

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    double a,b;
    cin>>a>>b;
    double r = max(a,b);
    double ans = 4.0/3.0 * pi * r*r*r;
    cout << ans << endl;
    
}


Measured memory_bytes: 3284
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int D, N, ans;

	cin >> D >> N;
	ans = N;

	rep(i, D) ans *= 100;
	if (N == 100) {
		if (D == 0) ans += 1;
		else if (D == 1) ans += 100;
		else ans += 10000;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque


def main():
    elements = deque(input().split())
    operands = deque()
    operators = {"+", "-", "*"}
    while elements:
        element = elements.popleft()
        if element in operators:
            operand2 = operands.pop()
            operand1 = operands.pop()
            result = eval(operand1 + element + operand2)
            operands.append(str(result))
        else:
            operands.append(element)
    print(int(operands.pop()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 6004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void read(int &x){
	char ch=getchar();x=0;
	for(;ch==' '||ch=='\n';ch=getchar());
	for(;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());	
}
void write(ll x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,cl[200004],N,sz[200004];
ll ans[200004];
vector<int>g[200004];
bool vis[200004],used[200004];
int szdfs(int x,int par){
	sz[x]=1;
	for (int i=0;i<g[x].size();i++){
		if(g[x][i]==par||vis[g[x][i]])continue;
		sz[x]+=szdfs(g[x][i],x);
	}
	return sz[x];
}
int centroid(int x,int par){
	bool ok=1;
	for(int i=0;i<g[x].size();i++){
		if(g[x][i]==par||vis[g[x][i]])continue;
		int val=centroid(g[x][i],x);
		if(val>0)return val;
		if(sz[g[x][i]]>N/2)ok=0;
	}
	if(N-sz[x]>N/2)ok=0;
	return (ok?x:-1);
}
void pathsearch(int x,int par,map<int,int>&mp){
	bool cle=0;
	if(!used[cl[x]])cle=1,used[cl[x]]=1;
	for(int i=0;i<g[x].size();i++){
		if(vis[g[x][i]]||g[x][i]==par)continue;
		pathsearch(g[x][i],x,mp);
	}
	if(cle)mp[cl[x]]+=sz[x],ans[cl[x]]+=sz[x],used[cl[x]]=0;
}
void update(map<int,int>&mp,ll X,ll x){
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		int A=it->first,B=it->second;
		ans[A]+=(1ll*(X-B)*B+1ll*B*(B-1)/2)*x;
	}
}
void solve(int x){
	szdfs(x,-1),N=sz[x];
	int root=centroid(x,-1);
	vis[root]=1,ans[cl[root]]++;
	int cnt=0;
	szdfs(root,-1);
	used[cl[root]]=1;
	map<int,int>mp1;mp1.clear();
	for(int i=0;i<g[root].size();i++)if(!vis[g[root][i]]){
		map<int,int>mp2;mp2.clear();
		pathsearch(g[root][i],root,mp2);
		update(mp2,sz[g[root][i]],-1);
		ans[cl[root]]+=1ll*sz[g[root][i]]*cnt; 
		cnt+=sz[g[root][i]];
		if(mp1.size()<mp2.size())swap(mp1,mp2);
		for(map<int,int>::iterator it=mp2.begin();it!=mp2.end();it++)mp1[(it->first)]+=(it->second);
	}
	ans[cl[root]]+=cnt;
	used[cl[root]]=0;
	update(mp1,cnt,1);
	for(int i=0;i<g[root].size();i++)if(!vis[g[root][i]])solve(g[root][i]);
}
int main(){
	read(n);
	for(int i=1;i<=n;i++)read(cl[i]);
	for(int i=1;i<n;i++){
		int u,v;
		read(u),read(v),g[u].push_back(v),g[v].push_back(u);
	}
	solve(1);
	for (int i=1;i<=n;i++)write(ans[i]),puts("");
}

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

int main() {
  
  int A;
  int B;
  
  cin >> A >> B;
  
  if (A == B){
    cout << A + B << endl; 
  }
  if (A > B){
    cout << A + A - 1 << endl;
  }
  else if (A < B){
    cout << B + B - 1 <<endl;
  }
}
  
    


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

int main() {
    string A,a,b;
    int n,m;
    cin >> a >> b;
    cin >> n >> m;
    cin >> A;
    if(A == a){
    	n -= 1;
    }else if(A == b){
    	m -= 1;
    }
    cout << n << ' ' << m << endl;
}

Measured memory_bytes: 256
n = int(input())
sp = []
for i in range(n):
    s, p = map(str, input().split())
    sp.append([s, int(p), i+1])

sp.sort(key=lambda x: x[1], reverse=True)
sp.sort(key=lambda x: x[0])

for e in sp:
    print(e[2])

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> h(n), dp(n);
  for(int i = 0; i < n; i++)
    cin >> h.at(i);
  for(int i = 1; i < n; i++) {
    int m = INT_MAX;
    for(int j = max(0, i - k); j < i; j++) {
      m = min(m, dp[j] + abs(h[i] - h[j]));
    }
    dp[i] = m;
  }
  cout << dp[n - 1] << '\n';
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n >> s;
    x = 0;
    ans = 0;
    REP(i, s.size()) {
        if (s.at(i) == 'I') {
            x++;
        } else {
            x--;
        }
        ans = max(x, ans);
    }
    MSG(ans)
}


Measured memory_bytes: 256
//53
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n;){
    bool out=false;
    for(int i=0;i<=9;i++){
      if(n&1<<i){
	if(out){
	  cout<<' ';
	}
	out=true;
	cout<<(1<<i);
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int N = ni();
		int K = ni();
		int[] A = na(N);

		for(int i = K; i < N; i++) {
			if(A[i - K] < A[i]) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
		
	}


	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 54804
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		int k = parseInt(sc.next());
		sc.close();
		ArrayList<ArrayList<Integer>> list = new ArrayList<>();
		for (i = 0; i < 26; i++) {
			list.add(new ArrayList<Integer>());
		}
		for (i = 0; i < s.length(); i++) {
			list.get((s.charAt(i)-'a')).add(i);
		}
		TreeSet<String> set = new TreeSet<>();
		for (int l = 0; l < 26; l++) {
			for (Integer ii:list.get(l)) {
				for (j = ii+1; j <= Math.min(ii+5,s.length()); j++) {
					set.add(s.substring(ii, j));
				}
			}
			if(set.size()>=5) break;
		}
		String ans = null;
		for (i = 0; i < k; i++) {
			ans=set.pollFirst();
		}
		out.println(ans);
	}
}

Measured memory_bytes: 24532
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        998244353
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  3009
ll dp[N][N];
ll n,s;
std::vector<ll> a(N);
ll func(ll pos,ll sum)
{
	if(sum==s)
		return (n-pos+1)%hell;
	if(sum>s)
		return 0;
	if(pos>=n)
		return sum==s;
	if(dp[pos][sum]!=-1)
		return dp[pos][sum]%hell;
	return dp[pos][sum]=((func(pos+1,sum))%hell+(func(pos+1,sum+a[pos]))%hell)%hell;


}
int main()
{
	
	io

	rep(i,0,N)
	{
		rep(j,0,N)
		{
			dp[i][j]=-1;
		}
	}
	cin>>n>>s;
	rep(i,0,n)
	cin>>a[i];	
	ll res=0;
	rep(i,0,n)
	{
		res=((res%hell)+(func(i,0))%hell)%hell;
	}
	cout<<res%hell;
	
}

Measured memory_bytes: 71168
d,g = map(int,input().split())
P = []
C = []
for i in range(d):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

res = float('inf')
for i in range(1 << d):
    yet = []
    aaa = []
    score = 0
    prob = 0
    for j in range(d):
        if i&1==1:
            # (j+1)*100 点問題をすべてとく
            score += P[j] * (j+1) * 100 + C[j]
            prob += P[j]
        else:
            aaa.append(j)
            yet.append(P[j])
        i >>= 1
    pivot = len(yet)-1
    flag = True
    while score < g:
        if pivot < 0:
            flag = False
            break
        if yet[pivot] > 0:
            yet[pivot] -= 1
            score += (aaa[pivot]+1) * 100
            prob += 1
        else:
            pivot -= 1
    if flag:
        res = min(res, prob)
print(res)


Measured memory_bytes: 3064
/*{{{*/
#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;
int main(){
    string s;
    R(s);
    bool err=0;
    REP(i,SZ(s)){
        if(s[i]=='L'&&i%2==0)err=1;
        if(s[i]=='R'&&i%2==1)err=1;
    }
    W(!err?"Yes":"No");
    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s; cin >> s;
  int n = s.size();
  int l[n+1], u[n+1]; rep(i, n+1) l[i] = u[i] = 0;

  rep(i, n) {
    if(s[i] == '<') l[i + 1] = l[i] + 1;
    if(s[n - 1 - i] == '>') u[n - i - 1] = u[n - i] + 1;
  }  
  ll ans = 0;
  rep(i, n + 1) ans += max(l[i], u[i]);
  cout << ans << endl;
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

string s, t;
lin ss[256], tt[256];

int main(void)
{
    cin >> s >> t;

    rep(i, 256)
    {
        ss[i] = -1;
        tt[i] = -1;
    }

    rep(i, s.length())
    {
        if(ss[s[i]] == -1)
            ss[s[i]] = i;
        if(tt[t[i]] == -1)
            tt[t[i]] = i;

        if(ss[s[i]] != tt[t[i]])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  long long a[n];
  long long b[n];
  REP(i,n){
    cin>>a[i];
  }
  REP(i,n){
    cin>>b[i];
  }
  vector<pair<long long, char>> seq;
  REP(i,n){
    seq.push_back(make_pair(a[i], 'a'));
    seq.push_back(make_pair(b[i], 'b'));
  }
  sort(ALL(seq));
  
  stack<long long> as;
  stack<long long> bs;
  
  long long ans = 1;
  REP(i,2*n){
    if(seq[i].second == 'a'){
      if(bs.empty()){
        as.push(seq[i].first);
      }else{
        ans *= (long long)bs.size();
        ans = mod(ans);
        bs.pop();
      }
    }else{
      if(as.empty()){
        bs.push(seq[i].first);
      }else{
        ans *= (long long)as.size();
        ans = mod(ans);
        as.pop();
      }
    }
  }
  
  cout<<ans<<endl;
      
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;

const int N = 101;
int n, m, sum, p, x;
int T[N];

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

  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> T[i];
    sum += T[i];
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> p >> x;
    int d = T[p] - x;
    cout << sum - d << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256