akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)

int fn(char a[]){
  int n = 0,k = 1;
  for(int i = 0 ; a[i] ; i++){
    if(a[i]=='m'){
      n += k*1000;
    }
    if(a[i]=='c'){
      n += k*100;
    }
    if(a[i]=='x'){
      n += k*10;
    }
    if(a[i]=='i'){
      n += k*1;
    }
    if('0' <= a[i] && a[i] <= '9'){
      k = a[i] - '0';
    }else{
      k=1;
    }
  }
  return n;
}

int main()
{
  int n;
  cin >> n;
  rep(i, n){
  char a1[10], a2[10];
  cin >> a1 >> a2;
  
    int a = 0;
    a = fn(a1) + fn(a2);
    
    if((a / 1000) > 1){
      cout << a/1000;
    }
    if(a / 1000){
      cout << "m";
    }
    a %= 1000;

    if((a / 100) > 1){
      cout << a/100;
    }
    if(a / 100){
      cout << "c";
    }
    a %= 100;

    if((a / 10) > 1){
      cout << a/10;
    }
    if(a / 10){
      cout << "x";
    }
    a %= 10;

    if(a > 1){
      cout << a;
    }
    if(a){
      cout << "i";
    }
    cout << '\n';
  }
}
 

Measured memory_bytes: 1164
import numpy as np
h, w = map(int, input().split())
a = np.zeros((h + 1) * (w + 1)).reshape(h + 1, w + 1)
for y in range(1, h + 1):
    t = list(map(int, input().split()))
    for x in range(1, w + 1):
        a[y, x] = t[x - 1] % 2
ans = []
for y in range(1, h + 1):
    for x in range(1, w + 1):
        if (a[y, x - 1]):
            a[y, x] = (a[y, x] + a[y, x - 1]) % 2
            ans.append((y, x - 1, y, x))
for y in range(1, h + 1):
    x = w
    if (a[y - 1, x]):
        a[y, x] = (a[y, x] + a[y - 1, x]) % 2
        ans.append((y - 1, x, y, x))
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])

Measured memory_bytes: 31972
use proconio::input;

fn main() {
    input! {
        x: usize,
    };
    let d2 = x % 100;
    let c = d2 / 5 + if d2 % 5 != 0 { 1 } else { 0 };
    let ans = x >= (c * 100 + d2);
    println!("{}", if ans { "1" } else { "0" });
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

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

	int a = n, b = 0;
	while (n >= 10) {
		b += n % 10;
		n /= 10;
	}
	b += n;

	cout << (a % b == 0 ? "Yes" : "No") << endl;

	return 0;
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	string S, T;
	cin >> S >> T;

	ll ans = INF;
	ll maxPos = S.size() - T.size()  + 1;
	REP(i, maxPos) {
		ll ansOne = 0;
		REP(j, T.size()) {
			if (T[j] != S[i + j]) {
				ansOne++;
			}
		}
		if (ansOne < ans) {
			ans = ansOne;
		}
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  string ans = "";

  while (N != 0) {
    ll res = N % 2;
    if (res < 0) res = -res;
    N = (N - res) / (-2);
    ans += (char)('0' + res);
  }
  reverse(ans.begin(), ans.end());
  if (ans == "") ans = "0";
  cout << ans;
  return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ll n;
    cin>>n;
    if(n==2){
        cout<<1<<endl;
        return 0;
    }
    ll ans1=1;
    ll ans2=1;
    ll ans3=0;
    for(ll i = 2;i*i <= n+1;++i) {
        ll t=n;
        if(n%i==1){
            ++ans2;
            if(i*i!=n-1)++ans2;
            continue;
        }
        if(n%i!=0)continue;
        ll j=i;
//cerr<<"t,j:"<<t<<" "<<j<<endl;
        while(j<=n){
            if(t%j!=0)break;
            if((t/j)%i==1){
                ++ans3;
                break;
            }
            else if(j==n)++ans1;
            j*=i;
        }
    }
    cout<<ans1+ans2+ans3<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
g=[]
for i in range(n):
    a,b=map(int,input().split())
    g.append([a,b])
g.sort()
i=0
while k>0:
    if k>g[i][1]:
        k-=g[i][1]
        i+=1
    else:
        ans=g[i][0]
        break
print(ans)


Measured memory_bytes: 54108
#include <iostream>
#include <cstring>
using namespace std;
int main() {
    string s;
    cin >> s;
    int len = s.size();
    for(int i = 0; i < len; i++)
        if(s[i] == '?')
            s[i] = 'D';
    cout << s << endl;
    return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int X, N, p[100];
    
    cin >> X >> N;
    
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    
    sort(p, p + N);
    
    int epsilon = 0;
    
    while (true) {
        int y = X + epsilon, yy = X - epsilon;
        
        if (!binary_search(p, p + N, yy)) {
            cout << yy << endl;
            break;
        } else if (!binary_search(p, p + N, y)) {
            cout << y << endl;
            break;
        } else {
            epsilon++;
        }
        
    }
    
}


Measured memory_bytes: 3644
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ar = a[::-1]
    lgcds = [1]*n
    rgcds = [1]*n
    lgcd, rgcd = a[0], ar[0]
    lgcds[0] = rgcd
    lgcds[1] = lgcd
    rgcds[n-1] = lgcd
    rgcds[n-2] = rgcd
    for i in range(2, n):
        lgcd = gcd(lgcd, a[i-1])
        rgcd = gcd(rgcd, ar[i-1])
        lgcds[i] = lgcd
        rgcds[n-1-i] = rgcd
    ans = 1
    for i in range(n):
        gi = gcd(lgcds[i], rgcds[i])
        if gi > ans:
            ans = gi
    print(ans)

def gcd(x, y):
    r = x % y
    while r:
        x, y, r = y, r, y%r
    return y

if __name__ == "__main__":
    main()

Measured memory_bytes: 64620
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
    long a, b, m, small, x, y, c;
    cin >> a >> b >> m;
    vector<int>as(a);
    vector<int>bs(b);
    vector<int>sas(a);
    vector<int>sbs(b);
    for (int i = 0; i < a; i++){
        cin >> as[i];
        sas[i] = as[i];
    }
    for (int i = 0; i < b; i++){
        cin >> bs[i];
        sbs[i] = bs[i];
    }
    sort(sas.begin(), sas.end());
    sort(sbs.begin(), sbs.end());
    small = sas[0] + sbs[0];
    for (int i = 0; i < m; i++){
        cin >> x >> y >> c;
        if (as[x - 1] + bs[y - 1] - c < small){
            small = as[x - 1] + bs[y - 1] - c;
        }
    }
    cout << small << endl;
} 

Measured memory_bytes: 1792
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  ll N;
  cin >> N;

  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> C(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (ll i = 0; i < N; i++) {
    cin >> B[i];
  }
  for (ll i = 0; i < N; i++) {
    cin >> C[i];
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    ll b = B[i];
    auto aIndex = lower_bound(A.begin(), A.end(), b) - A.begin();
    auto cIndex = upper_bound(C.begin(), C.end(), b) - C.begin();

    // cout << aIndex << " " << cIndex << endl;

    ans += (aIndex) * (N - cIndex);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#define MAX 36
#define True 1
#define False 0

typedef struct{
  char c;
  int num;
} card;

void cardsort(card []);
void select(card []);
int search(card [],card []); 

int number;

int main(){
  int i,j;
  card data[MAX];
  card data2[MAX];
  
  
  scanf("%d",&number);
  for(i=0;i<number;i++) {
    scanf(" %c%d",&data[i].c,&data[i].num);
  }
  
  for(i=0;i<number;i++) {
    data2[i] = data[i];
  }
  
  cardsort(data);
  select(data2);

  
  for(i=0;i<number-1;i++){
    printf("%c%d ",data[i].c,data[i].num);
  }
  printf("%c%d\n",data[number-1].c,data[number-1].num);
  printf("Stable\n");

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

  if(search(data,data2)==1) printf("Stable\n");
  else printf("Not stable\n");
  return 0;
}


void cardsort (card n[]){
  int i,j,tmp;
  char tmpc;
  for(i=0;i<number;i++){
    for(j=number-1;j>i;j--){
      if(n[j].num<n[j-1].num){
	tmp=n[j].num;
	n[j].num=n[j-1].num;
	n[j-1].num=tmp;

	tmpc=n[j].c;
	n[j].c=n[j-1].c;
	n[j-1].c=tmpc;
      }
    }
  }
}


void select(card n[]){

  int min,i,j,tmp;
  char tmpc;
  for(i=0;i<number;i++){
    min=i;
    for(j=i;j<number;j++){
      if(n[j].num<n[min].num){
	min=j;
      }
    }
    if(min != i){
      tmp=n[i].num;
      n[i].num=n[min].num;
      n[min].num=tmp;

      tmpc=n[i].c;
      n[i].c=n[min].c;
      n[min].c=tmpc;
    }
  }
}

int search(card data[],card data2[]){
  int i,count=0;
    for(i=0;i<number;i++){
      if(data[i].c != data2[i].c || data[i].c != data2[i].c){
	return False;
      }
    }
    return True;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> k){
  if((int)k.size() == n+1){
    int sco = 0;
    for(int i = 0; i < q; i++){
      if(k.at(b.at(i)) - k.at(a.at(i)) == c.at(i)) sco += d.at(i);
    }
    ans = max(ans, sco);
    return;
  }
  
  k.push_back(k.back());
  while(k.back() <= m){
    dfs(k);
    k.back()++;
  }
}

int main(){
  cin >> n >> m >> q;
  a = b = c = d = vector<int> (q);
  for(int i = 0; i < q; i++) cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  
  vector<int> sam(1, 1);
  dfs(sam);
  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<long> H(N);
  for (int i = 0; i < N; i++) {
    cin>>H.at(i);
  }
  bool a=true;
  long b=0;
  for (int i = 1; i < N; i++) {
    b=max(b,H.at(i-1));
    if(b>H.at(i)+1){
      a=false;
      break;
    }
    
  }
  
  
  if(a){
     cout<<"Yes"<<endl;
     
   }
  else{
    cout<<"No"<<endl;
  }

}



Measured memory_bytes: 1024
n=gets.to_i
words={}
n.times do
  word = gets.chomp.split("").sort.join("")
  if words.include?(word)
    words[word] +=1
  else
    words[word] = 1
  end
end
counter=0
 
words.each_pair do |key,value|
  if value > 1
    counter += value * (value -1) / 2
  end
end
puts counter

Measured memory_bytes: 18428
#include <stdio.h>
int main(){
	    int N,R;

    scanf("%d %d", &N, &R);
    
    if (N<10){
    	 printf("%d", R+(100*(10-N)));
	}
	
    if (N>=10){
    	printf("%d", R);
	}

    
	return 0;
}

Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define ll long long 
#define mp make_pair
#define pb push_back
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const long double PI = acos(-1.0);
const ll Mod=1000000007;
const ll Maxi=1e18;
const ll Mini=-1e18;
 
int main()
{
   IOS;
   //#ifndef ONLINE_JUDGE
  //freopen("input.txt","r",stdin);
   //#endif
  ll ti;
  //cin>>ti;
  ti=1;
  
  while(ti>0)
  {
   ll a,b,c;
   cin>>a>>b>>c;
   if(a+b+c>=22)
   {
    cout<<"bust";
   }
   else
    cout<<"win";
   ti--;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{  int n,h,w,mx;
   cin >> h >> w >> n;
   mx=max(h,w);
   cout << ceil(n*1.0 / mx);
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0<<endl;
        return 0;
    }
    ll sumn=1,summ=1;
    
    rep(i,1,n+1){
        sumn*=(ll)i;
        sumn%=MOD;
    }
    
    rep(i,1,m+1){
        summ*=(ll)i;
        summ%=MOD;
    }
    sumn*=summ;
    sumn%=MOD;
    
    if(n==m)sumn*=2;
    cout<<sumn%MOD<<endl;
    
    
    

    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong(), B = sc.nextLong(), ans = 0;
		if (A%2 == 1) {
			ans^=(A-1);
			A--;
		}
		while((B-A+1)%4!=0) {
			ans^=(B+1);
			B++;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 22996
def examA():
    N = I()
    ans = (10000 - N)%1000
    print(ans)
    return

def examB():
    T = ["AC","WA","TLE","RE"]
    N = I()
    S = [SI()for _ in range(N)]

    ans = [0]*4
    for s in S:
        for i in range(4):
            if s==T[i]:
                ans[i] += 1
                break
    for i in range(4):
        print(T[i]+" x "+str(ans[i]))
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 85432
#escape_sequence
#escape_ck_ans
N=int(input())
#red=list(map(int,input().split()))
#blue=list(map(int,input().split()))
red=[list(map(int,input().split())) for i in range(N)]
blue=[list(map(int,input().split())) for i in range(N)]
blue.sort(key=lambda x:x[0])
red.sort(key=lambda x:x[1],reverse=True)
#print(blue)
#print(red)
pairs=0
flag=[True for i in range(N)]
for i in range(N):#blue
    for j in range(N):#red
        if blue[i][0]>red[j][0] and blue[i][1]>red[j][1] and flag[j]==True:
            pairs+=1
            flag[j]=False#used_red
            break
print(pairs)




Measured memory_bytes: 3064
use std::io::*;
use std::str::*;

// const MOD: i32 = 1000000007;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: u32 = read().unwrap();
    let p: usize = read().unwrap();

    let mut e = 0;
    for _ in 0..n {
        let tmp: i64 = read().unwrap();
        if tmp % 2 == 0 {
            e += 1;
        }
    }

    let s: i64 = 2;
    if e == n && p == 0 {
        println!("{}", s.pow(n));
        return;
    }
    if e == n && p == 1 {
        println!("{}", 0);
        return;
    }
    println!("{}", s.pow(n - 1));
}


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

int main() {
  int a1,a2,a3;
  int a12,a23,a31;
  cin >> a1 >> a2 >> a3;
  a12 = fabs(a1-a2);
  a23 = fabs(a2-a3);
  a31 = fabs(a3-a1);
  int maxa=max(a31,max(a12,a23));
  cout << a12+a23+a31-maxa << endl;
}
  

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

using namespace std;

typedef long long ll;

int main()
{
    ll K, N;
    cin >> K >> N;
    vector<ll> A(N);
    for (auto &a : A)
    {
        cin >> a;
    }
    ll index = N;
    ll max = K - A[N - 1] + A[0];
    for (int i = 0; i < N - 1; i++)
    {
        if (max < A[i + 1] - A[i])
        {
            max = A[i + 1] - A[i];
            index = i;
        }
    }
    cout << K - max << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string s;
    for(int i=0;i<3;i++){
        cin>>s;
        s[0]=s[0]+'A'-'a'; //s[0] とか　char型の一文字単体でアスキーコードの数になっている！！
        cout<<s[0];
    }
    cout<<endl;
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 256
// Debug : debug template
// Number : number theory 

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define pi pair<int,int>
#define IOS ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);

const int inf = 0x3f3f3f3f;
const ll INF = 0xFFFFFFFFFFFFFFFL;

typedef tree<int,null_type, /*greater<int>,*/
less<int>,rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// find_by_order() and order_of_key() returns pointers
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)

ll N,W;
ll dp[102][100005];
vector<ll> weight, value;

void init(){
	for(int i=0;i<102;i++){
		for(int j=0;j<100005;j++)
			dp[i][j] = -1;
	}
	weight.resize(N);
	value.resize(N);
}

ll memoize(int index, int allowedW){
	// returns max value that can be reached, if we are at 'index'
	// with allowed weight as 'allowedW'
	if(allowedW<0)
		return INT_MIN;
	else if(index<0)
		return 0;

	if(dp[index][allowedW]!=-1)
		return dp[index][allowedW];

	return dp[index][allowedW] = max(value[index]+memoize(index-1, allowedW-weight[index]), memoize(index-1, allowedW)); 
}

void solve(){
	// your main solution for each testcase
	cin >> N >> W;
	init();
	for(int i=0;i<N;i++)
		cin >> weight[i] >> value[i];
	
	// print the max value that we can achieve, given that
	// we are at index=(N-1) with allowed weight as 'W'
	cout << memoize(N-1,W) << "\n";
}

int main(){
	IOS;
	int test=1;
	// cin >> test;
	while(test--)
		solve();

	return 0;
}


Measured memory_bytes: 80000
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll n,i,co=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        if(x%2)
            co++;
    }
    if(co%2)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int A, B;
      cin >> A >> B;
      
        if ((A * B) % 2 == 0){
       	 cout << "Even" << endl;
      	}
     
     	else {
        	cout << "Odd" << endl;
      	}
      
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn = 1e5 + 100;

int a[maxn], b[maxn], p[maxn];

int main () {
	ios_base::sync_with_stdio (false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		a[i] = i;
		b[i] = n - i + 1;
		cin >> p[i];
	}
	int mx = 0;
	for (int i = 1; i <= n; i++) {
		int k = a[p[i]] + b[p[i]];
		if (k > mx) {
			mx = k;
			continue;
		}
		k = mx - k + 1;
		for (int j = p[i]; j >= 1; j--)
			b[j] += k;
		for (int j = p[i]; j <= n; j++)
			a[j] += k;
		mx = max (mx, a[p[i]] + b[p[i]]);
	}
	for (int i = 1; i <= n; i++)
		cout << a[i] << " ";
	cout << endl;
	for (int i = 1; i <= n; i++)
		cout << b[i] << " ";
}


Measured memory_bytes: 896
K = int(input())
ans = 0


def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    else:
        return gcd(a, b % a)


for c in range(1, K+1):
    for b in range(1, K+1):
        for a in range(1, K+1):
            ans += gcd(gcd(a, b), c)
print(ans)


Measured memory_bytes: 81568
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
#ifndef ONLINE_JUDGE
	#define debug 1
#else
	#define debug 0
#endif
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());}
void printstr(char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
int n, s[105], score=0;
int main() {
	n=readint();
	rep(i,1,n) s[i]=readint();
	rep(i,1,n) score+=s[i];
	sort(s+1,s+1+n);
	if (score%10==0) {
		rep(i,1,n) if (s[i]%10!=0) {
			score-=s[i];break;
		}
	}
	if (score%10==0) score=0;
	printint(score);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <stack>
#include <deque>
#include <chrono>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<int,int> pii;
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define REPb(j, d, c) for (int j = int(d); j >= int(c); j--)
#define ff first
#define ss second
#define pb push_back
#define len(x) int((x).size())

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin>>s;
	
	int n = len(s);
	
	// decompose into A's, BC's and others
	
	vector<pii> decomp;
	
	// 0 is A
	// 1 is B
	// 2 is C
	
	int cur=-1;
	int cur_len=0;
	
	REP(i,0,n-1)
	{
	    if(s[i]=='A')
	    {
	        if(cur!=0)
	        {
	            decomp.pb({cur,cur_len});
	            cur_len=0;
	            cur=0;
	        }
	        
	        cur_len++;
	        continue;    
	    }
	    
	    if(i<n-1 && s[i]=='B' && s[i+1]=='C')
	    {
	        if(cur!=1)
	        {
	            decomp.pb({cur,cur_len});
	            cur_len=0;
	            cur=1;
	        }
	        
	        cur_len++;
	        i++;
	        continue;
	    }
	    
	    // otherwise nothing
	    
	    if(cur!=2)
	    {
	        decomp.pb({cur,cur_len});
	        cur_len=0;
	        cur=2;
	    }
	    
	    //cur=2;
	    cur_len++;
	}
	
	decomp.pb({cur,cur_len});
	
// 	for(auto d:decomp)
// 	{
// 	    cout<<d.ff<<" "<< d.ss<<endl;
// 	}
	
	int active_bc=0;
	ll ans=0;
	
	REPb(i,decomp.size()-1,0)
	{
	    if(decomp[i].ff==1) active_bc+=decomp[i].ss;
	    if(decomp[i].ff==0) ans+=ll(decomp[i].ss)*ll(active_bc);
	    if(decomp[i].ff==2) active_bc=0;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
using namespace std;
int main()
{
     int n1,n2,sum;
   scanf("%d %d",&n1,&n2);


    sum=n1+n2;
    if(sum%2==0){
        sum=sum/2;
        printf("%d",sum);
    }
    else
        printf("IMPOSSIBLE");

}


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

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

  int res = 0;
  int start;
  int end;
  for(int i = 0; i < N; ++i) {
    cin >> start >> end;
    res += end - start + 1;
  }
  
  cout << res << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  ll n, m;
  cin >> n >> m;
  ll sum = 0;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    sum += a;
  }
  cout << max(-1ll, n - sum) << endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String s=sc.next();
        String t=sc.next();
        String ans="";
        for(int i=0;i<n;i++){
            ans+=s.charAt(i);
            ans+=t.charAt(i);
        }
        System.out.println(ans);
        
    }

    
}

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

int main()
{
    int a,b,c,d,e,f,g;
    cin >> a;
    cin>> b;
    cin >> c;
    d=(a-b);
    e=(d/c);
    f=(e*c);
    g=(d-f);
    cout << g<< endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

struct segtree {
public:
	const int SIZE = 1 << 18;
	VI seg, lazy;
	//seg:区間の合計値 lazy:区間に対して、加える値でまだ遅延しているもの

	segtree() :seg(SIZE * 2), lazy(SIZE * 2) {}
	void lazy_evaluate(int k, int l, int r) {
		if (lazy[k] != 0) {
			seg[k] += lazy[k];
			//区間[l,r)にすべて同じ値を追加することになっていて、
			//segには合計値が入っているので、加える値を足す
			if (r - l > 1) {
				lazy[k * 2 + 1] += lazy[k];
				lazy[k * 2 + 2] += lazy[k];
			}
			lazy[k] = 0;
		}
	}

	void update(int a, int b, int k, int l, int r, int x) {
		lazy_evaluate(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l && r <= b) {
			lazy[k] += x;
			lazy_evaluate(k, l, r);
		}
		else {
			update(a, b, k * 2 + 1, l, (l + r) / 2, x);
			update(a, b, k * 2 + 2, (l + r) / 2, r, x);
			seg[k] = seg[k * 2 + 1] + seg[k * 2 + 2];
		}
	}
	int query(int a, int b, int k, int l, int r) {
		lazy_evaluate(k, l, r);
		if (r <= a || b <= l)return 0;
		if (a <= l && r <= b)return seg[k];
		int x = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int y = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return x + y;
	}

	void update(int a, int b, int x) { update(a, b, 0, 0, SIZE, x); }
	//update(a,b,x) := [a,b)を全てxを加える
	int query(int a, int b) { return query(a, b, 0, 0, SIZE); }
	//query(a,b) := [a,b)に対する合計値を求める

};

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

	int N; cin >> N;
	map<char, bool>mp;
	int ans = 0;
	REP(i, N) {
		char c; cin >> c;
		if (!mp[c]) {
			ans++;
			mp[c] = true;
		}
	}
	if (ans == 3)cout << "Three" << endl;
	else cout << "Four" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        System.out.println( Math.max( (Math.max(a*c,a*d)),(Math.max(b*c,b*d)) ) );



    }
}


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

int main(void) {
int n, i, x, ko;
std::cin >> n >> x;
std::vector<int> m(n);

for (i = 0; i < n; i++) {
  std::cin >> m[i];
}

for (i = 0; i < n; i++) {
  x  = x - m[i];
}

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

ko = x / m[0];
std::cout << ko + n << '\n';

return 0;
}


Measured memory_bytes: 256
import re
def Main():
  s = input()
  # r = re.findall("A.+Z",s)
  # # print(r)
  # cnt = 0
  # for i in r:
  #   cnt = max(cnt, len(i))
  ans = re.findall("A[A-Z]+Z", s)
  print(len(ans[0]))

  # print(cnt)
# QWERTYASDFZXCV

if __name__ == '__main__':
  Main()

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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    int a[n+1];
    for(int i =0;i<n;i++){
        cin>>a[i];
    }
    bool flag = true;
    int num = 1;
    int cnt = 0;
    for(int i = 0; i<n; i++){
        if(a[i] != num){
            cnt++;
        }else{
            num++;
        }
    }
    if(num == 1) cnt = -1;

    cout<< cnt <<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputNum = br.readLine().split(" ");
		int a = Integer.parseInt(inputNum[0]);
		int b = Integer.parseInt(inputNum[1]);
		int c = Integer.parseInt(inputNum[2]);

		int num[] = {a , b , c};

		Arrays.sort(num);

		System.out.println(num[0] + " " + num[1] + " " + num[2]);




	}

}

Measured memory_bytes: 16948
#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()

const int mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    rep (i, n) {
        string s;
        cin >> s;
        if (s == "AC") {
            ac++;
        } else if (s == "WA") {
            wa++;
        } else if (s == "TLE") {
            tle++;
        } else {
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}




Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.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 ans = 0;

void dfs(vector<int> A,int size_N, int size_Q,int size_M, int Qa[],int Qb[],int Qc[],int Qd[]){

    if(A.size() == size_N + 1) {
        int now = 0;
        for (int i = 0; i < size_Q; ++i) {
            if (A[Qb[i]] - A[Qa[i]] == Qc[i]) {
                now += Qd[i];
            }
        }
            if (ans < now) {
                ans = now;
            }
            return;

    }

    A.push_back(A.back());
    while(A.back() <= size_M) {
        dfs(A,size_N,size_Q,size_M,Qa,Qb,Qc,Qd);
        A.back()++;
    }
}


int main() {
    int N, M, Q;
    scanf("%d %d %d", &N, &M, &Q);
    int Qa[Q];
    int Qb[Q];
    int Qc[Q];
    int Qd[Q];
    for (int i = 0; i < Q; ++i) {
        scanf("%d %d %d %d", &Qa[i], &Qb[i], &Qc[i], &Qd[i]);
    }
    dfs(vector<int>(1, 1), N, Q, M, Qa, Qb, Qc, Qd);
    printf("%d", ans);


}


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

const ll inf = 1e18L + 5;

void max_self(int& a, int b ){
    a = max(a, b);
}

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

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

    ll res = 0;
    if( a < k ) {
        res += a;
        k -= a;
    } else {
        cout<<k;
        return 0;
    }

    if( b < k ) {
        k -= b;
    } else {
        cout<<res;
        return 0;
    }

    cout<<res-k;

    return 0;
}

Measured memory_bytes: 3640
N, M = map(int, input().split())
L = list(map(int, input().split()))

count = 0

if L[0] > M:
	count+= (L[0]-M)
	L[0]-= (L[0]-M)

for i in range (1, N):
	if L[i]+L[i-1] > M:
		count+= (L[i]+L[i-1])-M
		L[i]-= (L[i]+L[i-1])-M
    
print(count)

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

	/* input, output routines */
	#define RI(X) scanf("%d", &(X))
	#define RII(X, Y) scanf("%d%d", &(X), &(Y))
	#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
	#define DRI(X) int (X); scanf("%d", &X)
	#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
	#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
	#define debv(x,n)     REP(i,n) printf("%d ",(x)[i] );  nl  //output int list

	/* loops */
	#define FOR(i,a,b) for (int (i)=(a); (i) < (b); (i)++)
	#define REP(i,n) FOR(i,0,n)

	/* strings */
	#define rwc(c)  scanf("%c",&c)!=EOF && c!=10 && c!=32	//read word by char, important: validate, if (c==13) { getchar(); break; }
	#define rlc(c)  scanf("%c",&c)!=EOF && c!=10 			//read line by char
	#define rac(c)  scanf("%c",&c)!=EOF 					//read all char by char
	#define sz(x) (int((x).size()))

	/* data types */
	#define ull unsigned long long
	#define ll long long

	/* data structures */
	#define pi pair <int,int>
	typedef vector <int> vi;
	typedef vector <vi> vvi;

	/* Array */
	#define initn(a,n,x) REP(i,n) a[i]=x
	#define init(a,x) REP(i,sizeof(a)/4) a[i]=x; 
	#define ra(x) REP(i,sizeof(x)/4) scanf("%d",&x[i]) 
	#define showa(x) REP(i,sizeof(x)/4) printf("%d ",x[i])
	#define showan(x,n) REP(i,n) printf("%d ",x[i])
	#define sa(x) do {\
					showa(x);\
					printf("\n");\
				  } while (0)

	/* others */
	#define up(v,x) (upper_bound((v).begin(), (v).end(),(x))-(v).begin())
	#define lb(v,x) (lower_bound((v).begin(), (v).end(),(x))-(v).begin())
	#define bs(v,x) binary_search((v).begin(), (v).end(),x)

	#define flag printf("FLAG\n");
	#define nl printf("\n");
	#define pb push_back

	void print_vi(vector<int> v) {
	for (auto i: v) 
		cout<<i<<" ";
	cout<<endl;  
	}

	/* constants */
	#define inf (int)1e+9
	#define VIS 1
	#define UNVIS 0
	#define null NULL
	#define MAX (int)1e+6
	#define MIN -(int)1e+6
	
// ------------------------------------------------------------------------

int n, w;
vector<int> weight,value;
long long memo[(int)1e5+5][105];

long long maxValue(int ub, int pos) {

	if (ub<0) 
		return -inf;

	if (pos==n)
		return 0;

	if (memo[ub][pos]!=-1) 
		return memo[ub][pos];

	long long a = maxValue(ub-weight[pos],pos+1)+ value[pos];
	long long b = maxValue(ub,pos+1);

	memo[ub][pos]=max(a,b);

	return memo[ub][pos];
}

int main()
{
	
	cin.tie(NULL);
	cout.tie(NULL);

	/*Start*/

	scanf("%d%d",&n,&w);
	weight.resize(n);
	value.resize(n);
	for (int i=0; i<n; i++) {
		scanf("%d%d",&weight[i],&value[i]);
	}

	memset(memo,-1,sizeof(memo));

	// cout<<memo[9][5]<<endl;

	cout<<maxValue(w,0)<<endl;


    return 0;
}



Measured memory_bytes: 85672
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <iostream>
using namespace std;
string s[100005], c;
int main()
{
	long long n, a, b, i, j, k;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> c;
		sort(c.begin(),c.end());
		s[i] = c;
	}
	sort(s, s + n);
	int sum=1;
	k = 0;
	for (i = 1; i < n; i++)
	{
		if (s[i] != s[i - 1])
		{
			if (sum % 2 == 1)
			{
				j = (sum - 1) / 2;
				k = k + j * sum;
			}
			else
			{
				j = sum / 2;
				k = k + j * (sum - 1);
			}
			sum = 1;
			continue;
		}
		else
			if (i == n - 1)
			{
				if (s[i] == s[i - 1])
					sum++;
				if (sum % 2 == 1)
				{
					j= (sum - 1) / 2;
					k = k + j * sum;
				}
				else
				{
					j = sum / 2;
					k = k + j * (sum - 1);
				}
		      }
		sum++;
	}
	cout << k;

	return 0;
}

Measured memory_bytes: 5760
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      lrd: [(Usize1, Usize1, i64); m]
   }

   let mut to = vec![vec![]; n];
   for &(l, r, d) in lrd.iter() {
      to[l].push((r, d));
      to[r].push((l, -d));
   }

   let mut d = BTreeMap::<usize, i64>::new();
   for i in 0..n {
      if d.contains_key(&i) {
         continue;
      }
      d.insert(i, 0i64);
      if !dfs(i, &mut d, &to) {
         println!("No");
         return;
      }
   }
   println!("Yes");
}

fn dfs(v: usize, d: &mut BTreeMap<usize, i64>, to: &Vec<Vec<(usize, i64)>>) -> bool {
   let &now = d.get(&v).unwrap();
   let mut b = true;
   for &(u, x) in to[v].iter() {
      if let Some(&v) = d.get(&u) {
         if v != now + x {
            b = false;
            break;
         }
      } else {
         d.insert(u, now + x);
         if !dfs(u, d, to) {
            b = false;
            break;
         }
      }
   }
   b
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

Real f(Real h, Real y, Real z){
  if(y<=h && z<=h){
    Real a = h-y, b = h-z;
    return (a+b)*0.5;
  }else if(y>=h && z>=h){
    Real a = y-h, b = z-h;
    return (a+b)*0.5;
  }else{
    if(y<z)swap(y,z);
    Real a = y-h, b = h-z;
    return ((a*a+b*b)/(a+b))*0.5;
  }
}

int n;
int h[152];
Real dp[152][302];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",h+i);
  REP(i,152)REP(j,302)dp[i][j] = 1e25;
  dp[0][1] = 0.0;
  REP(i,n)FOR(j,1,302)if(dp[i][j] != 1e25){
    Real hh = h[i];
    FOR(to,1,302){
      CHMIN(dp[i+1][to], dp[i][j] + f(hh,j,to));
    }
  }
  Real ans = 1e25;
  REP(i,302)CHMIN(ans, dp[n][i]);
  printf("%.9f\n",ans);
  return 0;
}



Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <limits.h>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

vector<vector<pair<ll,ll>>> E(100007);
ll dis[100007];

int main(){
  ll N;
  cin >> N;
  rep(i,N-1){
    ll A,B,C;
    cin >> A >> B >> C;
    E[A].pb(mp(B,C));
    E[B].pb(mp(A,C));
  }
  ll q,K;
  cin >> q >> K;
  vector<ll> C(100007);
  C = vector<ll>(N+1,0);
  queue<pair<ll,ll>> Q;
  Q.push(mp(K,0));
  C[K]=1;
  while(!Q.empty()){
    auto x = Q.front();
    ll X=x.fr,Y=x.sc;
    dis[X]=Y;
    Q.pop();
    rep(i,E[X].size()){
      if(C[E[X][i].fr]==0){
        Q.push(mp(E[X][i].fr,Y+E[X][i].sc));
        C[E[X][i].fr]=1;
      }
    } 
  }
  rep(i,q){
    ll X,Y;
    cin >> X >> Y;
    cout << dis[X]+dis[Y] << endl;
  }
}

Measured memory_bytes: 13544
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(b-a<k+1&&c-a<k+1&&d-a<k+1&&e-a<k+1&&c-b<k+1&&d-b<k+1&&e-b<k+1&&d-c<k+1&&e-c<k+1&&e-d<k+1){
    cout<<"Yay!";}
    else cout<<":(";

}

Measured memory_bytes: 256
#D
import math
i = int(input())
low = 0
high = 45
for _ in range(100):
    l = 2**low
    h = 2**high
    m = 2**((low+high)/2)
    if i < m:
        high = (low+high)/2
    else:
        low = (low+high)/2
#print(low,high)
tmp = math.floor(high) + 1
print((2**tmp)-1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

int kaijo(int a){
int res=1;
for(int i=1;i<=a;i++){
res=(res*i)%mod;
}
return res%mod;
}
signed main() {
	int h,w;
cin>>h>>w;
if(abs(h-w)>1)cout<<0<<endl;
else if(h==w){
cout<<(2*kaijo(h)*kaijo(w))%mod<<endl;
}
else{
cout<<(kaijo(max(h,w))*kaijo(min(h,w)))%mod<<endl;
}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    ll L,R;
    cin >> L >> R;
    ll ans=2019;
    for(ll i=L; i<=min(R,L+2019); i++){
        for(ll j=i+1; j<=min(R,L+2019); j++){
            ans = min(ans,(ll)((i*j)%2019));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256