akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
#define fs first
#define sc second


using namespace std;

int main() {
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    if ((b - a - 1) % 2 == 0) {
        cout << "Borys\n";
    } else {
        cout << "Alice\n";
    }
    return 0;
}

Measured memory_bytes: 256
package main
 
import (
  "fmt"
  "strconv"
)

func max(A string, B string) string {
  if len(A) > len(B) || (len(A) == len(B) && A > B){
    return A
  }
  return B
}

func main() {
  var N, M int
  fmt.Scan(&N, &M)
  A := make([][]int, M)
  B := []int{0, 2, 5, 5, 4, 5, 6, 3, 7, 6}
  DP := make([]string, N + 1)
  var x int
  for i, _ := range A {
    fmt.Scan(&x)
    A[i] = []int{B[x], x}
    if B[x] <= N {
      DP[B[x]] = max(DP[B[x]], strconv.Itoa(x))
    }
  }
  for i, _ := range DP {
    for _, a := range A {
      if i > a[0] && len(DP[i - a[0]]) >= 1 {
        b := DP[i - a[0]] + strconv.Itoa(a[1])
        DP[i] = max(DP[i], b)
      }
    }
  }
  fmt.Println(DP[N])
}


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

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )

#define INF 1000000000

void swap(int* x, int *y)
{
	int t;

	t = *x;
	*x = *y;
	*y = t;
}

void insertSort(int p[], int n)
{
	int i, j,k;

	for (i = 1; i < n; i++)
	{
		j = i;
		while (j >= 1 && (p[j] < p[j - 1]))
		{
			swap(&p[j], &p[j - 1]);
			j--;
		}

		for (k = 0; k < n-1; k++)
			printf("%d ", p[k]);

		printf("%d\n",p[n-1]);
	}
}

int GCD(int x, int y)
{
	if (x < y)
		swap(&x, &y);

	if (y == 0)
		return x;

	return GCD(y, x % y);
}

int not_prime_count(int p[], int n)
{
	int count = 0;
	int i, j;
	int num;

	for (i = 0; i < n; i++)
	{
		for (j = 2; j < (int)(sqrt(p[i])+1); j++)
		{
			if (p[i] % j == 0)
			{
				count++;
				break;
			}
		}
	}
	return count;
}

typedef struct T
{
	char mark;
	int num;
}T;

int bubble_sort(T p[], int n)
{
	int i, j;
	int count = 0;
	char temp;

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n - 1 - i; j++)
		{
			if (p[j].num > p[j + 1].num)
			{
				swap(&p[j].num, &p[j + 1].num);
				temp = p[j].mark;
				p[j].mark = p[j + 1].mark;
				p[j + 1].mark = temp;

				count++;
			}
		}
	}
	for (i = 0; i < n - 1; i++)
		printf("%c%d ", p[i].mark,p[i].num);
	printf("%c%d\n", p[n-1].mark,p[n - 1].num);

	return count;
}

int selection_sort(T p[],int n)
{
	int i, j, min;
	int count = 0;
	char temp;

	for (i = 0; i < n; i++)
	{
		min = i;
		for (j = i; j < n; j++)
		{
			if (p[j].num < p[min].num)
				min = j;
		}

		if (i != min)
		{
			swap(&p[i].num, &p[min].num);
			temp = p[i].mark;
			p[i].mark = p[min].mark;
			p[min].mark = temp;
			count++;
		}
	}

	for (i = 0; i < n - 1; i++)
		printf("%c%d ", p[i].mark, p[i].num);
	printf("%c%d\n", p[n - 1].mark, p[n - 1].num);

	return count;
}

T card[100];
T card2[100];

int main()
{
	int N,K;
	int h[100000];
	int table[100000];

	scanf("%d%d", &N,&K);

	int i, j,min,num;
	for (i = 0; i < N; i++)
		scanf("%d", &h[i]);

	table[0]=0;
	//table[1] = ABS(h[1] - h[0]);

	for (i = 1; i < N; i++)
	{
		min = INF;
		for (j = 1; j <= K; j++)
		{
			if (j > i)
				break;

			num = table[i - j] + ABS(h[i] - h[i - j]);

			if (num < min)
				min = num;
		}
		table[i] = min;

		//table[i] = MIN(table[i - 2] + ABS(h[i - 2] - h[i]), table[i - 1] + ABS(h[i - 1] - h[i]));
	}

	printf("%d\n", table[N - 1]);

}

Measured memory_bytes: 896
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
MOD = 10**9+7
# MOD = 998244353

n = int(input())
E = [list(map(int, input().split())) for i in range(n)]
d = defaultdict(int)
for e in E:
    if e[0] == 0 and e[1] == 0:
        d[(0, 0)] += 1
    elif e[0] == 0:
        d[(0, 1)] += 1
    elif e[1] == 0:
        d[(1, 0)] += 1
    else:
        g = math.gcd(e[0], e[1])
        a, b = e[0]//g, e[1]//g
        if b < 0:
            a, b = -a, -b
        d[(a, b)] += 1

pd = 1
non = n - d[(0, 0)]
for k in d:
    if k == (0, 0) or k == (1, 0):
        continue

    elif k == (0, 1) and (1, 0) in d:
        a, b = d[(0, 1)], d[(1, 0)]
        pd = (pd * (pow(2, a, MOD) + pow(2, b, MOD) - 1)) % MOD
        non -= (a + b)

    elif k[0] > 0 and (-k[1], k[0]) in d:
        a, b = d[k], d[(-k[1], k[0])]
        pd = (pd*(pow(2, a, MOD) + pow(2, b, MOD) - 1))%MOD
        # print(a, b, pd)
        non -= (a+b)

# print(non, pd)
total = (pow(2, non, MOD)*pd - 1 + d[(0, 0)])%MOD
print(total)


Measured memory_bytes: 156584
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc  =  new Scanner(System.in);
		
		int n = sc.nextInt();
		long[] h = new long[n];
		for (int i = 0; i < n; i++) h[i] = sc.nextLong();
		
		int last = 0;
		int max = 0;
		
		for (int i = 0; i < n -1 ; i++) {
			if (h[i] - h[i+1] < 0) {
				//if (i+1 - last > max) max = i+1 - last;
				last = i+1;
			} else {
				if (i+1 - last > max) max = i+1 - last;
			}
			//System.out.println("last:"+ last + " max="+ max);
		}
		
		System.out.println(max);
	}

}


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

int main(){
	int w,a,b,ans=0;
	cin>>w>>a>>b;
	if(b>a+w)ans=b-(a+w);
	else if(a>b+w)ans=a-(b+w);
	cout<<ans<<"\n"s;
}


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(){
  ll n;
  ll r = 0;
  ll g = 0;
  ll b = 0;
  string s;
  ll count = 0;
  cin >> n >> s;
  rep(i,n){
    if(s[i] == 'R')
      r++;
    else if(s[i] == 'G')
      g++;
    else if(s[i] == 'B')
      b++;
  }
  for(ll i=1; i<=(n-1)/2;i++){
    for(ll j=0; j+(i*2)<n; j++){
      if((s[j]!=s[j+i])
           &&(s[j+i]!=s[j+(i*2)])
           &&(s[j] !=s[j+(i*2)])
         )
          count++;
    }
  }
  cout << r*g*b-count << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
string s,t;
int dp[3333][3333];
pair<int,int>parent[3333][3333];
char c[3333][3333];
main()
{
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
	{
		for(int j=0;j<t.size();j++)
		{
			if(s[i]==t[j])
			{
				dp[i+1][j+1]=dp[i][j]+1;
				parent[i+1][j+1]=make_pair(i,j);
				c[i+1][j+1]=s[i];
			}
			else
			{
				if(dp[i+1][j]>dp[i][j+1])
				{
					dp[i+1][j+1]=dp[i+1][j];
					parent[i+1][j+1]=make_pair(i+1,j);
				}
				else
				{
					dp[i+1][j+1]=dp[i][j+1];
					parent[i+1][j+1]=make_pair(i,j+1);
				}
			}
		}
	}
	pair<int,int>p=make_pair(s.size(),t.size());
	string ans="";
	while(p!=make_pair(0,0))
	{
		if(c[p.first][p.second]!=0)ans=c[p.first][p.second]+ans;
		p=parent[p.first][p.second];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 131328
'use strict';
const main = input => {
  const s = input[0];
  let count = 0;
  for(let i=0; i<Math.floor(s.length/2); i++) {
    if (s[i] != s[s.length-1-i]) count++;
  }
  console.log(count);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 21064
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

int f(ll a,ll b){
  int da=0,db=0;
  while(a>0){
    a /= 10;
    da++;
  }
  while(b>0){
    b /= 10;
    db++;
  }
  return max(da,db);
}

int main(){
  ll n;
  cin >> n;

  int r = sqrt(n);
  int ans = 100;
  for(int i=1;i<=r;i++){
    if(n%i==0){
      ans = min(ans,f(i,n/i));
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  map<P,int> mp;
  int ans=0,n,x,y,w;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x>>y>>w;
    for(int j=0;j<2;j++)
      for(int k=0;k<2;k++)
	ans=max(ans,mp[P(x+j,y+k)]+=w);
  }
  cout<<ans<<" / "<<1<<endl;
  return 0;
}

Measured memory_bytes: 28096
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int n;
    cin >> n;
    map<char,int> m;
    for(char c = 'a';c <= 'z';c++)m[c] = INF;
    rep(i,n){
        string s;
        cin >> s;
        map<char,int> sm;
        rep(i,s.length())sm[s[i]]++;
        for(auto a : sm)m[a.first] = min(m[a.first],a.second);
        for(char c = 'a';c <= 'z';c++)if(sm[c] == 0)m[c] = 0;
    }
    for(char c = 'a';c <= 'z';c++)if(m[c] != INF || m[c] != 0)cout << string(m[c],c);
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      cin >> N;
      int K;
      cin >> K;
      int min=1;
      
      // ここにプログラムを追記
      for(int i=0;i<N;i++){
        if( 2*min > min+K){
          min+=K;
        }else{
          min*=2;
        }
      }
      cout << min << endl;
      
    }

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
  int w[10]={1,2,4,8,16,32,64,128,256,512};
  int n;
  while(cin>>n){
    for(int i=0;n>0;i++){
      if (n%2){
	cout<<w[i];
	n/=2;
      if(n)cout<<" ";
      }
      else
	n/=2;
    }
    cout<<endl;
  }
  return 0;
}

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

int main()
{
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll K;
  cin >> K;

  ll c = max(0LL, A-K);
  ll d = max(0LL, B-max(0LL, K-A));

  printf("%lld %lld\n", c, d);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,m,i,j,k,x,y,z,sum=0;
  cin>>n>>m;
  for(i=0;i<m;i++)
  {
    cin>>x;
    sum+=x;
  }
  if(n-sum>=0)
  {
    cout<<n-sum<<endl;
  }  
  else
  {
    cout<<"-1"<<endl;
  }  
  return 0;
} 

Measured memory_bytes: 3636
#include <stdio.h>
int main(){

  int n,i,count=0;

  long long int re=1;

  int s = 1000000007;

  scanf("%d",&n);

  for(i=1;i<=n;i++){

    re*=i;

    if (re>s)re%=s;
  }

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

  
  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void) {
    ll n;
    cin >> n;

    ll cnt = 0, ans = 0;
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        if (a == b) cnt++;
        else
            cnt = 0;
        chmax(ans, cnt);
    }
    if (ans >= 3) puts("Yes");
    else
        puts("No");

    return 0;
}

Measured memory_bytes: 3632
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<math.h>
using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	int c=a+b;
	
	if(c%2==0)
	{
		cout<<c/2;
	}
	else
		cout<<"IMPOSSIBLE";
	
	return 0;
}

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

int main() {
  
  string s;
  
  cin >> s;
  
  bool ok = false;
  
  for ( int i = 0 ; i < s.length() - 1 ; i++ ) {
    if ( s[i] == 'A' and s[i+1] == 'C' ) ok = true;
  }
  
  if ( ok ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

temp = 10**6
index = 0
for i in range(n):
    if temp > abs(a - (t - h[i] * 0.006)):
        temp = abs(a - (t - h[i] * 0.006))
        index = i + 1

print(index)

Measured memory_bytes: 3064
def examB():
    A, B = LI()
    ans = 0
    for i in range(A,B+1):
        cur = str(i)
        if cur==cur[::-1]:
            ans +=1
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 40428
#include<iostream>
using namespace std;
int main(){
	
	char kazu[1001];
	int sum=0;
	cin>>kazu;
	while(kazu[0]!='0'){
		for(int i=0;kazu[i]!='\0';i++){
			sum+=kazu[i]-'0';
		}
		cout<<sum<<endl;
		sum=0;
		cin>>kazu;
	}
	
				
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct range_edge_graph {
    int n;
    struct edge { int to; long long weight;};
    vector<vector<edge>> g;
    
    range_edge_graph(int n_) {
		n = n_<<1;
        g.resize(n<<2);
        for (int i = 1; i < n; ++i) {
            int c1 = i<<1|0, c2 = i<<1|1;
            g[i].push_back({c1, 0});
            g[i].push_back({c2, 0});
            g[c1+2*n].push_back({i+2*n, 0});
            g[c2+2*n].push_back({i+2*n, 0});
        }
        for (int i = n; i < 2*n; ++i)
            g[i].push_back({i+2*n, 0});
    }

    // from [l1, r1) to [l2, r2)
    void add_edge(int l1, int r1, int l2, int r2, long long w) {
        int id = g.size();
        l1 += n, r1 += n;
        while (l1 < r1) {
            if (l1 & 1) g[l1+2*n].push_back({id, 0}), l1++;
            if (r1 & 1) --r1, g[r1+2*n].push_back({id, 0});
            l1 >>= 1, r1 >>= 1;
        }
        vector<edge> node;
        l2 += n, r2 += n;
        while (l2 < r2) {
            if (l2 & 1) node.push_back({l2++, w});
            if (r2 & 1) node.push_back({--r2, w});
            l2 >>= 1, r2 >>= 1;
        }
        g.push_back(node);
    }

    vector<long long> dijkstra(int s) {
        s += n;
        vector<long long> dist(g.size(), numeric_limits<long long>::max());
        dist[s] = 0;
        using P = pair<long long, long long>;
        priority_queue<P, vector<P>, greater<P>> que;
        que.emplace(0, s);
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (dist[v] < p.first) continue;
            for (edge& e : g[v]) {
                if (dist[e.to] > dist[v] + e.weight) {
                    dist[e.to] = dist[v] + e.weight;
                    que.emplace(dist[e.to], e.to);
                }
            }
        }
        vector<long long> res(dist.begin() + n, dist.begin() + 2*n);
        return res;
    }
};

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

    int n, m;
    cin >> n >> m;
    range_edge_graph g(n);

    for (int i = 0; i < m; ++i) {
        int l, r, c;
        cin >> l >> r >> c;
        l--; r--;
        g.add_edge(l, r+1, l, r+1, c);
    }
    auto dist = g.dijkstra(0);
    long long ans = dist[n-1];
    cout << (ans == numeric_limits<long long>::max() ? -1 : ans) << endl;
}


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

long long a, b, c, x, y;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> a >> b >> c >> x >> y;
	b = min(b, 2 * c);
	a = min(a, 2 * c);
	
	if(2 * c >= (a + b))
		return cout << 1LL * x * a + 1LL * y * b, 0;
	long long t = min(x, y);
	x -= t; y -= t;
	cout << 1LL * t * 2 * c + 1LL * x * a + 1LL * y * b;
}



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

int main() {
	int n;
	cin >> n;
	int ans = 0;
	// int x = n;
	ans = (n / 500) * 1000;
	n = n % 500 ;

	ans =  ans + (n / 5) * 5;
	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,k,ans = 0;
    cin >> n >> k;
    int l[n];
    rep(i, n)cin >> l[i];
    qsort(l, n, sizeof(int), desc);
    rep(i, k)ans += l[i];
    cout << ans << endl;
    return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#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 Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a,b,k;
  cin >> a >> b >> k;

  ll ansa = max(0LL, a-k);
  ll ansk = max(0LL, k-a);
  ll ansb = max(0LL, b-ansk);

  cout << ansa << " " << ansb << endl;
}


Measured memory_bytes: 256
A = input().split()
stack = []

for i in range(len(A)):
  if A[i] == "+":
    b = stack.pop()
    a = stack.pop()
    stack.append(a+b)
  elif A[i] == "-":
    b = stack.pop()
    a = stack.pop()
    stack.append(a-b)
  elif A[i] == "*":
    b = stack.pop()
    a = stack.pop()
    stack.append(a*b)
  else:
    stack.append(int(A[i]))

print(stack.pop())


Measured memory_bytes: 5604
#include <iostream>

using namespace std;

int main() {
  string s;
  while (cin >> s) {
    int a = s.length(), z = 0;
    for (int i = 0; i < s.length(); ++i) {
      if (s[i] == 'A') a = min(a, i);
      if (s[i] == 'Z') z = max(z, i);
    }
    cout << z - a + 1 << endl;
  }
}


Measured memory_bytes: 640
require 'set'

s = "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"
puts s.split(", ").map(&:to_i)[gets.to_i-1]


Measured memory_bytes: 1916
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;

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



int main(){
    int n, q, l, r;
    string s;
    cin>>n>>q>>s;
    vector<int> vec(s.size()+1);
    int exist=0;
    vec[1]=0;
    for(int i=2; i<=s.size(); i++){
            if(s[i-2]=='A'&&s[i-1]=='C'){
                ++exist;
            }
            vec[i]=exist;
        }
    for(int i=0; i<q; i++){
        cin>>l>>r;
        cout<<vec[r]-vec[l]<<endl;
    }
}


Measured memory_bytes: 1408
a,b = map(float,input().split())
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
b = Decimal(str(b)).quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)
a = Decimal(a)
ans = a*b
print(math.floor(ans))

Measured memory_bytes: 10084
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 107, K = 1e5 + 7;
int n, s, w[N], v[N], dp[N][K];

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n >> s;
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= w[i]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
            }
        }
    }
    int res = 0;
    for (int j = 0; j <= s; j++) {
        res = max(res, dp[n][j]);
    }
    cout << res;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


Measured memory_bytes: 79360
#include <iostream>
#include <algorithm>

const int maxn = 1e5+7;

int n;
int a[maxn][3];
int dp[maxn][3];

int main(int argc, char *argv[]) {  
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			std::cin >> a[i][j];
		}
	}
	for (int j = 0; j < 3; j++) {
		dp[0][j] = a[0][j];
	}
	for (int i = 1; i < n; i++) {
		dp[i][0] = a[i][0] + std::max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = a[i][1] + std::max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = a[i][2] + std::max(dp[i-1][1], dp[i-1][0]);
	}
	std::cout << std::max(std::max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]) << '\n';
}

Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		int alice = 0;
		int bob = 0;

		for(int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		}
		Arrays.sort(array);

		alice = rep(array,1);
		bob = rep(array,2);
		
		System.out.println(alice-bob);
	}
	static int rep(int[] array,int num) {
		int sum = 0;
		for(int i = array.length-num; i >= 0; i-=2) {
			sum += array[i];
		}
		return sum;
	}
}


Measured memory_bytes: 21844
sa = str(input())
sb = str(input())
sc = str(input())
turn = 'a'
while True:
    if turn == 'a':
        if sa == '':
            print('A')
            exit()
        turn = sa[0]
        sa = sa[1:]
    elif turn == 'b':
        if sb == '':
            print('B')
            exit()
        turn = sb[0]
        sb = sb[1:]
    else:
        if sc == '':
            print('C')
            exit()
        turn = sc[0]
        sc = sc[1:]


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

int		main(void)
{
	int N, M, C;

	cin >> N >> M >> C;
	vector<int> B(M);

	for (int i = 0; i < M; i++)
	{
		cin >> B[i];
	}
	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		int sum = 0;

		for (int j = 0; j < M; j++)
		{
			int A;
			
			cin >> A;
			sum += A * B[j];
		}
		if (sum + C > 0)
			ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>

using namespace std;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
char s[1000][1001];
int a[1000][1000];

int main() {
    int h, w, ans = 0, i, j;
    queue <pair<int, int>> q;
    
    scanf("%d %d", &h, &w);
    
    for (i = 0; i < h; i++) scanf("%s", s[i]);
    
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                a[i][j] = 0;
                q.push(make_pair(i, j));
            } else {
                a[i][j] = 1e9;
            }
        }
    }
    
    while (!q.empty()) {
        int x = q.front().first;
        int y = q.front().second;
        
        q.pop();
        
        for (i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            
            if (nx < 0 || nx >= h || ny < 0 || ny >= w || a[nx][ny] <= a[x][y] + 1) continue;
            
            a[nx][ny] = a[x][y] + 1;
            q.push(make_pair(nx, ny));
        }
    }
    
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            ans = max(ans, a[i][j]);
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 13328
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI   3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007

map<char, int> m;
map<char, int> m1;
int main()
{
	FAST;
	string s;
	cin >> s;
	ll x = 0;
	for(ll i = 0; i < s.size(); i ++){
		if(s[i] >= 'A' && s[i] <= 'Z'){
			x++;
		}
		m[s[i]] ++;
		m1[s[i]] = i;
	}
	if(m['C'] == 1 && x == 2 && m1['C'] >= 2 && m1['C'] <= s.size() -2 && m1['A'] == 0 && m['A'] == 1){
		cout << "AC";
		return 0;
	} 
	cout << "WA";
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int AT;
  AT = A * N;
  if(AT >= B){
    cout << B << endl;
  }
  if(AT < B){
    cout << AT << endl;
  }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

t = min(a)

dp = [0] * (k+1)

for x in a:
    dp[x] = 1

for i in range(k+1):
    for x in a:
        if i >= x:
            if dp[i] + (dp[i-x] + 1) % 2 > 0:
                dp[i] = 1
            else:
                dp[i] = 0

print("First" if dp[i] == 1 else "Second")


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

int main(void)
{
  string s;
  cin >> s;
  int slen = s.size();
  vector<int> result(26);
 
  //cout << slen;
  for(int i = 0; i < slen; i++)
  {
    for(int j = 0; j < 26; j ++)
    {
      if(s[i] == 'a' + j)
      {
        int r = 'a' + j;
        result[j] = 1;
        continue;
      }
    }
  }
  /*for(int i = 0; i < 26; i++)
  {
    cout << i << ": " << result[i] << endl;
  }*/
  for(int i = 0; i < 26; i++)
  {
    if(result[i] == 0)
    {
      char c = 'a' + i;
      cout << c << endl;
      return (0);
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	long long int n, a;
	cin >> n >> a;
	long long int ans = 1000000000000;
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	for(int i = 0; i <= 40; i++){
		// i : クッキーを食べる回数
		long long int l = 1, r = 100000000;
		// 何枚クッキーを焼いてから食べるか二分探索で調べる
		while(r - l > 1){
			long long int mid = (l + r) / 2;
			long long int res = 1;
			bool ok = false;
			for(int j = 0; j <= i; j++){
				res = res * mid;
				if(res >= n){
					r = mid;
					ok = true;
					break;
				}
			}
			if(!ok) l = mid;
		}
		// cout << i << " " << l << " " <<  r << " ";
		long long int res = 1;
		for(int j = 0; j <= i; j++){
			res = res * r;
		}
		long long int overnum = 0;
		while(res >= n){
			res = (res / r) * (r - 1);
			overnum++;
		}
		overnum--;
		res = (res / (r - 1)) * r;
		// cout << a * i + r * (i + 1) - overnum << endl;
		if(res >= n) ans = min(ans, (long long int)a * i + r * (i + 1) - overnum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int main() {
	char a;
	cin >> a;
    if ((a >= 'a') && (a <= 'z')) {
        cout<<'a'<<endl;
    }
    else if ((a >= 'A') && (a <= 'Z')) {
        cout<<'A'<<endl;
    }



}

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

#define NAME "M - Candies"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int maxn = 1e5;
const int mod = 1e9 + 7;

int dp[101][maxn+1];
int tmp[maxn+1];
int a[101];

void add(int &x, int val){
    x+=val;
    if (x>mod) x-=mod;
    if (x<0) x+=mod;
}

int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    int n,k;
    cin>>n>>k;
    //cout<<n<<" "<<k<<endl;
    for(int i=1;i<=n;i++) cin>>a[i];
    dp[0][k]=1;
    for(int i=1;i<=n;i++){

        for(int j=0;j<=k;j++){
            add(tmp[ max(0,j-a[i]) ], dp[i-1][j] );
            if (j+1<=k) add(tmp[j+1],-dp[i-1][j]);
            /*
            tmp[ max(0,j-a[i] ) ] += dp[i-1][j];
            if (j+1<=k) tmp[j+1] -= dp[i-1][j];
            */
        }
        //for(int j=0;j<=k;j++) cout<<tmp[j]<<" ";
        //cout<<endl;
        int presum=0;
        for(int j=0;j<=k;j++){
            add(presum,tmp[j]);
            add(dp[i][j],presum);
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
        ms(tmp,0);
    }
    cout<<dp[n][0]<<endl;
}


Measured memory_bytes: 43020
import sys
from collections import defaultdict, deque

input = sys.stdin.readline

def chmin(a, b):
    if a > b:
        return b
    else:
        return a

def main():
    N = int(input())
    f_inf = float('inf')
    # DP テーブルを初期化　(最小化問題なので INF に初期化)
    MAX_N = 110000
    dp = [f_inf] * MAX_N
    dp[0] = 0
    for i in range(1, N+1):
        for j in range(N):
            pow6 = 6 ** j
            if pow6 > N:
                break
            dp[i] = min(dp[i], dp[i-pow6] + 1)
        for j in range(N):
            pow9 = 9 ** j
            if pow9 > N:
                break
            dp[i] = min(dp[i], dp[i-pow9] + 1)
    print(dp[N])


if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    bool f[31] = {0};
    for(int i=0; i<28; i++) {
        int a;
        cin >> a;
        f[a] = true;
    }
    for(int i=1; i<=30; i++) {
        if(f[i] == false)
            cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 1164
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, y = map(int, input().split())
    for i in range(n+1):
        for j in range(n-i+1):
            if i*10000 + j*5000 + (n-i-j)*1000 == y:
                print(i, j, n-i-j)
                return
    print(-1, -1, -1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
s=input()
c=101
f=0
for i in range(len(s)):
    if s[i]=="C":
        c=min(c,i)
    elif s[i]=="F":
        f=max(f,i)

if s.count("C")>=1 and s.count("F")>=1 and f-c>0:
    print("Yes")
else:
    print("No")

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

int main() {
	long long int X;
	cin >> X;

	long long int mon500 = int(X / 500);
	X -= mon500 * 500;

	long long int mon5 = int(X / 5);
	long long int happy = 1000 * mon500 + 5 * mon5;

	cout << happy;

}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

ll xo[201010],sm[201010];

int main(){
    int n;
    cin>>n;
    vector<int> a(n);

    rep(i,n) cin>>a[i];
    rep(i,n) xo[i]=sm[i]=a[i];
    for(int i=1;i<n;i++) xo[i]^=xo[i-1];
    for(int i=1;i<n;i++) sm[i]+=sm[i-1];

    ll ans=0;
    rep(l,n){
        int ok=l,ng=n;
        while(ok+1!=ng){
            int md=(ok+ng)/2;

            ll x=xo[md];
            if(l) x^=xo[l-1];
            ll s=sm[md];
            if(l) s-=sm[l-1];

            if(x==s) ok=md;
            else ng=md;
        }
        ans+=ok-l+1;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 7204
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define MAXSIZE 20
int main(int argc, char *argv[]) {
//	

	
	char A[MAXSIZE], B[5];
	scanf("%s %s", A, B);
	int i;
	int j;
	int lenA = strlen(A);
	int lenB = strlen(B);
//	if (lenA < 10)
//	{
////		int A1[lenA], B1 = (int)
//		int resa = A* B;
//		printf("%d",resa);
//		return;
//	}
	char temp;
	for (i = 0; i < lenA/2; ++i)
	{
		temp = A[i];
		A[i] = A[lenA-1-i];
		A[lenA - 1 - i] = temp;
		
	}
//	printf("%d", 100000000);
	
	for ( i = 1; i < 3; i++)
	{
		B[i] = B[i + 1];
	}
	B[3] = '\0';
	
	temp = B[0];
	B[0] = B[2];
	B[2] = temp;
//	printf("%s\n", B);
	lenB = strlen(B);
	int *res = (int *)malloc((lenA + lenB) * sizeof(int));
	for (i = 0; i < lenA + lenB; ++i)
	{
		res[i] = 0;
	}
//	char *res = (char *)calloc(lenA + lenB , sizeof(char));
//	int res[lenA + 2] = 0;
	
	
	for ( i = 0; i < lenB; ++i)
	{
		for (j = 0; j < lenA; ++j)
		{
			res[i + j] += (A[j] - '0') * (B[i] - '0'); 
//			printf("%d", res[i + j]);
			if (res[i + j] > 9)
			{
				res[i + j + 1] += (res[i + j] / 10);
				res[i + j] %= 10;  
			}
		}
	}
	
	
	i =  lenA + lenB - 1;
	
	while (res[i] == 0)
	{
		i--;
	}
//	printf("%d\n", i);
	if (i < 2)
	{
		printf("%d", 0);
		
	}
	else
	{
//		printf("%d\n", res[i]);
	
		while (i >=  2)
		{
			printf("%d", res[i--]);
		}
		
	}
//1000 0000  0000 0000
//9990 0000  0000 0000
	
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for (int i = 0; i < N; i++){
        cin >> x[i];
    }
    int l = 0;
    int r = K-1;
    int ans = 300000000;
    while (r < N){
        ans = min({ans, x[r] - x[l] + abs(x[r]), x[r] - x[l] + abs(x[l])});
        l++;
        r++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int n,m;
    int ans=0;
    int count=1;
    string s[100],t[100];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>s[i];
    cin>>m;
    for(int i=0;i<m;i++)
        cin>>t[i];
    
    sort(s,s+n);
    
    for(int i=0;i<n;i++){
        if(s[i]==s[i+1]){
            count++;
        }
        else{
            for(int j=0;j<m;j++){
                if(s[i]==t[j]){
                    count--;
                }
            }
            if(ans<count)
                ans=count;
            count=1;
        }
            
    }
    cout<<ans<<endl;
    return 0;
}

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

ll exor(ll a){
    ll p=(a+1)/2;
    if((a+1)%2==0){
        return p%2;
    }else{
        return (p%2)^a;
    }
}

int main(){

    ll a,b;

    cin >> a >> b;

    ll ans=exor(a-1)^exor(b); 

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a1 = 0, a2 = 0, a3 = 0;
	int x;
	for(int i = 0; i < 10; i++){
		scanf("%d", &x);
		if(x > a3){
			a3 = x;
		}
		if(x > a2){
			a3 = a2;
			a2 = x;
		}
		if(x > a1){
			a2 = a1;
			a1 = x;
		}
	}

	printf("%d\n%d\n%d\n", a1, a2, a3);

	return 0;
}

Measured memory_bytes: 1028
n = int(input())
n_4,n_7,end = 0,0,0
while n_4*4 <= n:
    n_7  = 0
    while n_7*7 + n_4*4 <= n:
        if n_7*7 + n_4*4 == n:
            print("Yes")
            end = 1
            break
        n_7 += 1
    if end == 1: break
    n_4+=1
if end == 0:
    print("No")

Measured memory_bytes: 3060
using System;

public class AtCoder{
	public static void Main(){
		int n;
		n = int.Parse(Console.ReadLine().Trim());
		string[] s;
		s = Console.ReadLine().Trim().Split(' ');
		int t,a;
		t = int.Parse(s[0]);
		a = int.Parse(s[1]);
		s = Console.ReadLine().Trim().Split(' ');
		int[] h = new int[n];
		for(int i=0; i<n; i++){
			h[i] = int.Parse(s[i]);
		}
		
		double y, min;
		int mini = -1;
		min = 1000000;
		for(int i=0; i<n; i++){
			y = (t - h[i]*0.006 - a) * (t - h[i]*0.006 - a);
			if(y<min){
				min = y;
				mini = i;
			}
		}
		
		Console.WriteLine(mini + 1);
	}
}

Measured memory_bytes: 13140
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define mdn 998244353
#define N 410
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=1ll*ans*bs%mdn;
		bs=1ll*bs*bs%mdn; mi>>=1;
	}
	return ans;
}
int f[2][N][N],a[N],b[N],n,s,sa,sb;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)	a[i]=read(),b[i]=read(),sa+=a[i],sb+=b[i];
	int cur=0,lst=1; f[cur][0][0]=mdn-1;
	for(int i=1;i<=n;i++)
	{
		cur^=1,lst^=1; memcpy(f[cur],f[lst],sizeof(f[cur]));
		for(int p=1,l=0;l<b[i];l++,p=1ll*p*a[i]%mdn*ksm(l,mdn-2)%mdn)
		for(int j=a[i];j<=sa;j++)	for(int k=l;k<=sb;k++)
			upd(f[cur][j][k],mdn-1ll*p*f[lst][j-a[i]][k-l]%mdn);
	}
	int ans=0;
	for(int i=1;i<=sa;i++)
	{
		int p=1,inv=ksm(i,mdn-2),q=1ll*sa*inv%mdn;
		for(int k=0;k<=sb;k++,p=1ll*p*inv%mdn*k%mdn)
			upd(ans,1ll*f[cur][i][k]*p%mdn*q%mdn); 
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
bool primeNumber(int n) {
  if (n < 2)
    return false;
  else {
    for (int i = 2; i * i <= n; i++) {
      if (n % i == 0)
        return false;
    }
    return true;
  }
}
int main() {
  int n, count = 2;
  cin >> n;
  int prime[n];
  for (int i = 0; i < n;) {
    if (primeNumber(count) == true && count % 5 == 1) {
      prime[i] = count;
      i++;
    }
    count++;
  }
  for (int i = 0; i < n; i++) {
    cout << prime[i] << endl;
  }
  return 0;
}

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

int main(void)
{
    string S;
    cin >> S;

    sort(S.begin(), S.end());

    string ans = "Yes";
    if (S[0] != S[1] || S[2] != S[3] || S[0] == S[2])
        ans = "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
   int N,M,X,Y;
   std::cin>>N>>M>>X>>Y;
   int x[N], y[M];
   for(int i=0;i<N;i++)
       std::cin>>x[i];
    for(int i=0;i<M;i++)
        std::cin>>y[i];

   bool nowar=false;

   for(int i=-100;i<101;i++){
       bool check=true;
       if((X<i&&i<=Y)){
         for(int j=0;j<N;j++)
           for(int k=0;k<M;k++)
               if((x[j]>=i)||y[k]<i)
                 check=false;
         if(check) nowar=true;
         }
   }
   if(nowar) std::cout<<"No War"<<std::endl;
   else std::cout<<"War"<<std::endl;

   return 0;
}

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

const long long mod=998244353;

int main(int argc, char const *argv[])
{
	int n;
	string s;
	cin>>n>>s;
	int r=0,g=0,b=0,rg=0,gb=0,br=0;
	long long ans=1LL;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s.at(i)=='R')
		{
			if (gb>0)
			{
				ans*=(long long)gb;
				ans%=mod;
				--gb;
			}
			else if (g>0)
			{
				ans*=(long long)g;
				ans%=mod;
				--g;
				++rg;
			}
			else if (b>0)
			{
				ans*=(long long)b;
				ans%=mod;
				--b;
				++br;
			}
			else
			{
				ans*=(long long)n;
				ans%=mod;
				--n;
				++r;
			}
		}
		else if (s.at(i)=='G')
		{
			if (br>0)
			{
				ans*=(long long)br;
				ans%=mod;
				--br;
			}
			else if (b>0)
			{
				ans*=(long long)b;
				ans%=mod;
				--b;
				++gb;
			}
			else if (r>0)
			{
				ans*=(long long)r;
				ans%=mod;
				--r;
				++rg;
			}
			else
			{
				ans*=(long long)n;
				ans%=mod;
				--n;
				++g;
			}
		}
		else if (s.at(i)=='B')
		{
			if (rg>0)
			{
				ans*=(long long)rg;
				ans%=mod;
				--rg;
			}
			else if (r>0)
			{
				ans*=(long long)r;
				ans%=mod;
				--r;
				++br;
			}
			else if (g>0)
			{
				ans*=(long long)g;
				ans%=mod;
				--g;
				++gb;
			}
			else
			{
				ans*=(long long)n;
				ans%=mod;
				--n;
				++b;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,tong = 0;
ll C(ll h,ll k)
{
    ll q = 1,p = 1;
    for(ll i = h - k + 1;i <= h;i ++)
    {
        q *= i;
    }
    for(ll i = 1;i <= k;i ++)
    {
        p *= i;
    }
    return q/p;
}
int main()
{
    cin >> n >> m;
    if(n == 1 || m == 1)
    {
        if(n == 1)
        {
            if(m == 1) cout << 0;
            else cout << C(m,2);
        }
        else
        {
            cout << C(n,2);
        }
    }
    else
    {
        tong = C(n,2) + C(m,2);
        cout << tong;
    }
    return 0;
}


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

using namespace std;

int main()
{
    string s;

    cin >> s;

    int ans = 0;

    if (s == "SAT")
        ans = 1;
    if (s == "FRI")
        ans = 2;
    if (s == "THU")
        ans = 3;
    if (s == "WED")
        ans = 4;
    if (s == "TUE")
        ans = 5;
    if (s == "MON")
        ans = 6;
    if (s == "SUN")
        ans = 7;

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int k, s, num = 0;
	cin >> k >> s;
	for (int x = 0; x < k + 1; ++x) {
		for (int y = 0; y < k + 1; ++y) {
			if (0 <= s - x - y && s - x - y <= k)num = num + 1;
		}
	}
	cout << num << endl;

}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

template<typename T>
ostream& operator<< (ostream& out, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        out << *it << " ";
    }
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        in >> *it;
    }
    return in;
}

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    ll len = B - A + 1;
    if (K >= (len + 1) / 2) {
        for (int i = A; i <= B; ++i) {
            cout << i << endl;
        }
    } else {
        for (int i = A; i <= A + K - 1; ++i) {
            cout << i << endl;
        }
        for (int i = B - K + 1; i <= B; ++i) {
            cout << i << endl;
        }
    }
    return 0;
}

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

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    if (s == t.substr(0, t.length() - 1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a": " << a << endl;
#define mst(a, b) memset(a, b, sizeof(a))
#define ALL(x) x.begin(), x.end()
#define lc rt << 1
#define rc rt << 1 | 1
#define X first
#define Y second
inline int lowbit(int x) { return x & -x; }
typedef long long LL;
typedef double db;
typedef pair<int, int> pii;
const int N = 1e5 + 10;
const int M = 1e6 + 10;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const int mod = 1e9;

int x[3];
int y[3];

LL area(LL x, LL y, LL xx, LL yy) {
    return x * yy - y * xx;
}

int main() {
#ifdef purple_bro
    freopen("in.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    LL s;

    cin >> s;

    LL t = s % mod;
    s = (s / mod + (t != 0)) * mod;

    if (t == 0)
        t = mod;

    x[1] = mod;
    y[2] = s / mod;
    x[2] = 1;
    y[1] = mod - t;

    for (int i = 0; i < 3; i++)
        cout << x[i] << " " << y[i] << " ";

    cout << "\n";

//    cout << area(x[1], y[1], x[2], y[2]) << "\n";

    return 0;
}


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n, k; cin>>n>>k;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];

  ll l = 1;
  ll r = 1000000001;

  while (l < r) {
    ll m = (l+r)/2;
    ll t = 0;
    rep(i, n) {
      t += (a[i]-1)/m;
    }
    if (t <= k) r = m;
    else l = m+1;
  }
  cout << l << endl;

  return 0;
}


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

int main()
{
  int k, n;
  cin >> k >> n;

  int dmax = 0;

  vector<int> a(n);

  cin >> a[0];
  for(int i = 1; i < n; i++){
    cin >> a[i];
    if(a[i] - a[i - 1] > dmax){
      dmax = a[i] - a[i - 1];
    }
  }

  if(k - a[n - 1] + a[0] > dmax){
    dmax = k - a[n - 1] + a[0];
  }

  cout << k - dmax;

  return 0; 
}


Measured memory_bytes: 1024